diff --git a/src/Commands/TranslateCanvasCmd.cpp b/src/Commands/TranslateCanvasCmd.cpp new file mode 100644 index 0000000..67fdf6a --- /dev/null +++ b/src/Commands/TranslateCanvasCmd.cpp @@ -0,0 +1,24 @@ +#include "TranslateCanvasCmd.h" + +namespace ofx { +namespace piMapper { + +TranslateCanvasCmd::TranslateCanvasCmd(Application * app, ofPoint from, ofPoint to){ + _app = app; + _from = from; + _to = to; +} + +void TranslateCanvasCmd::exec(){ + ofLogNotice("TranslateCanvasCmd", "exec"); + _app->getState()->setTranslation(_to); +} + +void TranslateCanvasCmd::undo(){ + ofLogNotice("TranslateCanvasCmd", "undo"); + _app->getState()->setTranslation(_from); +} + +} // namespace piMapper +} // namespace ofx + diff --git a/src/Commands/TranslateCanvasCmd.h b/src/Commands/TranslateCanvasCmd.h new file mode 100644 index 0000000..0ddb408 --- /dev/null +++ b/src/Commands/TranslateCanvasCmd.h @@ -0,0 +1,29 @@ +// TranslateCanvasCmd +// Stores and restores the canvas of a mode/state. +// Created by Krisjanis Rijnieks 2016-09-13 + +#pragma once + +#include "BaseCmd.h" +#include "BaseSurface.h" +#include "Application.h" + +namespace ofx { +namespace piMapper { + +class TranslateCanvasCmd : public BaseUndoCmd { + + public: + TranslateCanvasCmd(Application * app, ofPoint from, ofPoint to); + void exec(); + void undo(); + + private: + Application * _app; + ofPoint _from; + ofPoint _to; +}; + +} // namespace piMapper +} // namespace ofx +