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){
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;
}
}
_state->onGuiEvent(this, e);
}
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 onSurfacePressed(Application * app, GuiSurfaceEvent & 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();
void draw(Application * app);
void onMousePressed(Application * app, ofMouseEventArgs & args);
void onGuiEvent(Application * app, GuiEvent & e){}
private:
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()));
}
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 ofx

2
src/Application/ProjectionMappingState.h

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

26
src/Application/ScaleWidget.cpp

@ -40,19 +40,21 @@ void ScaleWidget::onMousePressed(ofMouseEventArgs & args){
if(_handle.inside(args.x, args.y)){
_dragging = true;
_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){
_dragging = false;
if(_dragging){
GuiWidgetEvent e;
e.args = args;
ofNotifyEvent(guiWidgetEvent, e, this);
}
GuiWidgetEvent e;
e.args = args;
ofNotifyEvent(guiWidgetEvent, e, this);
_dragging = false;
}
void ScaleWidget::onMouseDragged(ofMouseEventArgs & args){
@ -62,11 +64,11 @@ void ScaleWidget::onMouseDragged(ofMouseEventArgs & args){
_line[1].x = args.x;
_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){

2
src/Application/SourceSelectionState.h

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

2
src/Application/TextureMappingState.h

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

Loading…
Cancel
Save