From c9a2d066daa1dfc6bc93843f0632cb2c72af99a7 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 9 Feb 2016 19:43:19 +0100 Subject: [PATCH] Create a test case with `GuiEvent` in `Application` --- src/Application/Application.cpp | 10 ++++++++++ src/Application/Application.h | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index f682fcc..65496b2 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -13,6 +13,8 @@ Application::Application(){ setState(PresentationState::instance()); ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed); ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased); + ofAddListener(ofEvents().mousePressed, this, &Application::onMousePressed); + ofAddListener(Gui::instance()->event, this, &Application::onGuiEvent); } void Application::setup(){ @@ -102,6 +104,14 @@ void Application::onKeyReleased(ofKeyEventArgs & args){ } } +void Application::onMousePressed(ofMouseEventArgs & args){ + Gui::instance()->notifyEvent(args); +} + +void Application::onGuiEvent(GuiEvent & e){ + cout << "GUI EVENT: " << e.args.x << ", " << e.args.y << ", " << e.type << endl; +} + void Application::addFboSource(FboSource & fboSource){ _mediaServer.addFboSource(fboSource); } diff --git a/src/Application/Application.h b/src/Application/Application.h index 93d9adf..a126a9d 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -18,6 +18,8 @@ // TODO: To be removed. #include "GuiMode.h" +#include "Gui.h" + #define PIMAPPER_DEF_SURFACES_XML_FILE "defaultSurfaces.xml" #define PIMAPPER_USER_SURFACES_XML_FILE "surfaces.xml" @@ -35,8 +37,15 @@ class Application { void setup(); void draw(); + void onKeyPressed(ofKeyEventArgs & args); void onKeyReleased(ofKeyEventArgs & args); + + // We use this to pass mouse events into the GUI layer + void onMousePressed(ofMouseEventArgs & args); + // Then we catch GUI events with this one and create commands + void onGuiEvent(GuiEvent & e); + void addFboSource(FboSource & fboSource); bool loadXmlSettings(string fileName);