1 | // Copyright (C) 2023 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICKMATERIALPLACEHOLDERTEXT_P_H |
5 | #define QQUICKMATERIALPLACEHOLDERTEXT_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/private/qglobal_p.h> |
19 | #include <QtGui/qcolor.h> |
20 | #include <QtQuickControls2Impl/private/qquickplaceholdertext_p.h> |
21 | |
22 | #include <QtCore/qpointer.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QParallelAnimationGroup; |
27 | |
28 | class QQuickMaterialPlaceholderText : public QQuickPlaceholderText |
29 | { |
30 | Q_OBJECT |
31 | Q_PROPERTY(bool filled READ isFilled WRITE setFilled NOTIFY filledChanged FINAL) |
32 | Q_PROPERTY(bool controlHasActiveFocus READ controlHasActiveFocus |
33 | WRITE setControlHasActiveFocus NOTIFY controlHasActiveFocusChanged FINAL) |
34 | Q_PROPERTY(bool controlHasText READ controlHasText WRITE setControlHasText NOTIFY controlHasTextChanged FINAL) |
35 | Q_PROPERTY(int largestHeight READ largestHeight NOTIFY largestHeightChanged FINAL) |
36 | Q_PROPERTY(qreal verticalPadding READ verticalPadding WRITE setVerticalPadding NOTIFY verticalPaddingChanged FINAL) |
37 | Q_PROPERTY(qreal controlImplicitBackgroundHeight READ controlImplicitBackgroundHeight |
38 | WRITE setControlImplicitBackgroundHeight NOTIFY controlImplicitBackgroundHeightChanged FINAL) |
39 | Q_PROPERTY(qreal controlHeight READ controlHeight WRITE setControlHeight FINAL) |
40 | Q_PROPERTY(int leftPadding WRITE setLeftPadding FINAL) |
41 | Q_PROPERTY(int floatingLeftPadding WRITE setFloatingLeftPadding FINAL) |
42 | QML_NAMED_ELEMENT(FloatingPlaceholderText) |
43 | QML_ADDED_IN_VERSION(6, 5) |
44 | |
45 | public: |
46 | explicit QQuickMaterialPlaceholderText(QQuickItem *parent = nullptr); |
47 | |
48 | bool isFilled() const; |
49 | void setFilled(bool filled); |
50 | |
51 | int largestHeight() const; |
52 | |
53 | bool controlHasActiveFocus() const; |
54 | void setControlHasActiveFocus(bool controlHasActiveFocus); |
55 | |
56 | bool controlHasText() const; |
57 | void setControlHasText(bool controlHasText); |
58 | |
59 | qreal controlImplicitBackgroundHeight() const; |
60 | void setControlImplicitBackgroundHeight(qreal controlImplicitBackgroundHeight); |
61 | |
62 | qreal controlHeight() const; |
63 | void setControlHeight(qreal controlHeight); |
64 | |
65 | qreal verticalPadding() const; |
66 | void setVerticalPadding(qreal verticalPadding); |
67 | |
68 | void setLeftPadding(int leftPadding); |
69 | void setFloatingLeftPadding(int floatingLeftPadding); |
70 | signals: |
71 | void filledChanged(); |
72 | void largestHeightChanged(); |
73 | void controlHasActiveFocusChanged(); |
74 | void controlHasTextChanged(); |
75 | void controlImplicitBackgroundHeightChanged(); |
76 | void verticalPaddingChanged(); |
77 | |
78 | private slots: |
79 | void adjustTransformOrigin(); |
80 | |
81 | private: |
82 | bool shouldFloat() const; |
83 | bool shouldAnimate() const; |
84 | |
85 | void updateY(); |
86 | void updateX(); |
87 | qreal normalTargetY() const; |
88 | qreal floatingTargetY() const; |
89 | qreal normalTargetX() const; |
90 | qreal floatingTargetX() const; |
91 | |
92 | void controlGotActiveFocus(); |
93 | void controlLostActiveFocus(); |
94 | |
95 | void maybeSetFocusAnimationProgress(); |
96 | |
97 | void componentComplete() override; |
98 | |
99 | bool m_filled = false; |
100 | bool m_controlHasActiveFocus = false; |
101 | bool m_controlHasText = false; |
102 | int m_largestHeight = 0; |
103 | qreal m_verticalPadding = 0; |
104 | qreal m_controlImplicitBackgroundHeight = 0; |
105 | qreal m_controlHeight = 0; |
106 | int m_leftPadding = 0; |
107 | int m_floatingLeftPadding = 0; |
108 | QPointer<QParallelAnimationGroup> m_focusInAnimation; |
109 | QPointer<QParallelAnimationGroup> m_focusOutAnimation; |
110 | }; |
111 | |
112 | QT_END_NAMESPACE |
113 | |
114 | #endif // QQUICKMATERIALPLACEHOLDERTEXT_P_H |
115 |