Browse Source

Add shift key handling in `Application`

master
Krisjanis Rijnieks 9 years ago
parent
commit
2cf81a1eac
  1. 15
      src/Application/Application.cpp
  2. 8
      src/Application/Application.h

15
src/Application/Application.cpp

@ -12,6 +12,7 @@ Application::Application(){
setState(PresentationState::instance());
ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed);
ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased);
}
void Application::setup(){
@ -39,6 +40,10 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
// before it is completely ported to the state system.
switch(args.key){
case OF_KEY_SHIFT:
_shiftKeyDown = true;
break;
case '1':
_cmdManager.exec(
new ofx::piMapper::SetApplicationStateCmd(
@ -91,6 +96,12 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
}
}
void Application::onKeyReleased(ofKeyEventArgs & args){
if(args.key == OF_KEY_SHIFT){
_shiftKeyDown = false;
}
}
void Application::addFboSource(FboSource & fboSource){
_mediaServer.addFboSource(fboSource);
}
@ -99,6 +110,10 @@ void Application::setState(ApplicationBaseState * st){
_state = st;
}
bool Application::isShiftKeyDown(){
return _shiftKeyDown;
}
bool Application::loadXmlSettings(string fileName){
if(!ofFile::doesFileExist(fileName)){
ofLogError("Application::loadXmlSettings()") << fileName << " does not exist";

8
src/Application/Application.h

@ -36,17 +36,19 @@ class Application {
void setup();
void draw();
void onKeyPressed(ofKeyEventArgs & args);
void onKeyReleased(ofKeyEventArgs & args);
void addFboSource(FboSource & fboSource);
bool loadXmlSettings(string fileName);
bool isShiftKeyDown();
SurfaceManagerGui * getGui(){ return &_gui; };
SurfaceManager * getSurfaceManager(){ return &_surfaceManager; };
CmdManager * getCmdManager(){ return &_cmdManager; };
protected:
void setState(ApplicationBaseState * st);
private:
friend class ApplicationBaseState;
friend class SetApplicationStateCmd;
@ -58,6 +60,8 @@ class Application {
MediaServer _mediaServer;
SurfaceManager _surfaceManager;
Info _info;
bool _shiftKeyDown;
};

Loading…
Cancel
Save