From a1d01e89d4617a429bd1962a70fab14d08cbad25 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Sat, 27 Dec 2014 21:21:29 +0300 Subject: [PATCH] Add Point/Rect constructors taking SDL_Point/SDL_Rect --- SDL2pp/Point.cc | 5 +++++ SDL2pp/Point.hh | 8 ++++++++ SDL2pp/Rect.cc | 7 +++++++ SDL2pp/Rect.hh | 8 ++++++++ 4 files changed, 28 insertions(+) diff --git a/SDL2pp/Point.cc b/SDL2pp/Point.cc index 07311db..b2e7cdb 100644 --- a/SDL2pp/Point.cc +++ b/SDL2pp/Point.cc @@ -30,6 +30,11 @@ Point::Point() { y = 0; } +Point::Point(const SDL_Point& point) { + x = point.x; + y = point.y; +} + Point::Point(int nx, int ny) { x = nx; y = ny; diff --git a/SDL2pp/Point.hh b/SDL2pp/Point.hh index d98e65b..98bcaaf 100644 --- a/SDL2pp/Point.hh +++ b/SDL2pp/Point.hh @@ -54,6 +54,14 @@ public: //////////////////////////////////////////////////////////// Point(); + //////////////////////////////////////////////////////////// + /// \brief Construct a point from existing SDL_Point + /// + /// \param point Existing SDL_Point + /// + //////////////////////////////////////////////////////////// + Point(const SDL_Point& point); + //////////////////////////////////////////////////////////// /// \brief Construct the point from given coordinates /// diff --git a/SDL2pp/Rect.cc b/SDL2pp/Rect.cc index aef68d3..9b739e9 100644 --- a/SDL2pp/Rect.cc +++ b/SDL2pp/Rect.cc @@ -34,6 +34,13 @@ Rect::Rect() { h = 0; } +Rect::Rect(const SDL_Rect& rect) { + x = rect.x; + y = rect.y; + w = rect.w; + h = rect.h; +} + Rect::Rect(int nx, int ny, int nw, int nh) { x = nx; y = ny; diff --git a/SDL2pp/Rect.hh b/SDL2pp/Rect.hh index 7b7049d..4439396 100644 --- a/SDL2pp/Rect.hh +++ b/SDL2pp/Rect.hh @@ -58,6 +58,14 @@ public: //////////////////////////////////////////////////////////// Rect(); + //////////////////////////////////////////////////////////// + /// \brief Construct a rect from existing SDL_Rect + /// + /// \param rect Existing SDL_Rect + /// + //////////////////////////////////////////////////////////// + Rect(const SDL_Rect& rect); + //////////////////////////////////////////////////////////// /// \brief Construct the rect from given corner coordinates, width and height ///