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
22QT_BEGIN_NAMESPACE
23
24class QParallelAnimationGroup;
25
26class QQuickMaterialPlaceholderText : public QQuickPlaceholderText
27{
28 Q_OBJECT
29 Q_PROPERTY(bool filled READ isFilled WRITE setFilled NOTIFY filledChanged FINAL)
30 Q_PROPERTY(bool controlHasActiveFocus READ controlHasActiveFocus
31 WRITE setControlHasActiveFocus NOTIFY controlHasActiveFocusChanged FINAL)
32 Q_PROPERTY(bool controlHasText READ controlHasText WRITE setControlHasText NOTIFY controlHasTextChanged FINAL)
33 Q_PROPERTY(int largestHeight READ largestHeight NOTIFY largestHeightChanged FINAL)
34 Q_PROPERTY(qreal verticalPadding READ verticalPadding WRITE setVerticalPadding NOTIFY verticalPaddingChanged FINAL)
35 Q_PROPERTY(qreal controlImplicitBackgroundHeight READ controlImplicitBackgroundHeight
36 WRITE setControlImplicitBackgroundHeight NOTIFY controlImplicitBackgroundHeightChanged FINAL)
37 Q_PROPERTY(qreal controlHeight READ controlHeight WRITE setControlHeight FINAL)
38 QML_NAMED_ELEMENT(FloatingPlaceholderText)
39 QML_ADDED_IN_VERSION(6, 5)
40
41public:
42 explicit QQuickMaterialPlaceholderText(QQuickItem *parent = nullptr);
43
44 bool isFilled() const;
45 void setFilled(bool filled);
46
47 int largestHeight() const;
48
49 bool controlHasActiveFocus() const;
50 void setControlHasActiveFocus(bool controlHasActiveFocus);
51
52 bool controlHasText() const;
53 void setControlHasText(bool controlHasText);
54
55 qreal controlImplicitBackgroundHeight() const;
56 void setControlImplicitBackgroundHeight(qreal controlImplicitBackgroundHeight);
57
58 qreal controlHeight() const;
59 void setControlHeight(qreal controlHeight);
60
61 qreal verticalPadding() const;
62 void setVerticalPadding(qreal verticalPadding);
63
64signals:
65 void filledChanged();
66 void largestHeightChanged();
67 void controlHasActiveFocusChanged();
68 void controlHasTextChanged();
69 void controlImplicitBackgroundHeightChanged();
70 void verticalPaddingChanged();
71
72private:
73 bool shouldFloat() const;
74 bool shouldAnimate() const;
75
76 void updateY();
77 qreal normalTargetY() const;
78 qreal floatingTargetY() const;
79
80 void controlGotActiveFocus();
81 void controlLostActiveFocus();
82
83 void maybeSetFocusAnimationProgress();
84
85 void componentComplete() override;
86
87 bool m_filled = false;
88 bool m_controlHasActiveFocus = false;
89 bool m_controlHasText = false;
90 int m_largestHeight = 0;
91 qreal m_verticalPadding = 0;
92 qreal m_controlImplicitBackgroundHeight = 0;
93 qreal m_controlHeight = 0;
94 QPointer<QParallelAnimationGroup> m_focusInAnimation;
95 QPointer<QParallelAnimationGroup> m_focusOutAnimation;
96};
97
98QT_END_NAMESPACE
99
100#endif // QQUICKMATERIALPLACEHOLDERTEXT_P_H
101

source code of qtdeclarative/src/quickcontrols/material/impl/qquickmaterialplaceholdertext_p.h