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 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 (const SDL_Rect &rect1, const SDL_Rect &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_t color) |
Fill a rectangle on a given surface. More... | |
Variables | |
constexpr const SDL_Rect | empty_rect { 0, 0, 0, 0 } |
|
static |
Definition at line 22 of file exception.cpp.
|
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 39 of file rect.hpp.
References draw_rectangle(), fill_rectangle(), intersect_rects(), point_in_rect(), rects_overlap(), union_rects(), and 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(), gui::menu::get_item_rect_internal(), image::load_image_sub_file(), gui2::vertical_scrollbar::on_positioner(), gui2::horizontal_scrollbar::on_positioner(), and gui2::slider::on_positioner().
void sdl::draw_rectangle | ( | const SDL_Rect & | rect, |
const color_t & | color | ||
) |
Draw a rectangle outline.
rect | The dimensions of the rectangle. |
color | The color of the rectangle. |
Definition at line 57 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 create_rect(), location_palette_item::draw_contents(), and gui2::widget::draw_debug_border().
void sdl::fill_rectangle | ( | const SDL_Rect & | rect, |
const color_t & | color | ||
) |
Draws a filled rectangle.
rect | The dimensions of the rectangle. |
color | The color of the rectangle. |
Definition at line 65 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 create_rect(), draw_background(), gui::textbox::draw_contents(), location_palette_item::draw_contents(), gui::scrollbar::draw_contents(), gui::textbox::draw_cursor(), gui2::widget::draw_debug_border(), gui::menu::draw_row(), and gui::menu::style::draw_row_bg().
|
inline |
Fill a rectangle on a given surface.
Alias for SDL_FillRect.
dst | The surface to operate on. |
dst_rect | The rectangle to fill. |
color | Color of the rectangle. |
Definition at line 114 of file rect.hpp.
References a, b, operator!=(), operator<<(), operator==(), and s.
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 | ( | const SDL_Rect & | rect1, |
const SDL_Rect & | rect2 | ||
) |
Calculates the intersection of two rectangles.
rect1 | One rectangle. |
rect2 | Another rectangle |
Definition at line 39 of file rect.cpp.
References empty_rect.
Referenced by create_rect(), 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 | ||
) |
Tests whether a point is inside a rectangle.
x | The x coordinate of the point. |
y | The y coordinate of the point. |
rect | The rectangle. |
Definition at line 22 of file rect.cpp.
References p.
Referenced by tooltips::click(), create_rect(), gui2::pane_implementation::find_at(), gui::scrollarea::handle_event(), editor::palette_manager::handle_event(), gui::scrollbar::handle_event(), gui::textbox::handle_event(), controller_base::handle_event(), controller_base::handle_scroll(), display::hex_clicked_on(), gui::tristate_button::hit(), location_palette_item::hit(), gui::button::hit(), gui2::widget::is_at(), controller_base::long_touch_callback(), display::minimap_location_on(), gui2::dialogs::drop_down_menu::mouse_up_callback(), events::mouse_handler_base::mouse_wheel(), gui2::vertical_scrollbar::on_positioner(), gui2::horizontal_scrollbar::on_positioner(), gui2::slider::on_positioner(), help::help_text_area::item_at::operator()(), point_in_rect(), help::help_browser::process_event(), gui::widget::process_help_string(), gui::widget::process_tooltip_string(), events::mouse_handler::right_click_show_menu(), and events::mouse_handler::touch_motion().
bool sdl::point_in_rect | ( | const point & | point, |
const SDL_Rect & | rect | ||
) |
Definition at line 28 of file rect.cpp.
References point_in_rect(), point::x, and point::y.
bool sdl::rects_overlap | ( | const SDL_Rect & | rect1, |
const SDL_Rect & | rect2 | ||
) |
Tests whether two rectangles overlap.
rect1 | One rectangle. |
rect2 | Another rectangle. |
Definition at line 33 of file rect.cpp.
Referenced by tooltips::add_tooltip(), tooltips::clear_tooltips(), create_rect(), display::draw_invalidated(), gui::widget::hidden(), gui2::listbox::list_item_clicked(), 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.
rect1 | One rectangle. |
rect2 | Another rectangle. |
Definition at line 49 of file rect.cpp.
Referenced by create_rect().
constexpr const SDL_Rect sdl::empty_rect { 0, 0, 0, 0 } |
Definition at line 31 of file rect.hpp.
Referenced by font::get_floating_label_rect(), gui::menu::get_item_rect_internal(), intersect_rects(), and gui2::widget::set_visible_rectangle().