Browse Source

Platform: added ScreenedApplication::globalBeforeDrawEvent().

pull/427/merge
Vladimír Vondruš 6 years ago
parent
commit
acc3932e0c
  1. 1
      doc/changelog.dox
  2. 18
      src/Magnum/Platform/ScreenedApplication.h
  3. 5
      src/Magnum/Platform/ScreenedApplication.hpp

1
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

18
src/Magnum/Platform/ScreenedApplication.h

@ -293,13 +293,23 @@ template<class Application> 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 Application> class BasicScreenedApplication:
friend Containers::LinkedListItem<BasicScreen<Application>, BasicScreenedApplication<Application>>;
friend BasicScreen<Application>;
#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;

5
src/Magnum/Platform/ScreenedApplication.hpp

@ -212,7 +212,12 @@ template<class Application> void BasicScreenedApplication<Application>::viewport
for(BasicScreen<Application>& s: *this) s.viewportEvent(event);
}
template<class Application> void BasicScreenedApplication<Application>::globalBeforeDrawEvent() {}
template<class Application> void BasicScreenedApplication<Application>::drawEvent() {
/* Call the "before" global event before all other */
globalBeforeDrawEvent();
/* Back-to-front rendering */
for(BasicScreen<Application>* s = screens().last(); s; s = s->nextNearerScreen())
if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Draw) s->drawEvent();

Loading…
Cancel
Save