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.hpp")
6namespace qml_material
7{
8class Button;
9class QML_MATERIAL_API IconButtonState : public ButtonInteractionState {
10 Q_OBJECT
11 QML_NAMED_ELEMENT(StateIconButton)
12 Q_PROPERTY(qml_material::Button* item READ item WRITE setItem NOTIFY itemChanged 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 Button* item() const;
30 void setItem(Button*);
31 int type() const;
32 void setType(int);
33 QBindable<int> bindableType();
34 int size() const;
35 void setSize(int);
36 QBindable<int> bindableSize();
37 bool isRound() const;
38 void setIsRound(bool);
39 QBindable<bool> bindableIsRound();
40 token::IconButtonSize sizeTokens() const;
41 void setSizeTokens(const token::IconButtonSize&);
42 QBindable<token::IconButtonSize> bindableSizeTokens();
43
44 token::IconButtonSizeItem sizeToken() const;
45 qreal containerHeight() const;
46 qreal iconSize() const;
47
48 int widthMode() const;
49 void setWidthMode(int);
50 QBindable<int> bindableWidthMode();
51 qreal containerWidth() const;
52 Q_SIGNAL void widthModeChanged();
53 Q_SIGNAL void containerWidthChanged();
54 Q_SIGNAL void typeChanged();
55 Q_SIGNAL void sizeChanged();
56 Q_SIGNAL void isRoundChanged();
57 Q_SIGNAL void sizeTokensChanged();
58 Q_SIGNAL void sizeTokenChanged();
59
60private:
61 void bindTargets();
62 QColor defaultTextColor() const;
63 QColor defaultBackgroundColor() const;
64
65 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, int, m_type,
66 int(Enum::IconButtonType::IBtStandard),
67 &IconButtonState::typeChanged)
68 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, int, m_size, int(Enum::ButtonSize::S),
69 &IconButtonState::sizeChanged)
70 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, bool, m_isRound, true,
71 &IconButtonState::isRoundChanged)
72 Q_OBJECT_BINDABLE_PROPERTY(IconButtonState, token::IconButtonSize, m_sizeTokens,
73 &IconButtonState::sizeTokensChanged)
74 Q_OBJECT_BINDABLE_PROPERTY(IconButtonState, token::IconButtonSizeItem, m_selectedSize,
75 &IconButtonState::sizeTokenChanged)
76
77 Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(IconButtonState, int, m_widthMode,
78 int(Enum::ButtonWidthMode::DefaultWidth),
79 &IconButtonState::widthModeChanged)
80 Q_OBJECT_BINDABLE_PROPERTY(IconButtonState, qreal, m_containerWidth,
81 &IconButtonState::containerWidthChanged)
82 BindingLifetime m_bindingLifetime { bindingSet().lifetime() };
83};
84} // 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