From ea406769262b5ebd7d9f775e26a8655a6ee94d00 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 16 Apr 2017 19:29:59 +0200 Subject: Add modal dialog primitive. --- plugingui/eventhandler.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'plugingui/eventhandler.cc') diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc index a57e74b..decca01 100644 --- a/plugingui/eventhandler.cc +++ b/plugingui/eventhandler.cc @@ -28,6 +28,7 @@ #include "window.h" #include "painter.h" +#include "dialog.h" namespace GUI { @@ -63,6 +64,16 @@ std::shared_ptr EventHandler::getNextEvent() void EventHandler::processEvents() { + bool block_interaction{false}; + for(auto dialog : dialogs) + { + if(dialog->visible()) + { + block_interaction |= dialog->isModal(); + dialog->eventHandler()->processEvents(); + } + } + events = nativeWindow.getEvents(); while(hasEvent()) @@ -147,6 +158,11 @@ void EventHandler::processEvents() case EventType::button: { + if(block_interaction) + { + continue; + } + auto buttonEvent = static_cast(event.get()); if(lastWasDoubleClick && (buttonEvent->direction == Direction::down)) { @@ -195,6 +211,11 @@ void EventHandler::processEvents() case EventType::scroll: { + if(block_interaction) + { + continue; + } + auto scrollEvent = static_cast(event.get()); auto widget = window.find(scrollEvent->x, scrollEvent->y); @@ -210,6 +231,10 @@ void EventHandler::processEvents() case EventType::key: { + if(block_interaction) + { + continue; + } // TODO: Filter out multiple arrow events. @@ -222,6 +247,11 @@ void EventHandler::processEvents() break; case EventType::close: + if(block_interaction) + { + continue; + } + closeNotifier(); break; } @@ -232,4 +262,15 @@ void EventHandler::processEvents() window.updateBuffer(); } +void EventHandler::registerDialog(Dialog* dialog) +{ + dialogs.push_back(dialog); +} + +void EventHandler::unregisterDialog(Dialog* dialog) +{ + dialogs.remove(dialog); +} + + } // GUI:: -- cgit v1.2.3