Browse Source

Create a bridge between the new state system and the old solution

master
Krisjanis Rijnieks 10 years ago
parent
commit
04a345b377
  1. 16
      src/Application/Application.cpp
  2. 3
      src/Application/Application.h
  3. 17
      src/Commands/SetApplicationStateCmd.cpp
  4. 9
      src/Commands/SetApplicationStateCmd.h

16
src/Application/Application.cpp

@ -26,26 +26,34 @@ namespace ofx {
// Here we handle application state changes only
void Application::onKeyPressed(ofKeyEventArgs & args) {
// For now we set the state of the new system and also the old
// before it is completely ported to the state system.
switch (args.key) {
case '1':
_ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd(
this, PresentationState::instance()));
this, PresentationState::instance(),
&_ofxPiMapper->getGui(), GuiMode::NONE));
break;
case '2':
_ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd(
this, TextureMappingState::instance()));
this, TextureMappingState::instance(),
&_ofxPiMapper->getGui(), GuiMode::TEXTURE_MAPPING));
break;
case '3':
_ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd(
this, ProjectionMappingState::instance()));
this, ProjectionMappingState::instance(),
&_ofxPiMapper->getGui(), GuiMode::PROJECTION_MAPPING));
break;
case '4':
_ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd(
this, SourceSelectionState::instance()));
this, SourceSelectionState::instance(),
&_ofxPiMapper->getGui(), GuiMode::SOURCE_SELECTION));
break;
default:
break;

3
src/Application/Application.h

@ -11,6 +11,9 @@
#include "TextureMappingState.h"
#include "SourceSelectionState.h"
// TODO: To be removed.
#include "GuiMode.h"
class ofxPiMapper;
namespace ofx {

17
src/Commands/SetApplicationStateCmd.cpp

@ -5,21 +5,36 @@ namespace ofx {
SetApplicationStateCmd::SetApplicationStateCmd(
Application * app,
ApplicationBaseState * st) {
ApplicationBaseState * st,
SurfaceManagerGui * gui,
int mode) {
_application = app;
_prevApplicationState = 0;
_applicationState = st;
// TODO: To be removed
_gui = gui;
_prevGuiMode = -1;
_mode = mode;
}
void SetApplicationStateCmd::exec() {
_prevApplicationState = _application->getState();
_application->setState(_applicationState);
// TODO: To be removed.
_prevGuiMode = _gui->getMode();
_gui->setMode(_mode);
}
void SetApplicationStateCmd::undo() {
ofLogNotice("SetApplicationStateCmd", "undo");
_application->setState(_prevApplicationState);
// TODO: To be removed.
_gui->setMode(_prevGuiMode);
}
} // namespace piMapper

9
src/Commands/SetApplicationStateCmd.h

@ -14,7 +14,9 @@ namespace ofx {
public:
SetApplicationStateCmd(
Application * app,
ApplicationBaseState * st);
ApplicationBaseState * st,
SurfaceManagerGui * gui,
int mode);
void exec();
void undo();
@ -23,6 +25,11 @@ namespace ofx {
Application * _application;
ApplicationBaseState * _prevApplicationState;
ApplicationBaseState * _applicationState;
// TODO: Remove these after porting to app state system is done
SurfaceManagerGui * _gui;
int _prevGuiMode;
int _mode;
};
} // namespace piMapper

Loading…
Cancel
Save