1 | /* $Id: UIGraphicsZoomButton.h 69498 2017-10-28 15:07:25Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIGraphicsZoomButton class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2016 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef __UIGraphicsZoomButton_h__
|
---|
19 | #define __UIGraphicsZoomButton_h__
|
---|
20 |
|
---|
21 | /* GUI includes: */
|
---|
22 | #include "UIGraphicsButton.h"
|
---|
23 |
|
---|
24 | /* Other VBox includes: */
|
---|
25 | #include "iprt/assert.h"
|
---|
26 |
|
---|
27 | /* Forward declarations: */
|
---|
28 | class QStateMachine;
|
---|
29 | class QPropertyAnimation;
|
---|
30 |
|
---|
31 | /* Zoom direction: */
|
---|
32 | enum UIGraphicsZoomDirection
|
---|
33 | {
|
---|
34 | UIGraphicsZoomDirection_Top = RT_BIT(0),
|
---|
35 | UIGraphicsZoomDirection_Bottom = RT_BIT(1),
|
---|
36 | UIGraphicsZoomDirection_Left = RT_BIT(2),
|
---|
37 | UIGraphicsZoomDirection_Right = RT_BIT(3)
|
---|
38 | };
|
---|
39 |
|
---|
40 | /* Zoom graphics-button representation: */
|
---|
41 | class UIGraphicsZoomButton : public UIGraphicsButton
|
---|
42 | {
|
---|
43 | Q_OBJECT;
|
---|
44 | Q_PROPERTY(bool stateDefault READ stateDefault WRITE setStateDefault);
|
---|
45 |
|
---|
46 | signals:
|
---|
47 |
|
---|
48 | /* Notify listeners about hover events: */
|
---|
49 | void sigHoverEnter();
|
---|
50 | void sigHoverLeave();
|
---|
51 |
|
---|
52 | public:
|
---|
53 |
|
---|
54 | /* Constructor: */
|
---|
55 | UIGraphicsZoomButton(QIGraphicsWidget *pParent, const QIcon &icon, int iDirection);
|
---|
56 |
|
---|
57 | /* API: Zoom stuff: */
|
---|
58 | int indent() const;
|
---|
59 | void setIndent(int iIndent);
|
---|
60 |
|
---|
61 | /* API: Animation stuff: */
|
---|
62 | void updateAnimation();
|
---|
63 |
|
---|
64 | protected:
|
---|
65 |
|
---|
66 | /* Data provider: */
|
---|
67 | QVariant data(int iKey) const;
|
---|
68 |
|
---|
69 | /* Handler: Mouse hover: */
|
---|
70 | void hoverEnterEvent(QGraphicsSceneHoverEvent *pEvent);
|
---|
71 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);
|
---|
72 |
|
---|
73 | /* Paint stuff: */
|
---|
74 | void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0);
|
---|
75 |
|
---|
76 | private:
|
---|
77 |
|
---|
78 | /* Animation stuff: */
|
---|
79 | bool isAnimationRunning() const;
|
---|
80 |
|
---|
81 | /* Property stuff: */
|
---|
82 | bool stateDefault() const;
|
---|
83 | void setStateDefault(bool fStateDefault);
|
---|
84 |
|
---|
85 | /* Variables: */
|
---|
86 | int m_iIndent;
|
---|
87 | int m_iDirection;
|
---|
88 | int m_iAnimationDuration;
|
---|
89 | QStateMachine *m_pStateMachine;
|
---|
90 | QPropertyAnimation *m_pForwardAnimation;
|
---|
91 | QPropertyAnimation *m_pBackwardAnimation;
|
---|
92 | bool m_fStateDefault;
|
---|
93 | };
|
---|
94 |
|
---|
95 | #endif /* __UIGraphicsZoomButton_h__ */
|
---|
96 |
|
---|