diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index e59e884c8..05f043e7a 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -52,6 +52,11 @@ namespace Magnum { namespace Platform { static_assert(GLFW_TRUE == true && GLFW_FALSE == false, "GLFW does not have sane bool values"); #endif +enum class GlfwApplication::Flag: UnsignedByte { + Redraw = 1 << 0, + TextInputActive = 1 << 1 +}; + GlfwApplication::GlfwApplication(const Arguments& arguments): GlfwApplication{arguments, Configuration{}} {} GlfwApplication::GlfwApplication(const Arguments& arguments, const Configuration& configuration): GlfwApplication{arguments, NoCreate} { @@ -686,6 +691,8 @@ void GlfwApplication::setSwapInterval(const Int interval) { glfwSwapInterval(interval); } +void GlfwApplication::redraw() { _flags |= Flag::Redraw; } + int GlfwApplication::exec() { CORRADE_ASSERT(_window, "Platform::GlfwApplication::exec(): no window opened", {}); @@ -810,6 +817,18 @@ void GlfwApplication::mouseMoveEvent(MouseMoveEvent&) {} void GlfwApplication::mouseScrollEvent(MouseScrollEvent&) {} void GlfwApplication::textInputEvent(TextInputEvent&) {} +bool GlfwApplication::isTextInputActive() const { + return !!(_flags & Flag::TextInputActive); +} + +void GlfwApplication::startTextInput() { + _flags |= Flag::TextInputActive; +} + +void GlfwApplication::stopTextInput() { + _flags &= ~Flag::TextInputActive; +} + #ifdef MAGNUM_TARGET_GL GlfwApplication::GLConfiguration::GLConfiguration(): _colorBufferSize{8, 8, 8, 0}, _depthBufferSize{24}, _stencilBufferSize{0}, diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h index 3474f9efb..935d1372d 100644 --- a/src/Magnum/Platform/GlfwApplication.h +++ b/src/Magnum/Platform/GlfwApplication.h @@ -498,7 +498,7 @@ class GlfwApplication { void setSwapInterval(Int interval); /** @copydoc Sdl2Application::redraw() */ - void redraw() { _flags |= Flag::Redraw; } + void redraw(); private: /** @@ -653,7 +653,7 @@ class GlfwApplication { * @ref textInputEvent(). * @see @ref startTextInput(), @ref stopTextInput() */ - bool isTextInputActive() const { return !!(_flags & Flag::TextInputActive); } + bool isTextInputActive() const; /** * @brief Start text input @@ -661,7 +661,7 @@ class GlfwApplication { * Starts text input that will go to @ref textInputEvent(). * @see @ref stopTextInput(), @ref isTextInputActive() */ - void startTextInput() { _flags |= Flag::TextInputActive; } + void startTextInput(); /** * @brief Stop text input @@ -670,7 +670,7 @@ class GlfwApplication { * @see @ref startTextInput(), @ref isTextInputActive(), * @ref textInputEvent() */ - void stopTextInput() { _flags &= ~Flag::TextInputActive; } + void stopTextInput(); private: /** @@ -699,11 +699,7 @@ class GlfwApplication { /*@}*/ private: - enum class Flag: UnsignedByte { - Redraw = 1 << 0, - TextInputActive = 1 << 1 - }; - + enum class Flag: UnsignedByte; typedef Containers::EnumSet Flags; CORRADE_ENUMSET_FRIEND_OPERATORS(Flags) diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index fb8e9a865..fd3cd2a28 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -79,6 +79,18 @@ Sdl2Application::InputEvent::Modifiers fixedModifiers(Uint16 mod) { } +enum class Sdl2Application::Flag: UnsignedByte { + Redraw = 1 << 0, + VSyncEnabled = 1 << 1, + NoTickEvent = 1 << 2, + NoAnyEvent = 1 << 3, + Exit = 1 << 4, + #ifdef CORRADE_TARGET_EMSCRIPTEN + TextInputActive = 1 << 5, + Resizable = 1 << 6 + #endif +}; + Sdl2Application::Sdl2Application(const Arguments& arguments): Sdl2Application{arguments, Configuration{}} {} Sdl2Application::Sdl2Application(const Arguments& arguments, const Configuration& configuration): Sdl2Application{arguments, NoCreate} { @@ -724,6 +736,8 @@ bool Sdl2Application::setSwapInterval(const Int interval) { return true; } +void Sdl2Application::redraw() { _flags |= Flag::Redraw; } + Sdl2Application::~Sdl2Application() { #ifdef MAGNUM_TARGET_GL _context.reset(); diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index 46c19767c..52b8fbd75 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -840,7 +840,7 @@ class Sdl2Application { * in the next iteration. You can call it from @ref drawEvent() itself * to redraw immediately without waiting for user input. */ - void redraw() { _flags |= Flag::Redraw; } + void redraw(); private: /** @@ -1142,18 +1142,7 @@ class Sdl2Application { /*@}*/ private: - enum class Flag: UnsignedByte { - Redraw = 1 << 0, - VSyncEnabled = 1 << 1, - NoTickEvent = 1 << 2, - NoAnyEvent = 1 << 3, - Exit = 1 << 4, - #ifdef CORRADE_TARGET_EMSCRIPTEN - TextInputActive = 1 << 5, - Resizable = 1 << 6 - #endif - }; - + enum class Flag: UnsignedByte; typedef Containers::EnumSet Flags; CORRADE_ENUMSET_FRIEND_OPERATORS(Flags)