Browse Source

python: expose Application cursor setup and warping.

next
Vladimír Vondruš 3 years ago
parent
commit
ee284aa4aa
  1. 2
      doc/python/pages/changelog.rst
  2. 3
      src/python/magnum/platform/application.h
  3. 18
      src/python/magnum/platform/glfw.cpp
  4. 15
      src/python/magnum/platform/sdl2.cpp

2
doc/python/pages/changelog.rst

@ -126,6 +126,8 @@ Changelog
:ref:`platform.glfw.Application.dpi_scaling`
- Exposed :ref:`platform.glfw.Application.swap_interval` and
:ref:`platform.glfw.Application.main_loop_iteration`
- Exposed :ref:`platform.sdl2.Application.cursor` and
:ref:`platform.sdl2.Application.warp_cursor`, same for GLFW
- Exposed :ref:`trade.AbstractImporter.features` and
:ref:`trade.AbstractImporter.flags` and corresponding enums
- Exposed a basic interface of :ref:`trade.AbstractImageConverter` and

3
src/python/magnum/platform/application.h

@ -88,6 +88,9 @@ template<class T, class Trampoline, class Holder> void application(py::class_<T,
.def_property_readonly("window_size", &T::windowSize, "Window size")
.def_property_readonly("framebuffer_size", &T::framebufferSize, "Framebuffer size")
.def_property_readonly("dpi_scaling", static_cast<Vector2(T::*)() const>(&T::dpiScaling), "DPI scaling")
/* Mouse handling */
.def_property("cursor", &T::cursor, &T::setCursor, "Cursor type")
.def("warp_cursor", &T::warpCursor, "Warp mouse cursor to given coordinates")
/* Event handlers */
.def("exit_event", &T::exitEvent, "Exit event")
.def("viewport_event", &T::viewportEvent, "Viewport event")

18
src/python/magnum/platform/glfw.cpp

@ -203,6 +203,24 @@ void glfw(py::module_& m) {
py::class_<PublicizedApplication::MouseMoveEvent, PublicizedApplication::InputEvent> mouseMoveEvent_{glfwApplication, "MouseMoveEvent", "Mouse move event"};
py::class_<PublicizedApplication::MouseScrollEvent, PublicizedApplication::InputEvent> mouseScrollEvent_{glfwApplication, "MouseScrollEvent", "Mouse scroll event"};
py::enum_<Platform::Application::Cursor>{glfwApplication, "Cursor", "Cursor type"}
.value("ARROW", Platform::Application::Cursor::Arrow)
.value("TEXT_INPUT", Platform::Application::Cursor::TextInput)
.value("CROSSHAIR", Platform::Application::Cursor::Crosshair)
#ifdef GLFW_RESIZE_NWSE_CURSOR
.value("RESIZE_NWSE", Platform::Application::Cursor::ResizeNWSE)
.value("RESIZE_NESW", Platform::Application::Cursor::ResizeNESW)
#endif
.value("RESIZE_WE", Platform::Application::Cursor::ResizeWE)
.value("RESIZE_NS", Platform::Application::Cursor::ResizeNS)
#ifdef GLFW_RESIZE_NWSE_CURSOR
.value("RESIZE_ALL", Platform::Application::Cursor::ResizeAll)
.value("NO", Platform::Application::Cursor::No)
#endif
.value("HAND", Platform::Application::Cursor::Hand)
.value("HIDDEN", Platform::Application::Cursor::Hidden)
.value("HIDDEN_LOCKED", Platform::Application::Cursor::HiddenLocked);
application(glfwApplication);
exitEvent(exitEvent_);
viewportEvent(viewportEvent_);

15
src/python/magnum/platform/sdl2.cpp

@ -203,6 +203,21 @@ void sdl2(py::module_& m) {
py::class_<PublicizedApplication::MouseMoveEvent, PublicizedApplication::InputEvent> mouseMoveEvent_{sdl2application, "MouseMoveEvent", "Mouse move event"};
py::class_<PublicizedApplication::MouseScrollEvent, PublicizedApplication::InputEvent> mouseScrollEvent_{sdl2application, "MouseScrollEvent", "Mouse scroll event"};
py::enum_<Platform::Application::Cursor>{sdl2application, "Cursor", "Cursor type"}
.value("ARROW", Platform::Application::Cursor::Arrow)
.value("TEXT_INPUT", Platform::Application::Cursor::TextInput)
.value("CROSSHAIR", Platform::Application::Cursor::Crosshair)
.value("WAIT_ARROW", Platform::Application::Cursor::WaitArrow)
.value("RESIZE_NWSE", Platform::Application::Cursor::ResizeNWSE)
.value("RESIZE_NESW", Platform::Application::Cursor::ResizeNESW)
.value("RESIZE_WE", Platform::Application::Cursor::ResizeWE)
.value("RESIZE_NS", Platform::Application::Cursor::ResizeNS)
.value("RESIZE_ALL", Platform::Application::Cursor::ResizeAll)
.value("NO", Platform::Application::Cursor::No)
.value("HAND", Platform::Application::Cursor::Hand)
.value("HIDDEN", Platform::Application::Cursor::Hidden)
.value("HIDDEN_LOCKED", Platform::Application::Cursor::HiddenLocked);
application(sdl2application);
exitEvent(exitEvent_);
viewportEvent(viewportEvent_);

Loading…
Cancel
Save