Browse Source

Platform: proper feature parity for GlfwApplication::ViewportEvent.

Not sure why I omitted this in dba35bac7a.
simd
Vladimír Vondruš 7 years ago
parent
commit
1e0d3d3727
  1. 8
      doc/changelog.dox
  2. 3
      src/Magnum/Platform/GlfwApplication.cpp
  3. 31
      src/Magnum/Platform/GlfwApplication.h

8
doc/changelog.dox

@ -76,9 +76,11 @@ See also:
@subsubsection changelog-latest-new-platform Platform libraries @subsubsection changelog-latest-new-platform Platform libraries
- Added @ref Platform::AndroidApplication::framebufferSize(), - Added @ref Platform::AndroidApplication::framebufferSize(),
@ref Platform::AndroidApplication::dpiScaling() and @ref Platform::AndroidApplication::dpiScaling(),
@ref Platform::AndroidApplication::ViewportEvent::dpiScaling() for @ref Platform::AndroidApplication::ViewportEvent::dpiScaling(),
compatibility with other application implementations @ref Platform::GlfwApplication::ViewportEvent::framebufferSize() and
@ref Platform::GlfwApplication::ViewportEvent::dpiScaling() to ensure
feature parity with @ref Sdl2Application
- Clarified HiDPI behavior of Android apps and mentioning - Clarified HiDPI behavior of Android apps and mentioning
@ref platforms-android-apps-manifest-screen-compatibility-mode "the necessary steps" @ref platforms-android-apps-manifest-screen-compatibility-mode "the necessary steps"
in the docs in the docs

3
src/Magnum/Platform/GlfwApplication.cpp

@ -459,7 +459,8 @@ void GlfwApplication::setupCallbacks() {
static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window))->drawEvent(); static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window))->drawEvent();
}); });
glfwSetFramebufferSizeCallback(_window, [](GLFWwindow* const window, const int w, const int h) { glfwSetFramebufferSizeCallback(_window, [](GLFWwindow* const window, const int w, const int h) {
ViewportEvent e{{w, h}}; auto& app = *static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window));
ViewportEvent e{{w, h}, app.framebufferSize(), app.dpiScaling()};
static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window))->viewportEvent(e); static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window))->viewportEvent(e);
}); });
glfwSetKeyCallback(_window, [](GLFWwindow* const window, const int key, int, const int action, const int mods) { glfwSetKeyCallback(_window, [](GLFWwindow* const window, const int key, int, const int action, const int mods) {

31
src/Magnum/Platform/GlfwApplication.h

@ -987,6 +987,8 @@ class GlfwApplication::Configuration {
* value. The `--magnum-dpi-scaling` command-line option has a priority * value. The `--magnum-dpi-scaling` command-line option has a priority
* over any application-set value. * over any application-set value.
* @see @ref setSize(const Vector2i&, const Vector2&) * @see @ref setSize(const Vector2i&, const Vector2&)
* @todo change this on a DPI change event (GLFW 3.3 has a callback:
* https://github.com/mosra/magnum/issues/243#issuecomment-388384089)
*/ */
Vector2 dpiScaling() const { return _dpiScaling; } Vector2 dpiScaling() const { return _dpiScaling; }
@ -1138,16 +1140,41 @@ class GlfwApplication::ViewportEvent {
/** /**
* @brief Window size * @brief Window size
* *
* On some platforms with HiDPI displays, window size can be different
* from @ref framebufferSize(). See @ref Platform-GlfwApplication-dpi
* for more information.
* @see @ref GlfwApplication::windowSize() * @see @ref GlfwApplication::windowSize()
*/ */
Vector2i windowSize() const { return _windowSize; } Vector2i windowSize() const { return _windowSize; }
/**
* @brief Framebuffer size
*
* On some platforms with HiDPI displays, framebuffer size can be
* different from @ref windowSize(). See
* @ref Platform-GlfwApplication-dpi for more information.
* @see @ref GlfwApplication::framebufferSize()
*/
Vector2i framebufferSize() const { return _framebufferSize; }
/**
* @brief DPI scaling
*
* On some platforms moving an app between displays can result in DPI
* scaling value being changed in tandem with a window/framebuffer
* size. Simply resizing a window doesn't change the DPI scaling value.
* See @ref Platform-GlfwApplication-dpi for more information.
* @see @ref GlfwApplication::dpiScaling()
*/
Vector2 dpiScaling() const { return _dpiScaling; }
private: private:
friend GlfwApplication; friend GlfwApplication;
explicit ViewportEvent(const Vector2i& windowSize): _windowSize{windowSize} {} explicit ViewportEvent(const Vector2i& windowSize, const Vector2i& framebufferSize, const Vector2& dpiScaling): _windowSize{windowSize}, _framebufferSize{framebufferSize}, _dpiScaling{dpiScaling} {}
Vector2i _windowSize; Vector2i _windowSize, _framebufferSize;
Vector2 _dpiScaling;
}; };
/** /**

Loading…
Cancel
Save