Browse Source

Add pure virtual `ApplicationBaseState::onGuiEvent` method

master
Krisjanis Rijnieks 9 years ago
parent
commit
5f20529efb
  1. 10
      src/Application/Application.cpp
  2. 2
      src/Application/ApplicationBaseState.h
  3. 2
      src/Application/PresentationState.h
  4. 12
      src/Application/ProjectionMappingState.cpp
  5. 2
      src/Application/ProjectionMappingState.h
  6. 26
      src/Application/ScaleWidget.cpp
  7. 2
      src/Application/SourceSelectionState.h
  8. 2
      src/Application/TextureMappingState.h

10
src/Application/Application.cpp

@ -152,15 +152,7 @@ void Application::onBackgroundPressed(GuiBackgroundEvent & e){
} }
void Application::onGuiEvent(GuiEvent & e){ void Application::onGuiEvent(GuiEvent & e){
if(e.widget == &Gui::instance()->getScaleWidget()){ _state->onGuiEvent(this, e);
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){

2
src/Application/ApplicationBaseState.h

@ -23,6 +23,8 @@ class ApplicationBaseState {
virtual void onJointPressed(Application * app, GuiJointEvent & e){} virtual void onJointPressed(Application * app, GuiJointEvent & e){}
virtual void onSurfacePressed(Application * app, GuiSurfaceEvent & e){} virtual void onSurfacePressed(Application * app, GuiSurfaceEvent & e){}
virtual void onBackgroundPressed(Application * app, GuiBackgroundEvent & e){} virtual void onBackgroundPressed(Application * app, GuiBackgroundEvent & e){}
virtual void onGuiEvent(Application * app, GuiEvent & e) = 0;
}; };

2
src/Application/PresentationState.h

@ -17,6 +17,8 @@ class PresentationState : public ApplicationBaseState {
static PresentationState * instance(); static PresentationState * instance();
void draw(Application * app); void draw(Application * app);
void onMousePressed(Application * app, ofMouseEventArgs & args); void onMousePressed(Application * app, ofMouseEventArgs & args);
void onGuiEvent(Application * app, GuiEvent & e){}
private: private:
static PresentationState * _instance; static PresentationState * _instance;

12
src/Application/ProjectionMappingState.cpp

@ -334,5 +334,17 @@ void ProjectionMappingState::onBackgroundPressed(Application * app, GuiBackgroun
app->getCmdManager()->exec(new DeselectSurfaceCmd(app->getSurfaceManager())); app->getCmdManager()->exec(new DeselectSurfaceCmd(app->getSurfaceManager()));
} }
void ProjectionMappingState::onGuiEvent(Application * app, 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;
}
}
}
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

2
src/Application/ProjectionMappingState.h

@ -48,6 +48,8 @@ class ProjectionMappingState : public ApplicationBaseState {
void onJointPressed(Application * app, GuiJointEvent & e); void onJointPressed(Application * app, GuiJointEvent & e);
void onSurfacePressed(Application * app, GuiSurfaceEvent & e); void onSurfacePressed(Application * app, GuiSurfaceEvent & e);
void onBackgroundPressed(Application * app, GuiBackgroundEvent & e); void onBackgroundPressed(Application * app, GuiBackgroundEvent & e);
void onGuiEvent(Application * app, GuiEvent & e);
private: private:
static ProjectionMappingState * _instance; static ProjectionMappingState * _instance;

26
src/Application/ScaleWidget.cpp

@ -40,19 +40,21 @@ void ScaleWidget::onMousePressed(ofMouseEventArgs & args){
if(_handle.inside(args.x, args.y)){ if(_handle.inside(args.x, args.y)){
_dragging = true; _dragging = true;
_originalLine = _line; _originalLine = _line;
GuiWidgetEvent e;
e.args = args;
ofNotifyEvent(guiWidgetEvent, e, this);
} }
GuiWidgetEvent e;
e.args = args;
ofNotifyEvent(guiWidgetEvent, e, this);
} }
void ScaleWidget::onMouseReleased(ofMouseEventArgs & args){ void ScaleWidget::onMouseReleased(ofMouseEventArgs & args){
_dragging = false; if(_dragging){
GuiWidgetEvent e;
e.args = args;
ofNotifyEvent(guiWidgetEvent, e, this);
}
GuiWidgetEvent e; _dragging = false;
e.args = args;
ofNotifyEvent(guiWidgetEvent, e, this);
} }
void ScaleWidget::onMouseDragged(ofMouseEventArgs & args){ void ScaleWidget::onMouseDragged(ofMouseEventArgs & args){
@ -62,11 +64,11 @@ void ScaleWidget::onMouseDragged(ofMouseEventArgs & args){
_line[1].x = args.x; _line[1].x = args.x;
_line[1].y = args.y; _line[1].y = args.y;
GuiWidgetEvent e;
e.args = args;
ofNotifyEvent(guiWidgetEvent, e, this);
} }
GuiWidgetEvent e;
e.args = args;
ofNotifyEvent(guiWidgetEvent, e, this);
} }
bool ScaleWidget::inside(float x, float y){ bool ScaleWidget::inside(float x, float y){

2
src/Application/SourceSelectionState.h

@ -13,6 +13,8 @@ class SourceSelectionState : public ApplicationBaseState {
public: public:
static SourceSelectionState * instance(); static SourceSelectionState * instance();
void draw(Application * app); void draw(Application * app);
void onGuiEvent(Application * app, GuiEvent & e){}
private: private:
static SourceSelectionState * _instance; static SourceSelectionState * _instance;

2
src/Application/TextureMappingState.h

@ -21,6 +21,8 @@ class TextureMappingState : public ApplicationBaseState {
void draw(Application * app); void draw(Application * app);
void onKeyPressed(Application * app, ofKeyEventArgs & args); void onKeyPressed(Application * app, ofKeyEventArgs & args);
void onBackgroundPressed(Application * app, GuiBackgroundEvent & e); void onBackgroundPressed(Application * app, GuiBackgroundEvent & e);
void onGuiEvent(Application * app, GuiEvent & e){}
private: private:
static TextureMappingState * _instance; static TextureMappingState * _instance;

Loading…
Cancel
Save