diff --git a/src/Application/States/ProjectionMappingState.cpp b/src/Application/States/ProjectionMappingState.cpp index a81ec2f..67f54dd 100644 --- a/src/Application/States/ProjectionMappingState.cpp +++ b/src/Application/States/ProjectionMappingState.cpp @@ -216,7 +216,7 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar app->getCmdManager()->exec( new SetNextSourceCmd( app->getSurfaceManager()->getSelectedSurface(), - app->getGui()->getSourcesEditor())); + app->getGui()->getSourcesEditorWidget())); }else{ app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager())); } diff --git a/src/Application/States/SourceSelectionState.cpp b/src/Application/States/SourceSelectionState.cpp index 25a6f74..cc41415 100644 --- a/src/Application/States/SourceSelectionState.cpp +++ b/src/Application/States/SourceSelectionState.cpp @@ -13,7 +13,8 @@ SourceSelectionState * SourceSelectionState::instance(){ } void SourceSelectionState::setup(Application * app){ - app->getGui()->getSourcesEditor()->setup(); + app->getGui()->getSourcesEditorWidget()->setSurfaceManager(app->getSurfaceManager()); + app->getGui()->getSourcesEditorWidget()->setup(); } void SourceSelectionState::draw(Application * app){ @@ -22,8 +23,8 @@ void SourceSelectionState::draw(Application * app){ app->getSurfaceManager()->draw(); ofPopStyle(); - // TODO: Separate SourcesEditor from SurfaceManagerGui, make it a widget - app->getGui()->getSourcesEditor()->draw(); + // TODO: Separate SourcesEditorWidget from SurfaceManagerGui, make it a widget + app->getGui()->getSourcesEditorWidget()->draw(); Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getSurfaceHighlightWidget().draw(); diff --git a/src/Application/States/TextureMappingState.cpp b/src/Application/States/TextureMappingState.cpp index d67dd16..bcfc78d 100644 --- a/src/Application/States/TextureMappingState.cpp +++ b/src/Application/States/TextureMappingState.cpp @@ -129,7 +129,7 @@ void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args) app->getCmdManager()->exec( new SetNextSourceCmd( app->getSurfaceManager()->getSelectedSurface(), - app->getGui()->getSourcesEditor())); + app->getGui()->getSourcesEditorWidget())); }else{ app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager())); } diff --git a/src/Commands/SetNextSourceCmd.cpp b/src/Commands/SetNextSourceCmd.cpp index f5b178e..25a2ac1 100644 --- a/src/Commands/SetNextSourceCmd.cpp +++ b/src/Commands/SetNextSourceCmd.cpp @@ -3,7 +3,7 @@ namespace ofx { namespace piMapper { -SetNextSourceCmd::SetNextSourceCmd(BaseSurface * surface, SourcesEditor * sourcesEditor){ +SetNextSourceCmd::SetNextSourceCmd(BaseSurface * surface, SourcesEditorWidget * sourcesEditor){ _surface = surface; _sourcesEditor = sourcesEditor; } diff --git a/src/Commands/SetNextSourceCmd.h b/src/Commands/SetNextSourceCmd.h index 41e915d..ab514c3 100644 --- a/src/Commands/SetNextSourceCmd.h +++ b/src/Commands/SetNextSourceCmd.h @@ -2,7 +2,7 @@ #include "BaseCmd.h" #include "BaseSurface.h" -#include "SourcesEditor.h" +#include "SourcesEditorWidget.h" #include "MediaServer.h" namespace ofx { @@ -13,18 +13,18 @@ struct SourceData { string id; }; -class SourcesEditor; +class SourcesEditorWidget; class SetNextSourceCmd : public BaseUndoCmd { public: - SetNextSourceCmd(BaseSurface * surface, SourcesEditor * sourcesEditor); + SetNextSourceCmd(BaseSurface * surface, SourcesEditorWidget * sourcesEditor); void exec(); void undo(); private: BaseSurface * _surface; - SourcesEditor * _sourcesEditor; + SourcesEditorWidget * _sourcesEditor; vector _sources; int _sourceIndex; // Previous source index int _nextSourceIndex; diff --git a/src/Commands/SetSourceCmd.cpp b/src/Commands/SetSourceCmd.cpp index 3d02a31..e886bef 100644 --- a/src/Commands/SetSourceCmd.cpp +++ b/src/Commands/SetSourceCmd.cpp @@ -6,7 +6,7 @@ namespace piMapper { SetSourceCmd::SetSourceCmd(int sourceType, string sourceId, BaseSurface * surface, - SourcesEditor * sourcesEditor){ + SourcesEditorWidget * sourcesEditor){ _sourceType = sourceType; _sourceId = sourceId; diff --git a/src/Commands/SetSourceCmd.h b/src/Commands/SetSourceCmd.h index 9e0ca33..c7515a8 100644 --- a/src/Commands/SetSourceCmd.h +++ b/src/Commands/SetSourceCmd.h @@ -6,12 +6,12 @@ #include "BaseCmd.h" #include "BaseSurface.h" -#include "SourcesEditor.h" +#include "SourcesEditorWidget.h" namespace ofx { namespace piMapper { -class SourcesEditor; +class SourcesEditorWidget; class SetSourceCmd : public BaseUndoCmd { @@ -19,7 +19,7 @@ class SetSourceCmd : public BaseUndoCmd { SetSourceCmd(int sourceType, string sourceId, BaseSurface * surface, - SourcesEditor * sourcesEditor); + SourcesEditorWidget * sourcesEditor); void exec(); void undo(); @@ -27,7 +27,7 @@ class SetSourceCmd : public BaseUndoCmd { int _sourceType; string _sourceId; BaseSurface * _surface; - SourcesEditor * _sourcesEditor; + SourcesEditorWidget * _sourcesEditor; int _oldSourceType; string _oldSourceId; diff --git a/src/Commands/TogglePerspectiveCmd.h b/src/Commands/TogglePerspectiveCmd.h index 546be1e..ccfb204 100644 --- a/src/Commands/TogglePerspectiveCmd.h +++ b/src/Commands/TogglePerspectiveCmd.h @@ -2,12 +2,12 @@ #include "BaseCmd.h" #include "QuadSurface.h" -#include "SourcesEditor.h" +#include "SourcesEditorWidget.h" namespace ofx { namespace piMapper { -class SourcesEditor; +class SourcesEditorWidget; class TogglePerspectiveCmd : public BaseUndoCmd { diff --git a/src/Surfaces/SurfaceManagerGui.cpp b/src/Surfaces/SurfaceManagerGui.cpp index ff354a8..13093bf 100644 --- a/src/Surfaces/SurfaceManagerGui.cpp +++ b/src/Surfaces/SurfaceManagerGui.cpp @@ -54,7 +54,7 @@ void SurfaceManagerGui::stopDrag(){ bDrag = false; } -SourcesEditor * SurfaceManagerGui::getSourcesEditor(){ +SourcesEditorWidget * SurfaceManagerGui::getSourcesEditorWidget(){ return &sourcesEditor; } diff --git a/src/Surfaces/SurfaceManagerGui.h b/src/Surfaces/SurfaceManagerGui.h index 230b810..e7c319f 100644 --- a/src/Surfaces/SurfaceManagerGui.h +++ b/src/Surfaces/SurfaceManagerGui.h @@ -6,7 +6,7 @@ #include "ofGraphics.h" #include "SurfaceManager.h" -#include "SourcesEditor.h" +#include "SourcesEditorWidget.h" #include "GuiMode.h" #include "CmdManager.h" #include "SelSurfaceCmd.h" @@ -33,7 +33,7 @@ class SurfaceManagerGui { void startDrag(); void stopDrag(); - SourcesEditor * getSourcesEditor(); + SourcesEditorWidget * getSourcesEditorWidget(); ofVec2f clickPosition; bool bDrag; @@ -41,7 +41,7 @@ class SurfaceManagerGui { private: SurfaceManager * surfaceManager; MediaServer * mediaServer; - SourcesEditor sourcesEditor; + SourcesEditorWidget sourcesEditor; int guiMode; diff --git a/src/UserInterface/SourcesEditor.cpp b/src/UserInterface/SourcesEditorWidget.cpp similarity index 66% rename from src/UserInterface/SourcesEditor.cpp rename to src/UserInterface/SourcesEditorWidget.cpp index 5fbce5d..834d1bb 100644 --- a/src/UserInterface/SourcesEditor.cpp +++ b/src/UserInterface/SourcesEditorWidget.cpp @@ -1,9 +1,9 @@ -#include "SourcesEditor.h" +#include "SourcesEditorWidget.h" namespace ofx { namespace piMapper { -SourcesEditor::SourcesEditor(){ +SourcesEditorWidget::SourcesEditorWidget(){ mediaServer = 0; addMediaServerListeners(); imageSelector = new RadioList(); @@ -11,7 +11,7 @@ SourcesEditor::SourcesEditor(){ fboSelector = new RadioList(); } -void SourcesEditor::setup(){ +void SourcesEditorWidget::setup(){ int numImages = mediaServer->getNumImages(); int numVideos = mediaServer->getNumVideos(); int numFbos = mediaServer->getNumFboSources(); @@ -21,17 +21,17 @@ void SourcesEditor::setup(){ // Get image names from media server vector imageNames = mediaServer->getImageNames(); imageSelector->setup("Images", imageNames, mediaServer->getImagePaths()); - ofAddListener(imageSelector->onRadioSelected, this, &SourcesEditor::handleImageSelected); + ofAddListener(imageSelector->onRadioSelected, this, &SourcesEditorWidget::handleImageSelected); } if(numVideos){ vector videoNames = mediaServer->getVideoNames(); videoSelector->setup("Videos", videoNames, mediaServer->getVideoPaths()); - ofAddListener(videoSelector->onRadioSelected, this, &SourcesEditor::handleVideoSelected); + ofAddListener(videoSelector->onRadioSelected, this, &SourcesEditorWidget::handleVideoSelected); } if(numFbos){ vector fboNames = mediaServer->getFboSourceNames(); fboSelector->setup("FBOs", fboNames, fboNames); - ofAddListener(fboSelector->onRadioSelected, this, &SourcesEditor::handleFboSelected); + ofAddListener(fboSelector->onRadioSelected, this, &SourcesEditorWidget::handleFboSelected); } // Align menus @@ -51,7 +51,7 @@ void SourcesEditor::setup(){ } -void SourcesEditor::draw(){ +void SourcesEditorWidget::draw(){ // Don't draw if there is no source selected if(surfaceManager->getSelectedSurface() == 0){ return; @@ -67,7 +67,7 @@ void SourcesEditor::draw(){ } } -void SourcesEditor::disable(){ +void SourcesEditorWidget::disable(){ if(imageSelector->size()){ imageSelector->disable(); } @@ -79,10 +79,10 @@ void SourcesEditor::disable(){ } } -void SourcesEditor::enable(){ +void SourcesEditorWidget::enable(){ // Don't enable if there is no surface selected if(surfaceManager->getSelectedSurface() == 0){ - ofLogNotice("SourcesEditor") << "No surface selected. Not enabling and not showing source list."; + ofLogNotice("SourcesEditorWidget") << "No surface selected. Not enabling and not showing source list."; return; } if(imageSelector->size()){ @@ -105,30 +105,30 @@ void SourcesEditor::enable(){ } } -void SourcesEditor::setSurfaceManager(SurfaceManager * newSurfaceManager){ +void SourcesEditorWidget::setSurfaceManager(SurfaceManager * newSurfaceManager){ surfaceManager = newSurfaceManager; } -void SourcesEditor::setCmdManager(CmdManager * cmdManager){ +void SourcesEditorWidget::setCmdManager(CmdManager * cmdManager){ _cmdManager = cmdManager; } -void SourcesEditor::setMediaServer(MediaServer * newMediaServer){ +void SourcesEditorWidget::setMediaServer(MediaServer * newMediaServer){ if(newMediaServer == 0){ - ofLogFatalError("SourcesEditor") << "New media server is 0"; + ofLogFatalError("SourcesEditorWidget") << "New media server is 0"; exit(EXIT_FAILURE); } clearMediaServer(); mediaServer = newMediaServer; } -MediaServer * SourcesEditor::getMediaServer(){ +MediaServer * SourcesEditorWidget::getMediaServer(){ return mediaServer; } -void SourcesEditor::selectSourceRadioButton(string & sourcePath){ +void SourcesEditorWidget::selectSourceRadioButton(string & sourcePath){ if(sourcePath == ""){ - ofLogNotice("SourcesEditor") << "Path is empty"; + ofLogNotice("SourcesEditorWidget") << "Path is empty"; if(imageSelector->size()){ imageSelector->unselectAll(); } @@ -157,65 +157,65 @@ void SourcesEditor::selectSourceRadioButton(string & sourcePath){ return; } // Log warning if we are still here - ofLogWarning("SourcesEditor") << "Could not find option in any of the source lists"; + ofLogWarning("SourcesEditorWidget") << "Could not find option in any of the source lists"; } } -void SourcesEditor::addMediaServerListeners(){ +void SourcesEditorWidget::addMediaServerListeners(){ // Check if the media server is valid if(mediaServer == 0){ - ofLogError("SourcesEditor::addMediaServerListeners", "Media server not set"); + ofLogError("SourcesEditorWidget::addMediaServerListeners", "Media server not set"); return; } // Add listeners to custom events of the media server - ofAddListener(mediaServer->onImageAdded, this, &SourcesEditor::handleImageAdded); - ofAddListener(mediaServer->onImageRemoved, this, &SourcesEditor::handleImageRemoved); - ofAddListener(mediaServer->onVideoAdded, this, &SourcesEditor::handleVideoAdded); - ofAddListener(mediaServer->onVideoRemoved, this, &SourcesEditor::handleVideoRemoved); - ofAddListener(mediaServer->onImageLoaded, this, &SourcesEditor::handleImageLoaded); - ofAddListener(mediaServer->onImageUnloaded, this, &SourcesEditor::handleImageUnloaded); - - ofAddListener(mediaServer->onFboSourceAdded, this, &SourcesEditor::handleFboSourceAdded); - ofAddListener(mediaServer->onFboSourceRemoved, this, &SourcesEditor::handleFboSourceRemoved); - ofAddListener(mediaServer->onFboSourceLoaded, this, &SourcesEditor::handleFboSourceLoaded); - ofAddListener(mediaServer->onFboSourceUnloaded, this, &SourcesEditor::handleFboSourceUnloaded); + ofAddListener(mediaServer->onImageAdded, this, &SourcesEditorWidget::handleImageAdded); + ofAddListener(mediaServer->onImageRemoved, this, &SourcesEditorWidget::handleImageRemoved); + ofAddListener(mediaServer->onVideoAdded, this, &SourcesEditorWidget::handleVideoAdded); + ofAddListener(mediaServer->onVideoRemoved, this, &SourcesEditorWidget::handleVideoRemoved); + ofAddListener(mediaServer->onImageLoaded, this, &SourcesEditorWidget::handleImageLoaded); + ofAddListener(mediaServer->onImageUnloaded, this, &SourcesEditorWidget::handleImageUnloaded); + + ofAddListener(mediaServer->onFboSourceAdded, this, &SourcesEditorWidget::handleFboSourceAdded); + ofAddListener(mediaServer->onFboSourceRemoved, this, &SourcesEditorWidget::handleFboSourceRemoved); + ofAddListener(mediaServer->onFboSourceLoaded, this, &SourcesEditorWidget::handleFboSourceLoaded); + ofAddListener(mediaServer->onFboSourceUnloaded, this, &SourcesEditorWidget::handleFboSourceUnloaded); } -void SourcesEditor::removeMediaServerListeners(){ +void SourcesEditorWidget::removeMediaServerListeners(){ // Check if the media server is valid if(mediaServer == 0){ - ofLogError("SourcesEditor::addMediaServerListeners", "Media server not set"); + ofLogError("SourcesEditorWidget::addMediaServerListeners", "Media server not set"); return; } // Remove listeners to custom events of the media server - ofRemoveListener(mediaServer->onImageAdded, this, &SourcesEditor::handleImageAdded); - ofRemoveListener(mediaServer->onImageRemoved, this, &SourcesEditor::handleImageRemoved); - ofRemoveListener(mediaServer->onVideoAdded, this, &SourcesEditor::handleVideoAdded); - ofRemoveListener(mediaServer->onVideoRemoved, this, &SourcesEditor::handleVideoRemoved); - ofRemoveListener(mediaServer->onImageLoaded, this, &SourcesEditor::handleImageLoaded); - ofRemoveListener(mediaServer->onImageUnloaded, this, &SourcesEditor::handleImageUnloaded); - ofRemoveListener(mediaServer->onFboSourceAdded, this, &SourcesEditor::handleFboSourceAdded); - ofRemoveListener(mediaServer->onFboSourceRemoved, this, &SourcesEditor::handleFboSourceRemoved); - ofRemoveListener(mediaServer->onFboSourceLoaded, this, &SourcesEditor::handleFboSourceLoaded); - ofRemoveListener(mediaServer->onFboSourceUnloaded, this, &SourcesEditor::handleFboSourceUnloaded); + ofRemoveListener(mediaServer->onImageAdded, this, &SourcesEditorWidget::handleImageAdded); + ofRemoveListener(mediaServer->onImageRemoved, this, &SourcesEditorWidget::handleImageRemoved); + ofRemoveListener(mediaServer->onVideoAdded, this, &SourcesEditorWidget::handleVideoAdded); + ofRemoveListener(mediaServer->onVideoRemoved, this, &SourcesEditorWidget::handleVideoRemoved); + ofRemoveListener(mediaServer->onImageLoaded, this, &SourcesEditorWidget::handleImageLoaded); + ofRemoveListener(mediaServer->onImageUnloaded, this, &SourcesEditorWidget::handleImageUnloaded); + ofRemoveListener(mediaServer->onFboSourceAdded, this, &SourcesEditorWidget::handleFboSourceAdded); + ofRemoveListener(mediaServer->onFboSourceRemoved, this, &SourcesEditorWidget::handleFboSourceRemoved); + ofRemoveListener(mediaServer->onFboSourceLoaded, this, &SourcesEditorWidget::handleFboSourceLoaded); + ofRemoveListener(mediaServer->onFboSourceUnloaded, this, &SourcesEditorWidget::handleFboSourceUnloaded); } -void SourcesEditor::handleImageSelected(string & imagePath){ +void SourcesEditorWidget::handleImageSelected(string & imagePath){ _cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_IMAGE, imagePath, surfaceManager->getSelectedSurface(), - (SourcesEditor *)this)); + (SourcesEditorWidget *)this)); } -void SourcesEditor::setImageSource(string & imagePath){ +void SourcesEditorWidget::setImageSource(string & imagePath){ // Unselect selected items videoSelector->unselectAll(); fboSelector->unselectAll(); BaseSurface * surface = surfaceManager->getSelectedSurface(); if(surface == 0){ - ofLogWarning("SourcesEditor") << "No surface selected"; + ofLogWarning("SourcesEditorWidget") << "No surface selected"; return; } @@ -231,21 +231,21 @@ void SourcesEditor::setImageSource(string & imagePath){ surface->setSource(mediaServer->loadImage(imagePath)); } -void SourcesEditor::handleVideoSelected(string & videoPath){ +void SourcesEditorWidget::handleVideoSelected(string & videoPath){ _cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_VIDEO, videoPath, surfaceManager->getSelectedSurface(), - (SourcesEditor *)this)); + (SourcesEditorWidget *)this)); } -void SourcesEditor::setVideoSource(string & videoPath){ +void SourcesEditorWidget::setVideoSource(string & videoPath){ // Unselect any selected items fboSelector->unselectAll(); imageSelector->unselectAll(); BaseSurface * surface = surfaceManager->getSelectedSurface(); if(surface == 0){ - ofLogWarning("SourcesEditor") << "No surface selected"; + ofLogWarning("SourcesEditorWidget") << "No surface selected"; return; } @@ -261,21 +261,21 @@ void SourcesEditor::setVideoSource(string & videoPath){ surface->setSource(mediaServer->loadVideo(videoPath)); } -void SourcesEditor::handleFboSelected(string & fboName){ +void SourcesEditorWidget::handleFboSelected(string & fboName){ _cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_FBO, fboName, surfaceManager->getSelectedSurface(), - (SourcesEditor *)this)); + (SourcesEditorWidget *)this)); } -void SourcesEditor::setFboSource(string & fboName){ +void SourcesEditorWidget::setFboSource(string & fboName){ videoSelector->unselectAll(); imageSelector->unselectAll(); // Get selected surface BaseSurface * surface = surfaceManager->getSelectedSurface(); if(surface == 0){ - ofLogWarning("SourcesEditor") << "No surface selected"; + ofLogWarning("SourcesEditorWidget") << "No surface selected"; return; } @@ -291,7 +291,7 @@ void SourcesEditor::setFboSource(string & fboName){ surface->setSource(mediaServer->loadFboSource(fboName)); } -void SourcesEditor::clearSource(){ +void SourcesEditorWidget::clearSource(){ BaseSurface * surface = surfaceManager->getSelectedSurface(); // Unload old media @@ -306,7 +306,7 @@ void SourcesEditor::clearSource(){ surface->setSource(surface->getDefaultSource()); } -void SourcesEditor::clearMediaServer(){ +void SourcesEditorWidget::clearMediaServer(){ if(mediaServer == 0){ return; } @@ -315,16 +315,16 @@ void SourcesEditor::clearMediaServer(){ mediaServer = 0; } -void SourcesEditor::handleImageAdded(string & path){} -void SourcesEditor::handleImageRemoved(string & path){} -void SourcesEditor::handleVideoAdded(string & path){} -void SourcesEditor::handleVideoRemoved(string & path){} -void SourcesEditor::handleImageLoaded(string & path){} -void SourcesEditor::handleImageUnloaded(string & path){} -void SourcesEditor::handleFboSourceAdded(string & name){} -void SourcesEditor::handleFboSourceRemoved(string & name){} -void SourcesEditor::handleFboSourceLoaded(string & name){} -void SourcesEditor::handleFboSourceUnloaded(string & name){} +void SourcesEditorWidget::handleImageAdded(string & path){} +void SourcesEditorWidget::handleImageRemoved(string & path){} +void SourcesEditorWidget::handleVideoAdded(string & path){} +void SourcesEditorWidget::handleVideoRemoved(string & path){} +void SourcesEditorWidget::handleImageLoaded(string & path){} +void SourcesEditorWidget::handleImageUnloaded(string & path){} +void SourcesEditorWidget::handleFboSourceAdded(string & name){} +void SourcesEditorWidget::handleFboSourceRemoved(string & name){} +void SourcesEditorWidget::handleFboSourceLoaded(string & name){} +void SourcesEditorWidget::handleFboSourceUnloaded(string & name){} } // namespace piMapper } // namespace ofx \ No newline at end of file diff --git a/src/UserInterface/SourcesEditor.h b/src/UserInterface/SourcesEditorWidget.h similarity index 96% rename from src/UserInterface/SourcesEditor.h rename to src/UserInterface/SourcesEditorWidget.h index 7f614e0..7ef6aeb 100644 --- a/src/UserInterface/SourcesEditor.h +++ b/src/UserInterface/SourcesEditorWidget.h @@ -11,9 +11,9 @@ namespace ofx { namespace piMapper { -class SourcesEditor { +class SourcesEditorWidget { public: - SourcesEditor(); + SourcesEditorWidget(); void setup(); void draw();