kis_zoom_manager.h 2.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 *  Copyright (C) 2006 Boudewijn Rempt <boud@valdyas.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#ifndef KIS_ZOOM_MANAGER
#define KIS_ZOOM_MANAGER

#include <QObject>
22
#include <QPointer>
23

24
#include <klocalizedstring.h>
25 26 27 28

#include <KoZoomMode.h>
#include <KoZoomAction.h>
#include <KoZoomHandler.h>
Casper Boemann's avatar
Casper Boemann committed
29
#include <KoZoomController.h>
30
#include "kis_signal_auto_connection.h"
31

32 33
#include "KisView.h"

34 35
class KoZoomHandler;
class KoZoomAction;
36
class KoRuler;
37
class KoUnit;
38 39
class KoCanvasController;
class QPoint;
40

41 42
#include "kritaui_export.h"

43
/**
44 45 46 47 48
 *  The zoom manager handles all user actions related to zooming
 *  and unzooming. The actual computation of zoom levels and things
 *  are the job of KoZoomHandler or its descendants
 */
class KRITAUI_EXPORT KisZoomManager : public QObject
Boudewijn Rempt's avatar
Boudewijn Rempt committed
49
{
50 51 52 53 54

    Q_OBJECT

public:

55
    KisZoomManager(QPointer<KisView> view, KoZoomHandler*, KoCanvasController *);
56
    ~KisZoomManager() override;
57

58 59
    void updateScreenResolution(QWidget *parentWidget);

60
    void setup(KActionCollection * actionCollection);
61
    void updateGUI();
62
    KoZoomController * zoomController() const {
Boudewijn Rempt's avatar
Boudewijn Rempt committed
63 64 65
        return m_zoomController;
    }

66 67
    void updateImageBoundsSnapping();

68 69
    QWidget *zoomActionWidget() const;

70 71 72
    KoRuler *horizontalRuler() const;
    KoRuler *verticalRuler() const;

73 74
    qreal zoom() const;

75
public Q_SLOTS:
76

77
    void slotZoomChanged(KoZoomMode::Mode mode, qreal zoom);
78
    void slotScrollAreaSizeChanged();
79 80
    void setShowRulers(bool show);
    void setRulersTrackMouse(bool value);
81
    void mousePositionChanged(const QPoint &viewPos);
82
    void changeAspectMode(bool aspectMode);
Lukáš Tvrdý's avatar
Lukáš Tvrdý committed
83
    void pageOffsetChanged();
Boudewijn Rempt's avatar
Boudewijn Rempt committed
84
    void zoomTo100();
85
    void applyRulersUnit(const KoUnit &baseUnit);
86
    void setMinMaxZoom();
87
    void setRulersPixelMultiple2(bool enabled);
Boudewijn Rempt's avatar
Boudewijn Rempt committed
88

89

90 91
private:
    void updateMouseTrackingConnections();
92

93 94
private:

95
    QPointer<KisView> m_view;
96
    KoZoomHandler * m_zoomHandler;
97
    KoCanvasController *m_canvasController;
Casper Boemann's avatar
Casper Boemann committed
98
    KoZoomController *m_zoomController;
99 100
    KoRuler * m_horizontalRuler;
    KoRuler * m_verticalRuler;
101
    KoZoomAction * m_zoomAction;
102
    QPointer<QWidget> m_zoomActionWidget;
103
    QPoint m_rulersOffset;
104
    KisSignalAutoConnectionsStore m_mouseTrackingConnections;
105 106 107 108
    qreal m_physicalDpiX;
    qreal m_physicalDpiY;
    qreal m_devicePixelRatio;
    bool m_aspectMode;
109 110
};

111

112
#endif