Browse Source

Improve Application::setup(), setup all states

master
Krisjanis Rijnieks 9 years ago
parent
commit
f064ba810c
  1. 6
      src/Application/Application.cpp
  2. 1
      src/Application/States/ApplicationBaseState.h
  3. 4
      src/Application/States/SourceSelectionState.cpp
  4. 1
      src/Application/States/SourceSelectionState.h
  5. 14
      src/UserInterface/SourcesEditor.cpp
  6. 2
      src/UserInterface/SourcesEditor.h

6
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);
}

1
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);

4
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);

1
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){}

14
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();

2
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();

Loading…
Cancel
Save