4#include "qml_material/input/interaction_source.hpp"
5#include "qml_material/token/token.hpp"
9struct IndicationValues {
10 Q_GADGET_EXPORT(QML_MATERIAL_API)
11 QML_VALUE_TYPE(indicationValues)
12 Q_PROPERTY(QColor color MEMBER color CONSTANT FINAL)
13 Q_PROPERTY(qreal opacity MEMBER opacity CONSTANT FINAL)
14 Q_PROPERTY(qreal pressOpacity MEMBER pressOpacity CONSTANT FINAL)
15 Q_PROPERTY(
int kind MEMBER kind CONSTANT FINAL)
16 Q_PROPERTY(
bool available MEMBER available CONSTANT FINAL)
18 QColor color { Qt::transparent };
19 qreal opacity = 0, pressOpacity = token::State {}.pressed.state_layer_opacity;
20 int kind = Interaction::None;
21 bool available =
false;
22 bool operator==(
const IndicationValues&)
const =
default;
25class QML_MATERIAL_API IndicationPolicy {
27 explicit IndicationPolicy(QObject* context, std::function<
void()> changed = {});
29 IndicationPolicy(
const IndicationPolicy&) =
delete;
30 IndicationPolicy& operator=(
const IndicationPolicy&) =
delete;
31 InteractionSource* source()
const {
return m_interactions.source(); }
32 void setSource(InteractionSource* source) { m_interactions.setSource(source); }
33 void setTarget(QQuickItem*);
34 const InteractionAccumulator& interactions()
const {
return m_interactions; }
35 QColor color()
const {
return m_color; }
36 void setColor(
const QColor& value) { m_color = value; }
38 void bindDefaultColor(
const QPropertyBinding<QColor>& binding) {
39 m_defaultColor.setBinding(binding);
41 QBindable<QColor> bindableColor() {
return &m_color; }
42 token::State tokens()
const {
return m_tokens; }
43 void setTokens(
const token::State& value) { m_tokens = value; }
45 void bindDefaultTokens(
const QPropertyBinding<token::State>& binding) {
46 m_defaultTokens.setBinding(binding);
48 QBindable<token::State> bindableTokens() {
return &m_tokens; }
49 bool pressEnabled()
const {
return m_pressEnabled; }
50 bool hoverEnabled()
const {
return m_hoverEnabled; }
51 bool focusEnabled()
const {
return m_focusEnabled; }
52 bool dragEnabled()
const {
return m_dragEnabled; }
53 void setPressEnabled(
bool);
54 void setHoverEnabled(
bool);
55 void setFocusEnabled(
bool);
56 void setDragEnabled(
bool);
57 IndicationValues values()
const;
61 QPointer<QObject> m_context;
62 std::function<void()> m_changed;
63 InteractionAccumulator m_interactions;
64 QPointer<QQuickItem> m_target;
65 QList<QMetaObject::Connection> m_targetConnections;
66 QProperty<bool> m_available {
true };
67 QProperty<QColor> m_defaultColor { QColor(Qt::transparent) }, m_color;
68 QProperty<token::State> m_defaultTokens, m_tokens;
69 QPropertyNotifier m_colorNotifier, m_tokensNotifier;
70 bool m_pressEnabled =
true, m_hoverEnabled =
true, m_focusEnabled =
true, m_dragEnabled =
true;