VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.h@ 103988

Last change on this file since 103988 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1/* $Id: UIGraphicsScrollBar.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIGraphicsScrollBar class declaration.
4 */
5
6/*
7 * Copyright (C) 2019-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsScrollBar_h
29#define FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsScrollBar_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* GUI includes: */
35#include "QIGraphicsWidget.h"
36
37/* Forward declarations: */
38class QGraphicsScene;
39class UIGraphicsButton;
40class UIGraphicsScrollBarToken;
41
42/** QIGraphicsWidget subclass providing GUI with graphics scroll-bar. */
43class UIGraphicsScrollBar : public QIGraphicsWidget
44{
45 Q_OBJECT;
46 Q_PROPERTY(int hoveringValue READ hoveringValue WRITE setHoveringValue);
47#ifdef VBOX_WS_MAC
48 Q_PROPERTY(int revealingValue READ revealingValue WRITE setRevealingValue);
49#endif
50
51signals:
52
53 /** Notifies listeners about hover enter. */
54 void sigHoverEnter();
55 /** Notifies listeners about hover leave. */
56 void sigHoverLeave();
57
58#ifdef VBOX_WS_MAC
59 /** Notifies listeners about token should be revealed. */
60 void sigRevealEnter();
61 /** Notifies listeners about token should be faded. */
62 void sigRevealLeave();
63#endif
64
65 /** Notifies listeners about @a iValue has changed. */
66 void sigValueChanged(int iValue);
67
68public:
69
70 /** Constructs graphics scroll-bar of requested @a enmOrientation, embedding it directly to passed @a pScene.
71 * @param fAutoHideMode Brings whether scroll-bar should be created in auto-hide mode. */
72 UIGraphicsScrollBar(Qt::Orientation enmOrientation, bool fAutoHideMode, QGraphicsScene *pScene);
73
74 /** Constructs graphics scroll-bar of requested @a enmOrientation passing @a pParent to the base-class.
75 * @param fAutoHideMode Brings whether scroll-bar should be created in auto-hide mode. */
76 UIGraphicsScrollBar(Qt::Orientation enmOrientation, bool fAutoHideMode, QIGraphicsWidget *pParent = 0);
77
78 /** Returns minimum size-hint. */
79 virtual QSizeF minimumSizeHint() const RT_OVERRIDE;
80
81 /** Returns scrolling step. */
82 int step() const;
83 /** Returns page scrolling step. */
84 int pageStep() const;
85
86 /** Defines @a iMinimum scroll-bar value. */
87 void setMinimum(int iMinimum);
88 /** Returns minimum scroll-bar value. */
89 int minimum() const;
90
91 /** Defines @a iMaximum scroll-bar value. */
92 void setMaximum(int iMaximum);
93 /** Returns minimum scroll-bar value. */
94 int maximum() const;
95
96 /** Defines current scroll-bar @a iValue. */
97 void setValue(int iValue);
98 /** Returns current scroll-bar value. */
99 int value() const;
100
101 /** Performs scrolling to certain @a desiredPos with certain @a iDelay. */
102 void scrollTo(const QPointF &desiredPos, int iDelay = 500);
103
104protected:
105
106 /** Handles resize @a pEvent. */
107 virtual void resizeEvent(QGraphicsSceneResizeEvent *pEvent) RT_OVERRIDE;
108
109 /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */
110 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *pWidget = 0) RT_OVERRIDE;
111
112 /** Handles mouse-press @a pEvent. */
113 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) RT_OVERRIDE;
114 /** Handles mouse-release @a pEvent. */
115 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent) RT_OVERRIDE;
116
117 /** Handles hover enter @a pEvent. */
118 virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent) RT_OVERRIDE;
119 /** Handles hover leave @a pEvent. */
120 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent) RT_OVERRIDE;
121
122 /** Handles timer @a pEvent. */
123 virtual void timerEvent(QTimerEvent *pEvent) RT_OVERRIDE;
124
125private slots:
126
127 /** Handles button 1 click signal. */
128 void sltButton1Clicked();
129 /** Handles button 2 click signal. */
130 void sltButton2Clicked();
131
132 /** Handles token being moved to cpecified @a pos. */
133 void sltTokenMoved(const QPointF &pos);
134
135 /** Handles default state leaving. */
136 void sltStateLeftDefault();
137 /** Handles hovered state leaving. */
138 void sltStateLeftHovered();
139 /** Handles default state entering. */
140 void sltStateEnteredDefault();
141 /** Handles hovered state entering. */
142 void sltStateEnteredHovered();
143
144#ifdef VBOX_WS_MAC
145 /** Handles signals to start revealing. */
146 void sltHandleRevealingStart();
147 /** Handles faded state entering. */
148 void sltStateEnteredFaded();
149 /** Handles revealed state entering. */
150 void sltStateEnteredRevealed();
151#endif
152
153private:
154
155 /** Prepares all. */
156 void prepare();
157 /** Prepares widgets. */
158 void prepareWidgets();
159 /** Prepares buttons. */
160 void prepareButtons();
161 /** Prepares token. */
162 void prepareToken();
163 /** Prepares animation. */
164 void prepareAnimation();
165 /** Prepares hovering animation. */
166 void prepareHoveringAnimation();
167#ifdef VBOX_WS_MAC
168 /** Prepares revealing animation. */
169 void prepareRevealingAnimation();
170#endif
171
172 /** Updates scroll-bar extent value. */
173 void updateExtent();
174 /** Layout widgets. */
175 void layoutWidgets();
176 /** Layout buttons. */
177 void layoutButtons();
178 /** Layout token. */
179 void layoutToken();
180
181 /** Returns actual token position. */
182 QPoint actualTokenPosition() const;
183
184 /** Paints background using specified @a pPainter and certain @a rectangle. */
185 void paintBackground(QPainter *pPainter, const QRect &rectangle) const;
186
187 /** Defines hovering animation @a iValue. */
188 void setHoveringValue(int iValue) { m_iHoveringValue = iValue; update(); }
189 /** Returns hovering animation value. */
190 int hoveringValue() const { return m_iHoveringValue; }
191
192#ifdef VBOX_WS_MAC
193 /** Defines revealing animation @a iValue. */
194 void setRevealingValue(int iValue) { m_iRevealingValue = iValue; update(); }
195 /** Returns revealing animation value. */
196 int revealingValue() const { return m_iRevealingValue; }
197#endif
198
199 /** Holds the orientation. */
200 const Qt::Orientation m_enmOrientation;
201 /** Holds whether scroll-bar is in auto-hide mode. */
202 bool m_fAutoHideMode;
203
204 /** Holds the scroll-bar extent. */
205 int m_iExtent;
206
207 /** Holds the minimum scroll-bar value. */
208 int m_iMinimum;
209 /** Holds the maximum scroll-bar value. */
210 int m_iMaximum;
211 /** Holds the current scroll-bar value. */
212 int m_iValue;
213
214 /** Holds the 1st arrow button instance. */
215 UIGraphicsButton *m_pButton1;
216 /** Holds the 2nd arrow button instance. */
217 UIGraphicsButton *m_pButton2;
218 /** Holds the scroll-bar token instance. */
219 UIGraphicsScrollBarToken *m_pToken;
220
221 /** Holds whether item is hovered. */
222 bool m_fHovered;
223 /** Holds the hover-on timer id. */
224 int m_iHoverOnTimerId;
225 /** Holds the hover-off timer id. */
226 int m_iHoverOffTimerId;
227 /** Holds the hovering animation value. */
228 int m_iHoveringValue;
229
230 /** Holds whether we are scrolling. */
231 bool m_fScrollInProgress;
232
233#ifdef VBOX_WS_MAC
234 /** Holds whether token is revealed. */
235 bool m_fRevealed;
236 /** Holds the revealing animation value. */
237 int m_iRevealingValue;
238 /** Holds the reveal-out timer id. */
239 int m_iRevealOnTimerId;
240 /** Holds the reveal-out timer id. */
241 int m_iRevealOffTimerId;
242#endif
243};
244
245#endif /* !FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsScrollBar_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette