Browse Source

Platform: deprecate badly designed & useless GlfwApp setCursorMode().

I'm not sure who thought making this settable only during app startup
(and never after) is a good idea. Let's use the new setCursor() APIs
instead.
pull/388/head
Vladimír Vondruš 7 years ago
parent
commit
8d9d247573
  1. 7
      doc/changelog.dox
  2. 11
      src/Magnum/Platform/GlfwApplication.cpp
  3. 61
      src/Magnum/Platform/GlfwApplication.h

7
doc/changelog.dox

@ -73,6 +73,13 @@ See also:
primitives were missing a face when both caps and texture coordinates were
enabled (see [mosra/magnum#386](https://github.com/mosra/magnum/issues/386))
@subsection changelog-latest-deprecated Deprecated APIs
- @cpp Platform::GlfwApplication::Configuration::setCursorMode() @ce and
related enum & getter are deprecated in favor of the new extended and more
flexible @ref Platform::GlfwApplication::setCursor(). The setting didn't
allow changing the cursor later, which made it pretty useless.
@section changelog-2019-10 2019.10
Released 2019-10-24, tagged as

11
src/Magnum/Platform/GlfwApplication.cpp

@ -271,7 +271,11 @@ bool GlfwApplication::tryCreate(const Configuration& configuration) {
hints */
if(configuration.windowFlags() >= Configuration::WindowFlag::Minimized)
glfwIconifyWindow(_window);
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH
glfwSetInputMode(_window, GLFW_CURSOR, Int(configuration.cursorMode()));
CORRADE_IGNORE_DEPRECATED_POP
#endif
/* Set callbacks */
setupCallbacks();
@ -451,7 +455,11 @@ bool GlfwApplication::tryCreate(const Configuration& configuration, const GLConf
hints */
if(configuration.windowFlags() >= Configuration::WindowFlag::Minimized)
glfwIconifyWindow(_window);
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH
glfwSetInputMode(_window, GLFW_CURSOR, Int(configuration.cursorMode()));
CORRADE_IGNORE_DEPRECATED_POP
#endif
/* Set callbacks */
setupCallbacks();
@ -721,8 +729,7 @@ GlfwApplication::Configuration::Configuration():
_title{"Magnum GLFW Application"},
_size{800, 600},
_windowFlags{WindowFlag::Focused},
_dpiScalingPolicy{DpiScalingPolicy::Default},
_cursorMode{CursorMode::Normal} {}
_dpiScalingPolicy{DpiScalingPolicy::Default} {}
GlfwApplication::Configuration::~Configuration() = default;

61
src/Magnum/Platform/GlfwApplication.h

@ -981,17 +981,38 @@ class GlfwApplication::Configuration {
typedef Implementation::GlfwDpiScalingPolicy DpiScalingPolicy;
#endif
/** @brief Cursor mode */
enum class CursorMode: Int {
/** Visible unconstrained cursor */
Normal = GLFW_CURSOR_NORMAL,
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief Cursor mode
*
* @deprecated Use @ref GlfwApplication::setCursor() instead.
*/
enum class CORRADE_DEPRECATED_ENUM("use GlfwApplication::setCursor() instead") CursorMode: Int {
/**
* Visible unconstrained cursor
*
* @deprecated Use @ref GlfwApplication::setCursor() with
* @ref Cursor::Arrow (or any other) instead.
*/
Normal CORRADE_DEPRECATED_ENUM("use GlfwApplication::setCursor() with Cursor::Arrow instead") = GLFW_CURSOR_NORMAL,
/** Hidden cursor */
Hidden = GLFW_CURSOR_HIDDEN,
/**
* Hidden cursor
*
* @deprecated Use @ref GlfwApplication::setCursor() with
* @ref Cursor::Hidden instead.
*/
Hidden CORRADE_DEPRECATED_ENUM("use GlfwApplication::setCursor() with Cursor::Hidden instead") = GLFW_CURSOR_HIDDEN,
/** Cursor hidden and locked window */
Disabled = GLFW_CURSOR_DISABLED
/**
* Cursor hidden and locked window
*
* @deprecated Use @ref GlfwApplication::setCursor() with
* @ref Cursor::HiddenLocked instead.
*/
Disabled CORRADE_DEPRECATED_ENUM("use GlfwApplication::setCursor() with Cursor::HiddenLocked instead") = GLFW_CURSOR_DISABLED
};
#endif
/*implicit*/ Configuration();
~Configuration();
@ -1084,21 +1105,33 @@ class GlfwApplication::Configuration {
return *this;
}
/** @brief Cursor mode */
CursorMode cursorMode() const {
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief Cursor mode
*
* @deprecated Use @ref GlfwApplication::cursor() instead.
*/
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_DEPRECATED("use GlfwApplication::cursor() instead") CursorMode cursorMode() const {
return _cursorMode;
}
CORRADE_IGNORE_DEPRECATED_POP
/**
* @brief Set cursor mode
* @return Reference to self (for method chaining)
*
* Default is @ref CursorMode::Normal.
*
* @deprecated Use @ref GlfwApplication::setCursor() instead.
*/
Configuration& setCursorMode(CursorMode cursorMode) {
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_DEPRECATED("use GlfwApplication::setCursor() instead") Configuration& setCursorMode(CursorMode cursorMode) {
_cursorMode = cursorMode;
return *this;
}
CORRADE_IGNORE_DEPRECATED_POP
#endif
private:
std::string _title;
@ -1106,7 +1139,11 @@ class GlfwApplication::Configuration {
WindowFlags _windowFlags;
DpiScalingPolicy _dpiScalingPolicy;
Vector2 _dpiScaling;
CursorMode _cursorMode;
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH
CursorMode _cursorMode = CursorMode::Normal;
CORRADE_IGNORE_DEPRECATED_POP
#endif
};
CORRADE_ENUMSET_OPERATORS(GlfwApplication::Configuration::WindowFlags)

Loading…
Cancel
Save