Browse Source

Add `SetNextSourceCmd` placeholder files

master
Krisjanis Rijnieks 9 years ago
parent
commit
461787837c
  1. 57
      src/Commands/SetNextSourceCmd.cpp
  2. 35
      src/Commands/SetNextSourceCmd.h

57
src/Commands/SetNextSourceCmd.cpp

@ -0,0 +1,57 @@
#include "SetNextSourceCmd.h"
namespace ofx {
namespace piMapper {
SetNextSourceCmd::SetNextSourceCmd(int sourceType,
string sourceId,
BaseSurface * surface,
SourcesEditor * sourcesEditor){
_sourceType = sourceType;
_sourceId = sourceId;
_surface = surface;
_sourcesEditor = sourcesEditor;
}
void SetNextSourceCmd::exec(){
ofLogNotice("SetNextSourceCmd", "exec");
_oldSourceType = _surface->getSource()->getType();
if(_surface->getSource()->isLoadable()){
_oldSourceId = _surface->getSource()->getPath();
}else{
_oldSourceId = _surface->getSource()->getName();
}
if(_sourceType == SourceType::SOURCE_TYPE_IMAGE){
_sourcesEditor->setImageSource(_sourceId);
}else if(_sourceType == SourceType::SOURCE_TYPE_VIDEO){
_sourcesEditor->setVideoSource(_sourceId);
}else if(_sourceType == SourceType::SOURCE_TYPE_FBO){
_sourcesEditor->setFboSource(_sourceId);
}else if(_sourceType == SourceType::SOURCE_TYPE_NONE){
_sourcesEditor->clearSource();
}
}
void SetNextSourceCmd::undo(){
ofLogNotice("SetNextSourceCmd", "undo");
if(_oldSourceType == SourceType::SOURCE_TYPE_IMAGE){
_sourcesEditor->setImageSource(_oldSourceId);
}else if(_oldSourceType == SourceType::SOURCE_TYPE_VIDEO){
_sourcesEditor->setVideoSource(_oldSourceId);
}else if(_oldSourceType == SourceType::SOURCE_TYPE_FBO){
_sourcesEditor->setFboSource(_oldSourceId);
}else if(_oldSourceType == SourceType::SOURCE_TYPE_NONE){
_sourcesEditor->clearSource();
}
_surface = 0;
_sourcesEditor = 0;
}
} // namespace piMapper
} // namespace ofx

35
src/Commands/SetNextSourceCmd.h

@ -0,0 +1,35 @@
#pragma once
#include "BaseCmd.h"
#include "BaseSurface.h"
#include "SourcesEditor.h"
namespace ofx {
namespace piMapper {
class SourcesEditor;
class SetNextSourceCmd : public BaseUndoCmd {
public:
SetNextSourceCmd(int sourceType,
string sourceId,
BaseSurface * surface,
SourcesEditor * sourcesEditor);
void exec();
void undo();
private:
int _sourceType;
string _sourceId;
BaseSurface * _surface;
SourcesEditor * _sourcesEditor;
int _oldSourceType;
string _oldSourceId;
};
} // namespace piMapper
} // namespace ofx
Loading…
Cancel
Save