diff --git a/doc/python/pages/changelog.rst b/doc/python/pages/changelog.rst index 78bb9a0..866acd8 100644 --- a/doc/python/pages/changelog.rst +++ b/doc/python/pages/changelog.rst @@ -146,6 +146,8 @@ Changelog :ref:`platform.glfw.Application.main_loop_iteration` - Exposed :ref:`platform.sdl2.Application.cursor` and :ref:`platform.sdl2.Application.warp_cursor`, same for GLFW +- Exposed all :ref:`platform.sdl2.Application.Configuration.WindowFlags` and + :ref:`platform.glfw.Application.Configuration.WindowFlags` - Exposed the new :ref:`text.AbstractShaper`, :ref:`text.RendererCore`, :ref:`text.Renderer`, :ref:`text.RendererGL` classes as well as the new :ref:`text.Feature`, :ref:`text.Script` enums and the diff --git a/src/python/magnum/platform/application.h b/src/python/magnum/platform/application.h index ef373eb..55a8a80 100644 --- a/src/python/magnum/platform/application.h +++ b/src/python/magnum/platform/application.h @@ -36,39 +36,32 @@ namespace magnum { namespace platform { -template void application(py::class_& c) { - py::class_ configuration{c, "Configuration", "Configuration"}; - - py::enum_ configurationWindowFlags{configuration, "WindowFlags", "Window flags"}; - configurationWindowFlags - .value("RESIZABLE", T::Configuration::WindowFlag::Resizable); - corrade::enumOperators(configurationWindowFlags); - - /** @todo drop this in favor of named constructor arguments, that's what - the Configuration tries to emulate after all */ - configuration +template void configuration(py::class_& c) { + c .def(py::init()) .def_property("title", /** @todo drop std::string in favor of our own string caster */ - [](typename T::Configuration& self) -> std::string { + [](T& self) -> std::string { return self.title(); }, - [](typename T::Configuration& self, const std::string& title) { + [](T& self, const std::string& title) { self.setTitle(title); }, "Window title") - .def_property("size", &T::Configuration::size, - [](typename T::Configuration& self, const Vector2i& size) { + .def_property("size", &T::size, + [](T& self, const Vector2i& size) { self.setSize(size); }, "Window size") .def_property("window_flags", - [](typename T::Configuration& self) { - return typename T::Configuration::WindowFlag(typename std::underlying_type::type(self.windowFlags())); + [](T& self) { + return typename T::WindowFlag(typename std::underlying_type::type(self.windowFlags())); }, - [](typename T::Configuration& self, typename T::Configuration::WindowFlag flags) { + [](T& self, typename T::WindowFlag flags) { self.setWindowFlags(flags); }, "Window flags"); /** @todo others */ +} +template void application(py::class_& c) { py::class_ glConfiguration{c, "GLConfiguration", "OpenGL context configuration"}; glConfiguration .def(py::init()); diff --git a/src/python/magnum/platform/glfw.cpp b/src/python/magnum/platform/glfw.cpp index d085887..1a38cce 100644 --- a/src/python/magnum/platform/glfw.cpp +++ b/src/python/magnum/platform/glfw.cpp @@ -196,6 +196,24 @@ void glfw(py::module_& m) { }, "Swap interval") .def("main_loop_iteration", &PyApplication::mainLoopIteration, "Run one iteration of application main loop"); + py::class_ configuration_{glfwApplication, "Configuration", "Configuration"}; + + py::enum_ configurationWindowFlags{configuration_, "WindowFlags", "Window flags"}; + configurationWindowFlags + .value("FULLSCREEN", Platform::Application::Configuration::WindowFlag::Fullscreen) + .value("BORDERLESS", Platform::Application::Configuration::WindowFlag::Borderless) + .value("RESIZABLE", Platform::Application::Configuration::WindowFlag::Resizable) + .value("HIDDEN", Platform::Application::Configuration::WindowFlag::Hidden) + .value("MAXIMIZED", Platform::Application::Configuration::WindowFlag::Maximized) + .value("MINIMIZED", Platform::Application::Configuration::WindowFlag::Minimized) + .value("ALWAYS_ON_TOP", Platform::Application::Configuration::WindowFlag::AlwaysOnTop) + .value("AUTO_ICONIFY", Platform::Application::Configuration::WindowFlag::AutoIconify) + .value("FOCUSED", Platform::Application::Configuration::WindowFlag::Focused) + /** @todo Contextless, once anything else than GL is exposed to + Python */ + .value("NONE", Platform::Application::Configuration::WindowFlag{}); + corrade::enumOperators(configurationWindowFlags); + PyNonDestructibleClass exitEvent_{glfwApplication, "ExitEvent", "Exit event"}; PyNonDestructibleClass viewportEvent_{glfwApplication, "ViewportEvent", "Viewport event"}; PyNonDestructibleClass inputEvent_{glfwApplication, "InputEvent", "Base for input events"}; @@ -234,6 +252,7 @@ void glfw(py::module_& m) { .value("HIDDEN", Platform::Application::Cursor::Hidden) .value("HIDDEN_LOCKED", Platform::Application::Cursor::HiddenLocked); + configuration(configuration_); application(glfwApplication); exitEvent(exitEvent_); viewportEvent(viewportEvent_); diff --git a/src/python/magnum/platform/sdl2.cpp b/src/python/magnum/platform/sdl2.cpp index f1625a6..4783e02 100644 --- a/src/python/magnum/platform/sdl2.cpp +++ b/src/python/magnum/platform/sdl2.cpp @@ -196,6 +196,28 @@ void sdl2(py::module_& m) { }, "Swap interval") .def("main_loop_iteration", &PyApplication::mainLoopIteration, "Run one iteration of application main loop"); + py::class_ configuration_{sdl2application, "Configuration", "Configuration"}; + + py::enum_ configurationWindowFlags{configuration_, "WindowFlags", "Window flags"}; + configurationWindowFlags + .value("RESIZABLE", Platform::Application::Configuration::WindowFlag::Resizable) + .value("FULLSCREEN", Platform::Application::Configuration::WindowFlag::Fullscreen) + .value("FULLSCREEN_DESKTOP", Platform::Application::Configuration::WindowFlag::FullscreenDesktop) + .value("BORDERLESS", Platform::Application::Configuration::WindowFlag::Borderless) + .value("HIDDEN", Platform::Application::Configuration::WindowFlag::Hidden) + .value("MAXIMIZED", Platform::Application::Configuration::WindowFlag::Maximized) + .value("MINIMIZED", Platform::Application::Configuration::WindowFlag::Minimized) + .value("MOUSE_LOCKED", Platform::Application::Configuration::WindowFlag::MouseLocked) + .value("ALWAYS_ON_TOP", Platform::Application::Configuration::WindowFlag::AlwaysOnTop) + .value("SKIP_TASKBAR", Platform::Application::Configuration::WindowFlag::SkipTaskbar) + .value("UTILITY", Platform::Application::Configuration::WindowFlag::Utility) + .value("TOOLTIP", Platform::Application::Configuration::WindowFlag::Tooltip) + .value("POPUP_MENU", Platform::Application::Configuration::WindowFlag::PopupMenu) + /** @todo Contextless, OpenGL, Vulkan, once anything else than GL is + exposed to Python */ + .value("NONE", Platform::Application::Configuration::WindowFlag{}); + corrade::enumOperators(configurationWindowFlags); + PyNonDestructibleClass exitEvent_{sdl2application, "ExitEvent", "Exit event"}; PyNonDestructibleClass viewportEvent_{sdl2application, "ViewportEvent", "Viewport event"}; PyNonDestructibleClass inputEvent_{sdl2application, "InputEvent", "Base for input events"}; @@ -233,6 +255,7 @@ void sdl2(py::module_& m) { .value("HIDDEN", Platform::Application::Cursor::Hidden) .value("HIDDEN_LOCKED", Platform::Application::Cursor::HiddenLocked); + configuration(configuration_); application(sdl2application); exitEvent(exitEvent_); viewportEvent(viewportEvent_);