Browse Source

Integrate the SourcesEditorWidget into Application

master
Krisjanis Rijnieks 9 years ago
parent
commit
fc0055cad7
  1. 7
      src/Application/Application.h
  2. 2
      src/Application/States/ProjectionMappingState.cpp
  3. 10
      src/Application/States/SourceSelectionState.cpp
  4. 2
      src/Application/States/TextureMappingState.cpp
  5. 12
      src/Commands/SetApplicationStateCmd.cpp
  6. 4
      src/Gui/Gui.cpp
  7. 3
      src/Gui/Gui.h
  8. 2
      src/Gui/Widgets/SourcesEditorWidget.cpp
  9. 9
      src/Surfaces/SurfaceManagerGui.cpp
  10. 4
      src/Surfaces/SurfaceManagerGui.h

7
src/Application/Application.h

@ -63,9 +63,10 @@ class Application : public KeyListener {
bool loadXmlSettings(string fileName); bool loadXmlSettings(string fileName);
bool isShiftKeyDown(); bool isShiftKeyDown();
SurfaceManagerGui * getGui(){ return &_gui; }; SurfaceManagerGui * getGui(){ return &_gui; }
SurfaceManager * getSurfaceManager(){ return &_surfaceManager; }; SurfaceManager * getSurfaceManager(){ return &_surfaceManager; }
CmdManager * getCmdManager(){ return &_cmdManager; }; CmdManager * getCmdManager(){ return &_cmdManager; }
MediaServer * getMediaServer(){ return &_mediaServer; }
void onCharacterReceived(KeyListenerEventData & e); void onCharacterReceived(KeyListenerEventData & e);
TerminalListener consoleListener; TerminalListener consoleListener;

2
src/Application/States/ProjectionMappingState.cpp

@ -216,7 +216,7 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar
app->getCmdManager()->exec( app->getCmdManager()->exec(
new SetNextSourceCmd( new SetNextSourceCmd(
app->getSurfaceManager()->getSelectedSurface(), app->getSurfaceManager()->getSelectedSurface(),
app->getGui()->getSourcesEditorWidget())); &Gui::instance()->getSourcesEditorWidget()));
}else{ }else{
app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager())); app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager()));
} }

10
src/Application/States/SourceSelectionState.cpp

@ -13,8 +13,10 @@ SourceSelectionState * SourceSelectionState::instance(){
} }
void SourceSelectionState::setup(Application * app){ void SourceSelectionState::setup(Application * app){
app->getGui()->getSourcesEditorWidget()->setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getSourcesEditorWidget().setSurfaceManager(app->getSurfaceManager());
app->getGui()->getSourcesEditorWidget()->setup(); Gui::instance()->getSourcesEditorWidget().setMediaServer(app->getMediaServer());
Gui::instance()->getSourcesEditorWidget().setCmdManager(app->getCmdManager());
Gui::instance()->getSourcesEditorWidget().setup();
} }
void SourceSelectionState::draw(Application * app){ void SourceSelectionState::draw(Application * app){
@ -23,9 +25,9 @@ void SourceSelectionState::draw(Application * app){
app->getSurfaceManager()->draw(); app->getSurfaceManager()->draw();
ofPopStyle(); ofPopStyle();
// TODO: Separate SourcesEditorWidget from SurfaceManagerGui, make it a widget Gui::instance()->getSourcesEditorWidget().draw();
app->getGui()->getSourcesEditorWidget()->draw();
// TODO: Move the following line to setup()
Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager());
Gui::instance()->getSurfaceHighlightWidget().draw(); Gui::instance()->getSurfaceHighlightWidget().draw();
} }

2
src/Application/States/TextureMappingState.cpp

@ -129,7 +129,7 @@ void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args)
app->getCmdManager()->exec( app->getCmdManager()->exec(
new SetNextSourceCmd( new SetNextSourceCmd(
app->getSurfaceManager()->getSelectedSurface(), app->getSurfaceManager()->getSelectedSurface(),
app->getGui()->getSourcesEditorWidget())); &Gui::instance()->getSourcesEditorWidget()));
}else{ }else{
app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager())); app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager()));
} }

12
src/Commands/SetApplicationStateCmd.cpp

@ -25,6 +25,12 @@ void SetApplicationStateCmd::exec(){
}else{ }else{
ofHideCursor(); ofHideCursor();
} }
if(_applicationState == SourceSelectionState::instance()){
Gui::instance()->getSourcesEditorWidget().enable();
}else{
Gui::instance()->getSourcesEditorWidget().disable();
}
} }
void SetApplicationStateCmd::undo(){ void SetApplicationStateCmd::undo(){
@ -40,6 +46,12 @@ void SetApplicationStateCmd::undo(){
}else{ }else{
ofHideCursor(); ofHideCursor();
} }
if(_prevApplicationState == SourceSelectionState::instance()){
Gui::instance()->getSourcesEditorWidget().enable();
}else{
Gui::instance()->getSourcesEditorWidget().disable();
}
} }
} // namespace piMapper } // namespace piMapper

4
src/Gui/Gui.cpp

