From 5ab0168cbb334c1d50291998ba4e239041b22ad5 Mon Sep 17 00:00:00 2001
From: Krisjanis Rijnieks <krisjanis.rijnieks@gmail.com>
Date: Tue, 13 May 2014 11:04:59 +0200
Subject: [PATCH] Add visual switching to sources editor with key 4

---
 example/src/ofApp.cpp        | 6 ++++--
 src/ofxGuiMode.h             | 3 ++-
 src/ofxSourcesEditor.cpp     | 5 +++++
 src/ofxSourcesEditor.h       | 4 ++++
 src/ofxSurfaceManagerGui.cpp | 7 ++++++-
 src/ofxSurfaceManagerGui.h   | 2 ++
 6 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/example/src/ofApp.cpp b/example/src/ofApp.cpp
index 2ef4120..7d41364 100644
--- a/example/src/ofApp.cpp
+++ b/example/src/ofApp.cpp
@@ -46,8 +46,9 @@ void ofApp::draw()
         ss << "There are 3 modes:\n\n";
         ss << " 1. Presentation mode\n";
         ss << " 2. Texture mapping mode\n";
-        ss << " 3. Projection mapping mode\n\n";
-        ss << "You can switch between the modes by using <1>, <2> and <3> keys on the keyboard.\n\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 << "Hit <i> to hide this message.";
         
         ofDrawBitmapStringHighlight(ss.str(), 10, 20, ofColor(0,0,0,100), ofColor(255,255,255,200));
@@ -62,6 +63,7 @@ void ofApp::keyPressed(int key)
         case '1': gui.setMode(ofxGuiMode::NONE); break;
         case '2': gui.setMode(ofxGuiMode::TEXTURE_MAPPING); break;
         case '3': gui.setMode(ofxGuiMode::PROJECTION_MAPPING); break;
+        case '4': gui.setMode(ofxGuiMode::SOURCE_SELECTION); break;
         case 'i': bShowInfo = !bShowInfo; break;
         case 'r': addRandomSurface(); break;
         default: break;
diff --git a/src/ofxGuiMode.h b/src/ofxGuiMode.h
index a022b5c..c60fe71 100644
--- a/src/ofxGuiMode.h
+++ b/src/ofxGuiMode.h
@@ -6,7 +6,8 @@ struct ofxGuiMode
     enum {
         NONE,
         TEXTURE_MAPPING,
-        PROJECTION_MAPPING
+        PROJECTION_MAPPING,
+        SOURCE_SELECTION
     };
 };
 
diff --git a/src/ofxSourcesEditor.cpp b/src/ofxSourcesEditor.cpp
index 563e87c..9a33c87 100644
--- a/src/ofxSourcesEditor.cpp
+++ b/src/ofxSourcesEditor.cpp
@@ -8,4 +8,9 @@ ofxSourcesEditor::ofxSourcesEditor()
 ofxSourcesEditor::~ofxSourcesEditor()
 {
     
+}
+
+void ofxSourcesEditor::draw()
+{
+    ofDrawBitmapString("Sources Editor", ofPoint(10, 20));
 }
\ No newline at end of file
diff --git a/src/ofxSourcesEditor.h b/src/ofxSourcesEditor.h
index 02ec86f..150ad1a 100644
--- a/src/ofxSourcesEditor.h
+++ b/src/ofxSourcesEditor.h
@@ -1,12 +1,16 @@
 #ifndef H_OFX_SOURCES_EDITOR
 #define H_OFX_SOURCES_EDITOR
 
+#include "ofGraphics.h"
+
 class ofxSourcesEditor
 {
 public:
     ofxSourcesEditor();
     ~ofxSourcesEditor();
     
+    void draw();
+    
 private:
     
 };
diff --git a/src/ofxSurfaceManagerGui.cpp b/src/ofxSurfaceManagerGui.cpp
index a2e2532..81a6c3c 100644
--- a/src/ofxSurfaceManagerGui.cpp
+++ b/src/ofxSurfaceManagerGui.cpp
@@ -67,6 +67,8 @@ void ofxSurfaceManagerGui::draw()
         // draw projection mapping editing gui
         projectionEditor.draw();
         
+    } else if ( guiMode == ofxGuiMode::SOURCE_SELECTION ) {
+        sourcesEditor.draw();
     }
 }
 
@@ -126,6 +128,8 @@ void ofxSurfaceManagerGui::mousePressed(ofMouseEventArgs &args)
             projectionEditor.clearJoints();
             surfaceManager->deselectSurface();
         }
+    } else if ( guiMode == ofxGuiMode::SOURCE_SELECTION ) {
+        
     }
 }
 
@@ -162,7 +166,8 @@ void ofxSurfaceManagerGui::setMode(int newGuiMode)
 {
     if (newGuiMode != ofxGuiMode::NONE &&
         newGuiMode != ofxGuiMode::TEXTURE_MAPPING &&
-        newGuiMode != ofxGuiMode::PROJECTION_MAPPING) {
+        newGuiMode != ofxGuiMode::PROJECTION_MAPPING &&
+        newGuiMode != ofxGuiMode::SOURCE_SELECTION) {
         throw std::runtime_error("Trying to set invalid mode.");
     }
     
diff --git a/src/ofxSurfaceManagerGui.h b/src/ofxSurfaceManagerGui.h
index 96186fb..4b24f20 100644
--- a/src/ofxSurfaceManagerGui.h
+++ b/src/ofxSurfaceManagerGui.h
@@ -8,6 +8,7 @@
 #include "ofxSurfaceManager.h"
 #include "ofxTextureEditor.h"
 #include "ofxProjectionEditor.h"
+#include "ofxSourcesEditor.h"
 #include "ofxGuiMode.h"
 
 class ofxSurfaceManagerGui
@@ -34,6 +35,7 @@ private:
     ofxSurfaceManager* surfaceManager;
     ofxTextureEditor textureEditor;
     ofxProjectionEditor projectionEditor;
+    ofxSourcesEditor sourcesEditor;
     int guiMode;
     bool bDrag;
     ofVec2f clickPosition;