Convert uses of create_rect to aggregate initialization when possible
This only includes cases where this can be done without triggering warnings about narrowing conversion. Also includes cleanups of sdl/rect.hpp includes.
This commit is contained in:
parent
9eae9eac3c
commit
4479682469
21 changed files with 72 additions and 62 deletions
|
@ -1300,7 +1300,7 @@ void display::drawing_buffer_commit()
|
|||
// Note that dstrect can be changed by sdl_blit
|
||||
// and so a new instance should be initialized
|
||||
// to pass to each call to sdl_blit.
|
||||
SDL_Rect dstrect = sdl::create_rect(blit.x(), blit.y(), 0, 0);
|
||||
SDL_Rect dstrect {blit.x(), blit.y(), 0, 0};
|
||||
SDL_Rect srcrect = blit.clip();
|
||||
SDL_Rect *srcrectArg = (srcrect.x | srcrect.y | srcrect.w | srcrect.h)
|
||||
? &srcrect : nullptr;
|
||||
|
@ -1527,7 +1527,7 @@ void display::render_image(int x, int y, const display::drawing_layer drawing_la
|
|||
if (image==nullptr)
|
||||
return;
|
||||
|
||||
SDL_Rect image_rect = sdl::create_rect(x, y, image->w, image->h);
|
||||
SDL_Rect image_rect {x, y, image->w, image->h};
|
||||
SDL_Rect clip_rect = map_area();
|
||||
if (!sdl::rects_overlap(image_rect, clip_rect))
|
||||
return;
|
||||
|
@ -1567,7 +1567,7 @@ void display::render_image(int x, int y, const display::drawing_layer drawing_la
|
|||
// divide the surface into 2 parts
|
||||
const int submerge_height = std::max<int>(0, surf->h*(1.0-submerged));
|
||||
const int depth = surf->h - submerge_height;
|
||||
SDL_Rect srcrect = sdl::create_rect(0, 0, surf->w, submerge_height);
|
||||
SDL_Rect srcrect {0, 0, surf->w, submerge_height};
|
||||
drawing_buffer_add(drawing_layer, loc, x, y, surf, srcrect);
|
||||
|
||||
if(submerge_height != surf->h) {
|
||||
|
@ -1854,10 +1854,12 @@ void display::draw_minimap_units()
|
|||
double u_w = 4.0 / 3.0 * xscaling;
|
||||
double u_h = yscaling;
|
||||
|
||||
SDL_Rect r = sdl::create_rect(minimap_location_.x + round_double(u_x)
|
||||
SDL_Rect r {
|
||||
minimap_location_.x + round_double(u_x)
|
||||
, minimap_location_.y + round_double(u_y)
|
||||
, round_double(u_w)
|
||||
, round_double(u_h));
|
||||
, round_double(u_h)
|
||||
};
|
||||
const Uint32 mapped_col = SDL_MapRGB(video().getSurface()->format,col.r,col.g,col.b);
|
||||
sdl::fill_rect(video().getSurface(), &r, mapped_col);
|
||||
}
|
||||
|
@ -2628,7 +2630,7 @@ void display::draw_hex(const map_location& loc) {
|
|||
int off_y = ypos + hex_size()/2;
|
||||
surface text = font::get_rendered_text(lexical_cast<std::string>(loc), font::SIZE_SMALL, font::NORMAL_COLOR);
|
||||
surface bg = create_neutral_surface(text->w, text->h);
|
||||
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
|
||||
SDL_Rect bg_rect {0, 0, text->w, text->h};
|
||||
sdl::fill_rect(bg, &bg_rect, 0xaa000000);
|
||||
off_x -= text->w / 2;
|
||||
off_y -= text->h / 2;
|
||||
|
@ -2646,7 +2648,7 @@ void display::draw_hex(const map_location& loc) {
|
|||
int off_y = ypos + hex_size()/2;
|
||||
surface text = font::get_rendered_text(lexical_cast<std::string>(get_map().get_terrain(loc)), font::SIZE_SMALL, font::NORMAL_COLOR);
|
||||
surface bg = create_neutral_surface(text->w, text->h);
|
||||
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
|
||||
SDL_Rect bg_rect {0, 0, text->w, text->h};
|
||||
sdl::fill_rect(bg, &bg_rect, 0xaa000000);
|
||||
off_x -= text->w / 2;
|
||||
off_y -= text->h / 2;
|
||||
|
@ -2663,7 +2665,7 @@ void display::draw_hex(const map_location& loc) {
|
|||
int off_y = ypos + hex_size()/2;
|
||||
surface text = font::get_rendered_text(lexical_cast<std::string>(num_images_bg + num_images_fg), font::SIZE_SMALL, font::NORMAL_COLOR);
|
||||
surface bg = create_neutral_surface(text->w, text->h);
|
||||
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
|
||||
SDL_Rect bg_rect {0, 0, text->w, text->h};
|
||||
sdl::fill_rect(bg, &bg_rect, 0xaa000000);
|
||||
off_x -= text->w / 2;
|
||||
off_y -= text->h / 2;
|
||||
|
@ -2820,7 +2822,7 @@ void display::refresh_report(const std::string& report_name, const config * new_
|
|||
for (config::const_child_itors elements = report.child_range("element");
|
||||
elements.begin() != elements.end(); elements.pop_front())
|
||||
{
|
||||
SDL_Rect area = sdl::create_rect(x, y, rect.w + rect.x - x, rect.h + rect.y - y);
|
||||
SDL_Rect area {x, y, rect.w + rect.x - x, rect.h + rect.y - y};
|
||||
if (area.h <= 0) break;
|
||||
|
||||
std::string t = elements.front()["text"];
|
||||
|
|
|
@ -216,7 +216,7 @@ public:
|
|||
{ return theme_.unit_image_location(screen_area()); }
|
||||
|
||||
SDL_Rect screen_area() const
|
||||
{ return sdl::create_rect(0, 0, w(), h()); }
|
||||
{ return {0, 0, w(), h()}; }
|
||||
|
||||
/**
|
||||
* Returns the maximum area used for the map
|
||||
|
|
|
@ -171,12 +171,12 @@ void mouse_action::set_terrain_mouse_overlay(editor_display& disp, const t_trans
|
|||
|
||||
// Blit left side
|
||||
image_fg = scale_surface(image_fg, new_size, new_size);
|
||||
SDL_Rect rcDestLeft = sdl::create_rect(offset, quarter_size, 0, 0);
|
||||
SDL_Rect rcDestLeft {offset, quarter_size, 0, 0};
|
||||
sdl_blit( image_fg, nullptr, image, &rcDestLeft );
|
||||
|
||||
// Blit right side
|
||||
image_bg = scale_surface(image_bg, new_size, new_size);
|
||||
SDL_Rect rcDestRight = sdl::create_rect(half_size, quarter_size, 0, 0);
|
||||
SDL_Rect rcDestRight {half_size, quarter_size, 0, 0};
|
||||
sdl_blit( image_bg, nullptr, image, &rcDestRight );
|
||||
|
||||
//apply mask so the overlay is contained within the mouseover hex
|
||||
|
@ -336,7 +336,7 @@ void mouse_action_paste::set_mouse_overlay(editor_display& disp)
|
|||
//TODO avoid hardcoded hex field size
|
||||
surface image = create_neutral_surface(72,72);
|
||||
|
||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||
SDL_Rect r {6, 6, 0, 0};
|
||||
sdl_blit(image60, nullptr, image, &r);
|
||||
|
||||
Uint8 alpha = 196;
|
||||
|
@ -454,7 +454,7 @@ void mouse_action_starting_position::set_mouse_overlay(editor_display& disp)
|
|||
//TODO avoid hardcoded hex field size
|
||||
surface image = create_neutral_surface(72,72);
|
||||
|
||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||
SDL_Rect r {6, 6, 0, 0};
|
||||
sdl_blit(image60, nullptr, image, &r);
|
||||
|
||||
Uint8 alpha = 196;
|
||||
|
|
|
@ -115,7 +115,7 @@ void mouse_action_map_label::set_mouse_overlay(editor_display& disp)
|
|||
//TODO avoid hardcoded hex field size
|
||||
surface image = create_neutral_surface(72,72);
|
||||
|
||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||
SDL_Rect r {6, 6, 0, 0};
|
||||
sdl_blit(image60, nullptr, image, &r);
|
||||
|
||||
Uint8 alpha = 196;
|
||||
|
|
|
@ -44,7 +44,7 @@ void mouse_action_village::set_mouse_overlay(editor_display& disp)
|
|||
//TODO avoid hardcoded hex field size
|
||||
surface image = create_neutral_surface(72,72);
|
||||
|
||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||
SDL_Rect r {6, 6, 0, 0};
|
||||
sdl_blit(image60, nullptr, image, &r);
|
||||
|
||||
Uint8 alpha = 196;
|
||||
|
|
|
@ -241,7 +241,7 @@ void tristate_button::draw_contents() {
|
|||
surface nbase = make_neutral_surface(base);
|
||||
|
||||
//TODO avoid magic numbers
|
||||
SDL_Rect r = sdl::create_rect(1, 1, 0, 0);
|
||||
SDL_Rect r {1, 1, 0, 0};
|
||||
sdl_blit(nitem, nullptr, nbase, &r);
|
||||
|
||||
if (!overlay.null()) {
|
||||
|
|
|
@ -119,7 +119,7 @@ surface floating_label::create_surface()
|
|||
// (where the text was blitted directly on screen)
|
||||
adjust_surface_alpha(foreground, ftofxp(1.13));
|
||||
|
||||
SDL_Rect r = sdl::create_rect( border_, border_, 0, 0);
|
||||
SDL_Rect r {border_, border_, 0, 0};
|
||||
adjust_surface_alpha(foreground, SDL_ALPHA_OPAQUE);
|
||||
sdl_blit(foreground, nullptr, background, &r);
|
||||
|
||||
|
@ -249,7 +249,7 @@ SDL_Rect get_floating_label_rect(int handle)
|
|||
if(i != labels.end()) {
|
||||
const surface surf = i->second.create_surface();
|
||||
if(surf != nullptr) {
|
||||
return sdl::create_rect(0, 0, surf->w, surf->h);
|
||||
return {0, 0, surf->w, surf->h};
|
||||
}
|
||||
}
|
||||
return sdl::empty_rect;
|
||||
|
|
|
@ -89,11 +89,12 @@ namespace gui{
|
|||
|
||||
if(box_ != nullptr) {
|
||||
box_->set_volatile(true);
|
||||
const SDL_Rect rect = sdl::create_rect(
|
||||
const SDL_Rect rect {
|
||||
area.x + label_area.w + border_size * 2
|
||||
, ypos
|
||||
, textbox_width
|
||||
, box_->height());
|
||||
, box_->height()
|
||||
};
|
||||
|
||||
box_->set_location(rect);
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ SDL_Rect draw_text_line(surface& gui_surface, const SDL_Rect& area, int size,
|
|||
}
|
||||
|
||||
if(area.w == 0) { // no place to draw
|
||||
return sdl::create_rect(0, 0, 0, 0);
|
||||
return {0, 0, 0, 0};
|
||||
}
|
||||
|
||||
const std::string etext = make_text_ellipsis(text, size, area.w);
|
||||
|
@ -355,7 +355,7 @@ SDL_Rect draw_text_line(surface& gui_surface, const SDL_Rect& area, int size,
|
|||
// for the main current use, we already parsed markup
|
||||
surface surface(render_text(etext,size,color,style,false));
|
||||
if(surface == nullptr) {
|
||||
return sdl::create_rect(0, 0, 0, 0);
|
||||
return {0, 0, 0, 0};
|
||||
}
|
||||
|
||||
SDL_Rect dest;
|
||||
|
|
|
@ -1080,7 +1080,7 @@ void image_shape::draw(surface& canvas,
|
|||
|
||||
image_.assign(make_neutral_surface(tmp));
|
||||
assert(image_);
|
||||
src_clip_ = sdl::create_rect(0, 0, image_->w, image_->h);
|
||||
src_clip_ = {0, 0, image_->w, image_->h};
|
||||
|
||||
wfl::map_formula_callable local_variables(variables);
|
||||
local_variables.add("image_original_width", wfl::variant(image_->w));
|
||||
|
|
|
@ -87,19 +87,19 @@ void terrain_layers::pre_show(window& window)
|
|||
std::ostringstream image_steam;
|
||||
|
||||
const int tz = game_config::tile_size;
|
||||
SDL_Rect r = sdl::create_rect(0,0,tz,tz);
|
||||
SDL_Rect r {0,0,tz,tz};
|
||||
|
||||
surface surf = image::get_image(img.get_filename());
|
||||
|
||||
// calculate which part of the image the terrain engine uses
|
||||
if(loc_cut.valid()) {
|
||||
// copied from image.cpp : load_image_sub_file()
|
||||
r = sdl::create_rect(
|
||||
r = {
|
||||
((tz * 3) / 4) * loc_cut.x
|
||||
, tz * loc_cut.y + (tz / 2) * (loc_cut.x % 2)
|
||||
, tz
|
||||
, tz
|
||||
);
|
||||
};
|
||||
|
||||
if(img.get_center_x() >= 0 && img.get_center_y() >= 0) {
|
||||
r.x += surf->w / 2 - img.get_center_x();
|
||||
|
@ -112,7 +112,7 @@ void terrain_layers::pre_show(window& window)
|
|||
// Cut and mask the image
|
||||
// ~CROP and ~BLIT have limitations, we do some math to avoid them
|
||||
// TODO: ^ eh? what limitations?
|
||||
SDL_Rect r2 = sdl::intersect_rects(r, sdl::create_rect(0,0,surf->w,surf->h));
|
||||
SDL_Rect r2 = sdl::intersect_rects(r, {0,0,surf->w,surf->h});
|
||||
if(r2.w > 0 && r2.h > 0) {
|
||||
image_steam
|
||||
<< "~BLIT(" << name
|
||||
|
|
|
@ -45,7 +45,7 @@ bool init()
|
|||
|
||||
SDL_Rect create_rect(const point& origin, const point& size)
|
||||
{
|
||||
return sdl::create_rect(origin.x, origin.y, size.x, size.y);
|
||||
return {origin.x, origin.y, size.x, size.y};
|
||||
}
|
||||
|
||||
font::pango_text::FONT_STYLE decode_font_style(const std::string& style)
|
||||
|
|
|
@ -218,7 +218,7 @@ bool halo_impl::effect::render()
|
|||
const int xpos = x_ + screenx - surf_->w/2;
|
||||
const int ypos = y_ + screeny - surf_->h/2;
|
||||
|
||||
SDL_Rect rect = sdl::create_rect(xpos, ypos, surf_->w, surf_->h);
|
||||
SDL_Rect rect {xpos, ypos, surf_->w, surf_->h};
|
||||
rect_ = rect;
|
||||
SDL_Rect clip_rect = disp->map_outside_area();
|
||||
|
||||
|
@ -281,7 +281,7 @@ void halo_impl::effect::unrender()
|
|||
const int xpos = x_ + screenx - surf_->w/2;
|
||||
const int ypos = y_ + screeny - surf_->h/2;
|
||||
|
||||
SDL_Rect rect = sdl::create_rect(xpos, ypos, surf_->w, surf_->h);
|
||||
SDL_Rect rect {xpos, ypos, surf_->w, surf_->h};
|
||||
sdl_blit(buffer_,nullptr,screen,&rect);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,11 +98,12 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
// if not, only the bottom half-hexes are clipped
|
||||
// and it looks asymmetrical.
|
||||
|
||||
SDL_Rect maprect = sdl::create_rect(
|
||||
SDL_Rect maprect {
|
||||
x * scale * 3 / 4 - (scale / 4)
|
||||
, y * scale + scale / 4 * (is_odd(x) ? 1 : -1) - (scale / 4)
|
||||
, 0
|
||||
, 0);
|
||||
, 0
|
||||
};
|
||||
|
||||
if (preferences_minimap_draw_terrain) {
|
||||
|
||||
|
@ -148,7 +149,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
|
||||
if(overlay != nullptr && overlay != tile) {
|
||||
surface combined = create_neutral_surface(tile->w, tile->h);
|
||||
SDL_Rect r = sdl::create_rect(0,0,0,0);
|
||||
SDL_Rect r {0,0,0,0};
|
||||
sdl_blit(tile, nullptr, combined, &r);
|
||||
r.x = std::max(0, (tile->w - overlay->w)/2);
|
||||
r.y = std::max(0, (tile->h - overlay->h)/2);
|
||||
|
@ -228,7 +229,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
col.b = col.b - (col.b - tmp.b)/2;
|
||||
}
|
||||
}
|
||||
SDL_Rect fillrect = sdl::create_rect(maprect.x, maprect.y, scale * 3/4, scale);
|
||||
SDL_Rect fillrect {maprect.x, maprect.y, scale * 3/4, scale};
|
||||
const Uint32 mapped_col = SDL_MapRGB(minimap->format,col.r,col.g,col.b);
|
||||
sdl::fill_rect(minimap, &fillrect, mapped_col);
|
||||
}
|
||||
|
@ -262,12 +263,12 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
}
|
||||
}
|
||||
|
||||
SDL_Rect fillrect = sdl::create_rect(
|
||||
SDL_Rect fillrect {
|
||||
maprect.x
|
||||
, maprect.y
|
||||
, scale * 3/4
|
||||
, scale
|
||||
);
|
||||
};
|
||||
|
||||
const Uint32 mapped_col = SDL_MapRGB(minimap->format,col.r,col.g,col.b);
|
||||
sdl::fill_rect(minimap, &fillrect, mapped_col);
|
||||
|
|
|
@ -94,11 +94,10 @@ void fill_rect_alpha(SDL_Rect &rect, Uint32 color, Uint8 alpha, surface target)
|
|||
|
||||
void draw_rectangle(int x, int y, int w, int h, Uint32 color, surface target)
|
||||
{
|
||||
|
||||
SDL_Rect top = create_rect(x, y, w, 1);
|
||||
SDL_Rect bot = create_rect(x, y + h - 1, w, 1);
|
||||
SDL_Rect left = create_rect(x, y, 1, h);
|
||||
SDL_Rect right = create_rect(x + w - 1, y, 1, h);
|
||||
SDL_Rect top {x, y, w, 1};
|
||||
SDL_Rect bot {x, y + h - 1, w, 1};
|
||||
SDL_Rect left {x, y, 1, h};
|
||||
SDL_Rect right {x + w - 1, y, 1, h};
|
||||
|
||||
sdl::fill_rect(target,&top,color);
|
||||
sdl::fill_rect(target,&bot,color);
|
||||
|
@ -111,7 +110,7 @@ void draw_solid_tinted_rectangle(int x, int y, int w, int h,
|
|||
double alpha, surface target)
|
||||
{
|
||||
|
||||
SDL_Rect rect = create_rect(x, y, w, h);
|
||||
SDL_Rect rect {x, y, w, h};
|
||||
fill_rect_alpha(rect,SDL_MapRGB(target->format,r,g,b),Uint8(alpha*255),target);
|
||||
}
|
||||
|
||||
|
|
|
@ -1315,7 +1315,7 @@ surface blur_surface(const surface &surf, int depth)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
SDL_Rect rect = sdl::create_rect(0, 0, surf->w, surf->h);
|
||||
SDL_Rect rect {0, 0, surf->w, surf->h};
|
||||
blur_surface(res, rect, depth);
|
||||
|
||||
return res;
|
||||
|
@ -1942,7 +1942,7 @@ void blit_surface(const surface& surf,
|
|||
const surface& src = is_neutral(surf) ? surf : make_neutral_surface(surf);
|
||||
|
||||
// Get the areas to blit
|
||||
SDL_Rect dst_rect = sdl::create_rect(0, 0, dst->w, dst->h);
|
||||
SDL_Rect dst_rect {0, 0, dst->w, dst->h};
|
||||
if(dstrect) {
|
||||
dst_rect.x = dstrect->x;
|
||||
dst_rect.w -= dstrect->x;
|
||||
|
@ -1952,7 +1952,7 @@ void blit_surface(const surface& surf,
|
|||
|
||||
}
|
||||
|
||||
SDL_Rect src_rect = sdl::create_rect(0, 0, src->w, src->h);
|
||||
SDL_Rect src_rect {0, 0, src->w, src->h};
|
||||
if(srcrect && srcrect->w && srcrect->h) {
|
||||
src_rect.x = srcrect->x;
|
||||
src_rect.y = srcrect->y;
|
||||
|
|
|
@ -175,7 +175,7 @@ void unit_drawer::redraw_unit (const unit & u) const
|
|||
// We draw bars only if wanted, visible on the map view
|
||||
bool draw_bars = ac.draw_bars_ ;
|
||||
if (draw_bars) {
|
||||
SDL_Rect unit_rect = sdl::create_rect(xsrc, ysrc +adjusted_params.y, hex_size, hex_size);
|
||||
SDL_Rect unit_rect {xsrc, ysrc +adjusted_params.y, hex_size, hex_size};
|
||||
draw_bars = sdl::rects_overlap(unit_rect, disp.map_outside_area());
|
||||
}
|
||||
surface ellipse_front(nullptr);
|
||||
|
@ -362,11 +362,12 @@ void unit_drawer::draw_bar(const std::string& image, int xpos, int ypos,
|
|||
else {
|
||||
const fixed_t xratio = fxpdiv(surf->w,bar_surf->w);
|
||||
const fixed_t yratio = fxpdiv(surf->h,bar_surf->h);
|
||||
const SDL_Rect scaled_bar_loc = sdl::create_rect(
|
||||
const SDL_Rect scaled_bar_loc {
|
||||
fxptoi(unscaled_bar_loc. x * xratio)
|
||||
, fxptoi(unscaled_bar_loc. y * yratio + 127)
|
||||
, fxptoi(unscaled_bar_loc. w * xratio + 255)
|
||||
, fxptoi(unscaled_bar_loc. h * yratio + 255));
|
||||
, fxptoi(unscaled_bar_loc. h * yratio + 255)
|
||||
};
|
||||
bar_loc = scaled_bar_loc;
|
||||
}
|
||||
|
||||
|
@ -383,7 +384,7 @@ void unit_drawer::draw_bar(const std::string& image, int xpos, int ypos,
|
|||
|
||||
const size_t skip_rows = bar_loc.h - height;
|
||||
|
||||
SDL_Rect top = sdl::create_rect(0, 0, surf->w, bar_loc.y);
|
||||
SDL_Rect top {0, 0, surf->w, bar_loc.y};
|
||||
SDL_Rect bot = sdl::create_rect(0, bar_loc.y + skip_rows, surf->w, 0);
|
||||
bot.h = surf->w - bot.y;
|
||||
|
||||
|
@ -439,10 +440,12 @@ const SDL_Rect& unit_drawer::calculate_energy_bar(surface surf) const
|
|||
}
|
||||
}
|
||||
|
||||
const SDL_Rect res = sdl::create_rect(first_col
|
||||
const SDL_Rect res {
|
||||
first_col
|
||||
, first_row
|
||||
, last_col-first_col
|
||||
, last_row+1-first_row);
|
||||
, last_row+1-first_row
|
||||
};
|
||||
energy_bar_rects_.emplace(surf, res);
|
||||
return calculate_energy_bar(surf);
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ void CVideo::video_event_handler::handle_window_event(const SDL_Event &event)
|
|||
void CVideo::blit_surface(int x, int y, surface surf, SDL_Rect* srcrect, SDL_Rect* clip_rect)
|
||||
{
|
||||
surface& target(getSurface());
|
||||
SDL_Rect dst = sdl::create_rect(x, y, 0, 0);
|
||||
SDL_Rect dst {x, y, 0, 0};
|
||||
|
||||
const clip_rect_setter clip_setter(target, clip_rect, clip_rect != nullptr);
|
||||
sdl_blit(surf,srcrect,target,&dst);
|
||||
|
|
|
@ -227,7 +227,7 @@ SDL_Rect scrollbar::grip_area() const
|
|||
if (h < minimum_grip_height_)
|
||||
h = minimum_grip_height_;
|
||||
int y = loc.y + (static_cast<int>(loc.h) - h) * grip_position_ / (full_height_ - grip_height_);
|
||||
return sdl::create_rect(loc.x, y, loc.w, h);
|
||||
return {loc.x, y, loc.w, h};
|
||||
}
|
||||
|
||||
void scrollbar::draw_contents()
|
||||
|
|
|
@ -107,10 +107,12 @@ void textbox::append_text(const std::string& text, bool auto_scroll, const color
|
|||
sdl_blit(text_image_,nullptr,new_surface,nullptr);
|
||||
SDL_SetSurfaceBlendMode(text_image_, SDL_BLENDMODE_BLEND);
|
||||
|
||||
SDL_Rect target = sdl::create_rect(0
|
||||
SDL_Rect target {
|
||||
0
|
||||
, text_image_->h
|
||||
, new_text->w
|
||||
, new_text->h);
|
||||
, new_text->h
|
||||
};
|
||||
SDL_SetSurfaceBlendMode(new_text, SDL_BLENDMODE_NONE);
|
||||
sdl_blit(new_text,nullptr,new_surface,&target);
|
||||
text_image_.assign(new_surface);
|
||||
|
@ -169,10 +171,12 @@ void textbox::set_cursor_pos(const int cursor_pos)
|
|||
void textbox::draw_cursor(int pos, CVideo &video) const
|
||||
{
|
||||
if(show_cursor_ && editable_ && enabled()) {
|
||||
SDL_Rect rect = sdl::create_rect(location().x + pos
|
||||
SDL_Rect rect {
|
||||
location().x + pos
|
||||
, location().y
|
||||
, 1
|
||||
, location().h);
|
||||
, location().h
|
||||
};
|
||||
|
||||
surface frame_buffer = video.getSurface();
|
||||
sdl::fill_rect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
|
||||
|
|
|
@ -111,22 +111,22 @@ void widget::bg_register(SDL_Rect const &rect)
|
|||
|
||||
void widget::set_location(int x, int y)
|
||||
{
|
||||
set_location(sdl::create_rect(x, y, rect_.w, rect_.h));
|
||||
set_location({x, y, rect_.w, rect_.h});
|
||||
}
|
||||
|
||||
void widget::set_width(int w)
|
||||
{
|
||||
set_location(sdl::create_rect(rect_.x, rect_.y, w, rect_.h));
|
||||
set_location({rect_.x, rect_.y, w, rect_.h});
|
||||
}
|
||||
|
||||
void widget::set_height(int h)
|
||||
{
|
||||
set_location(sdl::create_rect(rect_.x, rect_.y, rect_.w, h));
|
||||
set_location({rect_.x, rect_.y, rect_.w, h});
|
||||
}
|
||||
|
||||
void widget::set_measurements(int w, int h)
|
||||
{
|
||||
set_location(sdl::create_rect(rect_.x, rect_.y, w, h));
|
||||
set_location({rect_.x, rect_.y, w, h});
|
||||
}
|
||||
|
||||
int widget::width() const
|
||||
|
|
Loading…
Add table
Reference in a new issue