mirror of
https://github.com/kr15h/ofxPiMapper.git
synced 2026-06-16 12:31:49 +02:00
Rename MainView to Application and not just that
- Rename ViewState to ApplicationBaseState - Rename all ..ViewState's to just ..State's - Adjust ofxPiMapper main class so app compiles
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include "Application.h"
|
||||
#include "PresentationState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
Application::Application(){
|
||||
setState(PresentationState::instance());
|
||||
}
|
||||
|
||||
void Application::draw(){
|
||||
_state->draw(this);
|
||||
}
|
||||
|
||||
void Application::setState(ApplicationBaseState * st){
|
||||
_state = st;
|
||||
}
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
#include "ApplicationBaseState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class ApplicationBaseState;
|
||||
|
||||
class Application {
|
||||
public:
|
||||
Application();
|
||||
void draw();
|
||||
|
||||
protected:
|
||||
void setState(ApplicationBaseState * st);
|
||||
|
||||
private:
|
||||
friend class ApplicationBaseState;
|
||||
ApplicationBaseState * _state;
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "ApplicationBaseState.h"
|
||||
#include "PresentationState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
void ApplicationBaseState::setState(Application * app, ApplicationBaseState * st) {
|
||||
app->setState(st);
|
||||
}
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class Application;
|
||||
|
||||
class ApplicationBaseState {
|
||||
public:
|
||||
virtual void draw(Application * app){};
|
||||
virtual void setState(Application * app, ApplicationBaseState * st);
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "PresentationState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
PresentationState * PresentationState::_instance = 0;
|
||||
|
||||
PresentationState * PresentationState::instance() {
|
||||
if (_instance == 0) {
|
||||
_instance = new ofx::piMapper::PresentationState();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void PresentationState::draw(Application * app) {
|
||||
ofSetColor(255, 255, 0);
|
||||
ofDrawBitmapString("Presentation State", 10, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Application.h"
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
#include "ofGraphics.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class PresentationState : public ApplicationBaseState {
|
||||
public:
|
||||
static PresentationState * instance();
|
||||
void draw(Application * app);
|
||||
|
||||
private:
|
||||
static PresentationState * _instance;
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "ProjectionMappingState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
ProjectionMappingState * ProjectionMappingState::_instance = 0;
|
||||
|
||||
ProjectionMappingState * ProjectionMappingState::instance() {
|
||||
if (_instance == 0) {
|
||||
_instance = new ofx::piMapper::ProjectionMappingState();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void ProjectionMappingState::draw(Application * app) {
|
||||
ofDrawBitmapString("Projection Mapping State", 10, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Application.h"
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
#include "ofGraphics.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class ProjectionMappingState : public ApplicationBaseState {
|
||||
public:
|
||||
static ProjectionMappingState * instance();
|
||||
void draw(Application * app);
|
||||
|
||||
private:
|
||||
static ProjectionMappingState * _instance;
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "SourceSelectionState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
SourceSelectionState * SourceSelectionState::_instance = 0;
|
||||
|
||||
SourceSelectionState * SourceSelectionState::instance() {
|
||||
if (_instance == 0) {
|
||||
_instance = new ofx::piMapper::SourceSelectionState();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void SourceSelectionState::draw(Application * app) {
|
||||
ofDrawBitmapString("Source Selection State", 10, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Application.h"
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
#include "ofGraphics.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class SourceSelectionState : public ApplicationBaseState {
|
||||
public:
|
||||
static SourceSelectionState * instance();
|
||||
void draw(Application * app);
|
||||
|
||||
private:
|
||||
static SourceSelectionState * _instance;
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "TextureMappingState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
TextureMappingState * TextureMappingState::_instance = 0;
|
||||
|
||||
TextureMappingState * TextureMappingState::instance() {
|
||||
if (_instance == 0) {
|
||||
_instance = new ofx::piMapper::TextureMappingState();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void TextureMappingState::draw(Application * app) {
|
||||
ofDrawBitmapString("Texture Mapping State", 10, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Application.h"
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
#include "ofGraphics.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class TextureMappingState : public ApplicationBaseState {
|
||||
public:
|
||||
static TextureMappingState * instance();
|
||||
void draw(Application * app);
|
||||
|
||||
private:
|
||||
static TextureMappingState * _instance;
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "MainView.h"
|
||||
#include "PresentationViewState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
MainView::MainView(){
|
||||
setState(PresentationViewState::instance());
|
||||
}
|
||||
|
||||
void MainView::draw(){
|
||||
_state->draw(this);
|
||||
}
|
||||
|
||||
void MainView::setState(ViewState * st){
|
||||
_state = st;
|
||||
}
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -1,29 +0,0 @@
|
||||
// MainView
|
||||
// Main entrance point for the visible part of this application
|
||||
// Created by Krisjanis Rijnieks 2015-05-22
|
||||
#pragma once
|
||||
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
#include "ViewState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class ViewState;
|
||||
|
||||
class MainView {
|
||||
public:
|
||||
MainView();
|
||||
void draw();
|
||||
|
||||
protected:
|
||||
void setState(ViewState * st);
|
||||
|
||||
private:
|
||||
friend class ViewState;
|
||||
ViewState * _state;
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -1,21 +0,0 @@
|
||||
#include "PresentationViewState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
PresentationViewState * PresentationViewState::_instance = 0;
|
||||
|
||||
PresentationViewState * PresentationViewState::instance() {
|
||||
if (_instance == 0) {
|
||||
_instance = new ofx::piMapper::PresentationViewState();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void PresentationViewState::draw(MainView * mv) {
|
||||
ofSetColor(255, 255, 0);
|
||||
ofDrawBitmapString("Presentation View State", 10, 20);
|
||||
//ofLogNotice("PresentationViewState::draw");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// PresentationViewState
|
||||
// Presentation view state singleton
|
||||
// Created by Krisjanis Rijnieks 2015-05-24
|
||||
#pragma once
|
||||
|
||||
#include "MainView.h"
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
#include "ofGraphics.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class PresentationViewState : public ViewState {
|
||||
public:
|
||||
static PresentationViewState * instance();
|
||||
void draw(MainView * mv);
|
||||
|
||||
private:
|
||||
static PresentationViewState * _instance;
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -1,20 +0,0 @@
|
||||
#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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// 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
|
||||
@@ -1,20 +0,0 @@
|
||||
#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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// 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
|
||||
@@ -1,20 +0,0 @@
|
||||
#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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// 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
|
||||
@@ -1,12 +0,0 @@
|
||||
#include "ViewState.h"
|
||||
#include "PresentationViewState.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
void ViewState::setState(MainView * mv, ViewState * st) {
|
||||
mv->setState(st);
|
||||
}
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
@@ -1,21 +0,0 @@
|
||||
// ViewState
|
||||
// Base class for view states
|
||||
// Created by Krisjanis Rijnieks 2015-06-03
|
||||
#pragma once
|
||||
|
||||
#include "ofEvents.h"
|
||||
#include "ofLog.h"
|
||||
|
||||
namespace ofx {
|
||||
namespace piMapper {
|
||||
|
||||
class MainView;
|
||||
|
||||
class ViewState {
|
||||
public:
|
||||
virtual void draw(MainView * mv){};
|
||||
virtual void setState(MainView * mainView, ViewState * state);
|
||||
};
|
||||
|
||||
} // namespace piMapper
|
||||
} // namespace ofx
|
||||
+2
-2
@@ -32,7 +32,7 @@ void ofxPiMapper::setup(){
|
||||
|
||||
ofLogNotice("ofxPiMapper") << "Done setting up";
|
||||
|
||||
_mainView = new ofx::piMapper::MainView();
|
||||
_application = new ofx::piMapper::Application();
|
||||
_keyboard = new ofx::piMapper::Keyboard(this);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void ofxPiMapper::draw(){
|
||||
// TODO: remove undo test completely
|
||||
//ofDrawBitmapStringHighlight(ofToString(undoTestValue), 200, 200);
|
||||
|
||||
_mainView->draw();
|
||||
_application->draw();
|
||||
|
||||
} // draw
|
||||
|
||||
|
||||
+2
-8
@@ -1,9 +1,3 @@
|
||||
// ofxPiMapper
|
||||
// Author: Krisjanis Rijnieks
|
||||
|
||||
// On using prefixes like m or p (mMemberVariable, pMyPointer)
|
||||
// http://stackoverflow.com/questions/1228161/why-use-prefixes-on-member-variables-in-c-classes
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ofMain.h"
|
||||
@@ -19,7 +13,7 @@
|
||||
#include "SetGuiModeCmd.h"
|
||||
|
||||
// Main view with state design pattern
|
||||
#include "MainView.h"
|
||||
#include "Application.h" // Main application entry point
|
||||
#include "Keyboard.h"
|
||||
|
||||
#define PIMAPPER_DEF_SURFACES_XML_FILE "defaultSurfaces.xml"
|
||||
@@ -78,6 +72,6 @@ class ofxPiMapper{
|
||||
ofx::piMapper::SurfaceManagerGui gui;
|
||||
|
||||
|
||||
ofx::piMapper::MainView * _mainView;
|
||||
ofx::piMapper::Application * _application;
|
||||
ofx::piMapper::Keyboard * _keyboard;
|
||||
};
|
||||
Reference in New Issue
Block a user