From c5cea9004a1574e0aef4c7f9dd7a041bb7d91928 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Thu, 17 Sep 2015 20:54:51 +0200 Subject: [PATCH] Add and test MainView as singleton and ViewStates --- example/example.xcodeproj/project.pbxproj | 38 +++++++++++++++++++---- src/Views/MainView.cpp | 25 ++++++--------- src/Views/MainView.h | 21 +++++++------ src/Views/PresentationViewState.cpp | 15 ++++----- src/Views/PresentationViewState.h | 19 +++++------- src/Views/ProjectionMappingViewState.cpp | 20 ++++++++++++ src/Views/ProjectionMappingViewState.h | 24 ++++++++++++++ src/Views/SourceSelectionViewState.cpp | 20 ++++++++++++ src/Views/SourceSelectionViewState.h | 24 ++++++++++++++ src/Views/TextureMappingViewState.cpp | 20 ++++++++++++ src/Views/TextureMappingViewState.h | 24 ++++++++++++++ src/Views/ViewState.cpp | 12 ++++--- src/Views/ViewState.h | 22 ++++++------- src/ofxPiMapper.cpp | 8 +++++ src/ofxPiMapper.h | 6 ++++ 15 files changed, 233 insertions(+), 65 deletions(-) create mode 100644 src/Views/ProjectionMappingViewState.cpp create mode 100644 src/Views/ProjectionMappingViewState.h create mode 100644 src/Views/SourceSelectionViewState.cpp create mode 100644 src/Views/SourceSelectionViewState.h create mode 100644 src/Views/TextureMappingViewState.cpp create mode 100644 src/Views/TextureMappingViewState.h diff --git a/example/example.xcodeproj/project.pbxproj b/example/example.xcodeproj/project.pbxproj index 2551926..dbcabb9 100644 --- a/example/example.xcodeproj/project.pbxproj +++ b/example/example.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 391717EF1B08FFDA00F9A484 /* SetGuiModeCmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 391717ED1B08FFDA00F9A484 /* SetGuiModeCmd.cpp */; }; 391717F31B0A8A7300F9A484 /* MvAllTexCoordsCmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 391717F11B0A8A7300F9A484 /* MvAllTexCoordsCmd.cpp */; }; 391717F71B0BCBB500F9A484 /* MvTexCoordCmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 391717F51B0BCBB500F9A484 /* MvTexCoordCmd.cpp */; }; + 39203D351B1F9E9900280B0D /* ViewState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39203D331B1F9E9900280B0D /* ViewState.cpp */; }; 3926483B192224DA0008A7F5 /* ofxXmlSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39264839192224DA0008A7F5 /* ofxXmlSettings.cpp */; }; 39264841192224F90008A7F5 /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926483D192224F90008A7F5 /* tinyxml.cpp */; }; 39264842192224F90008A7F5 /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926483F192224F90008A7F5 /* tinyxmlerror.cpp */; }; @@ -22,7 +23,9 @@ 3933D5D819BB87BD000ACA55 /* ofxSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3933D5CD19BB87BD000ACA55 /* ofxSlider.cpp */; }; 3933D5D919BB87BD000ACA55 /* ofxSliderGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3933D5CF19BB87BD000ACA55 /* ofxSliderGroup.cpp */; }; 3933D5DA19BB87BD000ACA55 /* ofxToggle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3933D5D119BB87BD000ACA55 /* ofxToggle.cpp */; }; - 396761841B1285EB00EA1049 /* ViewState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 396761831B1285EB00EA1049 /* ViewState.cpp */; }; + 396427961BAB3DC900A06716 /* ProjectionMappingViewState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 396427941BAB3DC900A06716 /* ProjectionMappingViewState.cpp */; }; + 396427991BAB3EA600A06716 /* SourceSelectionViewState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 396427971BAB3EA600A06716 /* SourceSelectionViewState.cpp */; }; + 3964279C1BAB3F2F00A06716 /* TextureMappingViewState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3964279A1BAB3F2F00A06716 /* TextureMappingViewState.cpp */; }; 397EFC7C1A08E7680009286E /* ofxPiMapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 397EFC7B1A08E7680009286E /* ofxPiMapper.cpp */; }; 397EFC7F1A08FE720009286E /* FboSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 397EFC7D1A08FE720009286E /* FboSource.cpp */; }; 397EFC821A09047C0009286E /* CustomSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 397EFC801A09047C0009286E /* CustomSource.cpp */; }; @@ -133,6 +136,8 @@ 391717F21B0A8A7300F9A484 /* MvAllTexCoordsCmd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MvAllTexCoordsCmd.h; path = Commands/MvAllTexCoordsCmd.h; sourceTree = ""; }; 391717F51B0BCBB500F9A484 /* MvTexCoordCmd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MvTexCoordCmd.cpp; path = Commands/MvTexCoordCmd.cpp; sourceTree = ""; }; 391717F61B0BCBB500F9A484 /* MvTexCoordCmd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MvTexCoordCmd.h; path = Commands/MvTexCoordCmd.h; sourceTree = ""; }; + 39203D331B1F9E9900280B0D /* ViewState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewState.cpp; sourceTree = ""; }; + 39203D341B1F9E9900280B0D /* ViewState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewState.h; sourceTree = ""; }; 39264839192224DA0008A7F5 /* ofxXmlSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ofxXmlSettings.cpp; path = ../../ofxXmlSettings/src/ofxXmlSettings.cpp; sourceTree = ""; }; 3926483A192224DA0008A7F5 /* ofxXmlSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ofxXmlSettings.h; path = ../../ofxXmlSettings/src/ofxXmlSettings.h; sourceTree = ""; }; 3926483D192224F90008A7F5 /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxml.cpp; sourceTree = ""; }; @@ -157,7 +162,12 @@ 3933D5D119BB87BD000ACA55 /* ofxToggle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxToggle.cpp; sourceTree = ""; }; 3933D5D219BB87BD000ACA55 /* ofxToggle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxToggle.h; sourceTree = ""; }; 39366FD519BDA95E006E5BE6 /* ofxPiMapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxPiMapper.h; sourceTree = ""; }; - 396761831B1285EB00EA1049 /* ViewState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewState.cpp; sourceTree = ""; }; + 396427941BAB3DC900A06716 /* ProjectionMappingViewState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProjectionMappingViewState.cpp; sourceTree = ""; }; + 396427951BAB3DC900A06716 /* ProjectionMappingViewState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectionMappingViewState.h; sourceTree = ""; }; + 396427971BAB3EA600A06716 /* SourceSelectionViewState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SourceSelectionViewState.cpp; sourceTree = ""; }; + 396427981BAB3EA600A06716 /* SourceSelectionViewState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceSelectionViewState.h; sourceTree = ""; }; + 3964279A1BAB3F2F00A06716 /* TextureMappingViewState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureMappingViewState.cpp; sourceTree = ""; }; + 3964279B1BAB3F2F00A06716 /* TextureMappingViewState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureMappingViewState.h; sourceTree = ""; }; 397EFC7B1A08E7680009286E /* ofxPiMapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxPiMapper.cpp; sourceTree = ""; }; 397EFC7D1A08FE720009286E /* FboSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FboSource.cpp; sourceTree = ""; }; 397EFC7E1A08FE720009286E /* FboSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FboSource.h; sourceTree = ""; }; @@ -277,7 +287,6 @@ 39C1248719F1EB75005DF557 /* SurfaceType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurfaceType.h; sourceTree = ""; }; 39C31AE51B0FDC69005E3E09 /* MainView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainView.cpp; sourceTree = ""; }; 39C31AE61B0FDC69005E3E09 /* MainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainView.h; sourceTree = ""; }; - 39C31AE91B0FDD8C005E3E09 /* ViewState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewState.h; sourceTree = ""; }; 39C31AEB1B0FDFC3005E3E09 /* PresentationViewState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PresentationViewState.cpp; sourceTree = ""; }; 39C31AEC1B0FDFC3005E3E09 /* PresentationViewState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PresentationViewState.h; sourceTree = ""; }; 39C787BB1AC20D2400691393 /* CmdManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CmdManager.h; path = Commands/CmdManager.h; sourceTree = ""; }; @@ -398,9 +407,17 @@ path = ../../ofxGui/src; sourceTree = ""; }; + 396427931BAB3B4A00A06716 /* Input */ = { + isa = PBXGroup; + children = ( + ); + name = Input; + sourceTree = ""; + }; 396E8A2F190FEDD900705899 /* src */ = { isa = PBXGroup; children = ( + 396427931BAB3B4A00A06716 /* Input */, 39C31AE41B0FDC69005E3E09 /* Views */, 39FDD9E81AC0076200262205 /* Commands */, 39C1246D19F187D5005DF557 /* UserInterface */, @@ -672,10 +689,16 @@ children = ( 39C31AE61B0FDC69005E3E09 /* MainView.h */, 39C31AE51B0FDC69005E3E09 /* MainView.cpp */, - 39C31AE91B0FDD8C005E3E09 /* ViewState.h */, - 396761831B1285EB00EA1049 /* ViewState.cpp */, + 39203D341B1F9E9900280B0D /* ViewState.h */, + 39203D331B1F9E9900280B0D /* ViewState.cpp */, 39C31AEC1B0FDFC3005E3E09 /* PresentationViewState.h */, 39C31AEB1B0FDFC3005E3E09 /* PresentationViewState.cpp */, + 396427951BAB3DC900A06716 /* ProjectionMappingViewState.h */, + 396427941BAB3DC900A06716 /* ProjectionMappingViewState.cpp */, + 396427981BAB3EA600A06716 /* SourceSelectionViewState.h */, + 396427971BAB3EA600A06716 /* SourceSelectionViewState.cpp */, + 3964279B1BAB3F2F00A06716 /* TextureMappingViewState.h */, + 3964279A1BAB3F2F00A06716 /* TextureMappingViewState.cpp */, ); path = Views; sourceTree = ""; @@ -894,7 +917,7 @@ 39C1243719EE9589005DF557 /* ByteBufferUtils.cpp in Sources */, 3933D5DA19BB87BD000ACA55 /* ofxToggle.cpp in Sources */, 3933D5D319BB87BD000ACA55 /* ofxBaseGui.cpp in Sources */, - 396761841B1285EB00EA1049 /* ViewState.cpp in Sources */, + 39203D351B1F9E9900280B0D /* ViewState.cpp in Sources */, 39C1243C19EE9589005DF557 /* DirectoryFilter.cpp in Sources */, 3933D5D919BB87BD000ACA55 /* ofxSliderGroup.cpp in Sources */, 39C1243619EE9589005DF557 /* ByteBufferReader.cpp in Sources */, @@ -904,10 +927,12 @@ 397EFC7F1A08FE720009286E /* FboSource.cpp in Sources */, E4B69E200A3A1BDC003C02F2 /* main.cpp in Sources */, 39C1244719EE9589005DF557 /* RegexPathFilter.cpp in Sources */, + 3964279C1BAB3F2F00A06716 /* TextureMappingViewState.cpp in Sources */, 39A9AAE91B0518FC00AA83BC /* MvSurfaceCmd.cpp in Sources */, 39C1247C19F187D5005DF557 /* BaseJoint.cpp in Sources */, 39C1245219EE95DD005DF557 /* MediaServer.cpp in Sources */, 39C1243D19EE9589005DF557 /* DirectoryUtils.cpp in Sources */, + 396427991BAB3EA600A06716 /* SourceSelectionViewState.cpp in Sources */, 39264843192224F90008A7F5 /* tinyxmlparser.cpp in Sources */, 39A867961B0D312400165378 /* SetSourceCmd.cpp in Sources */, 3933D5D419BB87BD000ACA55 /* ofxButton.cpp in Sources */, @@ -954,6 +979,7 @@ 397EFC821A09047C0009286E /* CustomSource.cpp in Sources */, 39C1243819EE9589005DF557 /* ByteBufferWriter.cpp in Sources */, 3933D5D519BB87BD000ACA55 /* ofxGuiGroup.cpp in Sources */, + 396427961BAB3DC900A06716 /* ProjectionMappingViewState.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/Views/MainView.cpp b/src/Views/MainView.cpp index 61390fa..294f33a 100644 --- a/src/Views/MainView.cpp +++ b/src/Views/MainView.cpp @@ -1,25 +1,20 @@ #include "MainView.h" +#include "PresentationViewState.h" namespace ofx { namespace piMapper { - MainView::MainView(){ // MainView::MainView(MainController * mainController) - ofLogNotice("MainView::MainView"); - - // Init connection with the main controller maybe? - // _mainController = mainController; - - // Init main state + + MainView::MainView(){ setState(PresentationViewState::instance()); } - void MainView::mousePressed(ofMouseEventArgs & args){ - ofLogNotice("MainView::mousePressed"); - _state->mousePressed(args); + void MainView::draw(){ + _state->draw(this); } - void MainView::setState(ofx::piMapper::ViewState * state){ - ofLogNotice("MainView::setState"); - _state = state; + void MainView::setState(ViewState * st){ + _state = st; } - } -} \ No newline at end of file + + } // namespace piMapper +} // namespace ofx diff --git a/src/Views/MainView.h b/src/Views/MainView.h index 880b9b8..a6b2eed 100644 --- a/src/Views/MainView.h +++ b/src/Views/MainView.h @@ -3,26 +3,27 @@ // Created by Krisjanis Rijnieks 2015-05-22 #pragma once -#include "ViewState.h" #include "ofEvents.h" #include "ofLog.h" -#include "PresentationViewState.h" - -class ViewState; +#include "ViewState.h" namespace ofx { namespace piMapper { + + class ViewState; + class MainView { public: MainView(); - void mousePressed(ofMouseEventArgs & args); + void draw(); - private: - friend class ViewState; - void setState(ofx::piMapper::ViewState * state); + protected: + void setState(ViewState * st); private: + friend class ViewState; ViewState * _state; }; - } -} \ No newline at end of file + + } // namespace piMapper +} // namespace ofx diff --git a/src/Views/PresentationViewState.cpp b/src/Views/PresentationViewState.cpp index 214fbb9..448673f 100644 --- a/src/Views/PresentationViewState.cpp +++ b/src/Views/PresentationViewState.cpp @@ -2,19 +2,20 @@ namespace ofx { namespace piMapper { - ViewState * PresentationViewState::_instance = 0; + + PresentationViewState * PresentationViewState::_instance = 0; - ViewState * PresentationViewState::instance() { + PresentationViewState * PresentationViewState::instance() { if (_instance == 0) { - _instance = new PresentationViewState(); + _instance = new ofx::piMapper::PresentationViewState(); } return _instance; } - void PresentationViewState::mousePressed(ofMouseEventArgs & args) { - ofLogNotice("PresentationViewState::mousePressed") - << "x: " << args.x - << ", y: " << args.y; + void PresentationViewState::draw(MainView * mv) { + ofSetColor(255, 255, 0); + ofDrawBitmapString("Presentation View State", 10, 20); + ofLogNotice("PresentationViewState::draw"); } } } \ No newline at end of file diff --git a/src/Views/PresentationViewState.h b/src/Views/PresentationViewState.h index 5ce9aa7..a5beb5a 100644 --- a/src/Views/PresentationViewState.h +++ b/src/Views/PresentationViewState.h @@ -4,24 +4,21 @@ #pragma once #include "MainView.h" -#include "ViewState.h" #include "ofEvents.h" #include "ofLog.h" - -class MainView; +#include "ofGraphics.h" namespace ofx { namespace piMapper { + class PresentationViewState : public ViewState { public: - static ViewState * instance(); - void mousePressed(ofMouseEventArgs & args); - - protected: - PresentationViewState(); + static PresentationViewState * instance(); + void draw(MainView * mv); private: - static ViewState * _instance; + static PresentationViewState * _instance; }; - } -} \ No newline at end of file + + } // namespace piMapper +} // namespace ofx diff --git a/src/Views/ProjectionMappingViewState.cpp b/src/Views/ProjectionMappingViewState.cpp new file mode 100644 index 0000000..c735c6f --- /dev/null +++ b/src/Views/ProjectionMappingViewState.cpp @@ -0,0 +1,20 @@ +#include "ProjectionMappingViewState.h" + +namespace ofx { + namespace piMapper { + + ProjectionMappingViewState * ProjectionMappingViewState::_instance = 0; + + ProjectionMappingViewState * ProjectionMappingViewState::instance() { + if (_instance == 0) { + _instance = new ofx::piMapper::ProjectionMappingViewState(); + } + return _instance; + } + + void ProjectionMappingViewState::draw(MainView * mv) { + ofDrawBitmapString("Projection Mapping View State", 10, 20); + ofLogNotice("ProjectionMappingViewState::draw"); + } + } +} \ No newline at end of file diff --git a/src/Views/ProjectionMappingViewState.h b/src/Views/ProjectionMappingViewState.h new file mode 100644 index 0000000..2a3004a --- /dev/null +++ b/src/Views/ProjectionMappingViewState.h @@ -0,0 +1,24 @@ +// ProejectionMappingViewState +// Projection mapping view state singleton +// Created by Krisjanis Rijnieks 2015-09-17 +#pragma once + +#include "MainView.h" +#include "ofEvents.h" +#include "ofLog.h" +#include "ofGraphics.h" + +namespace ofx { + namespace piMapper { + + class ProjectionMappingViewState : public ViewState { + public: + static ProjectionMappingViewState * instance(); + void draw(MainView * mv); + + private: + static ProjectionMappingViewState * _instance; + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Views/SourceSelectionViewState.cpp b/src/Views/SourceSelectionViewState.cpp new file mode 100644 index 0000000..fcc54fd --- /dev/null +++ b/src/Views/SourceSelectionViewState.cpp @@ -0,0 +1,20 @@ +#include "SourceSelectionViewState.h" + +namespace ofx { + namespace piMapper { + + SourceSelectionViewState * SourceSelectionViewState::_instance = 0; + + SourceSelectionViewState * SourceSelectionViewState::instance() { + if (_instance == 0) { + _instance = new ofx::piMapper::SourceSelectionViewState(); + } + return _instance; + } + + void SourceSelectionViewState::draw(MainView * mv) { + ofDrawBitmapString("Source Selection View State", 10, 20); + ofLogNotice("SourceSelectionViewState::draw"); + } + } +} \ No newline at end of file diff --git a/src/Views/SourceSelectionViewState.h b/src/Views/SourceSelectionViewState.h new file mode 100644 index 0000000..6f436e9 --- /dev/null +++ b/src/Views/SourceSelectionViewState.h @@ -0,0 +1,24 @@ +// SourceSelectionViewState +// Source selection view state singleton +// Created by Krisjanis Rijnieks 2015-09-17 +#pragma once + +#include "MainView.h" +#include "ofEvents.h" +#include "ofLog.h" +#include "ofGraphics.h" + +namespace ofx { + namespace piMapper { + + class SourceSelectionViewState : public ViewState { + public: + static SourceSelectionViewState * instance(); + void draw(MainView * mv); + + private: + static SourceSelectionViewState * _instance; + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Views/TextureMappingViewState.cpp b/src/Views/TextureMappingViewState.cpp new file mode 100644 index 0000000..0843695 --- /dev/null +++ b/src/Views/TextureMappingViewState.cpp @@ -0,0 +1,20 @@ +#include "TextureMappingViewState.h" + +namespace ofx { + namespace piMapper { + + TextureMappingViewState * TextureMappingViewState::_instance = 0; + + TextureMappingViewState * TextureMappingViewState::instance() { + if (_instance == 0) { + _instance = new ofx::piMapper::TextureMappingViewState(); + } + return _instance; + } + + void TextureMappingViewState::draw(MainView * mv) { + ofDrawBitmapString("Texture Mapping View State", 10, 20); + ofLogNotice("TextureMappingViewState::draw"); + } + } +} \ No newline at end of file diff --git a/src/Views/TextureMappingViewState.h b/src/Views/TextureMappingViewState.h new file mode 100644 index 0000000..808a19a --- /dev/null +++ b/src/Views/TextureMappingViewState.h @@ -0,0 +1,24 @@ +// TextureMappingViewState +// Texture mapping view state singleton +// Created by Krisjanis Rijnieks 2015-09-17 +#pragma once + +#include "MainView.h" +#include "ofEvents.h" +#include "ofLog.h" +#include "ofGraphics.h" + +namespace ofx { + namespace piMapper { + + class TextureMappingViewState : public ViewState { + public: + static TextureMappingViewState * instance(); + void draw(MainView * mv); + + private: + static TextureMappingViewState * _instance; + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Views/ViewState.cpp b/src/Views/ViewState.cpp index 642a756..18873b1 100644 --- a/src/Views/ViewState.cpp +++ b/src/Views/ViewState.cpp @@ -1,10 +1,12 @@ #include "ViewState.h" +#include "PresentationViewState.h" namespace ofx { namespace piMapper { - void ViewState::mousePressed(ofMouseEventArgs & args) { } - void ViewState::setState(MainView * view, ViewState * state) { - view->setState(state); + + void ViewState::setState(MainView * mv, ViewState * st) { + mv->setState(st); } - } -} \ No newline at end of file + + } // namespace piMapper +} // namespace ofx diff --git a/src/Views/ViewState.h b/src/Views/ViewState.h index b4fe315..1331dec 100644 --- a/src/Views/ViewState.h +++ b/src/Views/ViewState.h @@ -1,21 +1,21 @@ // ViewState -// Base class for main view states -// Created by Krisjanis Rijnieks 2015-05-22 +// Base class for view states +// Created by Krisjanis Rijnieks 2015-06-03 #pragma once -#include "MainView.h" #include "ofEvents.h" - -class MainView; +#include "ofLog.h" namespace ofx { namespace piMapper { + + class MainView; + class ViewState { public: - virtual void mousePressed(ofMouseEventArgs & args); - - protected: - void setState(MainView * view, ViewState * state); + virtual void draw(MainView * mv){}; + virtual void setState(MainView * mainView, ViewState * state); }; - } -} \ No newline at end of file + + } // namespace piMapper +} // namespace ofx diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index a35c197..1a579ea 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -31,6 +31,12 @@ void ofxPiMapper::setup(){ isSetUp = true; ofLogNotice("ofxPiMapper") << "Done setting up"; + + _mainView = new ofx::piMapper::MainView(); +} + +void ofxPiMapper::stateSetup() { + // TODO: test state imp } void ofxPiMapper::draw(){ @@ -64,6 +70,8 @@ void ofxPiMapper::draw(){ // TODO: remove undo test completely //ofDrawBitmapStringHighlight(ofToString(undoTestValue), 200, 200); + _mainView->draw(); + } // draw void ofxPiMapper::keyPressed(ofKeyEventArgs &args){ diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 29a4291..d6233d4 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -18,6 +18,9 @@ #include "RmSurfaceCmd.h" #include "SetGuiModeCmd.h" +// Main view with state design pattern +#include "MainView.h" + #define PIMAPPER_DEF_SURFACES_XML_FILE "defaultSurfaces.xml" #define PIMAPPER_USER_SURFACES_XML_FILE "surfaces.xml" @@ -28,6 +31,7 @@ class ofxPiMapper{ ~ofxPiMapper(); void setup(); + void stateSetup(); void draw(); void keyPressed(ofKeyEventArgs& args); @@ -61,4 +65,6 @@ class ofxPiMapper{ // Discussion: Here now the GUI points only to surface manager, // maybe it should be as a separate layer? ofx::piMapper::SurfaceManagerGui gui; + + ofx::piMapper::MainView * _mainView; }; \ No newline at end of file