Browse Source

Move keyboard input mappings completely to application state system

master
Krisjanis Rijnieks 10 years ago
parent
commit
502f76b4a9
  1. 21
      src/Application/Application.cpp
  2. 1
      src/Application/PresentationState.cpp
  3. 4
      src/Application/ProjectionMappingState.cpp
  4. 4
      src/Application/SourceSelectionState.cpp
  5. 4
      src/Application/TextureMappingState.cpp
  6. 29
      src/ofxPiMapper.cpp
  7. 3
      src/ofxPiMapper.h

21
src/Application/Application.cpp

@ -41,24 +41,45 @@ namespace ofx {
this, PresentationState::instance(), this, PresentationState::instance(),
&_ofxPiMapper->getGui(), GuiMode::NONE)); &_ofxPiMapper->getGui(), GuiMode::NONE));
break; break;
case '2': case '2':
_ofxPiMapper->getCmdManager().exec( _ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd( new ofx::piMapper::SetApplicationStateCmd(
this, TextureMappingState::instance(), this, TextureMappingState::instance(),
&_ofxPiMapper->getGui(), GuiMode::TEXTURE_MAPPING)); &_ofxPiMapper->getGui(), GuiMode::TEXTURE_MAPPING));
break; break;
case '3': case '3':
_ofxPiMapper->getCmdManager().exec( _ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd( new ofx::piMapper::SetApplicationStateCmd(
this, ProjectionMappingState::instance(), this, ProjectionMappingState::instance(),
&_ofxPiMapper->getGui(), GuiMode::PROJECTION_MAPPING)); &_ofxPiMapper->getGui(), GuiMode::PROJECTION_MAPPING));
break; break;
case '4': case '4':
_ofxPiMapper->getCmdManager().exec( _ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd( new ofx::piMapper::SetApplicationStateCmd(
this, SourceSelectionState::instance(), this, SourceSelectionState::instance(),
&_ofxPiMapper->getGui(), GuiMode::SOURCE_SELECTION)); &_ofxPiMapper->getGui(), GuiMode::SOURCE_SELECTION));
break; break;
case 'f':
ofToggleFullscreen();
break;
case 'i':
_ofxPiMapper->toggleInfo();
break;
case 's':
_ofxPiMapper->getSurfaceManager().saveXmlSettings(
PIMAPPER_USER_SURFACES_XML_FILE);
break;
case 'z':
_ofxPiMapper->getCmdManager().undo();
break;
default: default:
// All the other keypresses are handled by the application state onKeyPressed // All the other keypresses are handled by the application state onKeyPressed
_state->onKeyPressed(this, args); _state->onKeyPressed(this, args);

1
src/Application/PresentationState.cpp

@ -14,7 +14,6 @@ namespace ofx {
void PresentationState::draw(Application * app) { void PresentationState::draw(Application * app) {
ofSetColor(255, 255, 0); ofSetColor(255, 255, 0);
ofDrawBitmapString("Presentation State", 10, 20);
} }
} }
} }

4
src/Application/ProjectionMappingState.cpp

@ -12,9 +12,7 @@ namespace ofx {
return _instance; return _instance;
} }
void ProjectionMappingState::draw(Application * app) { void ProjectionMappingState::draw(Application * app) {}
ofDrawBitmapString("Projection Mapping State", 10, 20);
}
void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args) { void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args) {
switch (args.key) { switch (args.key) {

4
src/Application/SourceSelectionState.cpp

@ -12,8 +12,6 @@ namespace ofx {
return _instance; return _instance;
} }
void SourceSelectionState::draw(Application * app) { void SourceSelectionState::draw(Application * app) {}
ofDrawBitmapString("Source Selection State", 10, 20);
}
} }
} }

4
src/Application/TextureMappingState.cpp

@ -12,8 +12,6 @@ namespace ofx {
return _instance; return _instance;
} }
void TextureMappingState::draw(Application * app) { void TextureMappingState::draw(Application * app) {}
ofDrawBitmapString("Texture Mapping State", 10, 20);
}
} }
} }

29
src/ofxPiMapper.cpp

@ -1,11 +1,7 @@
#include "ofxPiMapper.h" #include "ofxPiMapper.h"
ofxPiMapper::ofxPiMapper(): bShowInfo(false), isSetUp(false){ ofxPiMapper::ofxPiMapper(): bShowInfo(false), isSetUp(false){
ofAddListener(ofEvents().keyPressed, this, &ofxPiMapper::keyPressed);
}
ofxPiMapper::~ofxPiMapper(){
ofRemoveListener(ofEvents().keyPressed, this, &ofxPiMapper::keyPressed);
} }
void ofxPiMapper::setup(){ void ofxPiMapper::setup(){
@ -74,29 +70,6 @@ void ofxPiMapper::draw(){
} // draw } // draw
void ofxPiMapper::keyPressed(ofKeyEventArgs &args){
//ofLogNotice("ofxPiMapper") << "Key pressed: " << static_cast<char>(args.key);
switch (args.key) {
case 'i':
bShowInfo = !bShowInfo;
break;
case 'f':
ofToggleFullscreen();
break;
case 's':
surfaceManager.saveXmlSettings(PIMAPPER_USER_SURFACES_XML_FILE);
break;
case 'z':
// Undo any undo command operation
cmdManager.undo();
break;
default:
break;
}
} // keyPressed
void ofxPiMapper::addFboSource(ofx::piMapper::FboSource &fboSource){ void ofxPiMapper::addFboSource(ofx::piMapper::FboSource &fboSource){
mediaServer.addFboSource(fboSource); mediaServer.addFboSource(fboSource);
} // addFboSource } // addFboSource

3
src/ofxPiMapper.h

@ -27,12 +27,10 @@ class ofxPiMapper{
public: public:
ofxPiMapper(); ofxPiMapper();
~ofxPiMapper();
void setup(); void setup();
void stateSetup(); void stateSetup();
void draw(); void draw();
void keyPressed(ofKeyEventArgs& args);
void addFboSource(ofx::piMapper::FboSource& fboSource); void addFboSource(ofx::piMapper::FboSource& fboSource);
void addTriangleSurface(); void addTriangleSurface();
@ -41,6 +39,7 @@ class ofxPiMapper{
// Toggle help / info // Toggle help / info
void showInfo() { bShowInfo = true; }; void showInfo() { bShowInfo = true; };
void hideInfo() { bShowInfo = false; }; void hideInfo() { bShowInfo = false; };
void toggleInfo() { bShowInfo = !bShowInfo; }
// Getters // Getters
ofx::piMapper::CmdManager & getCmdManager(); ofx::piMapper::CmdManager & getCmdManager();

Loading…
Cancel
Save