Skip to content

Commit 3a2ad28

Browse files
committed
Documenting button
1 parent 26ac087 commit 3a2ad28

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

lib/include/elements/element/button.hpp

+24-10
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,30 @@ namespace cycfi::elements
5656
bool enabled : 1;
5757
};
5858

59-
class basic_button
60-
: public proxy_base
61-
, public receiver<bool>
59+
/**
60+
* \class basic_button
61+
*
62+
* \brief
63+
* A class that represents a basic GUI button, acting as a proxy which
64+
* delegates the rendering to a "button styler".
65+
*
66+
* The `basic_button` class is a foundational class for creating a GUI
67+
* button. This class is a proxy which delegates the rendering of the
68+
* actual button to a button styler subject. This division of
69+
* responsibilities allows for more flexibility in dictating the
70+
* button's appearance and interaction. The `basic_button` class
71+
* handles user interactions, while the button styler manages the
72+
* button's visual presentation. With this pattern, different stylers
73+
* can be implemented for various visual representations, for instance,
74+
* plain buttons, radio buttons, slide switches, checkboxes, and more.
75+
*
76+
* The communication with the "button styler" is done via the
77+
* `receiver<button_state>` API. This API provides a means for the
78+
* `basic_button` to update the button styler about changes in button's
79+
* state (such as on/off value, highlight, enabled state etc.) enabling
80+
* the styler to adjust the visual representation accordingly.
81+
*/
82+
class basic_button : public proxy_base, public receiver<bool>
6283
{
6384
public:
6485

@@ -95,13 +116,6 @@ namespace cycfi::elements
95116
button_state _state;
96117
};
97118

98-
inline void basic_button::edit(view& view_, bool val)
99-
{
100-
if (on_click)
101-
on_click(val);
102-
receiver<bool>::notify_edit(view_);
103-
}
104-
105119
////////////////////////////////////////////////////////////////////////////
106120
// Toggle Button
107121
////////////////////////////////////////////////////////////////////////////

lib/src/element/button.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ namespace cycfi::elements
126126
state(val);
127127
}
128128

129+
void basic_button::edit(view& view_, bool val)
130+
{
131+
if (on_click)
132+
on_click(val);
133+
receiver<bool>::notify_edit(view_);
134+
}
135+
129136
void basic_choice_click(context const& ctx, selectable& s)
130137
{
131138
auto [c, cctx] = find_composite(ctx);

0 commit comments

Comments
 (0)