summaryrefslogtreecommitdiff
path: root/plugingui/eventhandler.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-04-16 19:29:59 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2017-04-16 20:15:19 +0200
commitea406769262b5ebd7d9f775e26a8655a6ee94d00 (patch)
treeee13d3a143d977e3ff12d864dcdd795261944669 /plugingui/eventhandler.cc
parent1b3d6c39ae120aa8a80a5330977d23906f87c621 (diff)
Add modal dialog primitive.
Diffstat (limited to 'plugingui/eventhandler.cc')
-rw-r--r--plugingui/eventhandler.cc41
1 files changed, 41 insertions, 0 deletions
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<Event> 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<ButtonEvent*>(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<ScrollEvent*>(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::