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(),
&_ofxPiMapper->getGui(), GuiMode::NONE));
break;
case '2':
_ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd(
this, TextureMappingState::instance(),
&_ofxPiMapper->getGui(), GuiMode::TEXTURE_MAPPING));
break;
case '3':
_ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd(
this, ProjectionMappingState::instance(),
&_ofxPiMapper->getGui(), GuiMode::PROJECTION_MAPPING));
break;
case '4':
_ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetApplicationStateCmd(
this, SourceSelectionState::instance(),
&_ofxPiMapper->getGui(), GuiMode::SOURCE_SELECTION));
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:
// All the other keypresses are handled by the application state onKeyPressed
_state->onKeyPressed(this, args);

1
src/Application/PresentationState.cpp

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

4
src/Application/ProjectionMappingState.cpp

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

4
src/Application/SourceSelectionState.cpp

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

4
src/Application/TextureMappingState.cpp

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

29
src/ofxPiMapper.cpp

@ -1,11 +1,7 @@
#include "ofxPiMapper.h"
ofxPiMapper::ofxPiMapper(): bShowInfo(false), isSetUp(false){
ofAddListener(ofEvents().keyPressed, this, &ofxPiMapper::keyPressed);
}
ofxPiMapper::~ofxPiMapper(){
ofRemoveListener(ofEvents().keyPressed, this, &ofxPiMapper::keyPressed);
}
void ofxPiMapper::setup(){
@ -74,29 +70,6 @@ void ofxPiMapper::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){
mediaServer.addFboSource(fboSource);
} // addFboSource

3
src/ofxPiMapper.h

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

Loading…
Cancel
Save