From 873edcfa60d5879389f6e95ecea2fdd818bd9987 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sun, 3 Jan 2016 15:57:19 +0000 Subject: [PATCH] Add `SurfaceManagerGui` as pointer in `ofxPiMapper` class Update the rest of the code to treat it as a pointer. --- src/Application/Application.cpp | 8 ++++---- src/ofxPiMapper.cpp | 13 +++++++------ src/ofxPiMapper.h | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 6c44d57..71a1e4c 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -39,28 +39,28 @@ void Application::onKeyPressed(ofKeyEventArgs & args){ _ofxPiMapper->getCmdManager()->exec( new ofx::piMapper::SetApplicationStateCmd( this, PresentationState::instance(), - &_ofxPiMapper->getGui(), GuiMode::NONE)); + _ofxPiMapper->getGui(), GuiMode::NONE)); break; case '2': _ofxPiMapper->getCmdManager()->exec( new ofx::piMapper::SetApplicationStateCmd( this, TextureMappingState::instance(), - &_ofxPiMapper->getGui(), GuiMode::TEXTURE_MAPPING)); + _ofxPiMapper->getGui(), GuiMode::TEXTURE_MAPPING)); break; case '3': _ofxPiMapper->getCmdManager()->exec( new ofx::piMapper::SetApplicationStateCmd( this, ProjectionMappingState::instance(), - &_ofxPiMapper->getGui(), GuiMode::PROJECTION_MAPPING)); + _ofxPiMapper->getGui(), GuiMode::PROJECTION_MAPPING)); break; case '4': _ofxPiMapper->getCmdManager()->exec( new ofx::piMapper::SetApplicationStateCmd( this, SourceSelectionState::instance(), - &_ofxPiMapper->getGui(), GuiMode::SOURCE_SELECTION)); + _ofxPiMapper->getGui(), GuiMode::SOURCE_SELECTION)); break; case 'f': diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index 35adeba..b79dfd5 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -3,6 +3,7 @@ ofxPiMapper::ofxPiMapper(){ bShowInfo = false; isSetUp = false; + _gui = new ofx::piMapper::SurfaceManagerGui(); _cmdManager = new ofx::piMapper::CmdManager(); _mediaServer = new ofx::piMapper::MediaServer(); _info = new ofx::piMapper::Info(); @@ -12,8 +13,8 @@ void ofxPiMapper::setup(){ ofLogNotice("ofxPiMapper") << "Setting up..."; surfaceManager.setMediaServer(_mediaServer); - gui.setMediaServer(_mediaServer); - gui.setCmdManager(_cmdManager); + _gui->setMediaServer(_mediaServer); + _gui->setCmdManager(_cmdManager); if(!loadXmlSettings(PIMAPPER_USER_SURFACES_XML_FILE)){ ofLogWarning("ofxPiMapper::setup()") << "Failed to load user settings, go with default" << endl; @@ -23,7 +24,7 @@ void ofxPiMapper::setup(){ } } - gui.setSurfaceManager(&surfaceManager); + _gui->setSurfaceManager(&surfaceManager); isSetUp = true; ofLogNotice("ofxPiMapper") << "Done setting up"; _application = new ofx::piMapper::Application(this); @@ -33,7 +34,7 @@ void ofxPiMapper::draw(){ if(!isSetUp){ return; } - gui.draw(); + _gui->draw(); _application->draw(); _info->draw(); } @@ -58,8 +59,8 @@ ofx::piMapper::CmdManager * ofxPiMapper::getCmdManager(){ return _cmdManager; } -ofx::piMapper::SurfaceManagerGui & ofxPiMapper::getGui(){ - return gui; +ofx::piMapper::SurfaceManagerGui * ofxPiMapper::getGui(){ + return _gui; } ofx::piMapper::SurfaceManager & ofxPiMapper::getSurfaceManager(){ diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index e68159d..2e798a9 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -31,7 +31,7 @@ class ofxPiMapper { bool loadXmlSettings(string fileName); ofx::piMapper::CmdManager * getCmdManager(); - ofx::piMapper::SurfaceManagerGui & getGui(); + ofx::piMapper::SurfaceManagerGui * getGui(); ofx::piMapper::SurfaceManager & getSurfaceManager(); ofx::piMapper::SurfaceManager surfaceManager; ofx::piMapper::Info * getInfo(); @@ -41,7 +41,7 @@ class ofxPiMapper { bool bShowInfo; ofx::piMapper::CmdManager * _cmdManager; ofx::piMapper::MediaServer * _mediaServer; - ofx::piMapper::SurfaceManagerGui gui; + ofx::piMapper::SurfaceManagerGui * _gui; ofx::piMapper::Application * _application; ofx::piMapper::Info * _info; }; \ No newline at end of file