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

Classes

struct  exception
 
class  UserEvent
 
class  window
 The wrapper class for the SDL_Window class. More...
 

Functions

static std::string create_error (const std::string &operation, const bool use_sdl_error)
 
bool point_in_rect (int x, int y, const SDL_Rect &rect)
 Tests whether a point is inside a rectangle. More...
 
bool point_in_rect (const gui2::point &point, const SDL_Rect &rect)
 
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 draw_rectangle (const SDL_Rect &rect, const color_t &color)
 Draw a rectangle outline. More...
 
void fill_rectangle (const SDL_Rect &rect, const color_t &color)
 Draws a filled rectangle. More...
 
SDL_Rect create_rect (const int x, const int y, const int w, const int h)
 Creates an SDL_Rect with the given dimensions. More...
 
void fill_surface_rect (surface &dst, SDL_Rect *dst_rect, const Uint32 color)
 Fill a rectangle on a given surface. More...
 

Variables

CONSTEXPR 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 22 of file exception.cpp.

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

Creates an SDL_Rect with the given dimensions.

This is a simple wrapper in order to avoid the narrowing conversion warnings that occur when using aggregate initialization and non-int values.

Definition at line 42 of file rect.hpp.

References w.

Referenced by font::floating_label::draw(), gui2::image_shape::draw(), gui2::text_shape::draw(), draw_background(), unit_drawer::draw_bar(), gui::textbox::draw_contents(), display::draw_invalidated(), font::draw_text_line(), gui::menu::get_item_rect_internal(), image::load_image_sub_file(), font::render_text(), and font::floating_label::undraw().

void sdl::draw_rectangle ( const SDL_Rect &  rect,
const color_t color 
)

Draw a rectangle outline.

Parameters
rectThe dimensions of the rectangle.
colorThe color of the rectangle.

Definition at line 60 of file rect.cpp.

References color_t::a, color_t::b, color_t::g, CVideo::get_singleton(), CVideo::get_window(), and color_t::r.

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

void sdl::fill_rectangle ( const SDL_Rect &  rect,
const color_t color 
)
void sdl::fill_surface_rect ( surface dst,
SDL_Rect *  dst_rect,
const Uint32  color 
)
inline

Fill a rectangle on a given surface.

Alias for SDL_FillRect.

Parameters
dstThe surface to operate on.
dst_rectThe rectangle to fill.
colorColor of the rectangle.

Definition at line 117 of file rect.hpp.

Referenced by font::floating_label::create_surface(), unit_drawer::draw_bar(), draw_centered_on_background(), display::draw_hex(), and image::getMinimap().

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 42 of file rect.cpp.

References empty_rect.

Referenced by display::invalidate_visible_locations_in_rect(), gui2::dialogs::terrain_layers::pre_show(), surface_restorer::restore(), display::scroll(), gui2::scrollbar_container::set_visible_rectangle(), and gui2::widget::set_visible_rectangle().

bool sdl::point_in_rect ( int  x,
int  y,
const SDL_Rect &  rect 
)
bool sdl::point_in_rect ( const gui2::point point,
const SDL_Rect &  rect 
)

Definition at line 31 of file rect.cpp.

References point_in_rect(), gui2::point::x, and gui2::point::y.

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 36 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 52 of file rect.cpp.

Variable Documentation

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