| 1 | // Aseprite |
|---|---|
| 2 | // Copyright (C) 2017 David Capello |
| 3 | // |
| 4 | // This program is distributed under the terms of |
| 5 | // the End-User License Agreement for Aseprite. |
| 6 | |
| 7 | #ifdef HAVE_CONFIG_H |
| 8 | #include "config.h" |
| 9 | #endif |
| 10 | |
| 11 | #include "app/cmd/set_last_point.h" |
| 12 | |
| 13 | #include "app/doc.h" |
| 14 | |
| 15 | namespace app { |
| 16 | namespace cmd { |
| 17 | |
| 18 | SetLastPoint::SetLastPoint(Doc* doc, const gfx::Point& pos) |
| 19 | : WithDocument(doc) |
| 20 | , m_oldPoint(doc->lastDrawingPoint()) |
| 21 | , m_newPoint(pos) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | void SetLastPoint::onExecute() |
| 26 | { |
| 27 | setLastPoint(m_newPoint); |
| 28 | } |
| 29 | |
| 30 | void SetLastPoint::onUndo() |
| 31 | { |
| 32 | setLastPoint(m_oldPoint); |
| 33 | } |
| 34 | |
| 35 | void SetLastPoint::setLastPoint(const gfx::Point& pos) |
| 36 | { |
| 37 | Doc* doc = document(); |
| 38 | doc->setLastDrawingPoint(pos); |
| 39 | } |
| 40 | |
| 41 | } // namespace cmd |
| 42 | } // namespace app |
| 43 |