The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Functions | Variables
sdl Namespace Reference

Classes

struct  texception
 
class  twindow
 The wrapper class for the SDL_Window class. More...
 

Functions

static std::string create_error (const std::string &operation, const bool use_sdl_error)
 
SDL_Rect create_rect (const int x, const int y, const int w, const int h)
 Creates an empty SDL_Rect. More...
 
bool point_in_rect (int x, int y, const SDL_Rect &rect)
 Tests whether a point is inside a rectangle. More...
 
bool rects_overlap (const SDL_Rect &rect1, const SDL_Rect &rect2)
 Tests whether two rectangles overlap. More...
 
SDL_Rect intersect_rects (SDL_Rect const &rect1, SDL_Rect const &rect2)
 Calculates the intersection of two rectangles. More...
 
SDL_Rect union_rects (const SDL_Rect &rect1, const SDL_Rect &rect2)
 Calculates the union of two rectangles. More...
 
void fill_rect_alpha (SDL_Rect &rect, Uint32 color, Uint8 alpha, surface target)
 Fills a specified area of a surface with a given color and opacity. More...
 
void draw_rectangle (int x, int y, int w, int h, Uint32 color, surface tg)
 Draw a colored rectangle on a surface. More...
 
void draw_solid_tinted_rectangle (int x, int y, int w, int h, int r, int g, int b, double alpha, surface target)
 Fills a specified rectangle area of a surface with a given color and opacity. More...
 
void fill_rect (surface &dst, SDL_Rect *dst_rect, const Uint32 color)
 Fill a rectangle on a given surface. More...
 

Variables

const SDL_Rect empty_rect = { 0, 0, 0, 0 }
 

Function Documentation

static std::string sdl::create_error ( const std::string operation,
const bool  use_sdl_error 
)
static

Definition at line 23 of file exception.cpp.

SDL_Rect sdl::create_rect ( const int  x,
const int  y,
const int  w,
const int  h 
)

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.

Definition at line 28 of file rect.cpp.

References h.

Referenced by cutter::add_sub_image(), gui::textbox::append_text(), CVideo::blit_surface(), blit_surface(), blur_surface(), BOOST_AUTO_TEST_CASE(), unit_drawer::calculate_energy_bar(), gui2::create_rect(), font::floating_label::create_surface(), events::console_handler::do_layers(), font::floating_label::draw(), gui2::twindow::draw(), draw_background(), unit_drawer::draw_bar(), gui::progress_bar::draw_contents(), gui::textbox::draw_contents(), gui::slider::draw_contents(), mp::wait::leader_preview_pane::draw_contents(), gui::tristate_button::draw_contents(), dialogs::unit_preview_pane::draw_contents(), gui::textbox::draw_cursor(), display::draw_hex(), display::draw_invalidated(), display::draw_minimap_units(), draw_rectangle(), gui::menu::draw_row(), draw_solid_tinted_rectangle(), font::draw_text_line(), display::drawing_buffer_commit(), font::get_floating_label_rect(), battle_prediction_pane::get_hp_distrib_surface(), mp::gamebrowser::get_item_rect(), gui::menu::get_item_rect_internal(), unit_frame::get_overlaped_hex(), image::getMinimap(), gui::scrollbar::grip_area(), mp::create::layout_children(), image::load_image_sub_file(), image::blit_modification::operator()(), image::mask_modification::operator()(), storyscreen::part_ui::prepare_background(), unit_drawer::redraw_unit(), display::refresh_report(), halo::halo_impl::effect::render(), display::render_image(), storyscreen::part_ui::render_story_box(), font::render_text(), storyscreen::part_ui::render_title_box(), mp::run_lobby_loop(), screen_area(), display::screen_area(), gui::widget::set_height(), gui::widget::set_location(), gui::widget::set_measurements(), editor::mouse_action_map_label::set_mouse_overlay(), editor::mouse_action_village::set_mouse_overlay(), editor::mouse_action_paste::set_mouse_overlay(), editor::mouse_action_starting_position::set_mouse_overlay(), editor::mouse_action::set_terrain_mouse_overlay(), gui::widget::set_width(), about::show_about(), hotkey::show_binding_dialog(), gui::slider::slider_area(), mp::ui::ui(), font::floating_label::undraw(), halo::halo_impl::effect::unrender(), gui::floating_textbox::update_location(), update_rect(), and default_map_generator::user_config().

