/* This file is part of Magnum. Copyright © 2010, 2011, 2012, 2013, 2014, 2015 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** @file * @brief @ref compilation-speedup-hpp "Template implementation" for @ref ScreenedApplication.h and @ref Screen.h */ #include "Magnum/Platform/Screen.h" #include "Magnum/Platform/ScreenedApplication.h" namespace Magnum { namespace Platform { template BasicScreen::BasicScreen() = default; template BasicScreen::~BasicScreen() = default; template void BasicScreen::keyPressEvent(KeyEvent&) {} template void BasicScreen::keyReleaseEvent(KeyEvent&) {} template void BasicScreen::mousePressEvent(MouseEvent&) {} template void BasicScreen::mouseReleaseEvent(MouseEvent&) {} template void BasicScreen::mouseMoveEvent(MouseMoveEvent&) {} template BasicScreenedApplication::BasicScreenedApplication(const typename Application::Arguments& arguments, const typename Application::Configuration& configuration): Application(arguments, configuration) {} #ifndef CORRADE_GCC45_COMPATIBILITY template BasicScreenedApplication::BasicScreenedApplication(const typename Application::Arguments& arguments, std::nullptr_t): #else template BasicScreenedApplication::BasicScreenedApplication(const typename Application::Arguments& arguments, void*): #endif Application(arguments, nullptr) {} /* `= default` causes linker errors in GCC 4.4, maybe also in 4.5 */ template BasicScreenedApplication::~BasicScreenedApplication() {} template BasicScreenedApplication& BasicScreenedApplication::addScreen(BasicScreen& screen) { Containers::LinkedList>::insert(&screen); if(screens().first() == &screen) screen.focusEvent(); Application::redraw(); return *this; } template BasicScreenedApplication& BasicScreenedApplication::removeScreen(BasicScreen& screen) { screen.blurEvent(); Containers::LinkedList>::erase(&screen); Application::redraw(); return *this; } template BasicScreenedApplication& BasicScreenedApplication::focusScreen(BasicScreen& screen) { /* Already focused, nothing to do */ if(screens().first() == &screen) return *this; screens().first()->blurEvent(); Containers::LinkedList>::move(&screen, screens().first()); screen.focusEvent(); Application::redraw(); return *this; } template void BasicScreenedApplication::globalViewportEvent(const Vector2i&) {} template void BasicScreenedApplication::viewportEvent(const Vector2i& size) { /* Call global event before all other (to resize framebuffer first) */ globalViewportEvent(size); for(auto it = begin(*this); it != end(*this); ++it) (*it).viewportEvent(size); } template void BasicScreenedApplication::drawEvent() { /* Back-to-front rendering */ for(BasicScreen* s = screens().last(); s; s = s->nextNearerScreen()) if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Draw) s->drawEvent(); /* Call global event after all other (to swap buffers last) */ globalDrawEvent(); } template void BasicScreenedApplication::keyPressEvent(typename Application::KeyEvent& event) { /* Front-to-back event propagation, stop when the event gets accepted */ for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->keyPressEvent(event); if(event.isAccepted()) break; } } } template void BasicScreenedApplication::keyReleaseEvent(typename Application::KeyEvent& event) { /* Front-to-back event propagation, stop when the event gets accepted */ for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->keyReleaseEvent(event); if(event.isAccepted()) break; } } } template void BasicScreenedApplication::mousePressEvent(typename Application::MouseEvent& event) { /* Front-to-back event propagation, stop when the event gets accepted */ for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->mousePressEvent(event); if(event.isAccepted()) break; } } } template void BasicScreenedApplication::mouseReleaseEvent(typename Application::MouseEvent& event) { /* Front-to-back event propagation, stop when the event gets accepted */ for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->mouseReleaseEvent(event); if(event.isAccepted()) break; } } } template void BasicScreenedApplication::mouseMoveEvent(typename Application::MouseMoveEvent& event) { /* Front-to-back event propagation, stop when the event gets accepted */ for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->mouseMoveEvent(event); if(event.isAccepted()) break; } } } }}