Browse Source

Platform: hide internal {Glfw,Sdl2}Application flags from the header.

Because things are going to get messy soon (well, in case of SDL2 they
already are).
mousecapture
Vladimír Vondruš 6 years ago
parent
commit
bbc6102320
  1. 19
      src/Magnum/Platform/GlfwApplication.cpp
  2. 14
      src/Magnum/Platform/GlfwApplication.h
  3. 14
      src/Magnum/Platform/Sdl2Application.cpp
  4. 15
      src/Magnum/Platform/Sdl2Application.h

19
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},

14
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<Flag> Flags;
CORRADE_ENUMSET_FRIEND_OPERATORS(Flags)

14
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();

15
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<Flag> Flags;
CORRADE_ENUMSET_FRIEND_OPERATORS(Flags)

Loading…
Cancel
Save