Move create_rect to the sdl namespace.
This library dependency issues with CMake.
This commit is contained in:
parent
50ed2187e1
commit
954e068a54
48 changed files with 243 additions and 165 deletions
|
@ -360,6 +360,7 @@ endif()
|
|||
set(wesnoth-sdl_SRC
|
||||
sdl/alpha.cpp
|
||||
sdl/exception.cpp
|
||||
sdl/rect.cpp
|
||||
sdl/texture.cpp
|
||||
sdl/window.cpp
|
||||
)
|
||||
|
|
|
@ -154,6 +154,7 @@ libwesnoth_sdl_sources = Split("""
|
|||
sdl_utils.cpp
|
||||
sdl/alpha.cpp
|
||||
sdl/exception.cpp
|
||||
sdl/rect.cpp
|
||||
sdl/texture.cpp
|
||||
sdl/window.cpp
|
||||
tracer.cpp
|
||||
|
|
|
@ -199,7 +199,7 @@ void show_about(display &disp, const std::string &campaign)
|
|||
// get slight scrolling glitches in the credits screen.
|
||||
std::vector<std::string> text = about::get_text(campaign, true);
|
||||
|
||||
SDL_Rect screen_rect = create_rect(0, 0, screen->w, screen->h);
|
||||
SDL_Rect screen_rect = sdl::create_rect(0, 0, screen->w, screen->h);
|
||||
|
||||
const surface_restorer restorer(&video, screen_rect);
|
||||
|
||||
|
@ -305,11 +305,11 @@ void show_about(display &disp, const std::string &campaign)
|
|||
if (update_dimensions) {
|
||||
// rescale the background
|
||||
map_image_scaled = scale_surface(map_image, screen->w, screen->h);
|
||||
screen_rect = create_rect(0, 0, screen->w, screen->h);
|
||||
screen_rect = sdl::create_rect(0, 0, screen->w, screen->h);
|
||||
redraw_mapimage = true;
|
||||
|
||||
// update the frame
|
||||
frame_area = create_rect(
|
||||
frame_area = sdl::create_rect(
|
||||
screen->w * 3 / 32
|
||||
, top_margin
|
||||
, screen->w * 13 / 16
|
||||
|
@ -345,7 +345,7 @@ void show_about(display &disp, const std::string &campaign)
|
|||
} else {
|
||||
// redraw the saved part of the dialog where text scrolled
|
||||
// thus erasing all text
|
||||
SDL_Rect modified = create_rect(0, 0, max_text_width, text_rect.h);
|
||||
SDL_Rect modified = sdl::create_rect(0, 0, max_text_width, text_rect.h);
|
||||
sdl_blit(text_surf, &modified, screen, &text_rect_blit);
|
||||
update_rect(text_rect);
|
||||
}
|
||||
|
|
|
@ -432,29 +432,29 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<
|
|||
// Disable alpha channel to avoid problem with sdl_blit
|
||||
SDL_SetAlpha(surf, 0, SDL_ALPHA_OPAQUE);
|
||||
|
||||
SDL_Rect clip_rect = create_rect(0, 0, width, height);
|
||||
SDL_Rect clip_rect = sdl::create_rect(0, 0, width, height);
|
||||
Uint32 grey_color = SDL_MapRGBA(surf->format, 0xb7, 0xc1, 0xc1, 255);
|
||||
|
||||
Uint32 background_color = SDL_MapRGBA(surf->format, 25, 25, 25, 255);
|
||||
sdl_fill_rect(surf, &clip_rect, background_color);
|
||||
|
||||
// Draw the surrounding borders and separators.
|
||||
SDL_Rect top_border_rect = create_rect(0, 0, width, 2);
|
||||
SDL_Rect top_border_rect = sdl::create_rect(0, 0, width, 2);
|
||||
sdl_fill_rect(surf, &top_border_rect, grey_color);
|
||||
|
||||
SDL_Rect bottom_border_rect = create_rect(0, height - 2, width, 2);
|
||||
SDL_Rect bottom_border_rect = sdl::create_rect(0, height - 2, width, 2);
|
||||
sdl_fill_rect(surf, &bottom_border_rect, grey_color);
|
||||
|
||||
SDL_Rect left_border_rect = create_rect(0, 0, 2, height);
|
||||
SDL_Rect left_border_rect = sdl::create_rect(0, 0, 2, height);
|
||||
sdl_fill_rect(surf, &left_border_rect, grey_color);
|
||||
|
||||
SDL_Rect right_border_rect = create_rect(width - 2, 0, 2, height);
|
||||
SDL_Rect right_border_rect = sdl::create_rect(width - 2, 0, 2, height);
|
||||
sdl_fill_rect(surf, &right_border_rect, grey_color);
|
||||
|
||||
SDL_Rect hp_sep_rect = create_rect(hp_sep, 0, 2, height);
|
||||
SDL_Rect hp_sep_rect = sdl::create_rect(hp_sep, 0, 2, height);
|
||||
sdl_fill_rect(surf, &hp_sep_rect, grey_color);
|
||||
|
||||
SDL_Rect percent_sep_rect = create_rect(width - percent_sep - 2, 0, 2, height);
|
||||
SDL_Rect percent_sep_rect = sdl::create_rect(width - percent_sep - 2, 0, 2, height);
|
||||
sdl_fill_rect(surf, &percent_sep_rect, grey_color);
|
||||
|
||||
// Draw the rows (lower HP values are at the bottom).
|
||||
|
@ -502,16 +502,16 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<
|
|||
|
||||
int bar_len = std::max<int>(static_cast<int>((prob * (bar_space - 4)) + 0.5), 2);
|
||||
|
||||
SDL_Rect bar_rect_1 = create_rect(hp_sep + 4, 6 + (fs + 2) * i, bar_len, 8);
|
||||
SDL_Rect bar_rect_1 = sdl::create_rect(hp_sep + 4, 6 + (fs + 2) * i, bar_len, 8);
|
||||
sdl_fill_rect(surf, &bar_rect_1, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 100));
|
||||
|
||||
SDL_Rect bar_rect_2 = create_rect(hp_sep + 4, 7 + (fs + 2) * i, bar_len, 6);
|
||||
SDL_Rect bar_rect_2 = sdl::create_rect(hp_sep + 4, 7 + (fs + 2) * i, bar_len, 6);
|
||||
sdl_fill_rect(surf, &bar_rect_2, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 66));
|
||||
|
||||
SDL_Rect bar_rect_3 = create_rect(hp_sep + 4, 8 + (fs + 2) * i, bar_len, 4);
|
||||
SDL_Rect bar_rect_3 = sdl::create_rect(hp_sep + 4, 8 + (fs + 2) * i, bar_len, 4);
|
||||
sdl_fill_rect(surf, &bar_rect_3, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 33));
|
||||
|
||||
SDL_Rect bar_rect_4 = create_rect(hp_sep + 4, 9 + (fs + 2) * i, bar_len, 2);
|
||||
SDL_Rect bar_rect_4 = sdl::create_rect(hp_sep + 4, 9 + (fs + 2) * i, bar_len, 2);
|
||||
sdl_fill_rect(surf, &bar_rect_4, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 0));
|
||||
|
||||
// Draw probability percentage, aligned right.
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "game_preferences.hpp"
|
||||
#include "image.hpp"
|
||||
#include "preferences_display.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "video.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
@ -267,7 +268,7 @@ void draw(surface screen)
|
|||
cursor_y = new_cursor_y;
|
||||
|
||||
// Save the screen area where the cursor is being drawn onto the back buffer
|
||||
SDL_Rect area = create_rect(cursor_x - shift_x[current_cursor]
|
||||
SDL_Rect area = sdl::create_rect(cursor_x - shift_x[current_cursor]
|
||||
, cursor_y - shift_y[current_cursor]
|
||||
, surf->w
|
||||
, surf->h);
|
||||
|
@ -291,7 +292,7 @@ void undraw(surface screen)
|
|||
return;
|
||||
}
|
||||
|
||||
SDL_Rect area = create_rect(cursor_x - shift_x[current_cursor]
|
||||
SDL_Rect area = sdl::create_rect(cursor_x - shift_x[current_cursor]
|
||||
, cursor_y - shift_y[current_cursor]
|
||||
, cursor_buf->w
|
||||
, cursor_buf->h);
|
||||
|
|
|
@ -696,7 +696,7 @@ void save_preview_pane::draw_contents()
|
|||
surface screen = video().getSurface();
|
||||
|
||||
SDL_Rect const &loc = location();
|
||||
const SDL_Rect area = create_rect(loc.x + save_preview_border
|
||||
const SDL_Rect area = sdl::create_rect(loc.x + save_preview_border
|
||||
, loc.y + save_preview_border
|
||||
, loc.w - save_preview_border * 2
|
||||
, loc.h - save_preview_border * 2);
|
||||
|
@ -724,7 +724,7 @@ void save_preview_pane::draw_contents()
|
|||
have_leader_image = !image.null();
|
||||
|
||||
if(have_leader_image) {
|
||||
SDL_Rect image_rect = create_rect(area.x, area.y, image->w, image->h);
|
||||
SDL_Rect image_rect = sdl::create_rect(area.x, area.y, image->w, image->h);
|
||||
ypos += image_rect.h + save_preview_border;
|
||||
|
||||
sdl_blit(image,NULL,screen,&image_rect);
|
||||
|
@ -772,7 +772,7 @@ void save_preview_pane::draw_contents()
|
|||
if(map_surf != NULL) {
|
||||
// Align the map to the left when the leader image is missing.
|
||||
const int map_x = have_leader_image ? area.x + area.w - map_surf->w : area.x;
|
||||
SDL_Rect map_rect = create_rect(map_x
|
||||
SDL_Rect map_rect = sdl::create_rect(map_x
|
||||
, area.y
|
||||
, map_surf->w
|
||||
, map_surf->h);
|
||||
|
@ -1060,7 +1060,7 @@ void unit_preview_pane::draw_contents()
|
|||
surface screen = video().getSurface();
|
||||
|
||||
SDL_Rect const &loc = location();
|
||||
const SDL_Rect area = create_rect(loc.x + unit_preview_border
|
||||
const SDL_Rect area = sdl::create_rect(loc.x + unit_preview_border
|
||||
, loc.y + unit_preview_border
|
||||
, loc.w - unit_preview_border * 2
|
||||
, loc.h - unit_preview_border * 2);
|
||||
|
@ -1071,10 +1071,10 @@ void unit_preview_pane::draw_contents()
|
|||
if (!left_)
|
||||
unit_image = image::reverse_image(unit_image);
|
||||
|
||||
SDL_Rect image_rect = create_rect(area.x, area.y, 0, 0);
|
||||
SDL_Rect image_rect = sdl::create_rect(area.x, area.y, 0, 0);
|
||||
|
||||
if(unit_image != NULL) {
|
||||
SDL_Rect rect = create_rect(
|
||||
SDL_Rect rect = sdl::create_rect(
|
||||
right_align
|
||||
? area.x
|
||||
: area.x + area.w - unit_image->w
|
||||
|
@ -1103,7 +1103,7 @@ void unit_preview_pane::draw_contents()
|
|||
}
|
||||
|
||||
// Place the 'unit profile' button
|
||||
const SDL_Rect button_loc = create_rect(
|
||||
const SDL_Rect button_loc = sdl::create_rect(
|
||||
right_align
|
||||
? area.x
|
||||
: area.x + area.w - details_button_.location().w
|
||||
|
@ -1112,7 +1112,7 @@ void unit_preview_pane::draw_contents()
|
|||
, details_button_.location().h);
|
||||
details_button_.set_location(button_loc);
|
||||
|
||||
SDL_Rect description_rect = create_rect(image_rect.x
|
||||
SDL_Rect description_rect = sdl::create_rect(image_rect.x
|
||||
, image_rect.y + image_rect.h + details_button_.location().h
|
||||
, 0
|
||||
, 0);
|
||||
|
@ -1429,7 +1429,7 @@ static network::connection network_data_dialog(display& disp, const std::string&
|
|||
frame.layout(centered_layout);
|
||||
frame.draw();
|
||||
|
||||
const SDL_Rect progress_rect = create_rect(centered_layout.x + border
|
||||
const SDL_Rect progress_rect = sdl::create_rect(centered_layout.x + border
|
||||
, centered_layout.y + border
|
||||
, centered_layout.w - border * 2
|
||||
, centered_layout.h - border * 2);
|
||||
|
|
|
@ -407,7 +407,7 @@ const SDL_Rect& display::calculate_energy_bar(surface surf)
|
|||
}
|
||||
}
|
||||
|
||||
const SDL_Rect res = create_rect(first_col
|
||||
const SDL_Rect res = sdl::create_rect(first_col
|
||||
, first_row
|
||||
, last_col-first_col
|
||||
, last_row+1-first_row);
|
||||
|
@ -445,7 +445,7 @@ void display::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 = create_rect(
|
||||
const SDL_Rect scaled_bar_loc = sdl::create_rect(
|
||||
fxptoi(unscaled_bar_loc. x * xratio)
|
||||
, fxptoi(unscaled_bar_loc. y * yratio + 127)
|
||||
, fxptoi(unscaled_bar_loc. w * xratio + 255)
|
||||
|
@ -466,8 +466,8 @@ void display::draw_bar(const std::string& image, int xpos, int ypos,
|
|||
|
||||
const size_t skip_rows = bar_loc.h - height;
|
||||
|
||||
SDL_Rect top = create_rect(0, 0, surf->w, bar_loc.y);
|
||||
SDL_Rect bot = create_rect(0, bar_loc.y + skip_rows, surf->w, 0);
|
||||
SDL_Rect top = sdl::create_rect(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;
|
||||
|
||||
drawing_buffer_add(LAYER_UNIT_BAR, loc, xpos, ypos, surf, top);
|
||||
|
@ -478,7 +478,7 @@ void display::draw_bar(const std::string& image, int xpos, int ypos,
|
|||
if(unfilled < height && alpha >= ftofxp(0.3)) {
|
||||
const Uint8 r_alpha = std::min<unsigned>(unsigned(fxpmult(alpha,255)),255);
|
||||
surface filled_surf = create_compatible_surface(bar_surf, bar_loc.w, height - unfilled);
|
||||
SDL_Rect filled_area = create_rect(0, 0, bar_loc.w, height-unfilled);
|
||||
SDL_Rect filled_area = sdl::create_rect(0, 0, bar_loc.w, height-unfilled);
|
||||
sdl_fill_rect(filled_surf,&filled_area,SDL_MapRGBA(bar_surf->format,col.r,col.g,col.b, r_alpha));
|
||||
drawing_buffer_add(LAYER_UNIT_BAR, loc, xpos + bar_loc.x, ypos + bar_loc.y + unfilled, filled_surf);
|
||||
}
|
||||
|
@ -1298,7 +1298,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 = create_rect(blit.x(), blit.y(), 0, 0);
|
||||
SDL_Rect dstrect = sdl::create_rect(blit.x(), blit.y(), 0, 0);
|
||||
SDL_Rect srcrect = blit.clip();
|
||||
SDL_Rect *srcrectArg = (srcrect.x | srcrect.y | srcrect.w | srcrect.h)
|
||||
? &srcrect : NULL;
|
||||
|
@ -1513,7 +1513,7 @@ static void draw_background(surface screen, const SDL_Rect& area, const std::str
|
|||
|
||||
for(unsigned int w = 0, w_off = area.x; w < w_count; ++w, w_off += width) {
|
||||
for(unsigned int h = 0, h_off = area.y; h < h_count; ++h, h_off += height) {
|
||||
SDL_Rect clip = create_rect(w_off, h_off, 0, 0);
|
||||
SDL_Rect clip = sdl::create_rect(w_off, h_off, 0, 0);
|
||||
sdl_blit(background, NULL, screen, &clip);
|
||||
}
|
||||
}
|
||||
|
@ -1553,7 +1553,7 @@ void display::render_image(int x, int y, const display::tdrawing_layer drawing_l
|
|||
if (image==NULL)
|
||||
return;
|
||||
|
||||
SDL_Rect image_rect = create_rect(x, y, image->w, image->h);
|
||||
SDL_Rect image_rect = sdl::create_rect(x, y, image->w, image->h);
|
||||
SDL_Rect clip_rect = map_area();
|
||||
if (!rects_overlap(image_rect, clip_rect))
|
||||
return;
|
||||
|
@ -1591,7 +1591,7 @@ void display::render_image(int x, int y, const display::tdrawing_layer drawing_l
|
|||
// 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 = create_rect(0, 0, surf->w, submerge_height);
|
||||
SDL_Rect srcrect = sdl::create_rect(0, 0, surf->w, submerge_height);
|
||||
drawing_buffer_add(drawing_layer, loc, x, y, surf, srcrect);
|
||||
|
||||
if(submerge_height != surf->h) {
|
||||
|
@ -1950,7 +1950,7 @@ void display::draw_minimap_units()
|
|||
double u_w = 4.0 / 3.0 * xscaling;
|
||||
double u_h = yscaling;
|
||||
|
||||
SDL_Rect r = create_rect(minimap_location_.x + round_double(u_x)
|
||||
SDL_Rect r = sdl::create_rect(minimap_location_.x + round_double(u_x)
|
||||
, minimap_location_.y + round_double(u_y)
|
||||
, round_double(u_w)
|
||||
, round_double(u_h));
|
||||
|
@ -2540,7 +2540,7 @@ void display::draw_invalidated() {
|
|||
update_rect(xpos, ypos, zoom_, zoom_);
|
||||
|
||||
const bool on_map = get_map().on_board(loc);
|
||||
SDL_Rect hex_rect = create_rect(xpos, ypos, zoom_, zoom_);
|
||||
SDL_Rect hex_rect = sdl::create_rect(xpos, ypos, zoom_, zoom_);
|
||||
if(!rects_overlap(hex_rect,clip_rect)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2654,7 +2654,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 = create_rect(0, 0, text->w, text->h);
|
||||
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
|
||||
sdl_fill_rect(bg, &bg_rect, 0xaa000000);
|
||||
off_x -= text->w / 2;
|
||||
if (draw_terrain_codes_) {
|
||||
|
@ -2670,7 +2670,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 = create_rect(0, 0, text->w, text->h);
|
||||
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
|
||||
sdl_fill_rect(bg, &bg_rect, 0xaa000000);
|
||||
off_x -= text->w / 2;
|
||||
if (!draw_coordinates_) {
|
||||
|
@ -2816,7 +2816,7 @@ void display::refresh_report(std::string const &report_name, const config * new_
|
|||
for (config::const_child_itors elements = report.child_range("element");
|
||||
elements.first != elements.second; ++elements.first)
|
||||
{
|
||||
SDL_Rect area = create_rect(x, y, rect.w + rect.x - x, rect.h + rect.y - y);
|
||||
SDL_Rect area = sdl::create_rect(x, y, rect.w + rect.x - x, rect.h + rect.y - y);
|
||||
if (area.h <= 0) break;
|
||||
|
||||
std::string t = (*elements.first)["text"];
|
||||
|
|
|
@ -43,6 +43,7 @@ class arrow;
|
|||
#include "key.hpp"
|
||||
#include "team.hpp"
|
||||
#include "time_of_day.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "theme.hpp"
|
||||
#include "video.hpp"
|
||||
#include "widgets/button.hpp"
|
||||
|
@ -205,7 +206,7 @@ public:
|
|||
{ return theme_.unit_image_location(screen_area()); }
|
||||
|
||||
SDL_Rect screen_area() const
|
||||
{ return create_rect(0, 0, w(), h()); }
|
||||
{ return sdl::create_rect(0, 0, w(), h()); }
|
||||
|
||||
/**
|
||||
* Returns the maximum area used for the map
|
||||
|
|
|
@ -174,12 +174,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 = create_rect(offset, quarter_size, 0, 0);
|
||||
SDL_Rect rcDestLeft = sdl::create_rect(offset, quarter_size, 0, 0);
|
||||
sdl_blit ( image_fg, NULL, image, &rcDestLeft );
|
||||
|
||||
// Blit right side
|
||||
image_bg = scale_surface(image_bg, new_size, new_size);
|
||||
SDL_Rect rcDestRight = create_rect(half_size, quarter_size, 0, 0);
|
||||
SDL_Rect rcDestRight = sdl::create_rect(half_size, quarter_size, 0, 0);
|
||||
sdl_blit ( image_bg, NULL, image, &rcDestRight );
|
||||
|
||||
//apply mask so the overlay is contained within the mouseover hex
|
||||
|
@ -333,7 +333,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 = create_rect(6, 6, 0, 0);
|
||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||
blit_surface(image60, NULL, image, &r);
|
||||
|
||||
Uint8 alpha = 196;
|
||||
|
@ -456,7 +456,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 = create_rect(6, 6, 0, 0);
|
||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||
blit_surface(image60, NULL, image, &r);
|
||||
|
||||
Uint8 alpha = 196;
|
||||
|
|
|
@ -109,7 +109,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 = create_rect(6, 6, 0, 0);
|
||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||
blit_surface(image60, NULL, 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 = create_rect(6, 6, 0, 0);
|
||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||
blit_surface(image60, NULL, image, &r);
|
||||
|
||||
Uint8 alpha = 196;
|
||||
|
|
|
@ -242,7 +242,7 @@ void tristate_button::draw_contents() {
|
|||
surface nbase = make_neutral_surface(base);
|
||||
|
||||
//TODO avoid magic numbers
|
||||
SDL_Rect r = create_rect(1, 1, 0, 0);
|
||||
SDL_Rect r = sdl::create_rect(1, 1, 0, 0);
|
||||
blit_surface(nitem, NULL, nbase, &r);
|
||||
|
||||
if (!overlay.null()) {
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace gui{
|
|||
|
||||
if(box_ != NULL) {
|
||||
box_->set_volatile(true);
|
||||
const SDL_Rect rect = create_rect(
|
||||
const SDL_Rect rect = sdl::create_rect(
|
||||
area.x + label_area.w + border_size * 2
|
||||
, ypos
|
||||
, textbox_width
|
||||
|
|
17
src/font.cpp
17
src/font.cpp
|
@ -27,6 +27,7 @@
|
|||
#include "tooltips.hpp"
|
||||
#include "video.hpp"
|
||||
#include "sdl/alpha.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
#include "serialization/preprocessor.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
@ -752,7 +753,7 @@ static surface render_text(const std::string& text, int fontsize, const SDL_Colo
|
|||
for(std::vector<surface>::const_iterator j = i->begin(),
|
||||
j_end = i->end(); j != j_end; ++j) {
|
||||
SDL_SetAlpha(*j, 0, 0); // direct blit without alpha blending
|
||||
SDL_Rect dstrect = create_rect(xpos, ypos, 0, 0);
|
||||
SDL_Rect dstrect = sdl::create_rect(xpos, ypos, 0, 0);
|
||||
sdl_blit(*j, NULL, res, &dstrect);
|
||||
xpos += (*j)->w;
|
||||
height = std::max<size_t>((*j)->h, height);
|
||||
|
@ -777,11 +778,11 @@ SDL_Rect draw_text_line(surface gui_surface, const SDL_Rect& area, int size,
|
|||
{
|
||||
if (gui_surface.null()) {
|
||||
text_surface const &u = text_cache::find(text_surface(text, size, color, style));
|
||||
return create_rect(0, 0, u.width(), u.height());
|
||||
return sdl::create_rect(0, 0, u.width(), u.height());
|
||||
}
|
||||
|
||||
if(area.w == 0) { // no place to draw
|
||||
return create_rect(0, 0, 0, 0);
|
||||
return sdl::create_rect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
const std::string etext = make_text_ellipsis(text, size, area.w);
|
||||
|
@ -789,7 +790,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 == NULL) {
|
||||
return create_rect(0, 0, 0, 0);
|
||||
return sdl::create_rect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
SDL_Rect dest;
|
||||
|
@ -989,7 +990,7 @@ surface floating_label::create_surface()
|
|||
// (where the text was blitted directly on screen)
|
||||
foreground = adjust_surface_alpha(foreground, ftofxp(1.13), false);
|
||||
|
||||
SDL_Rect r = create_rect( border_, border_, 0, 0);
|
||||
SDL_Rect r = sdl::create_rect( border_, border_, 0, 0);
|
||||
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
||||
blit_surface(foreground, NULL, background, &r);
|
||||
|
||||
|
@ -1044,7 +1045,7 @@ void floating_label::draw(surface screen)
|
|||
return;
|
||||
}
|
||||
|
||||
SDL_Rect rect = create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
|
||||
SDL_Rect rect = sdl::create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
|
||||
const clip_rect_setter clip_setter(screen, &clip_rect_);
|
||||
sdl_blit(screen,&rect,buf_,NULL);
|
||||
sdl_blit(surf_,NULL,screen,&rect);
|
||||
|
@ -1058,7 +1059,7 @@ void floating_label::undraw(surface screen)
|
|||
return;
|
||||
}
|
||||
|
||||
SDL_Rect rect = create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
|
||||
SDL_Rect rect = sdl::create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
|
||||
const clip_rect_setter clip_setter(screen, &clip_rect_);
|
||||
sdl_blit(buf_,NULL,screen,&rect);
|
||||
|
||||
|
@ -1130,7 +1131,7 @@ SDL_Rect get_floating_label_rect(int handle)
|
|||
if(i != labels.end()) {
|
||||
const surface surf = i->second.create_surface();
|
||||
if(surf != NULL) {
|
||||
return create_rect(0, 0, surf->w, surf->h);
|
||||
return sdl::create_rect(0, 0, surf->w, surf->h);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -628,7 +628,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
// General tab
|
||||
int ypos = rect.y + top_border;
|
||||
scroll_label_.set_location(rect.x, ypos);
|
||||
SDL_Rect scroll_rect = create_rect(rect.x + scroll_label_.width()
|
||||
SDL_Rect scroll_rect = sdl::create_rect(rect.x + scroll_label_.width()
|
||||
, ypos
|
||||
, rect.w - scroll_label_.width() - right_border
|
||||
, 0);
|
||||
|
@ -637,7 +637,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
ypos += item_interline; turbo_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline; turbo_slider_label_.set_location(rect.x + horizontal_padding, ypos);
|
||||
ypos += short_interline;
|
||||
SDL_Rect turbo_rect = create_rect(rect.x + horizontal_padding
|
||||
SDL_Rect turbo_rect = sdl::create_rect(rect.x + horizontal_padding
|
||||
, ypos
|
||||
, rect.w - horizontal_padding - right_border
|
||||
, 0);
|
||||
|
@ -651,7 +651,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
ypos += item_interline; save_replays_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline; delete_saves_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline; autosavemax_slider_label_.set_location(rect.x + horizontal_padding, ypos);
|
||||
SDL_Rect autosavemax_rect = create_rect(rect.x + horizontal_padding
|
||||
SDL_Rect autosavemax_rect = sdl::create_rect(rect.x + horizontal_padding
|
||||
, ypos + short_interline
|
||||
, rect.w - horizontal_padding - right_border
|
||||
, 0);
|
||||
|
@ -674,7 +674,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
ypos += short_interline; idle_anim_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline;
|
||||
idle_anim_slider_label_.set_location(rect.x + horizontal_padding, ypos);
|
||||
SDL_Rect idle_anim_rect = create_rect(rect.x + horizontal_padding + idle_anim_slider_label_.width()
|
||||
SDL_Rect idle_anim_rect = sdl::create_rect(rect.x + horizontal_padding + idle_anim_slider_label_.width()
|
||||
, ypos
|
||||
, rect.w - horizontal_padding - idle_anim_slider_label_.width() - right_border
|
||||
, 0);
|
||||
|
@ -760,7 +760,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
|
||||
ypos += short_interline;
|
||||
sound_label_.set_location(rect.x + horizontal_padding, ypos);
|
||||
const SDL_Rect sound_rect = create_rect(rect.x + horizontal_padding + slider_label_width_
|
||||
const SDL_Rect sound_rect = sdl::create_rect(rect.x + horizontal_padding + slider_label_width_
|
||||
, ypos
|
||||
, rect.w - slider_label_width_ - horizontal_padding - right_border
|
||||
, 0);
|
||||
|
@ -771,7 +771,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
|
||||
ypos += short_interline;
|
||||
music_label_.set_location(rect.x + horizontal_padding, ypos);
|
||||
const SDL_Rect music_rect = create_rect(rect.x + horizontal_padding + slider_label_width_
|
||||
const SDL_Rect music_rect = sdl::create_rect(rect.x + horizontal_padding + slider_label_width_
|
||||
, ypos
|
||||
, rect.w - slider_label_width_ - horizontal_padding - right_border
|
||||
, 0);
|
||||
|
@ -781,7 +781,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
turn_bell_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline;
|
||||
bell_label_.set_location(rect.x + horizontal_padding, ypos);
|
||||
const SDL_Rect bell_rect = create_rect(rect.x + horizontal_padding + slider_label_width_
|
||||
const SDL_Rect bell_rect = sdl::create_rect(rect.x + horizontal_padding + slider_label_width_
|
||||
, ypos
|
||||
, rect.w - slider_label_width_ - horizontal_padding - right_border
|
||||
, 0);
|
||||
|
@ -791,7 +791,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
UI_sound_button_.set_location(rect.x, ypos);
|
||||
ypos += short_interline;
|
||||
UI_sound_label_.set_location(rect.x + horizontal_padding, ypos);
|
||||
const SDL_Rect UI_sound_rect = create_rect(rect.x + horizontal_padding + slider_label_width_
|
||||
const SDL_Rect UI_sound_rect = sdl::create_rect(rect.x + horizontal_padding + slider_label_width_
|
||||
, ypos
|
||||
, rect.w - slider_label_width_ - horizontal_padding - right_border
|
||||
, 0);
|
||||
|
@ -817,7 +817,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
ypos += item_interline;
|
||||
buffer_size_label_.set_location(rect.x, ypos);
|
||||
ypos += short_interline;
|
||||
SDL_Rect buffer_rect = create_rect(rect.x + horizontal_padding
|
||||
SDL_Rect buffer_rect = sdl::create_rect(rect.x + horizontal_padding
|
||||
, ypos
|
||||
, rect.w - horizontal_padding - right_border
|
||||
, 0);
|
||||
|
@ -830,7 +830,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
ypos = rect.y + top_border;
|
||||
chat_lines_label_.set_location(rect.x, ypos);
|
||||
ypos += short_interline;
|
||||
SDL_Rect chat_lines_rect = create_rect(rect.x + horizontal_padding
|
||||
SDL_Rect chat_lines_rect = sdl::create_rect(rect.x + horizontal_padding
|
||||
, ypos
|
||||
, rect.w - horizontal_padding - right_border
|
||||
, 0);
|
||||
|
@ -878,7 +878,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
|
||||
advanced_button_.set_location(rect.x,ypos);
|
||||
advanced_option_label_.set_location(rect.x,ypos);
|
||||
const SDL_Rect advanced_slider_rect = create_rect(rect.x
|
||||
const SDL_Rect advanced_slider_rect = sdl::create_rect(rect.x
|
||||
, ypos + short_interline
|
||||
, rect.w - right_border
|
||||
, 0);
|
||||
|
|
|
@ -114,7 +114,7 @@ void default_map_generator::user_config(display& disp)
|
|||
f.layout(xpos,ypos,width,height);
|
||||
f.draw();
|
||||
|
||||
SDL_Rect dialog_rect = create_rect(xpos, ypos, width, height);
|
||||
SDL_Rect dialog_rect = sdl::create_rect(xpos, ypos, width, height);
|
||||
surface_restorer dialog_restorer(&screen,dialog_rect);
|
||||
|
||||
const std::string& players_label = _("Players:");
|
||||
|
@ -163,7 +163,7 @@ void default_map_generator::user_config(display& disp)
|
|||
|
||||
const int slider_left = text_right + 10;
|
||||
const int slider_right = xpos + width - horz_margin - right_space;
|
||||
SDL_Rect slider_rect = create_rect(slider_left
|
||||
SDL_Rect slider_rect = sdl::create_rect(slider_left
|
||||
, players_rect.y
|
||||
, slider_right - slider_left
|
||||
, players_rect.h);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "gui/auxiliary/formula.hpp"
|
||||
#include "gui/auxiliary/log.hpp"
|
||||
#include "gui/widgets/helper.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "../../text.hpp"
|
||||
#include "utils/foreach.tpp"
|
||||
#include "video.hpp"
|
||||
|
@ -1092,13 +1093,14 @@ void timage::draw(surface& canvas,
|
|||
surface tmp(image::get_image(image::locator(name)));
|
||||
|
||||
if(!tmp) {
|
||||
ERR_GUI_D << "Image: '" << name << "' not found and won't be drawn." << std::endl;
|
||||
ERR_GUI_D << "Image: '" << name << "' not found and won't be drawn."
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
image_.assign(make_neutral_surface(tmp));
|
||||
assert(image_);
|
||||
src_clip_ = ::create_rect(0, 0, image_->w, image_->h);
|
||||
src_clip_ = sdl::create_rect(0, 0, image_->w, image_->h);
|
||||
|
||||
game_logic::map_formula_callable local_variables(variables);
|
||||
local_variables.add("image_original_width", variant(image_->w));
|
||||
|
@ -1137,7 +1139,7 @@ void timage::draw(surface& canvas,
|
|||
|
||||
// Copy the data to local variables to avoid overwriting the originals.
|
||||
SDL_Rect src_clip = src_clip_;
|
||||
SDL_Rect dst_clip = ::create_rect(x, y, 0, 0);
|
||||
SDL_Rect dst_clip = sdl::create_rect(x, y, 0, 0);
|
||||
surface surf;
|
||||
|
||||
// Test whether we need to scale and do the scaling if needed.
|
||||
|
@ -1179,7 +1181,7 @@ void timage::draw(surface& canvas,
|
|||
|
||||
for(int x = 0; x < columns; ++x) {
|
||||
for(int y = 0; y < rows; ++y) {
|
||||
const SDL_Rect dest = ::create_rect(
|
||||
const SDL_Rect dest = sdl::create_rect(
|
||||
x * image_->w, y * image_->h, 0, 0);
|
||||
blit_surface(image_, NULL, surf, &dest);
|
||||
}
|
||||
|
@ -1422,7 +1424,7 @@ void ttext::draw(surface& canvas,
|
|||
"canvas and will be clipped.\n";
|
||||
}
|
||||
|
||||
SDL_Rect dst = ::create_rect(x, y, canvas->w, canvas->h);
|
||||
SDL_Rect dst = sdl::create_rect(x, y, canvas->w, canvas->h);
|
||||
blit_surface(surf, 0, canvas, &dst);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "gui/auxiliary/log.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
|
||||
#include "formula_string_utils.hpp"
|
||||
|
||||
|
@ -46,7 +47,7 @@ bool init()
|
|||
|
||||
SDL_Rect create_rect(const tpoint& origin, const tpoint& size)
|
||||
{
|
||||
return ::create_rect(origin.x, origin.y, size.x, size.y);
|
||||
return sdl::create_rect(origin.x, origin.y, size.x, size.y);
|
||||
}
|
||||
|
||||
unsigned decode_font_style(const std::string& style)
|
||||
|
|
|
@ -757,7 +757,7 @@ void twindow::draw()
|
|||
/** @todo should probably be moved to event::thandler::draw. */
|
||||
static unsigned i = 0;
|
||||
if(++i % sunset_ == 0) {
|
||||
SDL_Rect r = ::create_rect(
|
||||
SDL_Rect r = sdl::create_rect(
|
||||
0, 0, frame_buffer->w, frame_buffer->h);
|
||||
const Uint32 color
|
||||
= SDL_MapRGBA(frame_buffer->format, 0, 0, 0, 255);
|
||||
|
|
|
@ -170,7 +170,7 @@ bool effect::render()
|
|||
const int xpos = x_ + screenx - surf_->w/2;
|
||||
const int ypos = y_ + screeny - surf_->h/2;
|
||||
|
||||
SDL_Rect rect = create_rect(xpos, ypos, surf_->w, surf_->h);
|
||||
SDL_Rect rect = sdl::create_rect(xpos, ypos, surf_->w, surf_->h);
|
||||
rect_ = rect;
|
||||
SDL_Rect clip_rect = disp->map_outside_area();
|
||||
|
||||
|
@ -235,7 +235,7 @@ void effect::unrender()
|
|||
const int xpos = x_ + screenx - surf_->w/2;
|
||||
const int ypos = y_ + screeny - surf_->h/2;
|
||||
|
||||
SDL_Rect rect = create_rect(xpos, ypos, surf_->w, surf_->h);
|
||||
SDL_Rect rect = sdl::create_rect(xpos, ypos, surf_->w, surf_->h);
|
||||
sdl_blit(buffer_,NULL,screen,&rect);
|
||||
update_rect(rect);
|
||||
}
|
||||
|
|
|
@ -564,14 +564,14 @@ void hotkey_preferences_dialog::show_binding_dialog(
|
|||
|
||||
const std::string text = _("Press desired hotkey (Esc cancels)");
|
||||
|
||||
SDL_Rect clip_rect = create_rect(0, 0, disp_.w(), disp_.h());
|
||||
SDL_Rect clip_rect = sdl::create_rect(0, 0, disp_.w(), disp_.h());
|
||||
SDL_Rect text_size = font::draw_text(NULL, clip_rect, font::SIZE_LARGE,
|
||||
font::NORMAL_COLOR, text, 0, 0);
|
||||
|
||||
const int centerx = disp_.w() / 2;
|
||||
const int centery = disp_.h() / 2;
|
||||
|
||||
SDL_Rect dlgr = create_rect(centerx - text_size.w / 2 - 30,
|
||||
SDL_Rect dlgr = sdl::create_rect(centerx - text_size.w / 2 - 30,
|
||||
centery - text_size.h / 2 - 16, text_size.w + 60,
|
||||
text_size.h + 32);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "image_modifications.hpp"
|
||||
#include "log.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
||||
#include "SDL_image.h"
|
||||
|
@ -567,7 +568,7 @@ surface locator::load_image_sub_file() const
|
|||
}
|
||||
|
||||
if(val_.loc_.valid()) {
|
||||
SDL_Rect srcrect = create_rect(
|
||||
SDL_Rect srcrect = sdl::create_rect(
|
||||
((tile_size*3) / 4) * val_.loc_.x
|
||||
, tile_size * val_.loc_.y + (tile_size / 2) * (val_.loc_.x % 2)
|
||||
, tile_size
|
||||
|
|
|
@ -276,7 +276,7 @@ surface blit_modification::operator()(const surface& src) const
|
|||
//blit_surface want neutral surfaces
|
||||
surface nsrc = make_neutral_surface(src);
|
||||
surface nsurf = make_neutral_surface(surf_);
|
||||
SDL_Rect r = create_rect(x_, y_, 0, 0);
|
||||
SDL_Rect r = sdl::create_rect(x_, y_, 0, 0);
|
||||
blit_surface(nsurf, NULL, nsrc, &r);
|
||||
return nsrc;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ surface mask_modification::operator()(const surface& src) const
|
|||
{
|
||||
if(src->w == mask_->w && src->h == mask_->h && x_ == 0 && y_ == 0)
|
||||
return mask_surface(src, mask_);
|
||||
SDL_Rect r = create_rect(x_, y_, 0, 0);
|
||||
SDL_Rect r = sdl::create_rect(x_, y_, 0, 0);
|
||||
surface new_mask = create_neutral_surface(src->w, src->h);
|
||||
blit_surface(mask_, NULL, new_mask, &r);
|
||||
return mask_surface(src, new_mask);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "marked-up_text.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "video.hpp"
|
||||
#include "image.hpp"
|
||||
|
||||
|
@ -199,7 +200,7 @@ void loadscreen::clear_screen()
|
|||
{
|
||||
int scrx = screen_.getx(); // Screen width.
|
||||
int scry = screen_.gety(); // Screen height.
|
||||
SDL_Rect area = create_rect(0, 0, scrx, scry); // Screen area.
|
||||
SDL_Rect area = sdl::create_rect(0, 0, scrx, scry); // Screen area.
|
||||
surface disp(screen_.getSurface()); // Screen surface.
|
||||
// Make everything black.
|
||||
sdl_fill_rect(disp,&area,SDL_MapRGB(disp->format,0,0,0));
|
||||
|
|
|
@ -2852,14 +2852,14 @@ void console_handler::do_layers() {
|
|||
std::ostringstream str;
|
||||
|
||||
int tz = image::tile_size;
|
||||
SDL_Rect r = create_rect(0,0,tz,tz);
|
||||
SDL_Rect r = sdl::create_rect(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 = create_rect(
|
||||
r = sdl::create_rect(
|
||||
((tz*3) / 4) * loc_cut.x
|
||||
, tz * loc_cut.y + (tz / 2) * (loc_cut.x % 2)
|
||||
, tz, tz);
|
||||
|
@ -2876,7 +2876,7 @@ void console_handler::do_layers() {
|
|||
|
||||
// cut and mask the image
|
||||
// ~CROP and ~BLIT have limitations, we do some math to avoid them
|
||||
SDL_Rect r2 = intersect_rects(r, create_rect(0,0,surf->w,surf->h));
|
||||
SDL_Rect r2 = intersect_rects(r, sdl::create_rect(0,0,surf->w,surf->h));
|
||||
if(r2.w > 0 && r2.h > 0) {
|
||||
str << "~BLIT("
|
||||
<< name << "~CROP("
|
||||
|
|
|
@ -96,7 +96,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
|
||||
// also do 1-pixel shift because the scaling
|
||||
// function seems to do it with its rounding
|
||||
SDL_Rect maprect = create_rect(
|
||||
SDL_Rect maprect = sdl::create_rect(
|
||||
x * scale * 3 / 4 - 1
|
||||
, y * scale + scale / 4 * (is_odd(x) ? 1 : -1) - 1
|
||||
, 0
|
||||
|
@ -146,7 +146,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
|
||||
if(overlay != NULL && overlay != tile) {
|
||||
surface combined = create_neutral_surface(tile->w, tile->h);
|
||||
SDL_Rect r = create_rect(0,0,0,0);
|
||||
SDL_Rect r = sdl::create_rect(0,0,0,0);
|
||||
sdl_blit(tile, NULL, combined, &r);
|
||||
r.x = std::max(0, (tile->w - overlay->w)/2);
|
||||
r.y = std::max(0, (tile->h - overlay->h)/2);
|
||||
|
@ -224,7 +224,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 = create_rect(maprect.x, maprect.y, scale * 3/4, scale);
|
||||
SDL_Rect fillrect = sdl::create_rect(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);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
}
|
||||
}
|
||||
|
||||
SDL_Rect fillrect = create_rect(
|
||||
SDL_Rect fillrect = sdl::create_rect(
|
||||
maprect.x
|
||||
, maprect.y
|
||||
, scale * 3/4
|
||||
|
|
|
@ -83,7 +83,7 @@ static void run_lobby_loop(display& disp, mp::ui& ui)
|
|||
font::cache_mode(font::CACHE_LOBBY);
|
||||
while (ui.get_result() == mp::ui::CONTINUE) {
|
||||
if (disp.video().modeChanged() || first) {
|
||||
SDL_Rect lobby_pos = create_rect(0
|
||||
SDL_Rect lobby_pos = sdl::create_rect(0
|
||||
, 0
|
||||
, disp.video().getx()
|
||||
, disp.video().gety());
|
||||
|
|
|
@ -612,7 +612,7 @@ void create::layout_children(const SDL_Rect& rect)
|
|||
int ypos_columntop = ypos;
|
||||
|
||||
// First column: image & random map options
|
||||
image_rect_ = create_rect(xpos, ypos, image_width, image_width);
|
||||
image_rect_ = sdl::create_rect(xpos, ypos, image_width, image_width);
|
||||
ypos += image_width + border_size;
|
||||
|
||||
num_players_label_.set_location(xpos, ypos);
|
||||
|
|
|
@ -95,7 +95,7 @@ SDL_Rect gamebrowser::get_item_rect(size_t index) const {
|
|||
return res;
|
||||
}
|
||||
const SDL_Rect& loc = inner_location();
|
||||
return create_rect(
|
||||
return sdl::create_rect(
|
||||
loc.x
|
||||
, loc.y + (index - visible_range_.first) * row_height()
|
||||
, loc.w
|
||||
|
|
|
@ -186,7 +186,7 @@ ui::ui(game_display& disp, const std::string& title, const config& cfg, chat& c,
|
|||
gamelist_refresh_(false),
|
||||
lobby_clock_(0)
|
||||
{
|
||||
const SDL_Rect area = create_rect(0
|
||||
const SDL_Rect area = sdl::create_rect(0
|
||||
, 0
|
||||
, disp.video().getx()
|
||||
, disp.video().gety());
|
||||
|
|
|
@ -86,7 +86,7 @@ void wait::leader_preview_pane::draw_contents()
|
|||
surface screen = video().getSurface();
|
||||
|
||||
SDL_Rect const &loc = location();
|
||||
const SDL_Rect area = create_rect(loc.x + leader_pane_border,
|
||||
const SDL_Rect area = sdl::create_rect(loc.x + leader_pane_border,
|
||||
loc.y + leader_pane_border,loc.w - leader_pane_border * 2,
|
||||
loc.h - leader_pane_border * 2);
|
||||
const clip_rect_setter clipper(screen, &area);
|
||||
|
|
30
src/sdl/rect.cpp
Normal file
30
src/sdl/rect.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "sdl/rect.hpp"
|
||||
|
||||
namespace sdl
|
||||
{
|
||||
|
||||
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
rect.w = w;
|
||||
rect.h = h;
|
||||
return rect;
|
||||
}
|
||||
|
||||
} // namespace sdl
|
44
src/sdl/rect.hpp
Normal file
44
src/sdl/rect.hpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef SDL_RECT_HPP_INCLUDED
|
||||
#define SDL_RECT_HPP_INCLUDED
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Constains the SDL_Rect helper code.
|
||||
*/
|
||||
|
||||
#include <SDL_version.h>
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
#include <SDL_rect.h>
|
||||
#else
|
||||
#include <SDL_video.h>
|
||||
#endif
|
||||
|
||||
namespace sdl
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates an empty SDL_Rect.
|
||||
*
|
||||
* Since SDL_Rect doesn't have a constructor it's not possible to create it as
|
||||
* a temporary for a function parameter. This functions overcomes this limit.
|
||||
*/
|
||||
SDL_Rect create_rect(const int x, const int y, const int w, const int h);
|
||||
|
||||
} // namespace sdl
|
||||
|
||||
#endif
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "SDL_image.h"
|
||||
#include "sdl/exception.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "sdl_utils.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "sdl_utils.hpp"
|
||||
#include "sdl/alpha.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
|
||||
#include "floating_point_emulation.hpp"
|
||||
#include "neon.hpp"
|
||||
|
@ -153,16 +154,6 @@ SDL_Rect union_rects(SDL_Rect const &rect1, SDL_Rect const &rect2)
|
|||
return res;
|
||||
}
|
||||
|
||||
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
rect.w = w;
|
||||
rect.h = h;
|
||||
return rect;
|
||||
}
|
||||
|
||||
bool operator<(const surface& a, const surface& b)
|
||||
{
|
||||
return a.get() < b.get();
|
||||
|
@ -1257,7 +1248,7 @@ surface blur_surface(const surface &surf, int depth, bool optimize)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SDL_Rect rect = create_rect(0, 0, surf->w, surf->h);
|
||||
SDL_Rect rect = sdl::create_rect(0, 0, surf->w, surf->h);
|
||||
blur_surface(res, rect, depth);
|
||||
|
||||
return optimize ? create_optimized_surface(res) : res;
|
||||
|
@ -1918,7 +1909,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 = create_rect(0, 0, dst->w, dst->h);
|
||||
SDL_Rect dst_rect = sdl::create_rect(0, 0, dst->w, dst->h);
|
||||
if(dstrect) {
|
||||
dst_rect.x = dstrect->x;
|
||||
dst_rect.w -= dstrect->x;
|
||||
|
@ -1928,7 +1919,7 @@ void blit_surface(const surface& surf,
|
|||
|
||||
}
|
||||
|
||||
SDL_Rect src_rect = create_rect(0, 0, src->w, src->h);
|
||||
SDL_Rect src_rect = sdl::create_rect(0, 0, src->w, src->h);
|
||||
if(srcrect && srcrect->w && srcrect->h) {
|
||||
src_rect.x = srcrect->x;
|
||||
src_rect.y = srcrect->y;
|
||||
|
@ -2280,10 +2271,10 @@ void surface_restorer::cancel()
|
|||
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 = sdl::create_rect(x, y, w, 1);
|
||||
SDL_Rect bot = sdl::create_rect(x, y + h - 1, w, 1);
|
||||
SDL_Rect left = sdl::create_rect(x, y, 1, h);
|
||||
SDL_Rect right = sdl::create_rect(x + w - 1, y, 1, h);
|
||||
|
||||
sdl_fill_rect(target,&top,color);
|
||||
sdl_fill_rect(target,&bot,color);
|
||||
|
@ -2296,7 +2287,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 = sdl::create_rect(x, y, w, h);
|
||||
fill_rect_alpha(rect,SDL_MapRGB(target->format,r,g,b),Uint8(alpha*255),target);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,13 +56,6 @@ bool rects_overlap(const SDL_Rect& rect1, const SDL_Rect& rect2);
|
|||
SDL_Rect intersect_rects(SDL_Rect const &rect1, SDL_Rect const &rect2);
|
||||
SDL_Rect union_rects(const SDL_Rect &rect1, const SDL_Rect &rect2);
|
||||
|
||||
/**
|
||||
* Creates an empty SDL_Rect.
|
||||
*
|
||||
* Since SDL_Rect doesn't have a constructor it's not possible to create it as
|
||||
* a temporary for a function parameter. This functions overcomes this limit.
|
||||
*/
|
||||
SDL_Rect create_rect(const int x, const int y, const int w, const int h);
|
||||
|
||||
struct surface
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace {
|
|||
|
||||
void blur_area(CVideo& video, int y, int h)
|
||||
{
|
||||
SDL_Rect blur_rect = create_rect(0, y, screen_area().w, h);
|
||||
SDL_Rect blur_rect = sdl::create_rect(0, y, screen_area().w, h);
|
||||
surface blur = get_surface_portion(video.getSurface(), blur_rect);
|
||||
blur = blur_surface(blur, 1, false);
|
||||
video.blit_surface(0, y, blur);
|
||||
|
@ -149,12 +149,12 @@ void part_ui::prepare_background()
|
|||
|
||||
layer = tile_surface(layer, tilew, tileh, false);
|
||||
|
||||
SDL_Rect drect = create_rect(
|
||||
SDL_Rect drect = sdl::create_rect(
|
||||
(background_->w - layer->w) / 2
|
||||
, (background_->h - layer->h) / 2
|
||||
, layer->w
|
||||
, layer->h);
|
||||
SDL_Rect srect = create_rect(
|
||||
SDL_Rect srect = sdl::create_rect(
|
||||
0
|
||||
, 0
|
||||
, layer->w
|
||||
|
@ -449,7 +449,7 @@ void part_ui::render_story_box()
|
|||
break;
|
||||
}
|
||||
|
||||
SDL_Rect update_area = create_rect(0
|
||||
SDL_Rect update_area = sdl::create_rect(0
|
||||
, fix_text_y
|
||||
, screen_area().w
|
||||
, fix_text_h);
|
||||
|
@ -489,8 +489,8 @@ void part_ui::render_story_box()
|
|||
|
||||
// Time to do some fucking visual effect.
|
||||
const int scan_height = 1, scan_width = txtsurf->w;
|
||||
SDL_Rect scan = create_rect(0, 0, scan_width, scan_height);
|
||||
SDL_Rect dstrect = create_rect(text_x_, 0, scan_width, scan_height);
|
||||
SDL_Rect scan = sdl::create_rect(0, 0, scan_width, scan_height);
|
||||
SDL_Rect dstrect = sdl::create_rect(text_x_, 0, scan_width, scan_height);
|
||||
surface scan_dst = video_.getSurface();
|
||||
bool scan_finished = false;
|
||||
while(true) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "sdl/rect.hpp"
|
||||
#include "sdl_utils.hpp"
|
||||
#include "widgets/drop_target.hpp"
|
||||
|
||||
|
@ -79,12 +80,12 @@ BOOST_AUTO_TEST_CASE( test_create_drop_targets )
|
|||
location_store locations;
|
||||
|
||||
// Create rectangles for drop targets
|
||||
locations.push_back(create_rect(50,50,20,20));
|
||||
locations.push_back(create_rect(50,100,20,20));
|
||||
locations.push_back(create_rect(50,150,20,20));
|
||||
locations.push_back(create_rect(50,200,20,20));
|
||||
locations.push_back(create_rect(50,250,20,20));
|
||||
locations.push_back(create_rect(50,300,20,20));
|
||||
locations.push_back(sdl::create_rect(50,50,20,20));
|
||||
locations.push_back(sdl::create_rect(50,100,20,20));
|
||||
locations.push_back(sdl::create_rect(50,150,20,20));
|
||||
locations.push_back(sdl::create_rect(50,200,20,20));
|
||||
locations.push_back(sdl::create_rect(50,250,20,20));
|
||||
locations.push_back(sdl::create_rect(50,300,20,20));
|
||||
|
||||
target_store targets;
|
||||
|
||||
|
@ -122,19 +123,19 @@ BOOST_AUTO_TEST_CASE( test_multiple_drop_groups )
|
|||
location_store locations2;
|
||||
|
||||
// Create rectangles for drop targets
|
||||
locations.push_back(create_rect(50,50,20,20));
|
||||
locations.push_back(create_rect(50,100,20,20));
|
||||
locations.push_back(create_rect(50,150,20,20));
|
||||
locations.push_back(create_rect(50,200,20,20));
|
||||
locations.push_back(create_rect(50,250,20,20));
|
||||
locations.push_back(create_rect(50,300,20,20));
|
||||
locations.push_back(sdl::create_rect(50,50,20,20));
|
||||
locations.push_back(sdl::create_rect(50,100,20,20));
|
||||
locations.push_back(sdl::create_rect(50,150,20,20));
|
||||
locations.push_back(sdl::create_rect(50,200,20,20));
|
||||
locations.push_back(sdl::create_rect(50,250,20,20));
|
||||
locations.push_back(sdl::create_rect(50,300,20,20));
|
||||
|
||||
locations2.push_back(create_rect(50,50,20,20));
|
||||
locations2.push_back(create_rect(100,50,20,20));
|
||||
locations2.push_back(create_rect(150,50,20,20));
|
||||
locations2.push_back(create_rect(200,50,20,20));
|
||||
locations2.push_back(create_rect(250,50,20,20));
|
||||
locations2.push_back(create_rect(300,50,20,20));
|
||||
locations2.push_back(sdl::create_rect(50,50,20,20));
|
||||
locations2.push_back(sdl::create_rect(100,50,20,20));
|
||||
locations2.push_back(sdl::create_rect(150,50,20,20));
|
||||
locations2.push_back(sdl::create_rect(200,50,20,20));
|
||||
locations2.push_back(sdl::create_rect(250,50,20,20));
|
||||
locations2.push_back(sdl::create_rect(300,50,20,20));
|
||||
|
||||
|
||||
target_store targets;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "exploder_cutter.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
#include "serialization/preprocessor.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
@ -137,7 +138,7 @@ void cutter::add_sub_image(const surface &surf, surface_map &map, const config*
|
|||
int x = atoi(pos[0].c_str());
|
||||
int y = atoi(pos[1].c_str());
|
||||
|
||||
const SDL_Rect cut = create_rect(x - mask.shift.x
|
||||
const SDL_Rect cut = sdl::create_rect(x - mask.shift.x
|
||||
, y - mask.shift.y
|
||||
, mask.image->w
|
||||
, mask.image->h);
|
||||
|
|
|
@ -1988,7 +1988,7 @@ void unit::redraw_unit()
|
|||
bool draw_bars = draw_bars_ ;
|
||||
if (draw_bars) {
|
||||
const int d = disp.hex_size();
|
||||
SDL_Rect unit_rect = create_rect(xsrc, ysrc +adjusted_params.y, d, d);
|
||||
SDL_Rect unit_rect = sdl::create_rect(xsrc, ysrc +adjusted_params.y, d, d);
|
||||
draw_bars = rects_overlap(unit_rect, disp.map_outside_area());
|
||||
}
|
||||
|
||||
|
|
|
@ -837,7 +837,7 @@ std::set<map_location> unit_frame::get_overlaped_hex(const int frame_time,const
|
|||
my_y -= current_data.directional_y;
|
||||
}
|
||||
|
||||
const SDL_Rect r = create_rect(my_x, my_y, w, h);
|
||||
const SDL_Rect r = sdl::create_rect(my_x, my_y, w, h);
|
||||
// check if our underlying hexes are invalidated
|
||||
// if we need to update ourselves because we changed, invalidate our hexes
|
||||
// and return whether or not our hexes was invalidated
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "preferences.hpp"
|
||||
#include "preferences_display.hpp"
|
||||
#include "sdl_utils.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "sdl/window.hpp"
|
||||
#include "video.hpp"
|
||||
|
||||
|
@ -164,7 +165,7 @@ static void calc_rects()
|
|||
int x = lower->second.x, y = lower->first;
|
||||
unsigned w = iter->x - x;
|
||||
unsigned h = next->first - y;
|
||||
SDL_Rect a = create_rect(x, y, w, h);
|
||||
SDL_Rect a = sdl::create_rect(x, y, w, h);
|
||||
|
||||
if (update_rects.empty()) {
|
||||
update_rects.push_back(a);
|
||||
|
@ -253,12 +254,12 @@ surface get_video_surface()
|
|||
|
||||
SDL_Rect screen_area()
|
||||
{
|
||||
return create_rect(0, 0, frameBuffer->w, frameBuffer->h);
|
||||
return sdl::create_rect(0, 0, frameBuffer->w, frameBuffer->h);
|
||||
}
|
||||
|
||||
void update_rect(size_t x, size_t y, size_t w, size_t h)
|
||||
{
|
||||
update_rect(create_rect(x, y, w, h));
|
||||
update_rect(sdl::create_rect(x, y, w, h));
|
||||
}
|
||||
|
||||
void update_rect(const SDL_Rect& rect_value)
|
||||
|
@ -353,7 +354,7 @@ CVideo::~CVideo()
|
|||
void CVideo::blit_surface(int x, int y, surface surf, SDL_Rect* srcrect, SDL_Rect* clip_rect)
|
||||
{
|
||||
surface target(getSurface());
|
||||
SDL_Rect dst = create_rect(x, y, 0, 0);
|
||||
SDL_Rect dst = sdl::create_rect(x, y, 0, 0);
|
||||
|
||||
const clip_rect_setter clip_setter(target, clip_rect, clip_rect != NULL);
|
||||
sdl_blit(surf,srcrect,target,&dst);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "language.hpp"
|
||||
#include "image.hpp"
|
||||
#include "marked-up_text.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "video.hpp"
|
||||
#include "wml_separators.hpp"
|
||||
|
@ -1138,7 +1139,7 @@ SDL_Rect menu::get_item_rect_internal(size_t item) const
|
|||
y = prev.y + prev.h;
|
||||
}
|
||||
|
||||
SDL_Rect res = create_rect(loc.x, y, loc.w, get_item_height(item));
|
||||
SDL_Rect res = sdl::create_rect(loc.x, y, loc.w, get_item_height(item));
|
||||
|
||||
SDL_Rect const &screen_area = ::screen_area();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "font.hpp"
|
||||
#include "marked-up_text.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "video.hpp"
|
||||
|
||||
namespace gui {
|
||||
|
@ -51,7 +52,7 @@ void progress_bar::draw_contents()
|
|||
int lightning_thickness = 2;
|
||||
static const SDL_Color selected_text_color = {0xCC,0xCC,0xCC,0};
|
||||
|
||||
SDL_Rect inner_area = create_rect(area.x + 1
|
||||
SDL_Rect inner_area = sdl::create_rect(area.x + 1
|
||||
, area.y + 1
|
||||
, area.w - 2
|
||||
, area.h - 2);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "widgets/scrollbar.hpp"
|
||||
#include "image.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "video.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
@ -228,7 +229,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 create_rect(loc.x, y, loc.w, h);
|
||||
return sdl::create_rect(loc.x, y, loc.w, h);
|
||||
}
|
||||
|
||||
void scrollbar::draw_contents()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "game_config.hpp"
|
||||
#include "font.hpp"
|
||||
#include "image.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "video.hpp"
|
||||
|
||||
|
@ -132,7 +133,7 @@ SDL_Rect slider::slider_area() const
|
|||
return default_value;
|
||||
|
||||
int xpos = loc.x + (value_ - min_) * (loc.w - image_->w) / (max_ - min_);
|
||||
return create_rect(xpos, loc.y, image_->w, image_->h);
|
||||
return sdl::create_rect(xpos, loc.y, image_->w, image_->h);
|
||||
}
|
||||
|
||||
void slider::draw_contents()
|
||||
|
@ -165,7 +166,7 @@ void slider::draw_contents()
|
|||
|
||||
surface screen = video().getSurface();
|
||||
|
||||
SDL_Rect line_rect = create_rect(loc.x + image->w / 2
|
||||
SDL_Rect line_rect = sdl::create_rect(loc.x + image->w / 2
|
||||
, loc.y + loc.h / 2
|
||||
, loc.w - image->w
|
||||
, 1);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "clipboard.hpp"
|
||||
#include "log.hpp"
|
||||
#include "sdl/alpha.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
#include "video.hpp"
|
||||
|
||||
|
@ -105,7 +106,7 @@ void textbox::append_text(const std::string& text, bool auto_scroll, const SDL_C
|
|||
|
||||
sdl_blit(text_image_,NULL,new_surface,NULL);
|
||||
|
||||
SDL_Rect target = create_rect(0
|
||||
SDL_Rect target = sdl::create_rect(0
|
||||
, text_image_->h
|
||||
, new_text->w
|
||||
, new_text->h);
|
||||
|
@ -167,7 +168,7 @@ 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 = create_rect(location().x + pos
|
||||
SDL_Rect rect = sdl::create_rect(location().x + pos
|
||||
, location().y
|
||||
, 1
|
||||
, location().h);
|
||||
|
@ -215,7 +216,7 @@ void textbox::draw_contents()
|
|||
break;
|
||||
}
|
||||
|
||||
SDL_Rect rect = create_rect(loc.x + startx
|
||||
SDL_Rect rect = sdl::create_rect(loc.x + startx
|
||||
, loc.y + starty - src.y
|
||||
, right - startx
|
||||
, line_height_);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "widgets/widget.hpp"
|
||||
#include "video.hpp"
|
||||
#include "sdl/rect.hpp"
|
||||
#include "tooltips.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
@ -112,22 +113,22 @@ void widget::bg_register(SDL_Rect const &rect)
|
|||
|
||||
void widget::set_location(int x, int y)
|
||||
{
|
||||
set_location(create_rect(x, y, rect_.w, rect_.h));
|
||||
set_location(sdl::create_rect(x, y, rect_.w, rect_.h));
|
||||
}
|
||||
|
||||
void widget::set_width(unsigned w)
|
||||
{
|
||||
set_location(create_rect(rect_.x, rect_.y, w, rect_.h));
|
||||
set_location(sdl::create_rect(rect_.x, rect_.y, w, rect_.h));
|
||||
}
|
||||
|
||||
void widget::set_height(unsigned h)
|
||||
{
|
||||
set_location(create_rect(rect_.x, rect_.y, rect_.w, h));
|
||||
set_location(sdl::create_rect(rect_.x, rect_.y, rect_.w, h));
|
||||
}
|
||||
|
||||
void widget::set_measurements(unsigned w, unsigned h)
|
||||
{
|
||||
set_location(create_rect(rect_.x, rect_.y, w, h));
|
||||
set_location(sdl::create_rect(rect_.x, rect_.y, w, h));
|
||||
}
|
||||
|
||||
unsigned widget::width() const
|
||||
|
|
Loading…
Add table
Reference in a new issue