1 | /* $Id: UIGraphicsZoomButton.h 103988 2024-03-21 13:49:47Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIGraphicsZoomButton class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-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_UIGraphicsZoomButton_h
|
---|
29 | #define FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsZoomButton_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* GUI includes: */
|
---|
35 | #include "UIGraphicsButton.h"
|
---|
36 |
|
---|
37 | /* Other VBox includes: */
|
---|
38 | #include "iprt/cdefs.h" // for RT_BIT stuff
|
---|
39 |
|
---|
40 | /* Forward declarations: */
|
---|
41 | class QStateMachine;
|
---|
42 | class QPropertyAnimation;
|
---|
43 |
|
---|
44 | /* Zoom direction: */
|
---|
45 | enum UIGraphicsZoomDirection
|
---|
46 | {
|
---|
47 | UIGraphicsZoomDirection_Top = RT_BIT(0),
|
---|
48 | UIGraphicsZoomDirection_Bottom = RT_BIT(1),
|
---|
49 | UIGraphicsZoomDirection_Left = RT_BIT(2),
|
---|
50 | UIGraphicsZoomDirection_Right = RT_BIT(3)
|
---|
51 | };
|
---|
52 |
|
---|
53 | /* Zoom graphics-button representation: */
|
---|
54 | class UIGraphicsZoomButton : public UIGraphicsButton
|
---|
55 | {
|
---|
56 | Q_OBJECT;
|
---|
57 | Q_PROPERTY(bool stateDefault READ stateDefault WRITE setStateDefault);
|
---|
58 |
|
---|
59 | signals:
|
---|
60 |
|
---|
61 | /* Notify listeners about hover events: */
|
---|
62 | void sigHoverEnter();
|
---|
63 | void sigHoverLeave();
|
---|
64 |
|
---|
65 | public:
|
---|
66 |
|
---|
67 | /* Constructor: */
|
---|
68 | UIGraphicsZoomButton(QIGraphicsWidget *pParent, const QIcon &icon, int iDirection);
|
---|
69 |
|
---|
70 | /* API: Zoom stuff: */
|
---|
71 | int indent() const;
|
---|
72 | void setIndent(int iIndent);
|
---|
73 |
|
---|
74 | /* API: Animation stuff: */
|
---|
75 | void updateAnimation();
|
---|
76 |
|
---|
77 | protected:
|
---|
78 |
|
---|
79 | /* Data provider: */
|
---|
80 | QVariant data(int iKey) const RT_OVERRIDE RT_FINAL;
|
---|
81 |
|
---|
82 | /* Handler: Mouse hover: */
|
---|
83 | void hoverEnterEvent(QGraphicsSceneHoverEvent *pEvent) RT_OVERRIDE RT_FINAL;
|
---|
84 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent) RT_OVERRIDE RT_FINAL;
|
---|
85 |
|
---|
86 | /* Paint stuff: */
|
---|
87 | void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0) RT_OVERRIDE RT_FINAL;
|
---|
88 |
|
---|
89 | private:
|
---|
90 |
|
---|
91 | /* Animation stuff: */
|
---|
92 | bool isAnimationRunning() const;
|
---|
93 |
|
---|
94 | /* Property stuff: */
|
---|
95 | bool stateDefault() const;
|
---|
96 | void setStateDefault(bool fStateDefault);
|
---|
97 |
|
---|
98 | /* Variables: */
|
---|
99 | int m_iIndent;
|
---|
100 | int m_iDirection;
|
---|
101 | int m_iAnimationDuration;
|
---|
102 | QStateMachine *m_pStateMachine;
|
---|
103 | QPropertyAnimation *m_pForwardAnimation;
|
---|
104 | QPropertyAnimation *m_pBackwardAnimation;
|
---|
105 | bool m_fStateDefault;
|
---|
106 | };
|
---|
107 |
|
---|
108 | #endif /* !FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsZoomButton_h */
|
---|