1 /*
2  * offsetlayer.h
3  * Copyright 2009, Jeff Bland <jeff@teamphobic.com>
4  * Copyright 2009, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
5  *
6  * This file is part of Tiled.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the Free
10  * Software Foundation; either version 2 of the License, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 #include <QRect>
25 #include <QPoint>
26 #include <QUndoCommand>
27 
28 namespace Tiled {
29 
30 class Layer;
31 
32 class MapDocument;
33 
34 /**
35  * Undo command that offsets a map layer.
36  */
37 class OffsetLayer : public QUndoCommand
38 {
39 public:
40     OffsetLayer(MapDocument *mapDocument,
41                 Layer *layer,
42                 QPoint offset,
43                 const QRect &bounds,
44                 bool xWrap,
45                 bool yWrap);
46 
47     ~OffsetLayer() override;
48 
49     void undo() override;
50     void redo() override;
51 
52 private:
53     MapDocument *mMapDocument;
54     bool mDone;
55     Layer *mOriginalLayer;
56     Layer *mOffsetLayer;
57     QPointF mOldOffset;
58     QPointF mNewOffset;
59 };
60 
61 } // namespace Tiled
62