void sdl::draw_rectangle ( int  x,
int  y,
int  w,
int  h,
Uint32  color,
surface  tg 
)

Draw a colored rectangle on a surface.

Parameters
xThe x coordinate of the rectangle.
yThe y coordinate of the rectangle.
wThe width of the rectangle.
hThe height of the rectangle.
colorThe color of the rectangle.
tgThe surface to operate on.

Definition at line 103 of file rect.cpp.

References create_rect(), fill_rect(), and right.

Referenced by location_palette_item::draw_contents(), help::help_text_area::draw_contents(), gui2::twidget::draw_debug_border(), and display::draw_minimap().

void sdl::draw_solid_tinted_rectangle ( int  x,
int  y,
int  w,
int  h,
int  r,
int  g,
int  b,
double  alpha,
surface  target 
)

Fills a specified rectangle area of a surface with a given color and opacity.

Shortcut for fill_rect_alpha().

Parameters
xThe x coordinate of the rectangle.
yThe y coordinate of the rectangle.
wThe width of the rectangle.
hThe height of the rectangle.
rThe red value of the color to be used.
gThe green value of the color to be used.
bThe blue value of the color to be used.
alphaOpacity for filling.
targetThe surface to operate on.

Definition at line 117 of file rect.cpp.

References create_rect(), and fill_rect_alpha().

Referenced by location_palette_item::draw_contents(), gui::textbox::draw_contents(), gui::menu::draw_row(), gui::menu::style::draw_row_bg(), playsingle_controller::play_scenario(), storyscreen::part_ui::render_background(), storyscreen::part_ui::render_story_box(), and storyscreen::part_ui::render_title_box().

void sdl::fill_rect ( surface dst,
SDL_Rect *  dst_rect,
const Uint32  color 
)
inline
void sdl::fill_rect_alpha ( SDL_Rect &  rect,
Uint32  color,
Uint8  alpha,
surface  target 
)

Fills a specified area of a surface with a given color and opacity.

Parameters
rectThe area that should be filled.
colorThe color to fill with.
alphaOpacity.
targetThe surface to operate on.

Definition at line 83 of file rect.cpp.

References create_compatible_surface(), fill_rect(), sdl_blit(), SDL_SetAlpha(), and SDL_SRCALPHA.

Referenced by gui2::twindow::draw(), gui::textbox::draw_contents(), draw_solid_tinted_rectangle(), and display::flip().

SDL_Rect sdl::intersect_rects ( SDL_Rect const &  rect1,
SDL_Rect const &  rect2 
)

Calculates the intersection of two rectangles.

Parameters
rect1One rectangle.
rect2Another rectangle
Returns
The intersection of rect1 and rect2, or empty_rect if they don't overlap.

Definition at line 58 of file rect.cpp.

References empty_rect, and h.

Referenced by events::console_handler::do_layers(), display::invalidate_visible_locations_in_rect(), surface_restorer::restore(), display::scroll(), gui2::tscrollbar_container::set_visible_rectangle(), and gui2::twidget::set_visible_rectangle().

bool sdl::point_in_rect ( int  x,
int  y,
const SDL_Rect &  rect 
)
bool sdl::rects_overlap ( const SDL_Rect &  rect1,
const SDL_Rect &  rect2 
)

Tests whether two rectangles overlap.

Parameters
rect1One rectangle.
rect2Another rectangle.
Returns
True if rect1 and rect2 intersect, false if not. Touching borders don't overlap.

Definition at line 52 of file rect.cpp.

Referenced by tooltips::add_tooltip(), tooltips::clear_tooltips(), display::draw_invalidated(), gui::widget::hidden(), unit_drawer::redraw_unit(), halo::halo_impl::effect::render(), and display::render_image().

SDL_Rect sdl::union_rects ( const SDL_Rect &  rect1,
const SDL_Rect &  rect2 
)

Calculates the union of two rectangles.

Note: "union" here doesn't mean the union of the sets of points of the two polygons, but rather the minimal rectangle that supersets both rectangles.

Parameters
rect1One rectangle.
rect2Another rectangle.
Returns
The union of rect1 and rect2.

Definition at line 71 of file rect.cpp.

Variable Documentation

const SDL_Rect sdl::empty_rect = { 0, 0, 0, 0 }