@ -104,6 +104,10 @@ ProjectionEditorWidget & Gui::getProjectionEditorWidget(){
return _projectionEditorWidget; return _projectionEditorWidget;
} }
SourcesEditorWidget & Gui::getSourcesEditorWidget(){
return _sourcesEditorWidget;
}
void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){ void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){
GuiEvent e; GuiEvent e;
e.args = event.args; e.args = event.args;

3
src/Gui/Gui.h

@ -10,6 +10,7 @@
#include "TextureHighlightWidget.h" #include "TextureHighlightWidget.h"
#include "TextureEditorWidget.h" #include "TextureEditorWidget.h"
#include "ProjectionEditorWidget.h" #include "ProjectionEditorWidget.h"
#include "SourcesEditorWidget.h"
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
@ -71,6 +72,7 @@ class Gui {
TextureHighlightWidget & getTextureHighlightWidget(); TextureHighlightWidget & getTextureHighlightWidget();
TextureEditorWidget & getTextureEditorWidget(); TextureEditorWidget & getTextureEditorWidget();
ProjectionEditorWidget & getProjectionEditorWidget(); ProjectionEditorWidget & getProjectionEditorWidget();
SourcesEditorWidget & getSourcesEditorWidget();
// Consider these as a part of the application states/modes. // Consider these as a part of the application states/modes.
void onMousePressed(ofMouseEventArgs & args); void onMousePressed(ofMouseEventArgs & args);
@ -93,6 +95,7 @@ class Gui {
TextureHighlightWidget _textureHighlightWidget; TextureHighlightWidget _textureHighlightWidget;
TextureEditorWidget _textureEditorWidget; TextureEditorWidget _textureEditorWidget;
ProjectionEditorWidget _projectionEditorWidget; ProjectionEditorWidget _projectionEditorWidget;
SourcesEditorWidget _sourcesEditorWidget;
}; };
} // piMapper } // piMapper

2
src/Gui/Widgets/SourcesEditorWidget.cpp

@ -67,6 +67,7 @@ void SourcesEditorWidget::draw(){
} }
} }
// TODO: Redesign the selectors completely so they do not need enable and disable.
void SourcesEditorWidget::disable(){ void SourcesEditorWidget::disable(){
if(imageSelector->size()){ if(imageSelector->size()){
imageSelector->disable(); imageSelector->disable();
@ -315,6 +316,7 @@ void SourcesEditorWidget::clearMediaServer(){
mediaServer = 0; mediaServer = 0;
} }
// TODO: There is no need for those at the moment. They add too much overhead.
void SourcesEditorWidget::handleImageAdded(string & path){} void SourcesEditorWidget::handleImageAdded(string & path){}
void SourcesEditorWidget::handleImageRemoved(string & path){} void SourcesEditorWidget::handleImageRemoved(string & path){}
void SourcesEditorWidget::handleVideoAdded(string & path){} void SourcesEditorWidget::handleVideoAdded(string & path){}

9
src/Surfaces/SurfaceManagerGui.cpp

@ -12,12 +12,12 @@ SurfaceManagerGui::SurfaceManagerGui(){
void SurfaceManagerGui::setMediaServer(MediaServer * newMediaServer){ void SurfaceManagerGui::setMediaServer(MediaServer * newMediaServer){
mediaServer = newMediaServer; mediaServer = newMediaServer;
sourcesEditor.setMediaServer(mediaServer); //sourcesEditor.setMediaServer(mediaServer);
} }
void SurfaceManagerGui::setCmdManager(CmdManager * cmdManager){ void SurfaceManagerGui::setCmdManager(CmdManager * cmdManager){
_cmdManager = cmdManager; _cmdManager = cmdManager;
sourcesEditor.setCmdManager(_cmdManager); //sourcesEditor.setCmdManager(_cmdManager);
} }
void SurfaceManagerGui::setMode(int newGuiMode){ void SurfaceManagerGui::setMode(int newGuiMode){
@ -35,11 +35,14 @@ void SurfaceManagerGui::setMode(int newGuiMode){
guiMode = newGuiMode; guiMode = newGuiMode;
/*
if(guiMode == GuiMode::SOURCE_SELECTION){ if(guiMode == GuiMode::SOURCE_SELECTION){
sourcesEditor.enable(); sourcesEditor.enable();
}else{ }else{
sourcesEditor.disable(); sourcesEditor.disable();
} }
*/
} }
int SurfaceManagerGui::getMode(){ int SurfaceManagerGui::getMode(){
@ -54,9 +57,11 @@ void SurfaceManagerGui::stopDrag(){
bDrag = false; bDrag = false;
} }
/*
SourcesEditorWidget * SurfaceManagerGui::getSourcesEditorWidget(){ SourcesEditorWidget * SurfaceManagerGui::getSourcesEditorWidget(){
return &sourcesEditor; return &sourcesEditor;
} }
*/
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

4
src/Surfaces/SurfaceManagerGui.h

@ -33,7 +33,7 @@ class SurfaceManagerGui {
void startDrag(); void startDrag();
void stopDrag(); void stopDrag();
SourcesEditorWidget * getSourcesEditorWidget(); //SourcesEditorWidget * getSourcesEditorWidget();
ofVec2f clickPosition; ofVec2f clickPosition;
bool bDrag; bool bDrag;
@ -41,7 +41,7 @@ class SurfaceManagerGui {
private: private:
SurfaceManager * surfaceManager; SurfaceManager * surfaceManager;
MediaServer * mediaServer; MediaServer * mediaServer;
SourcesEditorWidget sourcesEditor; //SourcesEditorWidget sourcesEditor;
int guiMode; int guiMode;

Loading…
Cancel
Save