Browse Source

Add storing and reseting TextureMappingState canvas translation

In SetApplicationStateCmd
master
Krisjanis Rijnieks 9 years ago
parent
commit
48052d7863
  1. 4
      src/Application/States/ApplicationBaseState.h
  2. 11
      src/Application/States/TextureMappingState.cpp
  3. 3
      src/Application/States/TextureMappingState.h
  4. 3
      src/Commands/SetApplicationStateCmd.cpp
  5. 2
      src/Commands/SetApplicationStateCmd.h

4
src/Application/States/ApplicationBaseState.h

@ -25,6 +25,10 @@ class ApplicationBaseState {
virtual void onBackgroundPressed(Application * app, GuiBackgroundEvent & e){}
virtual void onGuiEvent(Application * app, GuiEvent & e) = 0;
// These are only used by TextureMappingState for now.
virtual ofPoint getTranslation(){ return ofPoint(0, 0); }
virtual void setTranslation(ofPoint p){}
};

11
src/Application/States/TextureMappingState.cpp

@ -125,5 +125,16 @@ void TextureMappingState::onMouseDragged(Application * app, ofMouseEventArgs & a
}
}
ofPoint TextureMappingState::getTranslation(){
cout << "TextureMappingState::getTranslation()" << endl;
return _canvasTranslate;
}
void TextureMappingState::setTranslation(ofPoint p){
cout << "TextureMappingState::setTranslation()" << endl;
_canvasTranslate = p;
_clickCanvasTranslate = p;
}
} // namespace piMapper
} // namespace ofx

3
src/Application/States/TextureMappingState.h

@ -27,6 +27,9 @@ class TextureMappingState : public ApplicationBaseState {
void onMouseDragged(Application * app, ofMouseEventArgs & args);
void onGuiEvent(Application * app, GuiEvent & e){}
ofPoint getTranslation();
void setTranslation(ofPoint p);
private:
static TextureMappingState * _instance;

3
src/Commands/SetApplicationStateCmd.cpp

@ -21,6 +21,8 @@ SetApplicationStateCmd::SetApplicationStateCmd(Application * app,
void SetApplicationStateCmd::exec(){
_prevApplicationState = _application->getState();
_application->setState(_applicationState);
_applicationState->setTranslation(ofPoint(0, 0));
_translation = _prevApplicationState->getTranslation();
// TODO: To be removed.
_prevGuiMode = _gui->getMode();
@ -30,6 +32,7 @@ void SetApplicationStateCmd::exec(){
void SetApplicationStateCmd::undo(){
ofLogNotice("SetApplicationStateCmd", "undo");
_application->setState(_prevApplicationState);
_application->getState()->setTranslation(_translation);
// TODO: To be removed.
_gui->setMode(_prevGuiMode);

2
src/Commands/SetApplicationStateCmd.h

@ -26,6 +26,8 @@ class SetApplicationStateCmd : public BaseUndoCmd {
ApplicationBaseState * _prevApplicationState;
ApplicationBaseState * _applicationState;
ofPoint _translation;
// TODO: Remove these after porting to app state system is done
SurfaceManagerGui * _gui;
int _prevGuiMode;

Loading…
Cancel
Save