diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 60c8e64..c4aeb4c 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -45,6 +45,12 @@ void Application::setup(){ consoleListener.setup(this); } + // Setup all states. + PresentationState::instance()->setup(this); + TextureMappingState::instance()->setup(this); + ProjectionMappingState::instance()->setup(this); + SourceSelectionState::instance()->setup(this); + // TODO: Consider whether this is the right place for it Gui::instance()->getScaleWidget().setSurfaceManager(&_surfaceManager); } diff --git a/src/Application/States/ApplicationBaseState.h b/src/Application/States/ApplicationBaseState.h index 68a2f67..109636f 100644 --- a/src/Application/States/ApplicationBaseState.h +++ b/src/Application/States/ApplicationBaseState.h @@ -12,6 +12,7 @@ class Application; class ApplicationBaseState { public: + virtual void setup(Application * app){} virtual void update(Application * app){} virtual void draw(Application * app){} virtual void setState(Application * app, ApplicationBaseState * st); diff --git a/src/Application/States/SourceSelectionState.cpp b/src/Application/States/SourceSelectionState.cpp index 84d8c7f..25a6f74 100644 --- a/src/Application/States/SourceSelectionState.cpp +++ b/src/Application/States/SourceSelectionState.cpp @@ -12,6 +12,10 @@ SourceSelectionState * SourceSelectionState::instance(){ return _instance; } +void SourceSelectionState::setup(Application * app){ + app->getGui()->getSourcesEditor()->setup(); +} + void SourceSelectionState::draw(Application * app){ ofPushStyle(); ofSetColor(255, 255, 255, 255); diff --git a/src/Application/States/SourceSelectionState.h b/src/Application/States/SourceSelectionState.h index d6c1ba0..158005e 100644 --- a/src/Application/States/SourceSelectionState.h +++ b/src/Application/States/SourceSelectionState.h @@ -13,6 +13,7 @@ class SourceSelectionState : public ApplicationBaseState { public: static SourceSelectionState * instance(); + void setup(Application * app); void draw(Application * app); void onGuiEvent(Application * app, GuiEvent & e){} diff --git a/src/UserInterface/SourcesEditor.cpp b/src/UserInterface/SourcesEditor.cpp index e464531..d555266 100644 --- a/src/UserInterface/SourcesEditor.cpp +++ b/src/UserInterface/SourcesEditor.cpp @@ -10,6 +10,10 @@ SourcesEditor::SourcesEditor(){ mediaServer = new MediaServer(); isMediaServerExternal = false; addMediaServerListeners(); + + imageSelector = new RadioList(); + videoSelector = new RadioList(); + fboSelector = new RadioList(); } void SourcesEditor::init(){ @@ -36,18 +40,14 @@ SourcesEditor::~SourcesEditor(){ } void SourcesEditor::registerAppEvents(){ - ofAddListener(ofEvents().setup, this, &SourcesEditor::setup); + //ofAddListener(ofEvents().setup, this, &SourcesEditor::setup); } void SourcesEditor::unregisterAppEvents(){ - ofRemoveListener(ofEvents().setup, this, &SourcesEditor::setup); + //ofRemoveListener(ofEvents().setup, this, &SourcesEditor::setup); } -void SourcesEditor::setup(ofEventArgs & args){ - imageSelector = new RadioList(); - videoSelector = new RadioList(); - fboSelector = new RadioList(); - +void SourcesEditor::setup(){ // Get media count int numImages = mediaServer->getNumImages(); int numVideos = mediaServer->getNumVideos(); diff --git a/src/UserInterface/SourcesEditor.h b/src/UserInterface/SourcesEditor.h index c209ea3..45233ca 100644 --- a/src/UserInterface/SourcesEditor.h +++ b/src/UserInterface/SourcesEditor.h @@ -24,7 +24,7 @@ class SourcesEditor { void registerAppEvents(); void unregisterAppEvents(); - void setup(ofEventArgs & args); + void setup(); void draw(); void loadImage(string name, string path); void disable();