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 isShiftKeyDown();
SurfaceManagerGui * getGui(){ return &_gui; };
SurfaceManager * getSurfaceManager(){ return &_surfaceManager; };
CmdManager * getCmdManager(){ return &_cmdManager; };
SurfaceManagerGui * getGui(){ return &_gui; }
SurfaceManager * getSurfaceManager(){ return &_surfaceManager; }
CmdManager * getCmdManager(){ return &_cmdManager; }
MediaServer * getMediaServer(){ return &_mediaServer; }
void onCharacterReceived(KeyListenerEventData & e);
TerminalListener consoleListener;

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

2
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()->getSourcesEditorWidget()));
&Gui::instance()->getSourcesEditorWidget()));
}else{
app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager()));
}

12
src/Commands/SetApplicationStateCmd.cpp

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

4
src/Gui/Gui.cpp

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

3
src/Gui/Gui.h

@ -10,6 +10,7 @@
#include "TextureHighlightWidget.h"
#include "TextureEditorWidget.h"
#include "ProjectionEditorWidget.h"
#include "SourcesEditorWidget.h"
namespace ofx {
namespace piMapper {
@ -71,6 +72,7 @@ class Gui {
TextureHighlightWidget & getTextureHighlightWidget();
TextureEditorWidget & getTextureEditorWidget();
ProjectionEditorWidget & getProjectionEditorWidget();
SourcesEditorWidget & getSourcesEditorWidget();
// Consider these as a part of the application states/modes.
void onMousePressed(ofMouseEventArgs & args);
@ -93,6 +95,7 @@ class Gui {
TextureHighlightWidget _textureHighlightWidget;
TextureEditorWidget _textureEditorWidget;
ProjectionEditorWidget _projectionEditorWidget;
SourcesEditorWidget _sourcesEditorWidget;
};
} // 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(){
if(imageSelector->size()){
imageSelector->disable();
@ -315,6 +316,7 @@ void SourcesEditorWidget::clearMediaServer(){
mediaServer = 0;
}
// TODO: There is no need for those at the moment. They add too much overhead.
void SourcesEditorWidget::handleImageAdded(string & path){}
void SourcesEditorWidget::handleImageRemoved(string & path){}
void SourcesEditorWidget::handleVideoAdded(string & path){}

9
src/Surfaces/SurfaceManagerGui.cpp

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

4
src/Surfaces/SurfaceManagerGui.h

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

Loading…
Cancel
Save