ACF $AcfVersion:0$
CPopupNavigator.h
Go to the documentation of this file.
1#pragma once
2
3#include <QPen>
4#include <QPixmap>
5#include <QScrollBar>
6#include <QScrollArea>
7#include <QToolButton>
8
9
10namespace iview
11{
12
13
41class CPopupNavigator : public QWidget
42{
43 Q_OBJECT
44
45 Q_PROPERTY(double opacity READ opacity WRITE setOpacity)
46 Q_PROPERTY(double sliderOpacity READ sliderOpacity WRITE setSliderOpacity)
47 Q_PROPERTY(bool panning READ isPanningEnabled WRITE enablePanning)
48 Q_PROPERTY(QPen backgroundPen READ backgroundPen WRITE setBackgroundPen)
50 Q_PROPERTY(QPen sliderPen READ sliderPen WRITE setSliderPen)
51 Q_PROPERTY(QBrush sliderBrush READ sliderBrush WRITE setSliderBrush)
52
53public:
55 explicit CPopupNavigator(QWidget *parent = 0);
57 virtual ~CPopupNavigator();
58
59 void setBackgroundPen(const QPen& pen);
60 inline QPen backgroundPen() const { return m_pen; }
61
62 void setBackgroundBrush(const QBrush& brush);
63 inline QBrush backgroundBrush() const { return m_brush; }
64
65 void setSliderPen(const QPen& pen);
66 inline QPen sliderPen() const { return m_panPen; }
67
68 void setSliderBrush(const QBrush& brush);
69 inline QBrush sliderBrush() const { return m_panBrush; }
70
71 void setOpacity(double opacity);
72 inline double opacity() const { return m_opacity; }
73
75 inline double sliderOpacity() const { return m_panOpacity; }
76
80 inline bool isPanningEnabled() const { return m_panning; }
81
82 void connectSource(QAbstractScrollArea *area);
83 void connectSource(QAbstractSlider *horizontal, QAbstractSlider *vertical);
85
88 void connectButton(QToolButton*);
89
92 void resetSize(const QSize& size);
93 void resetSize(int width, int height) { resetSize(QSize(width, height)); }
94
98 void setFromPixmap(const QPixmap& pixmap);
99
100 // reimp
101 virtual QSize minimumSizeHint() const { return QSize(64,64); }
102
103Q_SIGNALS:
104 void scrollHorizontal(int value);
105 void scrollVertical(int value);
106
108 void wheeled(QWheelEvent *we);
109
110public Q_SLOTS:
114 void enablePanning(bool on = true);
115
116protected:
117 virtual void paintEvent(QPaintEvent *) override;
118 virtual bool eventFilter(QObject *, QEvent *) override;
119 virtual void mousePressEvent(QMouseEvent *) override;
120 virtual void mouseMoveEvent(QMouseEvent *) override;
121 virtual bool event(QEvent *) override;
122
123 virtual void drawBackground(QPainter& p, QRect r);
124 virtual void drawSlider(QPainter& p, QRect r);
125
126private:
127 void setHorizontalRange(int min, int max);
128 void setHorizontalValue(int value);
129 void setHorizontalViewSize(int size);
130
131 void setVerticalRange(int min, int max);
132 void setVerticalValue(int value);
133 void setVerticalViewSize(int size);
134
135 void setViewSize(const QSize& size);
136
137 void calculateXsize(int size);
138 void calculateYsize(int size);
139
140 void connectH(QAbstractSlider *sl);
141 void connectV(QAbstractSlider *sl);
142
143 int m_minX, m_maxX, m_sizeX, m_valueX;
144 int m_valueXpan, m_sizeXpan;
145
146 int m_minY, m_maxY, m_sizeY, m_valueY;
147 int m_valueYpan, m_sizeYpan;
148
149 QSize m_viewSize;
150 QPoint m_viewPos;
151
152 QPen m_pen, m_panPen;
153 QBrush m_brush, m_panBrush;
154 QPixmap m_pixmap;
155
156 double m_opacity, m_panOpacity;
157
158 bool m_panning;
159 int m_oldX, m_oldY;
160
161 QAbstractSlider *m_sliderX, *m_sliderY;
162};
163
164
165} // namespace
166
2-dimensional scrolling widget.
void connectButton(QToolButton *)
Connects to a tool button which will show this CPopupNavigator as a popup menu.
void setBackgroundBrush(const QBrush &brush)
double sliderOpacity() const
void setSliderPen(const QPen &pen)
void setSliderBrush(const QBrush &brush)
void setBackgroundPen(const QPen &pen)
virtual void mouseMoveEvent(QMouseEvent *) override
void enablePanning(bool on=true)
Sets panning mode to on (true by default).
void connectSource(QAbstractSlider *horizontal, QAbstractSlider *vertical)
QBrush backgroundBrush() const
void setFromPixmap(const QPixmap &pixmap)
Sets the pixmap to be shown as the background of the navigator.
virtual void drawSlider(QPainter &p, QRect r)
QBrush sliderBrush() const
virtual bool event(QEvent *) override
void scrollVertical(int value)
virtual QSize minimumSizeHint() const
void scrollHorizontal(int value)
virtual void mousePressEvent(QMouseEvent *) override
void connectSource(QAbstractScrollArea *area)
void resetSize(const QSize &size)
Removes background pixmap (if any) and resets the size of the navigator to size.
void setSliderOpacity(double opacity)
void wheeled(QWheelEvent *we)
virtual void paintEvent(QPaintEvent *) override
virtual void drawBackground(QPainter &p, QRect r)
virtual bool eventFilter(QObject *, QEvent *) override
bool isPanningEnabled() const
Returns true if mouse panning is enabled (default), false otherwise.
void setOpacity(double opacity)
void resetSize(int width, int height)
In this library is defined 2D view concept and standard visualisation objects.