From 6556d7a2ee1e64a99eb7cc1d215863179ebd32a8 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Sun, 23 Jul 2017 23:01:39 -0700 Subject: [PATCH 1/2] Added Window::GetBordersSize (issue #82) --- SDL2pp/Window.cc | 10 ++++++++++ SDL2pp/Window.hh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index 6413ff4..9be1fcb 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -264,6 +264,16 @@ Window& Window::SetResizable(bool resizable) { SDL_SetWindowResizable(window_, resizable ? SDL_TRUE : SDL_FALSE); return *this; } + +Window::Borders Window::GetBordersSize() const { + int top = 0, left = 0, bottom = 0, right = 0; + + if (SDL_GetWindowBordersSize(window_, &top, &left, &bottom, &right) != 0) { + throw SDL2pp::Exception("SDL_GetWindowBordersSize"); + } + + return Borders{ top, left, bottom, right }; +} #endif } diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index 1679567..bfbddee 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -578,6 +578,50 @@ public: /// //////////////////////////////////////////////////////////// Window& SetResizable(bool resizable = true); + + //////////////////////////////////////////////////////////// + /// \brief Read only data structure to represent the size borders of a window + /// + /// \ingroup windows + /// + //////////////////////////////////////////////////////////// + struct Borders { + //////////////////////////////////////////////////////////// + /// \brief The size of the top border of a window + /// + //////////////////////////////////////////////////////////// + const int Top; + + //////////////////////////////////////////////////////////// + /// \brief The size of the left border of a window + /// + //////////////////////////////////////////////////////////// + const int Left; + + //////////////////////////////////////////////////////////// + /// \brief The size of the bottom border of a window + /// + //////////////////////////////////////////////////////////// + const int Bottom; + + //////////////////////////////////////////////////////////// + /// \brief The size of the right border of a window + /// + //////////////////////////////////////////////////////////// + const int Right; + }; + + //////////////////////////////////////////////////////////// + /// \brief Get the size of the borders (decorations) around the window + /// + /// \returns An object with the size of each border of the window + /// + /// \throws SDL2pp::Exception + /// + /// \see https://wiki.libsdl.org/SDL_GetWindowBordersSize + /// + //////////////////////////////////////////////////////////// + Borders GetBordersSize() const; #endif }; From b1f4de7446148c35fccdd14168e1f2102b5254a3 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Sun, 23 Jul 2017 23:26:36 -0700 Subject: [PATCH 2/2] Added Window::SetModal (issue #84) --- SDL2pp/Window.cc | 8 ++++++++ SDL2pp/Window.hh | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index 9be1fcb..dd51309 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -265,6 +265,14 @@ Window& Window::SetResizable(bool resizable) { return *this; } +Window& Window::SetModal(Window& parent) { + if (SDL_SetWindowModalFor(window_, parent.window_) != 0) { + throw SDL2pp::Exception("SDL_SetWindowModalFor"); + } + + return *this; +} + Window::Borders Window::GetBordersSize() const { int top = 0, left = 0, bottom = 0, right = 0; diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index bfbddee..e8d1ed3 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -578,6 +578,20 @@ public: /// //////////////////////////////////////////////////////////// Window& SetResizable(bool resizable = true); + + //////////////////////////////////////////////////////////// + /// \brief Sets the modal to the parent window + /// + /// \param[in] parent The window that should be the parent + /// + /// \returns Reference to self + /// + /// \throws SDL2pp::Exception + /// + /// \see https://wiki.libsdl.org/SDL_SetWindowModalFor + /// + //////////////////////////////////////////////////////////// + Window &SetModal(Window& parent); //////////////////////////////////////////////////////////// /// \brief Read only data structure to represent the size borders of a window