1 /*
2  *  Copyright (c) 2010 Dmitry Kazakov <dimula73@gmail.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KIS_CANVAS_CONTROLLER_H
20 #define KIS_CANVAS_CONTROLLER_H
21 
22 #include <KoCanvasControllerWidget.h>
23 #include <libs/flake/KoCanvasSupervisor.h>
24 
25 #include "kritaui_export.h"
26 #include "kis_types.h"
27 
28 class KConfigGroup;
29 class KisView;
30 
31 class KRITAUI_EXPORT KisCanvasController : public KoCanvasControllerWidget
32 {
33     Q_OBJECT
34 
35 public:
36     KisCanvasController(QPointer<KisView>parent, KoCanvasSupervisor *observerProvider, KActionCollection * actionCollection);
37     ~KisCanvasController() override;
38 
39     void setCanvas(KoCanvasBase *canvas) override;
40     void keyPressEvent(QKeyEvent *event) override;
41     void wheelEvent(QWheelEvent *event) override;
42     bool eventFilter(QObject *watched, QEvent *event) override;
43     void updateDocumentSize(const QSizeF &sz, bool recalculateCenter) override;
44     void activate() override;
45 
46     QPointF currentCursorPosition() const override;
47 
48 public:
49     using KoCanvasController::documentSize;
50     bool wrapAroundMode() const;
51     bool levelOfDetailMode() const;
52 
53     void saveCanvasState(KisPropertiesConfiguration &config) const;
54     void restoreCanvasState(const KisPropertiesConfiguration &config);
55 
56     void resetScrollBars() override;
57 
58 public Q_SLOTS:
59     void mirrorCanvas(bool enable);
60     void rotateCanvas(qreal angle, const QPointF &center);
61     void rotateCanvas(qreal angle);
62     void rotateCanvasRight15();
63     void rotateCanvasLeft15();
64     qreal rotation() const;
65     void resetCanvasRotation();
66     void slotToggleWrapAroundMode(bool value);
67     void slotTogglePixelGrid(bool value);
68     void slotToggleLevelOfDetailMode(bool value);
69 
70 Q_SIGNALS:
71     void documentSizeChanged();
72 
73 private:
74     struct Private;
75     Private * const m_d;
76 };
77 
78 #endif /* KIS_CANVAS_CONTROLLER_H */
79