diff --git a/doc/changelog.dox b/doc/changelog.dox index 108df0281..dfa941c9a 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -404,6 +404,7 @@ See also: default to 32-bit RGBA color buffer instead of 24-bit RGB, to avoid the framebuffer degrading to 16-bit colors on some platforms (see [mosra/magnum-integration#59](https://github.com/mosra/magnum-integration/issues/59)) +- Added @ref Platform::BasicScreenedApplication::globalBeforeDrawEvent() @subsubsection changelog-latest-changes-trade Trade library diff --git a/src/Magnum/Platform/ScreenedApplication.h b/src/Magnum/Platform/ScreenedApplication.h index bc77523d9..48b2d1d36 100644 --- a/src/Magnum/Platform/ScreenedApplication.h +++ b/src/Magnum/Platform/ScreenedApplication.h @@ -293,13 +293,23 @@ template class BasicScreenedApplication: */ virtual void globalViewportEvent(typename Application::ViewportEvent& size); + /** + * @brief Before draw event + * @m_since_latest + * + * Called *before* all screens' @ref BasicScreen::drawEvent() "drawEvent()". + * Unlike @ref globalDrawEvent() doesn't need to be implemented. + */ + virtual void globalBeforeDrawEvent(); + /** * @brief Draw event * * Called *after* all screens' @ref BasicScreen::drawEvent() "drawEvent()". * You should call at least @ref Sdl2Application::swapBuffers() "swapBuffers()". * If you want to draw immediately again, call also - * @ref Sdl2Application::redraw() "redraw()". + * @ref Sdl2Application::redraw() "redraw()". See also + * @ref globalBeforeDrawEvent(). */ virtual void globalDrawEvent() = 0; @@ -308,9 +318,9 @@ template class BasicScreenedApplication: friend Containers::LinkedListItem, BasicScreenedApplication>; friend BasicScreen; #endif - /* The user is supposed to override only globalViewportEvent() and - globalDrawEvent(), these implementations are dispatching the events - to attached screens. */ + /* The user is supposed to override only globalViewportEvent(), + globalDrawEvent() and possibly globalBeforeDrawEvent(), these + implementations are dispatching the events to attached screens. */ void viewportEvent(typename Application::ViewportEvent& event) override final; void drawEvent() override final; void mousePressEvent(typename Application::MouseEvent& event) override final; diff --git a/src/Magnum/Platform/ScreenedApplication.hpp b/src/Magnum/Platform/ScreenedApplication.hpp index 08e7083fe..0cc65788f 100644 --- a/src/Magnum/Platform/ScreenedApplication.hpp +++ b/src/Magnum/Platform/ScreenedApplication.hpp @@ -212,7 +212,12 @@ template void BasicScreenedApplication::viewport for(BasicScreen& s: *this) s.viewportEvent(event); } +template void BasicScreenedApplication::globalBeforeDrawEvent() {} + template void BasicScreenedApplication::drawEvent() { + /* Call the "before" global event before all other */ + globalBeforeDrawEvent(); + /* Back-to-front rendering */ for(BasicScreen* s = screens().last(); s; s = s->nextNearerScreen()) if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Draw) s->drawEvent();