Skip to content

Commit dd03b64

Browse files
committed
Clean up and documentation
1 parent 70a257f commit dd03b64

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

lib/include/elements/element/style/sprite_button.hpp

+100
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111

1212
namespace cycfi::elements
1313
{
14+
/**
15+
* \class
16+
* sprite_button_styler
17+
*
18+
* \brief
19+
* A class template that styles a button with a sprite.
20+
*
21+
* This class template inherits from a base button class and provides
22+
* additional functionality to style the button using a sprite. The
23+
* sprite can be used to represent different states of the button.
24+
*
25+
* \tparam Base The base button class to inherit from.
26+
*/
1427
template <typename Base>
1528
class sprite_button_styler : public Base
1629
{
@@ -46,6 +59,20 @@ namespace cycfi::elements
4659
// Inlines
4760
//--------------------------------------------------------------------------
4861

62+
/**
63+
* \brief
64+
* Draws the sprite button with the given context.
65+
*
66+
* This function overrides the draw function in the base class to
67+
* provide specific drawing functionality for the sprite button. It
68+
* determines the appropriate frame of the sprite to display based on
69+
* the button's state (enabled/disabled, value, and highlight).
70+
*
71+
* \param ctx
72+
* The context within which the element should be drawn. The context
73+
* provides information about the view, canvas, and other properties
74+
* that might be necessary for drawing the element.
75+
*/
4976
template <typename Base>
5077
inline void sprite_button_styler<Base>::draw(context const& ctx)
5178
{
@@ -61,6 +88,30 @@ namespace cycfi::elements
6188
}
6289
}
6390

91+
/**
92+
* \brief
93+
* Creates a momentary button with a sprite button styler.
94+
*
95+
* This function template creates a proxy object for a momentary button
96+
* styled with a sprite. A momentary button is a button that only
97+
* remains active while it is being pressed.
98+
*
99+
* \tparam Base
100+
* The base type of the momentary button. `Base` should be a momentary
101+
* button that adheres to ` MomentaryButton` concept with
102+
* `basic_button` as the default type.
103+
*
104+
* \tparam Styler
105+
* The type of the sprite styler. The sprite styler must adhere to the
106+
* SpriteSubject concept,
107+
*
108+
* \param s
109+
* The sprite styler to be used for the button.
110+
*
111+
* \return
112+
* A proxy object that combines the sprite button styler with the
113+
* momentary button.
114+
*/
64115
template <
65116
concepts::MomentaryButton Base
66117
, concepts::SpriteSubject Styler
@@ -71,6 +122,30 @@ namespace cycfi::elements
71122
return {std::forward<Styler>(s)};
72123
}
73124

125+
/**
126+
* \brief
127+
* Creates a toggle button with a sprite button styler.
128+
*
129+
* This function template creates a proxy object for a toggle button
130+
* styled with a sprite. A toggle button is a button that remains
131+
* active until it is pressed again.
132+
*
133+
* \tparam Base
134+
* The base type of the latching button. `Base` should be a toggle
135+
* button that adheres to ` ToggleButton` concept with
136+
* `basic_toggle_button` as the default type.
137+
*
138+
* \tparam Styler
139+
* The type of the sprite styler. The sprite styler must adhere to the
140+
* SpriteSubject concept,
141+
*
142+
* \param s
143+
* The sprite styler to be used for the button.
144+
*
145+
* \return
146+
* A proxy object that combines the sprite button styler with the
147+
* toggle button.
148+
*/
74149
template <
75150
concepts::ToggleButton Base
76151
, concepts::SpriteSubject Styler
@@ -81,6 +156,31 @@ namespace cycfi::elements
81156
return {std::forward<Styler>(s)};
82157
}
83158

159+
/**
160+
* \brief
161+
* Creates a latching button with a sprite button styler.
162+
*
163+
* This function template creates a proxy object for a latching button
164+
* styled with a sprite. A latching button is a button that maintains
165+
* its state after being clicked and holds this state indefinitely
166+
* until it is reset programmatically.
167+
*
168+
* \tparam Base
169+
* The base type of the latching button. `Base` should be a latching
170+
* button that adheres to `LatchingButton` concept with
171+
* `basic_latching_button` as the default type.
172+
*
173+
* \tparam Styler
174+
* The type of the sprite styler. The sprite styler must adhere to the
175+
* SpriteSubject concept,
176+
*
177+
* \param s
178+
* The sprite styler to be used for the button.
179+
*
180+
* \return
181+
* A proxy object that combines the sprite button styler with the
182+
* latching button.
183+
*/
84184
template <
85185
concepts::LatchingButton Base
86186
, concepts::SpriteSubject Styler

lib/include/elements/element/style/sprite_dial.hpp

+49
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@
1212

1313
namespace cycfi::elements
1414
{
15+
/**
16+
* \class
17+
* sprite_dial_styler
18+
*
19+
* \brief
20+
* A class template that styles a dial control with a sprite.
21+
*
22+
* This class template inherits from a base dial class and provides
23+
* additional functionality to style the dial using a sprite. The
24+
* sprite can be used to represent different states or positions of the
25+
* dial. The dial has a value that is a normalized `double` in the
26+
* range [0, 1]. This value maps to different frames in the sprite to
27+
* visually show the dial position.
28+
*
29+
* \tparam Base The base dial class to inherit from.
30+
*/
1531
template <typename Base>
1632
class sprite_dial_styler : public Base
1733
{
@@ -30,6 +46,20 @@ namespace cycfi::elements
3046
// Inlines
3147
//--------------------------------------------------------------------------
3248

49+
/**
50+
* \brief
51+
* Draws the sprite dial with the given context.
52+
*
53+
* The draw function determines the appropriate frame of the sprite to
54+
* display based on the dial's value: a normalized `double` in the
55+
* range [0, 1], which maps to different frames in the sprite to
56+
* visually show the dial position.
57+
*
58+
* \param ctx
59+
* The context within which the element should be drawn. The context
60+
* provides information about the view, canvas, and other properties
61+
* that might be necessary for drawing the element.
62+
*/
3363
template <typename Base>
3464
inline void sprite_dial_styler<Base>::draw(context const& ctx)
3565
{
@@ -40,6 +70,25 @@ namespace cycfi::elements
4070
}
4171
}
4272

73+
/**
74+
* \brief
75+
* Creates a dial control with a sprite dial styler.
76+
*
77+
* \tparam Styler
78+
* The type of the sprite styler. The sprite styler must adhere to the
79+
* SpriteSubject concept.
80+
*
81+
* \param styler
82+
* The sprite styler to be used for the dial.
83+
*
84+
* \param init_value
85+
* The initial value of the dial, which is a normalized `double` in the
86+
* range [0, 1].
87+
*
88+
* \return
89+
* A proxy object that combines the sprite dial styler with the basic
90+
* dial.
91+
*/
4392
template <concepts::SpriteSubject Styler>
4493
inline proxy<remove_cvref_t<Styler>, sprite_dial_styler<basic_dial>>
4594
dial(Styler&& styler, double init_value)

0 commit comments

Comments
 (0)