diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 40e5c01..5448f03 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -20,6 +20,8 @@ Application::Application(){ ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed); ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed); ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed); + + ofAddListener(Gui::instance()->guiEvent, this, &Application::onGuiEvent); string SSHConnection = ofSystem("if [ -z $SSH_CONNECTION ]; then echo no; else echo yes; fi"); if(SSHConnection == "yes"){ @@ -149,6 +151,18 @@ void Application::onBackgroundPressed(GuiBackgroundEvent & e){ _state->onBackgroundPressed(this, e); } +void Application::onGuiEvent(GuiEvent & e){ + if(e.widget == &Gui::instance()->getScaleWidget()){ + if(e.args.type == e.args.Pressed){ + cout << "Scale Pressed" << endl; + }else if(e.args.type == e.args.Released){ + cout << "Scale Released" << endl; + }else if(e.args.type == e.args.Dragged){ + cout << "Scale Dragged" << endl; + } + } +} + void Application::addFboSource(FboSource & fboSource){ _mediaServer.addFboSource(fboSource); } diff --git a/src/Application/Application.h b/src/Application/Application.h index f2adea1..c44b395 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -51,7 +51,8 @@ class Application : public KeyListener { void onJointPressed(GuiJointEvent & e); void onSurfacePressed(GuiSurfaceEvent & e); void onBackgroundPressed(GuiBackgroundEvent & e); - // Every state should have it's own GUI layer + + void onGuiEvent(GuiEvent & e); void addFboSource(FboSource & fboSource); void addFboSource(FboSource * fboSource); diff --git a/src/Application/Gui.cpp b/src/Application/Gui.cpp index 2296250..934ebba 100644 --- a/src/Application/Gui.cpp +++ b/src/Application/Gui.cpp @@ -85,13 +85,10 @@ ScaleWidget & Gui::getScaleWidget(){ } void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){ - if(event.args.type == event.args.Pressed){ - cout << "ScaleWidget Pressed" << endl; - }else if(event.args.type == event.args.Released){ - cout << "ScaleWidget Released" << endl; - }else if(event.args.type == event.args.Dragged){ - cout << "ScaleWidget Dragged" << endl; - } + GuiEvent e; + e.args = event.args; + e.widget = &_scaleWidget; + ofNotifyEvent(guiEvent, e, this); } } // piMapper diff --git a/src/Application/Gui.h b/src/Application/Gui.h index 98d476c..648b46e 100644 --- a/src/Application/Gui.h +++ b/src/Application/Gui.h @@ -68,6 +68,8 @@ class Gui { void onScaleWidgetEvent(GuiWidgetEvent & event); + ofEvent guiEvent; + private: Gui(); ~Gui();