Browse Source

Platform: respect DPI in setMin/MaxWindowSize().

I hope this doesn't break someone's use case.
pull/397/head
Vladimír Vondruš 7 years ago
parent
commit
51e65aaae0
  1. 8
      doc/changelog.dox
  2. 10
      src/Magnum/Platform/GlfwApplication.cpp
  3. 10
      src/Magnum/Platform/GlfwApplication.h
  4. 8
      src/Magnum/Platform/Sdl2Application.cpp
  5. 10
      src/Magnum/Platform/Sdl2Application.h

8
doc/changelog.dox

@ -101,6 +101,9 @@ See also:
- @ref Platform::Sdl2Application::viewportEvent() gets properly fired also - @ref Platform::Sdl2Application::viewportEvent() gets properly fired also
when window size changes programmatically (such as through when window size changes programmatically (such as through
@ref Platform::Sdl2Application::setMinWindowSize() "setMinWindowSize()") @ref Platform::Sdl2Application::setMinWindowSize() "setMinWindowSize()")
- @ref Platform::GlfwApplication::setMinWindowSize() /
@ref Platform::GlfwApplication::setMaxWindowSize() and equivalent APIs in
@ref Platform::Sdl2Application now correctly take DPI scaling into account
- The @ref Primitives::cylinderSolid() and @ref Primitives::coneSolid() - The @ref Primitives::cylinderSolid() and @ref Primitives::coneSolid()
primitives were missing a face when both caps and texture coordinates were primitives were missing a face when both caps and texture coordinates were
enabled (see [mosra/magnum#386](https://github.com/mosra/magnum/issues/386)) enabled (see [mosra/magnum#386](https://github.com/mosra/magnum/issues/386))
@ -122,6 +125,11 @@ See also:
@ref Animation library was changed to allow mutable access to the keys & @ref Animation library was changed to allow mutable access to the keys &
values it references. Existing code needs to be changed to say values it references. Existing code needs to be changed to say
@cpp TrackView<const K, const V> @ce instead of @cpp TrackView<K, V> @ce. @cpp TrackView<const K, const V> @ce instead of @cpp TrackView<K, V> @ce.
- @ref Platform::GlfwApplication::setMinWindowSize() /
@ref Platform::GlfwApplication::setMaxWindowSize() and equivalent APIs in
@ref Platform::Sdl2Application now premultiply the value with
@ref Platform::GlfwApplication::dpiScaling() "dpiScaling()" to work
independently on display DPI. This might break existing uses.
@subsection changelog-latest-documentation Documentation @subsection changelog-latest-documentation Documentation

10
src/Magnum/Platform/GlfwApplication.cpp

@ -588,15 +588,17 @@ Vector2i GlfwApplication::windowSize() const {
void GlfwApplication::setMinWindowSize(const Vector2i& size) { void GlfwApplication::setMinWindowSize(const Vector2i& size) {
CORRADE_ASSERT(_window, "Platform::GlfwApplication::setMinWindowSize(): no window opened", ); CORRADE_ASSERT(_window, "Platform::GlfwApplication::setMinWindowSize(): no window opened", );
glfwSetWindowSizeLimits(_window, size.x(), size.y(), _maxWindowSize.x(), _maxWindowSize.y()); const Vector2i newSize = _dpiScaling*size;
_minWindowSize = size; glfwSetWindowSizeLimits(_window, newSize.x(), newSize.y(), _maxWindowSize.x(), _maxWindowSize.y());
_minWindowSize = newSize;
} }
void GlfwApplication::setMaxWindowSize(const Vector2i& size) { void GlfwApplication::setMaxWindowSize(const Vector2i& size) {
CORRADE_ASSERT(_window, "Platform::GlfwApplication::setMaxWindowSize(): no window opened", ); CORRADE_ASSERT(_window, "Platform::GlfwApplication::setMaxWindowSize(): no window opened", );
glfwSetWindowSizeLimits(_window, _minWindowSize.x(), _minWindowSize.y(), size.x(), size.y()); const Vector2i newSize = _dpiScaling*size;
_maxWindowSize = size; glfwSetWindowSizeLimits(_window, _minWindowSize.x(), _minWindowSize.y(), newSize.x(), newSize.y());
_maxWindowSize = newSize;
} }
#endif #endif

10
src/Magnum/Platform/GlfwApplication.h

@ -360,8 +360,9 @@ class GlfwApplication {
* @param size The minimum size, in screen coordinates * @param size The minimum size, in screen coordinates
* *
* If a value is set to @cpp -1 @ce, it will disable/remove the * If a value is set to @cpp -1 @ce, it will disable/remove the
* corresponding limit. * corresponding limit. To make the sizing work independently of the
* * display DPI, @p size is internally multiplied with @ref dpiScaling()
* before getting applied.
* @note Supported since GLFW 3.2. * @note Supported since GLFW 3.2.
*/ */
void setMinWindowSize(const Vector2i& size = {-1, -1}); void setMinWindowSize(const Vector2i& size = {-1, -1});
@ -371,8 +372,9 @@ class GlfwApplication {
* @param size The maximum size, in screen coordinates * @param size The maximum size, in screen coordinates
* *
* If a value is set to @cpp -1 @ce, it will disable/remove the * If a value is set to @cpp -1 @ce, it will disable/remove the
* corresponding limit. * corresponding limit. To make the sizing work independently of the
* * display DPI, @p size is internally multiplied with @ref dpiScaling()
* before getting applied.
* @note Supported since GLFW 3.2. * @note Supported since GLFW 3.2.
*/ */
void setMaxWindowSize(const Vector2i& size = {-1, -1}); void setMaxWindowSize(const Vector2i& size = {-1, -1});

8
src/Magnum/Platform/Sdl2Application.cpp

@ -612,12 +612,16 @@ Vector2i Sdl2Application::windowSize() const {
#ifndef CORRADE_TARGET_EMSCRIPTEN #ifndef CORRADE_TARGET_EMSCRIPTEN
void Sdl2Application::setMinWindowSize(const Vector2i& size) { void Sdl2Application::setMinWindowSize(const Vector2i& size) {
CORRADE_ASSERT(_window, "Platform::Sdl2Application::setMinWindowSize(): no window opened", ); CORRADE_ASSERT(_window, "Platform::Sdl2Application::setMinWindowSize(): no window opened", );
SDL_SetWindowMinimumSize(_window, size.x(), size.y());
const Vector2i newSize = _dpiScaling*size;
SDL_SetWindowMinimumSize(_window, newSize.x(), newSize.y());
} }
void Sdl2Application::setMaxWindowSize(const Vector2i& size) { void Sdl2Application::setMaxWindowSize(const Vector2i& size) {
CORRADE_ASSERT(_window, "Platform::Sdl2Application::setMaxWindowSize(): no window opened", ); CORRADE_ASSERT(_window, "Platform::Sdl2Application::setMaxWindowSize(): no window opened", );
SDL_SetWindowMaximumSize(_window, size.x(), size.y());
const Vector2i newSize = _dpiScaling*size;
SDL_SetWindowMaximumSize(_window, newSize.x(), newSize.y());
} }
#endif #endif

10
src/Magnum/Platform/Sdl2Application.h

@ -634,8 +634,9 @@ class Sdl2Application {
* @param size The minimum size, in screen coordinates * @param size The minimum size, in screen coordinates
* *
* Note that, unlike in @ref GlfwApplication, SDL2 doesn't have a way * Note that, unlike in @ref GlfwApplication, SDL2 doesn't have a way
* to disable/remove a size limit. * to disable/remove a size limit. To make the sizing work
* * independently of the display DPI, @p size is internally multiplied
* with @ref dpiScaling() before getting applied.
* @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten".
*/ */
void setMinWindowSize(const Vector2i& size); void setMinWindowSize(const Vector2i& size);
@ -645,8 +646,9 @@ class Sdl2Application {
* @param size The maximum size, in screen coordinates * @param size The maximum size, in screen coordinates
* *
* Note that, unlike in @ref GlfwApplication, SDL2 doesn't have a way * Note that, unlike in @ref GlfwApplication, SDL2 doesn't have a way
* to disable/remove a size limit. * to disable/remove a size limit. To make the sizing work
* * independently of the display DPI, @p size is internally multiplied
* with @ref dpiScaling() before getting applied.
* @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten".
*/ */
void setMaxWindowSize(const Vector2i& size); void setMaxWindowSize(const Vector2i& size);

Loading…
Cancel
Save