6 changed files with 159 additions and 6 deletions
@ -0,0 +1,57 @@ |
|||||
|
#include "SetSourceCmd.h" |
||||
|
|
||||
|
namespace ofx{ |
||||
|
namespace piMapper{ |
||||
|
|
||||
|
SetSourceCmd::SetSourceCmd(int sourceType, |
||||
|
string sourceId, |
||||
|
BaseSurface * surface, |
||||
|
SourcesEditor * sourcesEditor){ |
||||
|
|
||||
|
_sourceType = sourceType; |
||||
|
_sourceId = sourceId; |
||||
|
_surface = surface; |
||||
|
_sourcesEditor = sourcesEditor; |
||||
|
} |
||||
|
|
||||
|
void SetSourceCmd::exec(){ |
||||
|
ofLogNotice("SetSourceCmd", "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 SetSourceCmd::undo(){ |
||||
|
ofLogNotice("SetSourceCmd", "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
|
||||
|
|
@ -0,0 +1,40 @@ |
|||||
|
// SetSourceCmd
|
||||
|
// Set selected surface source undoable command
|
||||
|
// Created by Krisjanis Rijnieks 2015-05-20
|
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include "BaseCmd.h" |
||||
|
#include "BaseSurface.h" |
||||
|
#include "SourcesEditor.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
namespace ofx{ |
||||
|
namespace piMapper{ |
||||
|
|
||||
|
class SourcesEditor; |
||||
|
|
||||
|
class SetSourceCmd : public BaseUndoCmd{ |
||||
|
|
||||
|
public: |
||||
|
SetSourceCmd(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…
Reference in new issue