Browse Source

Use the new `Info` class instead of inline code

master
Krisjanis Rijnieks 10 years ago
parent
commit
2aa24ad581
  1. 2
      src/Application/Application.cpp
  2. 30
      src/ofxPiMapper.cpp
  3. 13
      src/ofxPiMapper.h

2
src/Application/Application.cpp

@ -68,7 +68,7 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
break; break;
case 'i': case 'i':
_ofxPiMapper->toggleInfo(); _ofxPiMapper->getInfo()->toggle();
break; break;
case 's': case 's':

30
src/ofxPiMapper.cpp

@ -3,6 +3,7 @@
ofxPiMapper::ofxPiMapper(){ ofxPiMapper::ofxPiMapper(){
bShowInfo = false; bShowInfo = false;
isSetUp = false; isSetUp = false;
_info = 0;
} }
void ofxPiMapper::setup(){ void ofxPiMapper::setup(){
@ -24,36 +25,17 @@ void ofxPiMapper::setup(){
isSetUp = true; isSetUp = true;
ofLogNotice("ofxPiMapper") << "Done setting up"; ofLogNotice("ofxPiMapper") << "Done setting up";
_application = new ofx::piMapper::Application(this); _application = new ofx::piMapper::Application(this);
_info = new ofx::piMapper::Info();
} }
void ofxPiMapper::draw(){ void ofxPiMapper::draw(){
if(!isSetUp){ if(!isSetUp){
return; return;
} }
gui.draw(); gui.draw();
if(bShowInfo){
stringstream ss;
ss << "There are 4 modes:\n\n";
ss << " 1. Presentation mode\n";
ss << " 2. Texture mapping mode\n";
ss << " 3. Projection mapping mode\n";
ss << " 4. Source selection mode\n\n";
ss << "You can switch between the modes by using <1>, <2>, <3> and <4> "
"keys on the keyboard.\n\n";
ss << "Press <t> to add new triangle surface\n";
ss << "Press <q> to add new quad surface\n";
ss << "Press <s> to save the composition\n";
ss << "Press <f> to toggle fullscreen\n";
ss << "Press <i> to hide this message";
ofDrawBitmapStringHighlight(ss.str(), 10, 20,
ofColor(0, 0, 0, 100),
ofColor(255, 255, 255, 200));
}
_application->draw(); _application->draw();
} // draw _info->draw();
}
void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource){ void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource){
mediaServer.addFboSource(fboSource); mediaServer.addFboSource(fboSource);
@ -85,4 +67,8 @@ ofx::piMapper::MediaServer & ofxPiMapper::getMediaServer(){
ofx::piMapper::SurfaceManager & ofxPiMapper::getSurfaceManager(){ ofx::piMapper::SurfaceManager & ofxPiMapper::getSurfaceManager(){
return surfaceManager; return surfaceManager;
}
ofx::piMapper::Info * ofxPiMapper::getInfo(){
return _info;
} }

13
src/ofxPiMapper.h

@ -9,6 +9,7 @@
#include "CmdManager.h" #include "CmdManager.h"
#include "RmSurfaceCmd.h" #include "RmSurfaceCmd.h"
#include "Application.h" #include "Application.h"
#include "Info.h"
#define PIMAPPER_DEF_SURFACES_XML_FILE "defaultSurfaces.xml" #define PIMAPPER_DEF_SURFACES_XML_FILE "defaultSurfaces.xml"
#define PIMAPPER_USER_SURFACES_XML_FILE "surfaces.xml" #define PIMAPPER_USER_SURFACES_XML_FILE "surfaces.xml"
@ -28,15 +29,6 @@ class ofxPiMapper {
void draw(); void draw();
void registerFboSource(ofx::piMapper::FboSource & fboSource); void registerFboSource(ofx::piMapper::FboSource & fboSource);
bool loadXmlSettings(string fileName); bool loadXmlSettings(string fileName);
void showInfo(){
bShowInfo = true;
}
void hideInfo(){
bShowInfo = false;
}
void toggleInfo(){
bShowInfo = !bShowInfo;
}
ofx::piMapper::CmdManager & getCmdManager(); ofx::piMapper::CmdManager & getCmdManager();
ofx::piMapper::SurfaceManagerGui & getGui(); ofx::piMapper::SurfaceManagerGui & getGui();
@ -44,6 +36,7 @@ class ofxPiMapper {
ofx::piMapper::SurfaceManager & getSurfaceManager(); ofx::piMapper::SurfaceManager & getSurfaceManager();
ofx::piMapper::CmdManager cmdManager; ofx::piMapper::CmdManager cmdManager;
ofx::piMapper::SurfaceManager surfaceManager; ofx::piMapper::SurfaceManager surfaceManager;
ofx::piMapper::Info * getInfo();
private: private:
bool isSetUp; bool isSetUp;
@ -51,5 +44,5 @@ class ofxPiMapper {
ofx::piMapper::MediaServer mediaServer; ofx::piMapper::MediaServer mediaServer;
ofx::piMapper::SurfaceManagerGui gui; ofx::piMapper::SurfaceManagerGui gui;
ofx::piMapper::Application * _application; ofx::piMapper::Application * _application;
ofx::piMapper::Info * _info;
}; };
Loading…
Cancel
Save