Skip to content

Commit

Permalink
Marked create_rect inline and updated its documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed May 26, 2017
1 parent 078a4f6 commit ffbaa84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/sdl/rect.cpp
Expand Up @@ -18,12 +18,6 @@

namespace sdl
{

SDL_Rect create_rect(const int x, const int y, const int w, const int h)
{
return {x, y, w, h};
}

bool point_in_rect(int x, int y, const SDL_Rect& rect)
{
return x >= rect.x && y >= rect.y && x < rect.x + rect.w && y < rect.y + rect.h;
Expand Down
11 changes: 7 additions & 4 deletions src/sdl/rect.hpp
Expand Up @@ -34,12 +34,15 @@ namespace sdl
CONSTEXPR const SDL_Rect empty_rect { 0, 0, 0, 0 };

/**
* Creates an empty SDL_Rect.
* Creates an SDL_Rect with the given dimensions.
*
* 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.
* This is a simple wrapper in order to avoid the narrowing conversion warnings
* that occur when using aggregate initialization and non-int values.
*/
SDL_Rect create_rect(const int x, const int y, const int w, const int h);
inline SDL_Rect create_rect(const int x, const int y, const int w, const int h)
{
return {x, y, w, h};
}

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

0 comments on commit ffbaa84

Please sign in to comment.