Added GetDisplayUsableBounds (issue #81)

This commit is contained in:
Vraiment 2017-07-24 22:45:24 -07:00
parent 01e080ade9
commit 9b82524c1a
2 changed files with 43 additions and 2 deletions

View File

@ -21,6 +21,19 @@
#include <SDL2pp/Display.hh> #include <SDL2pp/Display.hh>
namespace SDL2pp { #include <SDL2pp/Exception.hh>
#include <SDL_video.h>
namespace SDL2pp {
#if SDL_VERSION_ATLEAST(2, 0, 5)
Rect GetDisplayUsableBounds(int displayIndex) {
Rect result;
if (SDL_GetDisplayUsableBounds(displayIndex, &result) < 0) {
throw Exception("SDL_GetDisplayUsableBounds");
}
return result;
}
#endif
} }

View File

@ -24,8 +24,36 @@
#include <SDL2pp/Export.hh> #include <SDL2pp/Export.hh>
namespace SDL2pp { #include <SDL_version.h>
#include <SDL2pp/Rect.hh>
namespace SDL2pp {
#if SDL_VERSION_ATLEAST(2, 0, 5)
////////////////////////////////////////////////////////////
/// \brief Gets the usable desktop area of a given display
///
/// This function retrieves an rectangle with the usable area
/// of the given display, with the initial display being
/// located at (0,0). This function does takes into account
/// space that is not usable, like OS X's menu bar, removing it
/// and returning the actual usable area.
///
/// \ingroup graphics
///
/// \headerfile SDL2pp/Display.hh
///
/// \param[in] displayIndex The display to retrieve the usable area
///
/// \returns A rectangle with the usable area of the given display
///
/// \throws SDL2pp::Exception
///
/// \see https://wiki.libsdl.org/SDL_GetDisplayUsableBounds
///
////////////////////////////////////////////////////////////
SDL2PP_EXPORT Rect GetDisplayUsableBounds(int displayIndex);
#endif
} }
#endif #endif