Author: mordante
Date: Sun Mar 9 19:13:26 2008
New Revision: 24450
URL: http://svn.gna.org/viewcvs/wesnoth?rev=24450&view=rev
Log:
Add a helper function to easily create a SDL_Rect.
Modified:
trunk/src/sdl_utils.cpp
trunk/src/sdl_utils.hpp
Modified: trunk/src/sdl_utils.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.cpp?rev=24450&r1=24449&r2=24450&view=diff
==============================================================================
--- trunk/src/sdl_utils.cpp (original)
+++ trunk/src/sdl_utils.cpp Sun Mar 9 19:13:26 2008
@@ -87,6 +87,15 @@
res.w = maximum<int>(minimum<int>(rect1.x + rect1.w, rect2.x + rect2.w)
- res.x, 0);
res.h = maximum<int>(minimum<int>(rect1.y + rect1.h, rect2.y + rect2.h)
- res.y, 0);
return res;
+}
+
+//! Creates an empty SDL_Rect.
+//!
+//! Since SDL_Rect can't be created as temp variable in one step create this
wrapper.
+SDL_Rect create_rect(const int x, const int y, const int w, const int h)
+{
+ SDL_Rect rect = { x, y, w, h };
+ return rect;
}
bool operator<(const surface& a, const surface& b)
Modified: trunk/src/sdl_utils.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.hpp?rev=24450&r1=24449&r2=24450&view=diff
==============================================================================
--- trunk/src/sdl_utils.hpp (original)
+++ trunk/src/sdl_utils.hpp Sun Mar 9 19:13:26 2008
@@ -55,6 +55,8 @@
bool point_in_rect(int x, int y, const SDL_Rect& rect);
bool rects_overlap(const SDL_Rect& rect1, const SDL_Rect& rect2);
SDL_Rect intersect_rects(SDL_Rect const &rect1, SDL_Rect const &rect2);
+//! Creates an empty SDL_Rect.
+SDL_Rect create_rect(const int x, const int y, const int w, const int h);
struct surface
{
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits