QmlMaterial 0.1.0
Loading...
Searching...
No Matches
icon_button_state.hpp
1#pragma once
2#include "qml_material/style/button_interaction_state.hpp"
3#include "qml_material/token/button.hpp"
4#include <optional>
5Q_MOC_INCLUDE("qml_material/control/button_control.hpp")
6namespace qml_material
7{
8class QML_MATERIAL_API IconButtonState : public ButtonValueState {
9 Q_OBJECT
10 QML_NAMED_ELEMENT(StateIconButton)
11 Q_PROPERTY(int shapeMode READ shapeMode WRITE setShapeMode NOTIFY shapeModeChanged BINDABLE
12 bindableShapeMode FINAL)
13 Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged BINDABLE bindableType FINAL)
14 Q_PROPERTY(int size READ size WRITE setSize NOTIFY sizeChanged BINDABLE bindableSize FINAL)
15 Q_PROPERTY(int widthMode READ widthMode WRITE setWidthMode NOTIFY widthModeChanged BINDABLE
16 bindableWidthMode FINAL)
17 Q_PROPERTY(qreal containerWidth READ containerWidth NOTIFY containerWidthChanged)
18 Q_PROPERTY(bool isRound READ isRound WRITE setIsRound NOTIFY isRoundChanged BINDABLE
19 bindableIsRound FINAL)
20 Q_PROPERTY(qml_material::token::IconButtonSize sizeTokens READ sizeTokens WRITE setSizeTokens
21 NOTIFY sizeTokensChanged BINDABLE bindableSizeTokens FINAL)
22 Q_PROPERTY(
23 qml_material::token::IconButtonSizeItem sizeToken READ sizeToken NOTIFY sizeTokenChanged)
24 Q_PROPERTY(qreal containerHeight READ containerHeight NOTIFY sizeTokenChanged)
25 Q_PROPERTY(qreal iconSize READ iconSize NOTIFY sizeTokenChanged)
26
27public:
28 explicit IconButtonState(QObject* parent = nullptr);
29 int shapeMode() const { return m_shapeMode; }
30 void setShapeMode(int value) { m_shapeMode = value; }
31 QBindable<int> bindableShapeMode() { return &m_shapeMode; }
32 Q_SIGNAL void shapeModeChanged();
33 int type() const;
34 void setType(int);
35 QBindable<int> bindableType();
36 int size() const;
37 void setSize(int);
38 QBindable<int> bindableSize();
39 bool isRound() const;
40 void setIsRound(bool);
41 QBindable<bool> bindableIsRound();
42 token::IconButtonSize sizeTokens() const;
43 void setSizeTokens(const token::IconButtonSize&);
44 QBindable<token::IconButtonSize> bindableSizeTokens();
45
46 token::IconButtonSizeItem sizeToken() const;
47 qreal containerHeight() const;
48 qreal iconSize() const;
49
50 int widthMode() const;
51 void setWidthMode(int);
52 QBindable<int> bindableWidthMode();
53 qreal containerWidth() const;
54 Q_SIGNAL void widthModeChanged();
55 Q_SIGNAL void containerWidthChanged();
56 Q_SIGNAL void typeChanged();
57 Q_SIGNAL void sizeChanged();
58 Q_SIGNAL void isRoundChanged();
59 Q_SIGNAL void sizeTokensChanged();
60 Q_SIGNAL void sizeTokenChanged();
61
62private:
63 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, int, m_shapeMode,
64 int(Enum::ButtonShapeMode::FixedShape),
65 &IconButtonState::shapeModeChanged)
66 void bindTargets();
67 QColor defaultTextColor() const;
68 QColor defaultBackgroundColor() const;
69
70 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, int, m_type,
71 int(Enum::IconButtonType::IBtStandard),
72 &IconButtonState::typeChanged)
73 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, int, m_size, int(Enum::ButtonSize::S),
74 &IconButtonState::sizeChanged)
75 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, bool, m_isRound, true,
76 &IconButtonState::isRoundChanged)
77 Q_OBJECT_BINDABLE_PROPERTY(IconButtonState, token::IconButtonSize, m_sizeTokens,
78 &IconButtonState::sizeTokensChanged)
79 Q_OBJECT_BINDABLE_PROPERTY(IconButtonState, token::IconButtonSizeItem, m_selectedSize,
80 &IconButtonState::sizeTokenChanged)
81
82 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, int, m_widthMode,
83 int(Enum::ButtonWidthMode::DefaultWidth),
84 &IconButtonState::widthModeChanged)
85 Q_OBJECT_BINDABLE_PROPERTY(IconButtonState, qreal, m_containerWidth,
86 &IconButtonState::containerWidthChanged)
87 BindingLifetime m_bindingLifetime { bindingSet().lifetime() };
88};
89} // namespace qml_material
Icon button size tokens for a specific size class.
Definition button.hpp:114
Collection of icon button size tokens for different size classes.
Definition button.hpp:148