Browse Source

Capture GuiEvent in Application

master
Krisjanis Rijnieks 9 years ago
parent
commit
7f67ec6621
  1. 14
      src/Application/Application.cpp
  2. 3
      src/Application/Application.h
  3. 11
      src/Application/Gui.cpp
  4. 2
      src/Application/Gui.h

14
src/Application/Application.cpp

@ -20,6 +20,8 @@ Application::Application(){
ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed); ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed);
ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed); ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed);
ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed); 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"); string SSHConnection = ofSystem("if [ -z $SSH_CONNECTION ]; then echo no; else echo yes; fi");
if(SSHConnection == "yes"){ if(SSHConnection == "yes"){
@ -149,6 +151,18 @@ void Application::onBackgroundPressed(GuiBackgroundEvent & e){
_state->onBackgroundPressed(this, 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){ void Application::addFboSource(FboSource & fboSource){
_mediaServer.addFboSource(fboSource); _mediaServer.addFboSource(fboSource);
} }

3
src/Application/Application.h

@ -51,7 +51,8 @@ class Application : public KeyListener {
void onJointPressed(GuiJointEvent & e); void onJointPressed(GuiJointEvent & e);
void onSurfacePressed(GuiSurfaceEvent & e); void onSurfacePressed(GuiSurfaceEvent & e);
void onBackgroundPressed(GuiBackgroundEvent & 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);
void addFboSource(FboSource * fboSource); void addFboSource(FboSource * fboSource);

11
src/Application/Gui.cpp

@ -85,13 +85,10 @@ ScaleWidget & Gui::getScaleWidget(){
} }
void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){ void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){
if(event.args.type == event.args.Pressed){ GuiEvent e;
cout << "ScaleWidget Pressed" << endl; e.args = event.args;
}else if(event.args.type == event.args.Released){ e.widget = &_scaleWidget;
cout << "ScaleWidget Released" << endl; ofNotifyEvent(guiEvent, e, this);
}else if(event.args.type == event.args.Dragged){
cout << "ScaleWidget Dragged" << endl;
}
} }
} // piMapper } // piMapper

2
src/Application/Gui.h

@ -68,6 +68,8 @@ class Gui {
void onScaleWidgetEvent(GuiWidgetEvent & event); void onScaleWidgetEvent(GuiWidgetEvent & event);
ofEvent <GuiEvent> guiEvent;
private: private:
Gui(); Gui();
~Gui(); ~Gui();

Loading…
Cancel
Save