本文整理汇总了C++中screen_area函数的典型用法代码示例。如果您正苦于以下问题:C++ screen_area函数的具体用法?C++ screen_area怎么用?C++ screen_area使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了screen_area函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: the_end
void the_end(display &disp, std::string text, unsigned int duration)
{
//
// Some sane defaults.
//
if(text.empty())
text = _("The End");
if(!duration)
duration = 3500;
SDL_Rect area = screen_area();
CVideo &video = disp.video();
sdl_fill_rect(video.getSurface(),&area,0);
update_whole_screen();
disp.flip();
const size_t font_size = font::SIZE_XLARGE;
area = font::text_area(text,font_size);
area.x = screen_area().w/2 - area.w/2;
area.y = screen_area().h/2 - area.h/2;
for(size_t n = 0; n < 255; n += 5) {
if(n)
sdl_fill_rect(video.getSurface(),&area,0);
const SDL_Color col = create_color(n, n, n, n);
font::draw_text(&video,area,font_size,col,text,area.x,area.y);
update_rect(area);
events::pump();
events::raise_process_event();
events::raise_draw_event();
disp.flip();
disp.delay(10);
}
//
// Delay after the end of fading.
// Rounded to multiples of 10.
//
unsigned int count = duration/10;
while(count) {
events::pump();
events::raise_process_event();
events::raise_draw_event();
disp.flip();
disp.delay(10);
--count;
}
}
开发者ID:justinzane,项目名称:wesnoth-ng,代码行数:52,代码来源:intro.cpp
示例2: screen_area
SDL_Rect dialog_frame::draw_title(CVideo* video)
{
SDL_Rect rect = {0, 0, 10000, 10000};
rect = screen_area();
return font::draw_text(video, rect, font::SIZE_LARGE, font::TITLE_COLOR,
title_, dim_.title.x, dim_.title.y, false, TTF_STYLE_BOLD);
}
开发者ID:CliffsDover,项目名称:wesnoth_ios,代码行数:7,代码来源:show_dialog.cpp
示例3: inner_location
void textbox::draw_contents()
{
SDL_Rect const &loc = inner_location();
surface surf = video().getSurface();
draw_solid_tinted_rectangle(loc.x,loc.y,loc.w,loc.h,0,0,0,
focus(NULL) ? alpha_focus_ : alpha_, surf);
SDL_Rect src;
if(text_image_ == NULL) {
update_text_cache(true);
}
if(text_image_ != NULL) {
src.y = yscroll_;
src.w = std::min<size_t>(loc.w,text_image_->w);
src.h = std::min<size_t>(loc.h,text_image_->h);
src.x = text_pos_;
SDL_Rect dest = screen_area();
dest.x = loc.x;
dest.y = loc.y;
// Fills the selected area
if(is_selection()) {
const int start = std::min<int>(selstart_,selend_);
const int end = std::max<int>(selstart_,selend_);
int startx = char_x_[start];
int starty = char_y_[start];
const int endx = char_x_[end];
const int endy = char_y_[end];
while(starty <= endy) {
const size_t right = starty == endy ? endx : text_image_->w;
if(right <= size_t(startx)) {
break;
}
SDL_Rect rect = create_rect(loc.x + startx
, loc.y + starty - src.y
, right - startx
, line_height_);
const clip_rect_setter clipper(surf, &loc);
Uint32 color = SDL_MapRGB(surf->format, 0, 0, 160);
fill_rect_alpha(rect, color, 140, surf);
starty += int(line_height_);
startx = 0;
}
}
sdl_blit(text_image_, &src, surf, &dest);
}
draw_cursor((cursor_pos_ == 0 ? 0 : cursor_pos_ - 1), video());
update_rect(loc);
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:60,代码来源:textbox.cpp
示例4: location
void button::calculate_size()
{
if (type_ == TYPE_IMAGE){
SDL_Rect loc_image = location();
loc_image.h = image_->h;
loc_image.w = image_->w;
set_location(loc_image);
return;
}
SDL_Rect const &loc = location();
bool change_size = loc.h == 0 || loc.w == 0;
if (!change_size) {
unsigned w = loc.w - (type_ == TYPE_PRESS ? horizontal_padding : checkbox_horizontal_padding + base_width_);
if (type_ != TYPE_IMAGE)
{
int fs = font_size;
int style = TTF_STYLE_NORMAL;
std::string::const_iterator i_beg = label_.begin(), i_end = label_.end(),
i = font::parse_markup(i_beg, i_end, &fs, NULL, &style);
if (i != i_end) {
std::string tmp(i, i_end);
label_.erase(i - i_beg, i_end - i_beg);
label_ += font::make_text_ellipsis(tmp, fs, w, style);
}
}
}
if (type_ != TYPE_IMAGE){
textRect_ = font::draw_text(NULL, screen_area(), font_size,
font::BUTTON_COLOR, label_, 0, 0);
}
if (!change_size)
return;
#ifdef USE_TINY_GUI
set_height(textRect_.h+vertical_padding);
#else
set_height(std::max(textRect_.h+vertical_padding,base_height_));
#endif
if(type_ == TYPE_PRESS) {
#ifdef USE_TINY_GUI
set_width(textRect_.w + horizontal_padding);
#else
if(spacing_ == MINIMUM_SPACE) {
set_width(textRect_.w + horizontal_padding);
} else {
set_width(std::max(textRect_.w+horizontal_padding,base_width_));
}
#endif
} else {
if(label_.empty()) {
set_width(base_width_);
} else {
set_width(checkbox_horizontal_padding + textRect_.w + base_width_);
}
}
}
开发者ID:aelthwin,项目名称:Battle-for-Wesnoth--Zombie-Edition,代码行数:59,代码来源:button.cpp
示例5: blur_area
void part_ui::render_story_box_borders(SDL_Rect& update_area)
{
const part::BLOCK_LOCATION tbl = p_.story_text_location();
if(has_background_) {
surface border_top = NULL;
surface border_bottom = NULL;
if(tbl == part::BLOCK_BOTTOM || tbl == part::BLOCK_MIDDLE) {
border_top = image::get_image(storybox_top_border_path);
}
if(tbl == part::BLOCK_TOP || tbl == part::BLOCK_MIDDLE) {
border_bottom = image::get_image(storybox_bottom_border_path);
}
//
// If one of those are null at this point, it means that either we
// don't need that border pic, or it is missing (in such case get_image()
// would report).
//
if(border_top.null() != true) {
if((border_top = scale_surface_blended(border_top, screen_area().w, border_top->h)).null()) {
WARN_NG << "storyscreen got a null top border surface after rescaling\n";
}
else {
update_area.y -= border_top->h;
update_area.h += border_top->h;
blur_area(video_, update_area.y, border_top->h);
video_.blit_surface(0, update_area.y, border_top);
}
}
if(border_bottom.null() != true) {
if((border_bottom = scale_surface_blended(border_bottom, screen_area().w, border_bottom->h)).null()) {
WARN_NG << "storyscreen got a null bottom border surface after rescaling\n";
}
else {
blur_area(video_, update_area.h, border_bottom->h);
video_.blit_surface(0, update_area.y+update_area.h, border_bottom);
update_area.h += border_bottom->h;
}
}
}
}
开发者ID:SkyPrayerStudio,项目名称:War-Of-Kingdom,代码行数:46,代码来源:render.cpp
示例6: location
void button::calculate_size()
{
if (type_ == TYPE_IMAGE){
SDL_Rect loc_image = location();
loc_image.h = image_->h;
loc_image.w = image_->w;
set_location(loc_image);
return;
}
SDL_Rect const &loc = location();
bool change_size = loc.h == 0 || loc.w == 0;
if (!change_size) {
unsigned w = loc.w - (type_ == TYPE_PRESS ? horizontal_padding : checkbox_horizontal_padding + base_width_);
if (type_ != TYPE_IMAGE){
label_ = font::make_text_ellipsis(label_, font_size, w, false);
}
}
if (type_ != TYPE_IMAGE){
textRect_ = font::draw_text(NULL, screen_area(), font_size,
font::BUTTON_COLOUR, label_, 0, 0);
}
if (!change_size)
return;
#ifdef USE_TINY_GUI
set_height(textRect_.h+vertical_padding);
#else
set_height(std::max(textRect_.h+vertical_padding,base_height_));
#endif
if(type_ == TYPE_PRESS) {
#ifdef USE_TINY_GUI
set_width(textRect_.w + horizontal_padding);
#else
if(spacing_ == MINIMUM_SPACE) {
set_width(textRect_.w + horizontal_padding);
} else {
set_width(std::max(textRect_.w+horizontal_padding,base_width_));
}
#endif
} else {
if(label_.empty()) {
set_width(base_width_);
} else {
set_width(checkbox_horizontal_padding + textRect_.w + base_width_);
}
}
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:50,代码来源:button.cpp
示例7: fullscreen
static bool fullscreen(CVideo& video)
{
preferences::set_fullscreen(video , !preferences::fullscreen());
// Setting to fullscreen doesn't seem to generate a resize event.
const SDL_Rect& rect = screen_area();
SDL_Event event;
event.type = SDL_VIDEORESIZE;
event.resize.type = SDL_VIDEORESIZE;
event.resize.w = rect.w;
event.resize.h = rect.h;
SDL_PushEvent(&event);
return true;
}
开发者ID:asimonov-im,项目名称:wesnoth,代码行数:17,代码来源:title_screen.cpp
示例8: show_tooltip
static void show_tooltip(const tooltip& tip)
{
if(video_ == NULL) {
return;
}
clear_tooltip();
const SDL_Color bgcolor = {0,0,0,160};
#if defined(_KINGDOM_EXE) || !defined(_WIN32)
SDL_Rect area = screen_area();
#else
SDL_Rect area = create_rect(0, 0, 800, 600);
#endif
unsigned int border = 10;
font::floating_label flabel(tip.message);
flabel.set_font_size(font_size);
flabel.set_color(font::NORMAL_COLOR);
flabel.set_clip_rect(area);
flabel.set_width(text_width);
flabel.set_bg_color(bgcolor);
flabel.set_border_size(border);
tooltip_handle = font::add_floating_label(flabel);
SDL_Rect rect = font::get_floating_label_rect(tooltip_handle);
//see if there is enough room to fit it above the tip area
if(tip.rect.y > rect.h) {
rect.y = tip.rect.y - rect.h;
} else {
rect.y = tip.rect.y + tip.rect.h;
}
rect.x = tip.rect.x;
if(rect.x < 0) {
rect.x = 0;
} else if(rect.x + rect.w > area.w) {
rect.x = area.w - rect.w;
}
font::move_floating_label(tooltip_handle,rect.x,rect.y);
}
开发者ID:coolsee,项目名称:War-Of-Kingdom,代码行数:45,代码来源:tooltips.cpp
示例9: do_preferences_dialog
static void do_preferences_dialog(game_display& disp, const config& game_config)
{
const preferences::display_manager disp_manager(&disp);
preferences::show_preferences_dialog(disp,game_config);
/**
* The screen size might have changed force an update of the size.
*
* @todo This might no longer be needed when gui2 is done.
*/
const SDL_Rect rect = screen_area();
preferences::set_resolution(disp.video(), rect.w, rect.h);
gui2::settings::gamemap_width += rect.w - gui2::settings::screen_width ;
gui2::settings::gamemap_height += rect.h - gui2::settings::screen_height ;
gui2::settings::screen_width = rect.w;
gui2::settings::screen_height = rect.h;
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:18,代码来源:multiplayer.cpp
示例10: show_tooltip
static void show_tooltip(const tooltip& tip)
{
if(video_ == NULL) {
return;
}
clear_tooltip();
const SDL_Color bgcolor = {0,0,0,160};
SDL_Rect area = screen_area();
unsigned int border = 10;
font::floating_label flabel(tip.message, tip.foreground);
flabel.use_markup(tip.markup);
flabel.set_font_size(font_size);
flabel.set_color(font::NORMAL_COLOR);
flabel.set_clip_rect(area);
flabel.set_width(text_width);
flabel.set_alignment(font::LEFT_ALIGN);
flabel.set_bg_color(bgcolor);
flabel.set_border_size(border);
tooltip_handle = font::add_floating_label(flabel);
SDL_Rect rect = font::get_floating_label_rect(tooltip_handle);
//see if there is enough room to fit it above the tip area
if(tip.rect.y > rect.h) {
rect.y = tip.rect.y - rect.h;
} else {
rect.y = tip.rect.y + tip.rect.h;
}
rect.x = tip.rect.x;
if(rect.x < 0) {
rect.x = 0;
} else if(rect.x + rect.w > area.w) {
rect.x = area.w - rect.w;
}
font::move_floating_label(tooltip_handle,rect.x,rect.y);
}
开发者ID:rasata,项目名称:wesnoth,代码行数:43,代码来源:tooltips.cpp
示例11: fullscreen
static bool fullscreen(CVideo& video)
{
video.set_fullscreen(!preferences::fullscreen());
#if !SDL_VERSION_ATLEAST(2, 0, 0)
// Setting to fullscreen doesn't seem to generate a resize event.
const SDL_Rect& rect = screen_area();
SDL_Event event;
event.type = SDL_VIDEORESIZE;
event.resize.type = SDL_VIDEORESIZE;
event.resize.w = rect.w;
event.resize.h = rect.h;
SDL_PushEvent(&event);
#endif
return true;
}
开发者ID:MysteryPoo,项目名称:wesnoth,代码行数:19,代码来源:title_screen.cpp
示例12: show_tooltip
static void show_tooltip(const tooltip& tip)
{
if(video_ == NULL) {
return;
}
clear_tooltip();
const SDL_Color bgcolour = {0,0,0,128};
SDL_Rect area = screen_area();
#ifdef USE_TINY_GUI
unsigned int border = 2;
#else
unsigned int border = 10;
#endif
const std::string wrapped_message = font::word_wrap_text(tip.message, font_size, text_width);
tooltip_handle = font::add_floating_label(wrapped_message,font_size,tip.color,
0,0,0,0,-1,area,font::LEFT_ALIGN,&bgcolour,border);
SDL_Rect rect = font::get_floating_label_rect(tooltip_handle);
//see if there is enough room to fit it above the tip area
if(tip.rect.y > rect.h) {
rect.y = tip.rect.y - rect.h;
} else {
rect.y = tip.rect.y + tip.rect.h;
}
rect.x = tip.rect.x;
if(rect.x < 0) {
rect.x = 0;
} else if(rect.x + rect.w > area.w) {
rect.x = area.w - rect.w;
}
font::move_floating_label(tooltip_handle,rect.x,rect.y);
}
开发者ID:oys0317,项目名称:opensanguo,代码行数:39,代码来源:tooltips.cpp
示例13: fullscreen
static bool fullscreen(CVideo& video)
{
preferences::set_fullscreen(video, !preferences::fullscreen());
// Setting to fullscreen doesn't seem to generate a resize event.
const SDL_Rect& rect = screen_area();
SDL_Event event;
#if SDL_VERSION_ATLEAST(2, 0, 0)
event.type = SDL_WINDOWEVENT;
event.window.event = SDL_WINDOWEVENT_RESIZED;
event.window.data1 = rect.w;
event.window.data2 = rect.h;
#else
event.type = SDL_VIDEORESIZE;
event.resize.type = SDL_VIDEORESIZE;
event.resize.w = rect.w;
event.resize.h = rect.h;
#endif
SDL_PushEvent(&event);
return true;
}
开发者ID:PositiveMD,项目名称:wesnoth,代码行数:24,代码来源:title_screen.cpp
示例14: w
/**
* the dimensions of the display. x and y are width/height.
* mapx is the width of the portion of the display which shows the game area.
* Between mapx and x is the sidebar region.
*/
int w() const { return screen_.getx(); } /**< width */
int h() const { return screen_.gety(); } /**< height */
const SDL_Rect& minimap_area() const
{ return theme_.mini_map_location(screen_area()); }
开发者ID:asimonov-im,项目名称:wesnoth,代码行数:9,代码来源:display.hpp
示例15: unit_image_area
const SDL_Rect& unit_image_area() const
{ return theme_.unit_image_location(screen_area()); }
开发者ID:asimonov-im,项目名称:wesnoth,代码行数:2,代码来源:display.hpp
示例16: choose_monitor
/*! Pick a monitor to place a window on. */
static Rect* choose_monitor(ObClient *c, gboolean client_to_be_foregrounded,
ObAppSettings *settings)
{
Rect *area;
ObPlaceHead *choice;
guint i;
ObClient *p;
GSList *it;
choice = g_new(ObPlaceHead, screen_num_monitors);
for (i = 0; i < screen_num_monitors; ++i) {
choice[i].monitor = i;
choice[i].flags = 0;
}
/* find monitors with group members */
if (c->group) {
for (it = c->group->members; it; it = g_slist_next(it)) {
ObClient *itc = it->data;
if (itc != c) {
guint m = client_monitor(itc);
if (m < screen_num_monitors) {
if (screen_compare_desktops(itc->desktop, c->desktop))
choice[m].flags |= HEAD_GROUP_DESK;
else
choice[m].flags |= HEAD_GROUP;
}
}
}
}
i = screen_monitor_primary(FALSE);
if (i < screen_num_monitors) {
choice[i].flags |= HEAD_PRIMARY;
if (config_place_monitor == OB_PLACE_MONITOR_PRIMARY)
choice[i].flags |= HEAD_PLACED;
if (settings &&
settings->monitor_type == OB_PLACE_MONITOR_PRIMARY)
choice[i].flags |= HEAD_PERAPP;
}
i = screen_monitor_active();
if (i < screen_num_monitors) {
if (config_place_monitor == OB_PLACE_MONITOR_ACTIVE)
choice[i].flags |= HEAD_PLACED;
if (settings &&
settings->monitor_type == OB_PLACE_MONITOR_ACTIVE)
choice[i].flags |= HEAD_PERAPP;
}
i = screen_monitor_pointer();
if (i < screen_num_monitors) {
if (config_place_monitor == OB_PLACE_MONITOR_MOUSE)
choice[i].flags |= HEAD_PLACED;
if (settings &&
settings->monitor_type == OB_PLACE_MONITOR_MOUSE)
choice[i].flags |= HEAD_PERAPP;
}
if (settings) {
i = settings->monitor - 1;
if (i < screen_num_monitors)
choice[i].flags |= HEAD_PERAPP;
}
/* direct parent takes highest precedence */
if ((p = client_direct_parent(c))) {
i = client_monitor(p);
if (i < screen_num_monitors)
choice[i].flags |= HEAD_PARENT;
}
qsort(choice, screen_num_monitors, sizeof(ObPlaceHead),
client_to_be_foregrounded ? cmp_foreground : cmp_background);
/* save the areas of the monitors in order of their being chosen */
for (i = 0; i < screen_num_monitors; ++i)
{
ob_debug("placement choice %d is monitor %d", i, choice[i].monitor);
if (choice[i].flags & HEAD_PARENT)
ob_debug(" - parent on monitor");
if (choice[i].flags & HEAD_PLACED)
ob_debug(" - placement choice");
if (choice[i].flags & HEAD_PRIMARY)
ob_debug(" - primary monitor");
if (choice[i].flags & HEAD_GROUP_DESK)
ob_debug(" - group on same desktop");
if (choice[i].flags & HEAD_GROUP)
ob_debug(" - group on other desktop");
}
area = screen_area(c->desktop, choice[0].monitor, NULL);
g_free(choice);
/* return the area for the chosen monitor */
return area;
}
开发者ID:AllesCoolAllesBestens,项目名称:openbox,代码行数:100,代码来源:place.c
示例17: screen_area
static Rect *choose_pointer_monitor(ObClient *c)
{
return screen_area(c->desktop, screen_monitor_pointer(), NULL);
}
开发者ID:AllesCoolAllesBestens,项目名称:openbox,代码行数:4,代码来源:place.c
示例18: strlen
(const FcChar8*)mc->dispstr, strlen(mc->dispstr), &extents);
mc->geom.w = extents.xOff;
mc->geom.h = sc->xftfont->height + 1;
mc->num = 1;
TAILQ_FOREACH(mi, resultq, resultentry) {
(*mc->print)(mi, mc->listing);
XftTextExtentsUtf8(X_Dpy, sc->xftfont,
(const FcChar8*)mi->print,
MIN(strlen(mi->print), MENU_MAXENTRY), &extents);
mc->geom.w = MAX(mc->geom.w, extents.xOff);
mc->geom.h += sc->xftfont->height + 1;
mc->num++;
}
area = screen_area(sc, mc->geom.x, mc->geom.y, CWM_GAP);
area.w += area.x - Conf.bwidth * 2;
area.h += area.y - Conf.bwidth * 2;
xsave = mc->geom.x;
ysave = mc->geom.y;
/* Never hide the top, or left side, of the menu. */
if (mc->geom.x + mc->geom.w >= area.w)
mc->geom.x = area.w - mc->geom.w;
if (mc->geom.x < area.x) {
mc->geom.x = area.x;
mc->geom.w = MIN(mc->geom.w, (area.w - area.x));
}
if (mc->geom.y + mc->geom.h >= area.h)
mc->geom.y = area.h - mc->geom.h;
开发者ID:netzbasis,项目名称:openbsd-xenocara,代码行数:31,代码来源:menu.c
示例19: screen_area
void menu::draw_row(const size_t row_index, const SDL_Rect& rect, ROW_TYPE type)
{
//called from style, draws one row's contents in a generic and adaptable way
const std::vector<std::string>& row = (type == HEADING_ROW) ? heading_ : items_[row_index].fields;
SDL_Rect const &area = screen_area();
SDL_Rect const &loc = inner_location();
const std::vector<int>& widths = column_widths();
bool lang_rtl = current_language_rtl();
int dir = (lang_rtl) ? -1 : 1;
SDL_Rect column = loc;
int xpos = rect.x;
if(lang_rtl)
xpos += rect.w;
for(size_t i = 0; i != row.size(); ++i) {
if(lang_rtl)
xpos -= widths[i];
if(type == HEADING_ROW) {
#ifdef SDL_GPU
const SDL_Rect pos = sdl::create_rect(xpos, rect.y, widths[i], rect.h);
if(highlight_heading_ == int(i)) {
sdl::fill_rect(video(), pos, 255, 255, 255, 75);
} else if(sortby_ == int(i)) {
sdl::fill_rect(video(), pos, 255, 255, 255, 25);
}
}
const int last_x = xpos;
column.w = widths[i];
std::string str = row[i];
std::vector<std::string> img_text_items = utils::split(str, IMG_TEXT_SEPARATOR, utils::REMOVE_EMPTY);
for (std::vector<std::string>::const_iterator it = img_text_items.begin();
it != img_text_items.end(); ++it) {
str = *it;
if (!str.empty() && str[0] == IMAGE_PREFIX) {
const std::string image_name(str.begin()+1,str.end());
sdl::timage img = style_->get_item_image(image_name);
const int remaining_width = max_width_ < 0 ? area.w :
std::min<int>(max_width_, ((lang_rtl)? xpos - rect.x : rect.x + rect.w - xpos));
if(!img.null() && img.width() <= remaining_width
&& rect.y + img.height() < area.h) {
const size_t y = rect.y + (rect.h - img.height())/2;
const size_t w = img.width() + 5;
const size_t x = xpos + ((lang_rtl) ? widths[i] - w : 0);
video().draw_texture(img, x, y);
if(!lang_rtl)
xpos += w;
column.w -= w;
}
} else {
column.x = xpos;
const bool has_wrap = (str.find_first_of("\r\n") != std::string::npos);
//prevent ellipsis calculation if there is any line wrapping
std::string to_show = str;
if (use_ellipsis_ && !has_wrap)
{
int fs = style_->get_font_size();
int style = TTF_STYLE_NORMAL;
int w = loc.w - (xpos - rect.x) - 2 * style_->get_thickness();
std::string::const_iterator i_beg = to_show.begin(), i_end = to_show.end(),
i = font::parse_markup(i_beg, i_end, &fs, nullptr, &style);
if (i != i_end) {
std::string tmp(i, i_end);
to_show.erase(i - i_beg, i_end - i_beg);
to_show += font::make_text_ellipsis(tmp, fs, w, style);
}
}
const SDL_Rect& text_size = font::text_area(str,style_->get_font_size());
const size_t y = rect.y + (rect.h - text_size.h)/2;
const size_t padding = 2;
sdl::timage text_img = font::draw_text_to_texture(column,style_->get_font_size(),font::NORMAL_COLOR,to_show);
video().draw_texture(text_img, (type == HEADING_ROW ? xpos+padding : xpos), y);
if(type == HEADING_ROW && sortby_ == int(i)) {
sdl::timage sort_img = image::get_texture("buttons/sliders/slider_arrow_blue.png");
sort_img.set_rotation(sortreversed_ ? 0 : 180);
if(!sort_img.null() && sort_img.width() <= widths[i] && sort_img.height() <= rect.h) {
const size_t sort_x = xpos + widths[i] - sort_img.width() - padding;
const size_t sort_y = rect.y + rect.h/2 - sort_img.height()/2;
video().draw_texture(sort_img, sort_x, sort_y);
}
}
xpos += dir * (text_size.w + 5);
}
}
if(lang_rtl)
xpos = last_x;
else
xpos = last_x + widths[i];
}
#else
if(highlight_heading_ == int(i)) {
sdl::draw_solid_tinted_rectangle(xpos,rect.y,widths[i],rect.h,255,255,255,0.3,video().getSurface());
} else if(sortby_ == int(i)) {
sdl::draw_solid_tinted_rectangle(xpos,rect.y,widths[i],rect.h,255,255,255,0.1,video().getSurface());
}
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:97,代码来源:menu.cpp
示例20: close_button
void default_map_generator::user_config(display& disp)
{
const resize_lock prevent_resizing;
const events::event_context dialog_events_context;
CVideo& screen = disp.video();
const int width = 600;
const int height = 400;
const int xpos = screen.getx()/2 - width/2;
int ypos = screen.gety()/2 - height/2;
gui::button close_button(screen,_("Close"));
std::vector<gui::button*> buttons(1,&close_button);
gui::dialog_frame f(screen,_("Map Generator"),gui::dialog_frame::default_style,true,&buttons);
f.layout(xpos,ypos,width,height);
f.draw();
SDL_Rect dialog_rect = sdl::create_rect(xpos, ypos, width, height);
surface_restorer dialog_restorer(&screen,dialog_rect);
const std::string& players_label = _("Players:");
const std::string& width_label = _("Width:");
const std::string& height_label = _("Height:");
const std::string& iterations_label = _("Number of hills:");
const std::string& hillsize_label = _("Max hill size:");
const std::string& villages_label = _("Villages:");
const std::string& castlesize_label = _("Castle size:");
const std::string& landform_label = _("Landform:");
SDL_Rect players_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,players_label,0,0);
SDL_Rect width_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,width_label,0,0);
SDL_Rect height_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,height_label,0,0);
SDL_Rect iterations_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,iterations_label,0,0);
SDL_Rect hillsize_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,hillsize_label,0,0);
SDL_Rect villages_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,villages_label,0,0);
SDL_Rect castlesize_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,castlesize_label,0,0);
SDL_Rect landform_rect = font::draw_text(NULL,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,landform_label,0,0);
const int horz_margin = 15;
const int text_right = xpos + horz_margin +
std::max<int>(std::max<int>(std::max<int>(std::max<int>(std::max<int>(std::max<int>(
players_rect.w,width_rect.w),height_rect.w),iterations_rect.w),hillsize_rect.w),villages_rect.w),castlesize_rect.w);
players_rect.x = text_right - players_rect.w;
width_rect.x = text_right - width_rect.w;
height_rect.x = text_right - height_rect.w;
iterations_rect.x = text_right - iterations_rect.w;
hillsize_rect.x = text_right - hillsize_rect.w;
villages_rect.x = text_right - villages_rect.w;
castlesize_rect.x = text_right - castlesize_rect.w;
landform_rect.x = text_right - landform_rect.w;
const int vertical_margin = 20;
players_rect.y = ypos + vertical_margin*2;
width_rect.y = players_rect.y + players_rect.h + vertical_margin;
height_rect.y = width_rect.y + width_rect.h + vertical_margin;
iterations_rect.y = height_rect.y + height_rect.h + vertical_margin;
hillsize_rect.y = iterations_rect.y + iterations_rect.h + vertical_margin;
villages_rect.y = hillsize_rect.y + hillsize_rect.h + vertical_margin;
castlesize_rect.y = villages_rect.y + iterations_rect.h + vertical_margin;
landform_rect.y = castlesize_rect.y + villages_rect.h + vertical_margin;
const int right_space = 150;
const int slider_left = text_right + 10;
const int slider_right = xpos + width - horz_margin - right_space;
SDL_Rect slider_rect = sdl::create_rect(slider_left
, players_rect.y
, slider_right - slider_left
, players_rect.h);
gui::slider players_slider(screen);
players_slider.set_location(slider_rect);
players_slider.set_min(2);
players_slider.set_max(gamemap::MAX_PLAYERS);
players_slider.set_value(nplayers_);
const int min_width = 20;
const int max_width = 100;
const int max_height = 100;
const int extra_size_per_player = 2;
slider_rect.y = width_rect.y;
gui::slider width_slider(screen);
width_slider.set_location(slider_rect);
width_slider.set_min(min_width+(players_slider.value()-2)*extra_size_per_player);
width_slider.set_max(max_width);
width_slider.set_value(width_);
slider_rect.y = height_rect.y;
gui::slider height_slider(screen);
height_slider.set_location(slider_rect);
height_slider.set_min(min_width+(players_slider.value()-2)*extra_size_per_player);
height_slider.set_max(max_height);
height_slider.set_value(height_);
const int min_iterations = 10;
const int max_iterations = 3000;
//.........这里部分代码省略.........
开发者ID:Zappaman,项目名称:wesnoth,代码行数:101,代码来源:mapgen_dialog.cpp
注:本文中的screen_area函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论