Skip to content

Commit

Permalink
GUI2: Move alternate create_rect() implementation to sdl/rect.hpp
Browse files Browse the repository at this point in the history
gui/widgets/helper.*pp had an implementation creating a rectangle
from points. It was added to sdl/rect.hpp.
  • Loading branch information
mesilliac committed Jun 29, 2022
1 parent 132a45c commit 9b9d30b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
5 changes: 0 additions & 5 deletions src/gui/widgets/helper.cpp
Expand Up @@ -31,11 +31,6 @@

namespace gui2
{
SDL_Rect create_rect(const point& origin, const point& size)
{
return {origin.x, origin.y, size.x, size.y};
}

font::pango_text::FONT_STYLE decode_font_style(const std::string& style)
{
static const std::map<std::string, font::pango_text::FONT_STYLE> font_style_map {
Expand Down
10 changes: 0 additions & 10 deletions src/gui/widgets/helper.hpp
Expand Up @@ -34,16 +34,6 @@ class map_formula_callable;

namespace gui2
{
/**
* Creates a rectangle.
*
* @param origin The top left corner.
* @param size The width (x) and height (y).
*
* @returns SDL_Rect with the proper rectangle.
*/
SDL_Rect create_rect(const point& origin, const point& size);

/**
* Converts a color string to a color.
*
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/widget.cpp
Expand Up @@ -311,7 +311,7 @@ point widget::get_size() const

SDL_Rect widget::get_rectangle() const
{
return create_rect(get_origin(), get_size());
return sdl::create_rect(get_origin(), get_size());
}

int widget::get_x() const
Expand Down
13 changes: 13 additions & 0 deletions src/sdl/rect.hpp
Expand Up @@ -40,6 +40,19 @@ inline SDL_Rect create_rect(const int x, const int y, const int w, const int h)
return {x, y, w, h};
}

/**
* Creates a rectangle.
*
* @param origin The top left corner.
* @param size The width (x) and height (y).
*
* @returns SDL_Rect with the proper rectangle.
*/
inline SDL_Rect create_rect(const point& origin, const point& size)
{
return {origin.x, origin.y, size.x, size.y};
}

/**
* Tests whether a point is inside a rectangle.
*
Expand Down

0 comments on commit 9b9d30b

Please sign in to comment.