@@ -59,35 +59,71 @@ namespace concepts
59
59
`TBase`:: Type that conforms to the ToggleButton concept.
60
60
`LBase`:: Type that conforms to the LatchingButton concept.
61
61
62
+
62
63
=== Expressions
63
64
64
- [,c++]
65
+ [cols="2,3", options="header"]
66
+ |===
67
+ | Expression | Semantics
68
+
69
+ a|
70
+ [source,c++]
65
71
----
66
- // Basic default buttons
67
72
momentary_button(styler);
73
+ ----
74
+ a|
75
+ * Creates a momentary button with the given styler element.
76
+
77
+ a|
78
+ [source,c++]
79
+ ----
68
80
toggle_button(styler);
69
- latching_button(styler);
81
+ ----
82
+ a|
83
+ * Creates a toggle button with the given styler element.
84
+
85
+ a|
86
+ [source,c++]
87
+ ----
88
+ latching_button(styler)
89
+ ----
90
+ a|
91
+ * Creates a latching button with the given styler element.
70
92
71
- // Custom buttons
72
- momentary_button<MBase>(styler);
73
- toggle_button<TBase>(styler);
74
- latching_button<LBase>(styler);
93
+ a|
94
+ [source,c++]
75
95
----
96
+ momentary_button<MBase>(
97
+ styler
98
+ )
99
+ ----
100
+ a|
101
+ * Creates a momentary button with the given styler element.
102
+ * `MBase` is the base type that must conform to the `MomentaryButton`
103
+ concept.
76
104
77
- === Semantics
105
+ a|
106
+ [source,c++]
107
+ ----
108
+ toggle_button<TBase>(
109
+ styler
110
+ )
111
+ ----
112
+ a|
113
+ * Creates a toggle button with the given styler element.
114
+ * `TBase` is the base type that must conform to the `ToggleButton` concept.
78
115
79
- . `momentary_button`
80
- is a function that creates a momentary button with the given styler
81
- element. `MBase`, if provided, is the base type that must conform to
82
- the `MomentaryButton` concept.
83
- . `toggle_button`
84
- is a function that creates a toggle button with the given styler
85
- element. `TBase`, if provided, is the the base type that must conform
86
- to the `ToggleButton` concept.
87
- . `latching_button`
88
- is a function that creates a latching button with the given styler
89
- element. `LBase`, if provided, is the the base type that must conform
90
- to the `LatchingButton` concept.
116
+ a|
117
+ [source,c++]
118
+ ----
119
+ latching_button<LBase>(
120
+ styler
121
+ )
122
+ ----
123
+ a|
124
+ * Creates a latching button with the given styler element.
125
+ * `LBase` is the base type that must conform to the `LatchingButton` concept.
126
+ |===
91
127
92
128
The provided base types `MBase`, `TBase`, and `LBase` offer the flexibility
93
129
to use custom button behavior, provided they adhere to their respective
@@ -103,43 +139,48 @@ button is clicked.
103
139
`btn`:: A Button instance.
104
140
`f` :: A callback function with the signature `void(bool state)`.
105
141
106
- === Expression
142
+ === Expressions
107
143
108
- [,c++]
144
+ [cols="2,3", options="header"]
145
+ |===
146
+ | Expression | Semantics
147
+
148
+ a|
149
+ [source,c++]
109
150
----
110
151
btn.on_click = f;
111
152
----
153
+ a|
154
+ * Assigns a callable function, `f`, to the button's `on_click` event.
155
+ * The `on_click` callback is called at the trailing edge of the click, just
156
+ before release.
157
+ * Momentary and latching buttons will always have a state of `true` when
158
+ its `on_click` callback is called.
159
+ * Toggle buttons will will have a state that alternates between `true` and
160
+ `false` with each click.
161
+ |===
112
162
113
- === Semantics
114
-
115
- The type of the `on_click` callable object is:
163
+ The client provides a callback function, typically a c++ lambda, that will be
164
+ called when the button is clicked. The type of the `on_click` callable object
165
+ is:
116
166
117
- [,c++]
167
+ [source ,c++]
118
168
----
119
- std::function<void(bool state))
169
+ std::function<void(bool state)>
120
170
----
121
171
122
- The client provides a callback function, typically a c++ lambda, that will be
123
- called when the button is clicked. The `state` argument indicates whether the
124
- button is ON (`true`) or OFF (`false`).
125
-
126
- . The `on_click` callback is called at the trailing edge of the click, just
127
- before release.
128
-
129
- . Momentary and latching buttons will always have a state of `true` when
130
- its `on_click` callback is called.
131
-
132
- . Toggle buttons will will have a state that alternates between `true` and
133
- `false` with each click.
172
+ The `state` argument indicates whether the button is ON (`true`) or OFF
173
+ (`false`).
134
174
135
175
=== Example
136
176
137
177
[,c++]
138
178
----
139
- btn.on_click = [](bool state)
140
- {
141
- std::cout << "Button clicked: " << state << std::endl;
142
- };
179
+ btn.on_click =
180
+ [](bool state)
181
+ {
182
+ std::cout << "Button clicked: " << state << std::endl;
183
+ };
143
184
----
144
185
145
186
== Enable/Disable
@@ -153,20 +194,29 @@ differently to indicate that it is disabled.
153
194
`btn` :: A Button instance.
154
195
`state` :: A boolean value indicating whether the button is enabled or disabled.
155
196
156
- === Expression
197
+ === Expressions
157
198
158
- [,c++]
199
+ [cols="2,3", options="header"]
200
+ |===
201
+ | Expression | Semantics
202
+
203
+ a|
204
+ [source,c++]
159
205
----
160
- btn.enable(state) <1>
161
- btn.is_enabled() <2>
206
+ btn.enable(state)
162
207
----
163
-
164
- === Semantics
165
-
166
- <1> Pass `true` to the `state` argument to enable the button, or
167
- `false` to disable it. When disabled, the button will not respond
168
- to clicks.
169
- <2> Returns `true` if the button is enabled, and `false` otherwise.
208
+ a|
209
+ * Sets the button's enabled state. Pass `true` to the `state` argument to
210
+ enable the button, or `false` to disable it.
211
+ * When disabled, the button will not respond to clicks.
212
+ a|
213
+ [source,c++]
214
+ ----
215
+ btn.is_enabled()
216
+ ----
217
+ a|
218
+ * Returns `true` if the button is enabled, `false` otherwise.
219
+ |===
170
220
171
221
== Value
172
222
@@ -183,18 +233,28 @@ functions, `value()` and `value(val)`.
183
233
`btn` :: A Button instance.
184
234
`val` :: A boolean value.
185
235
186
- === Expression
236
+ === Expressions
237
+
238
+ [cols="2,3", options="header"]
239
+ |===
240
+ | Expression | Semantics
187
241
188
- [,c++]
242
+ a|
243
+ [source,c++]
189
244
----
190
- btn.value(val) <1>
191
- btn.vauel() <2>
245
+ btn.value(val)
192
246
----
247
+ a|
248
+ * Sets the value of the button to `val`.
193
249
194
- === Semantics
195
-
196
- <1> Sets the value of the button to `val`.
197
- <2> Returns the current value of the button.
250
+ a|
251
+ [source,c++]
252
+ ----
253
+ btn.value()
254
+ ----
255
+ a|
256
+ * Returns the current value of the button.
257
+ |===
198
258
199
259
== Button Styler
200
260
0 commit comments