2#include "qml_material/style/common_state.hpp"
7class QML_MATERIAL_API ButtonInteractionState :
public CommonState {
11 ~ButtonInteractionState()
override;
12 Q_INVOKABLE qreal groupOpticalOffset(
const qml_material::CornersGroup&)
const;
13 Q_SIGNAL
void itemChanged();
16 void enableGroupShape();
17 int groupSize()
const;
18 enum class Interaction
26 using BindingSet = StateBindingSet<Interaction>;
27 using BindingLifetime = BindingSet::Lifetime;
28 BindingSet& bindingSet() {
return m_bindings; }
29 StateBindings baseBindings() {
return m_bindings.base(); }
30 StateBindings stateBindings(Interaction state) {
return m_bindings.state(state); }
33 m_selection.takeBinding();
34 m_hovered.takeBinding();
37 void setHoverBinding(
const QPropertyBinding<bool>& binding) { m_hovered.setBinding(binding); }
38 enum class FocusTreatment
44 enum class PressSource
49 explicit ButtonInteractionState(QObject* parent =
nullptr,
50 FocusTreatment focus = FocusTreatment::Pressed,
51 PressSource press = PressSource::Down);
52 AbstractButton* inputItem()
const;
53 void setInputItem(AbstractButton*);
55 bool checkable()
const;
58 bool visualFocus()
const;
59 bool disabled()
const;
60 std::optional<qreal> backgroundHeight()
const;
61 void bindStateLayerOpacity();
64 void updateGroupContext();
65 CornersGroup groupCorners()
const;
66 QList<QMetaObject::Connection> m_groupConnections;
67 QProperty<quint64> m_groupRevision { 0 };
68 static QString stateName(Interaction);
69 BindingSet m_bindings { Interaction::Base };
71 Interaction state = Interaction::Base;
72 quint64 generation = 0;
73 bool operator==(
const Selection&)
const =
default;
75 void selectionChanged();
76 bool m_inputReady =
false;
77 QProperty<AbstractButton*> m_item {
nullptr };
78 QList<QMetaObject::Connection> m_connections;
79 QProperty<bool> m_disabled {
false };
80 QProperty<bool> m_hovered {
false };
81 Q_OBJECT_BINDABLE_PROPERTY(ButtonInteractionState, Selection, m_selection,
82 &ButtonInteractionState::selectionChanged)