TermOx
checkbox.hpp
1 #ifndef TERMOX_WIDGET_WIDGETS_CHECKBOX_HPP
2 #define TERMOX_WIDGET_WIDGETS_CHECKBOX_HPP
3 #include <memory>
4 #include <utility>
5 
6 #include <signals_light/signal.hpp>
7 
8 #include <termox/common/overload.hpp>
9 #include <termox/painter/glyph_string.hpp>
10 #include <termox/system/mouse.hpp>
11 #include <termox/widget/detail/link_lifetimes.hpp>
12 #include <termox/widget/layouts/horizontal.hpp>
13 #include <termox/widget/layouts/vertical.hpp>
14 #include <termox/widget/pipe.hpp>
15 #include <termox/widget/widgets/label.hpp>
16 
17 namespace ox {
18 
20 
21 template <template <typename> typename Layout_t>
22 class Checkbox : public Label<Layout_t> {
23  private:
24  using Base_t = Label<Layout_t>;
25 
26  public:
27  enum class State : bool { Unchecked, Checked };
28 
29  struct Display {
30  Glyph_string checked;
31  Glyph_string unchecked;
32  };
33 
34  struct Parameters {
35  State initial_state;
36  Display display;
37  bool locked;
38  };
39 
40  public:
42  sl::Signal<void()> checked;
43 
45  sl::Signal<void()> unchecked;
46 
48  sl::Signal<void()> toggled;
49 
50  public:
52  explicit Checkbox(State initial_state, Display display, bool locked);
53 
55  explicit Checkbox(Parameters p);
56 
57  public:
59  void check();
60 
62  void uncheck();
63 
65  void toggle();
66 
68  [[nodiscard]] auto get_state() const -> State;
69 
71  void lock();
72 
74  void unlock();
75 
77  [[nodiscard]] auto is_locked() const -> bool;
78 
80  void set_display(Display d);
81 
83  [[nodiscard]] auto get_display() -> Display;
84 
85  protected:
86  auto mouse_press_event(Mouse const& m) -> bool override;
87 
88  private:
89  State state_;
90  Display display_;
91  bool locked_;
92 
93  private:
95  void update_display();
96 };
97 
98 using HCheckbox = Checkbox<layout::Horizontal>;
99 using VCheckbox = Checkbox<layout::Vertical>;
100 
102 [[nodiscard]] auto hcheckbox(HCheckbox::State initial_state,
103  HCheckbox::Display display,
104  bool locked) -> std::unique_ptr<HCheckbox>;
105 
107 [[nodiscard]] auto hcheckbox(HCheckbox::Parameters p)
108  -> std::unique_ptr<HCheckbox>;
109 
111 [[nodiscard]] auto vcheckbox(VCheckbox::State initial_state,
112  VCheckbox::Display display,
113  bool locked) -> std::unique_ptr<VCheckbox>;
114 
116 [[nodiscard]] auto vcheckbox(VCheckbox::Parameters p)
117  -> std::unique_ptr<VCheckbox>;
118 
119 } // namespace ox
120 
121 namespace ox::detail {
122 
124 template <template <typename> typename Layout_t,
125  typename Checkbox_type,
126  bool label_last>
128  : public Label_wrapper<Layout_t, Checkbox_type, Layout_t, label_last> {
129  private:
131 
132  public:
133  using Label_wrapper_t = Base_t;
134  using Checkbox_t = Checkbox_type;
135  using Label_t = Label<Layout_t>;
136 
137  public:
138  Checkbox_t& checkbox = Base_t::wrapped;
139  Label_t& label = Base_t::label;
140 
141  public:
142  explicit Label_checkbox_impl(
143  typename Base_t::Parameters label_parameters = {},
144  typename Checkbox_t::Parameters checkbox_parameters = {})
145  : Base_t{std::move(label_parameters), std::move(checkbox_parameters)}
146  {
147  using namespace pipe;
148  Base_t::label | on_mouse_press([&](auto) { checkbox.toggle(); });
149  Base_t::padding | on_mouse_press([&](auto) { checkbox.toggle(); });
150  }
151 
152  private:
153  using Base_t::wrapped;
154 };
155 
156 } // namespace ox::detail
157 
158 namespace ox {
159 
161 
162 template <typename T>
163 inline auto constexpr make_labeled_cb_fn =
164  [](typename T::Label_wrapper_t::Parameters label_parameters = {},
165  typename T::Checkbox_t::Parameters checkbox_parameters = {})
166  -> std::unique_ptr<T> {
167  return std::make_unique<T>(std::move(label_parameters),
168  std::move(checkbox_parameters));
169 };
170 
172 
173 template <typename Checkbox_t>
174 inline auto constexpr make_checkbox_fn = Overload{
175  [](typename Checkbox_t::Parameters parameters = {})
176  -> std::unique_ptr<Checkbox_t> {
177  return std::make_unique<Checkbox_t>(std::move(parameters));
178  },
179  [](typename Checkbox_t::State initial_state,
180  bool locked) -> std::unique_ptr<Checkbox_t> {
181  return std::make_unique<Checkbox_t>(initial_state, locked);
182  },
183 };
184 
185 // ☒
186 class Checkbox1 : public HCheckbox {
187  public:
188  struct Parameters {
189  State initial_state = State::Unchecked;
190  bool locked = false;
191  };
192 
193  public:
194  Checkbox1(State initial_state = State::Unchecked, bool locked = false)
195  : HCheckbox{initial_state, {U"☒", U"☐"}, locked}
196  {}
197 
198  Checkbox1(Parameters p) : Checkbox1{p.initial_state, p.locked} {}
199 };
200 
201 inline auto constexpr checkbox1 = make_checkbox_fn<Checkbox1>;
202 
203 using HCheckbox1_label =
204  detail::Label_checkbox_impl<layout::Horizontal, Checkbox1, true>;
205 using HCheckbox_label = HCheckbox1_label;
206 
207 using HLabel_checkbox1 =
208  detail::Label_checkbox_impl<layout::Horizontal, Checkbox1, false>;
209 using HLabel_checkbox = HLabel_checkbox1;
210 
211 using VCheckbox1_label =
212  detail::Label_checkbox_impl<layout::Vertical, Checkbox1, true>;
213 using VCheckbox_label = VCheckbox1_label;
214 
215 using VLabel_checkbox1 =
216  detail::Label_checkbox_impl<layout::Vertical, Checkbox1, false>;
217 using VLabel_checkbox = VLabel_checkbox1;
218 
219 inline auto constexpr hcheckbox1_label = make_labeled_cb_fn<HCheckbox_label>;
220 inline auto constexpr hcheckbox_label = hcheckbox1_label;
221 inline auto constexpr hlabel_checkbox1 = make_labeled_cb_fn<HLabel_checkbox>;
222 inline auto constexpr hlabel_checkbox = hlabel_checkbox1;
223 inline auto constexpr vcheckbox1_label = make_labeled_cb_fn<VCheckbox_label>;
224 inline auto constexpr vcheckbox_label = vcheckbox1_label;
225 inline auto constexpr vlabel_checkbox1 = make_labeled_cb_fn<VLabel_checkbox>;
226 inline auto constexpr vlabel_checkbox = vlabel_checkbox1;
227 
228 // [x]
229 class Checkbox2 : public HCheckbox {
230  public:
231  struct Parameters {
232  State initial_state = State::Unchecked;
233  bool locked = false;
234  };
235 
236  public:
237  Checkbox2(State initial_state = State::Unchecked, bool locked = false)
238  : HCheckbox{initial_state, {U"[x]", U"[ ]"}, locked}
239  {}
240 
241  Checkbox2(Parameters p) : Checkbox2{p.initial_state, p.locked} {}
242 };
243 
244 inline auto constexpr checkbox2 = make_checkbox_fn<Checkbox2>;
245 
246 using HCheckbox2_label =
247  detail::Label_checkbox_impl<layout::Horizontal, Checkbox2, true>;
248 using HLabel_checkbox2 =
249  detail::Label_checkbox_impl<layout::Horizontal, Checkbox2, false>;
250 using VCheckbox2_label =
251  detail::Label_checkbox_impl<layout::Vertical, Checkbox2, true>;
252 using VLabel_checkbox2 =
253  detail::Label_checkbox_impl<layout::Vertical, Checkbox2, false>;
254 
255 inline auto constexpr hcheckbox2_label = make_labeled_cb_fn<HCheckbox2_label>;
256 inline auto constexpr hlabel_checkbox2 = make_labeled_cb_fn<HLabel_checkbox2>;
257 inline auto constexpr vcheckbox2_label = make_labeled_cb_fn<VCheckbox2_label>;
258 inline auto constexpr vlabel_checkbox2 = make_labeled_cb_fn<VLabel_checkbox2>;
259 
260 // ┌
261 // x
262 // └
263 class Checkbox3 : public VCheckbox {
264  public:
265  struct Parameters {
266  State initial_state = State::Unchecked;
267  bool locked = false;
268  };
269 
270  public:
271  Checkbox3(State initial_state = State::Unchecked, bool locked = false)
272  : VCheckbox{initial_state, {U"┌x└", U"┌ └"}, locked}
273  {}
274 
275  Checkbox3(Parameters p) : Checkbox3{p.initial_state, p.locked} {}
276 };
277 
278 inline auto constexpr checkbox3 = make_checkbox_fn<Checkbox3>;
279 
280 using HCheckbox3_label =
281  detail::Label_checkbox_impl<layout::Horizontal, Checkbox3, true>;
282 
283 inline auto constexpr hcheckbox3_label = make_labeled_cb_fn<HCheckbox3_label>;
284 
285 // ┐
286 // x
287 // ┘
288 class Checkbox4 : public VCheckbox {
289  public:
290  struct Parameters {
291  State initial_state = State::Unchecked;
292  bool locked = false;
293  };
294 
295  public:
296  Checkbox4(State initial_state = State::Unchecked, bool locked = false)
297  : VCheckbox{initial_state, {U"┐x┘", U"┐ ┘"}, locked}
298  {}
299 
300  Checkbox4(Parameters p) : Checkbox4{p.initial_state, p.locked} {}
301 };
302 
303 inline auto constexpr checkbox4 = make_checkbox_fn<Checkbox4>;
304 
305 using HLabel_checkbox4 =
306  detail::Label_checkbox_impl<layout::Horizontal, Checkbox4, false>;
307 
308 inline auto constexpr hlabel_checkbox4 = make_labeled_cb_fn<HLabel_checkbox4>;
309 
310 // ┌x┐
311 class Checkbox5 : public HCheckbox {
312  public:
313  struct Parameters {
314  State initial_state = State::Unchecked;
315  bool locked = false;
316  };
317 
318  public:
319  Checkbox5(State initial_state = State::Unchecked, bool locked = false)
320  : HCheckbox{initial_state, {U"┌x┐", U"┌ ┐"}, locked}
321  {}
322 
323  Checkbox5(Parameters p) : Checkbox5{p.initial_state, p.locked} {}
324 };
325 
326 inline auto constexpr checkbox5 = make_checkbox_fn<Checkbox5>;
327 
328 using VCheckbox5_label =
329  detail::Label_checkbox_impl<layout::Vertical, Checkbox5, true>;
330 
331 inline auto constexpr vcheckbox5_label = make_labeled_cb_fn<VCheckbox5_label>;
332 
333 // └x┘
334 class Checkbox6 : public HCheckbox {
335  public:
336  struct Parameters {
337  State initial_state = State::Unchecked;
338  bool locked = false;
339  };
340 
341  public:
342  Checkbox6(State initial_state = State::Unchecked, bool locked = false)
343  : HCheckbox{initial_state, {U"└x┘", U"└ ┘"}, locked}
344  {}
345 
346  Checkbox6(Parameters p) : Checkbox6{p.initial_state, p.locked} {}
347 };
348 
349 inline auto constexpr checkbox6 = make_checkbox_fn<Checkbox6>;
350 
351 using VLabel_checkbox6 =
352  detail::Label_checkbox_impl<layout::Vertical, Checkbox6, false>;
353 
354 inline auto constexpr vlabel_checkbox6 = make_labeled_cb_fn<VLabel_checkbox6>;
355 
356 // ╭
357 // x
358 // ╰
359 class Checkbox7 : public VCheckbox {
360  public:
361  struct Parameters {
362  State initial_state = State::Unchecked;
363  bool locked = false;
364  };
365 
366  public:
367  Checkbox7(State initial_state = State::Unchecked, bool locked = false)
368  : VCheckbox{initial_state, {U"╭x╰", U"╭ ╰"}, locked}
369  {}
370 
371  Checkbox7(Parameters p) : Checkbox7{p.initial_state, p.locked} {}
372 };
373 
374 inline auto constexpr checkbox7 = make_checkbox_fn<Checkbox7>;
375 
376 using HCheckbox7_label =
377  detail::Label_checkbox_impl<layout::Horizontal, Checkbox7, true>;
378 
379 inline auto constexpr hcheckbox7_label = make_labeled_cb_fn<HCheckbox7_label>;
380 
381 // ╮
382 // x
383 // ╯
384 class Checkbox8 : public VCheckbox {
385  public:
386  struct Parameters {
387  State initial_state = State::Unchecked;
388  bool locked = false;
389  };
390 
391  public:
392  Checkbox8(State initial_state = State::Unchecked, bool locked = false)
393  : VCheckbox{initial_state, {U"╮x╯", U"╮ ╯"}, locked}
394  {}
395 
396  Checkbox8(Parameters p) : Checkbox8{p.initial_state, p.locked} {}
397 };
398 
399 inline auto constexpr checkbox8 = make_checkbox_fn<Checkbox8>;
400 
401 using HLabel_checkbox8 =
402  detail::Label_checkbox_impl<layout::Horizontal, Checkbox8, false>;
403 
404 inline auto constexpr hlabel_checkbox8 = make_labeled_cb_fn<HLabel_checkbox8>;
405 
406 // ╭x╮
407 class Checkbox9 : public HCheckbox {
408  public:
409  struct Parameters {
410  State initial_state = State::Unchecked;
411  bool locked = false;
412  };
413 
414  public:
415  Checkbox9(State initial_state = State::Unchecked, bool locked = false)
416  : HCheckbox{initial_state, {U"╭x╮", U"╭ ╮"}, locked}
417  {}
418 
419  Checkbox9(Parameters p) : Checkbox9{p.initial_state, p.locked} {}
420 };
421 
422 inline auto constexpr checkbox9 = make_checkbox_fn<Checkbox9>;
423 
424 using VCheckbox9_label =
425  detail::Label_checkbox_impl<layout::Vertical, Checkbox9, true>;
426 
427 inline auto constexpr vcheckbox9_label = make_labeled_cb_fn<VCheckbox9_label>;
428 
429 // ╰x╯
430 class Checkbox10 : public HCheckbox {
431  public:
432  struct Parameters {
433  State initial_state = State::Unchecked;
434  bool locked = false;
435  };
436 
437  public:
438  Checkbox10(State initial_state = State::Unchecked, bool locked = false)
439  : HCheckbox{initial_state, {U"╰x╯", U"╰ ╯"}, locked}
440  {}
441 
442  Checkbox10(Parameters p) : Checkbox10{p.initial_state, p.locked} {}
443 };
444 
445 inline auto constexpr checkbox10 = make_checkbox_fn<Checkbox10>;
446 
447 using VLabel_checkbox10 =
448  detail::Label_checkbox_impl<layout::Vertical, Checkbox10, false>;
449 
450 inline auto constexpr vlabel_checkbox10 = make_labeled_cb_fn<VLabel_checkbox10>;
451 
452 // -----------------------------------------------------------------------------
453 
454 // ┘
455 // ╴
456 // ┐
457 class Checkbox11 : public VCheckbox {
458  public:
459  struct Parameters {
460  State initial_state = State::Unchecked;
461  bool locked = false;
462  };
463 
464  public:
465  Checkbox11(State initial_state = State::Unchecked, bool locked = false)
466  : VCheckbox{initial_state, {U"┘╴┐", U"┘ ┐"}, locked}
467  {}
468 
469  Checkbox11(Parameters p) : Checkbox11{p.initial_state, p.locked} {}
470 };
471 
472 inline auto constexpr checkbox11 = make_checkbox_fn<Checkbox11>;
473 
474 using HCheckbox11_label =
475  detail::Label_checkbox_impl<layout::Horizontal, Checkbox11, true>;
476 
477 inline auto constexpr hcheckbox11_label = make_labeled_cb_fn<HCheckbox11_label>;
478 
479 // └
480 // ╶
481 // ┌
482 class Checkbox12 : public VCheckbox {
483  public:
484  struct Parameters {
485  State initial_state = State::Unchecked;
486  bool locked = false;
487  };
488 
489  public:
490  Checkbox12(State initial_state = State::Unchecked, bool locked = false)
491  : VCheckbox{initial_state, {U"└╶┌", U"└ ┌"}, locked}
492  {}
493 
494  Checkbox12(Parameters p) : Checkbox12{p.initial_state, p.locked} {}
495 };
496 
497 inline auto constexpr checkbox12 = make_checkbox_fn<Checkbox12>;
498 
499 using HLabel_checkbox12 =
500  detail::Label_checkbox_impl<layout::Horizontal, Checkbox12, false>;
501 
502 inline auto constexpr hlabel_checkbox12 = make_labeled_cb_fn<HLabel_checkbox12>;
503 
504 // ┘╵└
505 class Checkbox13 : public HCheckbox {
506  public:
507  struct Parameters {
508  State initial_state = State::Unchecked;
509  bool locked = false;
510  };
511 
512  public:
513  Checkbox13(State initial_state = State::Unchecked, bool locked = false)
514  : HCheckbox{initial_state, {U"┘╵└", U"┘ └"}, locked}
515  {}
516 
517  Checkbox13(Parameters p) : Checkbox13{p.initial_state, p.locked} {}
518 };
519 
520 inline auto constexpr checkbox13 = make_checkbox_fn<Checkbox13>;
521 
522 using VCheckbox13_label =
523  detail::Label_checkbox_impl<layout::Vertical, Checkbox13, true>;
524 
525 inline auto constexpr vcheckbox13_label = make_labeled_cb_fn<VCheckbox13_label>;
526 
527 // ┐╷┌
528 class Checkbox14 : public HCheckbox {
529  public:
530  struct Parameters {
531  State initial_state = State::Unchecked;
532  bool locked = false;
533  };
534 
535  public:
536  Checkbox14(State initial_state = State::Unchecked, bool locked = false)
537  : HCheckbox{initial_state, {U"┐╷┌", U"┐ ┌"}, locked}
538  {}
539 
540  Checkbox14(Parameters p) : Checkbox14{p.initial_state, p.locked} {}
541 };
542 
543 inline auto constexpr checkbox14 = make_checkbox_fn<Checkbox14>;
544 
545 using VLabel_checkbox14 =
546  detail::Label_checkbox_impl<layout::Vertical, Checkbox14, false>;
547 
548 inline auto constexpr vlabel_checkbox14 = make_labeled_cb_fn<VLabel_checkbox14>;
549 
550 // ╯
551 // ╴
552 // ╮
553 class Checkbox15 : public VCheckbox {
554  public:
555  struct Parameters {
556  State initial_state = State::Unchecked;
557  bool locked = false;
558  };
559 
560  public:
561  Checkbox15(State initial_state = State::Unchecked, bool locked = false)
562  : VCheckbox{initial_state, {U"╯╴╮", U"╯ ╮"}, locked}
563  {}
564 
565  Checkbox15(Parameters p) : Checkbox15{p.initial_state, p.locked} {}
566 };
567 
568 inline auto constexpr checkbox15 = make_checkbox_fn<Checkbox15>;
569 
570 using HCheckbox15_label =
571  detail::Label_checkbox_impl<layout::Horizontal, Checkbox15, true>;
572 
573 inline auto constexpr hcheckbox15_label = make_labeled_cb_fn<HCheckbox15_label>;
574 
575 // ╰
576 // ╶
577 // ╭
578 class Checkbox16 : public VCheckbox {
579  public:
580  struct Parameters {
581  State initial_state = State::Unchecked;
582  bool locked = false;
583  };
584 
585  public:
586  Checkbox16(State initial_state = State::Unchecked, bool locked = false)
587  : VCheckbox{initial_state, {U"╰╶╭", U"╰ ╭"}, locked}
588  {}
589 
590  Checkbox16(Parameters p) : Checkbox16{p.initial_state, p.locked} {}
591 };
592 
593 inline auto constexpr checkbox16 = make_checkbox_fn<Checkbox16>;
594 
595 using HLabel_checkbox16 =
596  detail::Label_checkbox_impl<layout::Horizontal, Checkbox16, false>;
597 
598 inline auto constexpr hlabel_checkbox16 = make_labeled_cb_fn<HLabel_checkbox16>;
599 
600 // ╯╵╰
601 class Checkbox17 : public HCheckbox {
602  public:
603  struct Parameters {
604  State initial_state = State::Unchecked;
605  bool locked = false;
606  };
607 
608  public:
609  Checkbox17(State initial_state = State::Unchecked, bool locked = false)
610  : HCheckbox{initial_state, {U"╯╵╰", U"╯ ╰"}, locked}
611  {}
612 
613  Checkbox17(Parameters p) : Checkbox17{p.initial_state, p.locked} {}
614 };
615 
616 inline auto constexpr checkbox17 = make_checkbox_fn<Checkbox17>;
617 
618 using VCheckbox17_label =
619  detail::Label_checkbox_impl<layout::Vertical, Checkbox17, true>;
620 
621 inline auto constexpr vcheckbox17_label = make_labeled_cb_fn<VCheckbox17_label>;
622 
623 // ╮╷╭
624 class Checkbox18 : public HCheckbox {
625  public:
626  struct Parameters {
627  State initial_state = State::Unchecked;
628  bool locked = false;
629  };
630 
631  public:
632  Checkbox18(State initial_state = State::Unchecked, bool locked = false)
633  : HCheckbox{initial_state, {U"╮╷╭", U"╮ ╭"}, locked}
634  {}
635 
636  Checkbox18(Parameters p) : Checkbox18{p.initial_state, p.locked} {}
637 };
638 
639 inline auto constexpr checkbox18 = make_checkbox_fn<Checkbox18>;
640 
641 using VLabel_checkbox18 =
642  detail::Label_checkbox_impl<layout::Vertical, Checkbox18, false>;
643 
644 inline auto constexpr vlabel_checkbox18 = make_labeled_cb_fn<VLabel_checkbox18>;
645 
646 // -----------------------------------------------------------------------------
647 
648 // ├x┤
649 class Checkbox19 : public HCheckbox {
650  public:
651  struct Parameters {
652  State initial_state = State::Unchecked;
653  bool locked = false;
654  };
655 
656  public:
657  Checkbox19(State initial_state = State::Unchecked, bool locked = false)
658  : HCheckbox{initial_state, {U"├x┤", U"├ ┤"}, locked}
659  {}
660 
661  Checkbox19(Parameters p) : Checkbox19{p.initial_state, p.locked} {}
662 };
663 
664 inline auto constexpr checkbox19 = make_checkbox_fn<Checkbox19>;
665 
666 using HCheckbox19_label =
667  detail::Label_checkbox_impl<layout::Horizontal, Checkbox19, true>;
668 using HLabel_checkbox19 =
669  detail::Label_checkbox_impl<layout::Horizontal, Checkbox19, false>;
670 using VCheckbox19_label =
671  detail::Label_checkbox_impl<layout::Vertical, Checkbox19, true>;
672 using VLabel_checkbox19 =
673  detail::Label_checkbox_impl<layout::Vertical, Checkbox19, false>;
674 
675 inline auto constexpr hcheckbox19_label = make_labeled_cb_fn<HCheckbox19_label>;
676 inline auto constexpr hlabel_checkbox19 = make_labeled_cb_fn<HLabel_checkbox19>;
677 inline auto constexpr vcheckbox19_label = make_labeled_cb_fn<VCheckbox19_label>;
678 inline auto constexpr vlabel_checkbox19 = make_labeled_cb_fn<VLabel_checkbox19>;
679 
680 // ┤x├
681 class Checkbox20 : public HCheckbox {
682  public:
683  struct Parameters {
684  State initial_state = State::Unchecked;
685  bool locked = false;
686  };
687 
688  public:
689  Checkbox20(State initial_state = State::Unchecked, bool locked = false)
690  : HCheckbox{initial_state, {U"┤x├", U"┤ ├"}, locked}
691  {}
692 
693  Checkbox20(Parameters p) : Checkbox20{p.initial_state, p.locked} {}
694 };
695 
696 inline auto constexpr checkbox20 = make_checkbox_fn<Checkbox20>;
697 
698 using HCheckbox20_label =
699  detail::Label_checkbox_impl<layout::Horizontal, Checkbox20, true>;
700 using HLabel_checkbox20 =
701  detail::Label_checkbox_impl<layout::Horizontal, Checkbox20, false>;
702 using VCheckbox20_label =
703  detail::Label_checkbox_impl<layout::Vertical, Checkbox20, true>;
704 using VLabel_checkbox20 =
705  detail::Label_checkbox_impl<layout::Vertical, Checkbox20, false>;
706 
707 inline auto constexpr hcheckbox20_label = make_labeled_cb_fn<HCheckbox20_label>;
708 inline auto constexpr hlabel_checkbox20 = make_labeled_cb_fn<HLabel_checkbox20>;
709 inline auto constexpr vcheckbox20_label = make_labeled_cb_fn<VCheckbox20_label>;
710 inline auto constexpr vlabel_checkbox20 = make_labeled_cb_fn<VLabel_checkbox20>;
711 
712 } // namespace ox
713 
714 namespace ox::slot {
715 
716 template <template <typename> typename Layout_t>
717 auto toggle(Checkbox<Layout_t>& cb) -> sl::Slot<void()>;
718 
719 template <template <typename> typename Layout_t>
720 auto check(Checkbox<Layout_t>& cb) -> sl::Slot<void()>;
721 
722 template <template <typename> typename Layout_t>
723 auto uncheck(Checkbox<Layout_t>& cb) -> sl::Slot<void()>;
724 
725 } // namespace ox::slot
726 #endif // TERMOX_WIDGET_WIDGETS_CHECKBOX_HPP
Definition: checkbox.hpp:430
Definition: checkbox.hpp:457
Definition: checkbox.hpp:482
Definition: checkbox.hpp:505
Definition: checkbox.hpp:528
Definition: checkbox.hpp:553
Definition: checkbox.hpp:578
Definition: checkbox.hpp:601
Definition: checkbox.hpp:624
Definition: checkbox.hpp:649
Definition: checkbox.hpp:186
Definition: checkbox.hpp:681
Definition: checkbox.hpp:229
Definition: checkbox.hpp:263
Definition: checkbox.hpp:288
Definition: checkbox.hpp:311
Definition: checkbox.hpp:334
Definition: checkbox.hpp:359
Definition: checkbox.hpp:384
Definition: checkbox.hpp:407
Checkbox Widget that is either checked or not checked.
Definition: checkbox.hpp:22
void uncheck()
Set the state to be unchecked.
Definition: checkbox.cpp:52
void toggle()
Change state to be unchecked if currently checked, checked otherwise.
Definition: checkbox.cpp:65
sl::Signal< void()> unchecked
Emitted when box becomes unchecked.
Definition: checkbox.hpp:45
void set_display(Display d)
Set the look of each Checkbox State.
Definition: checkbox.cpp:103
auto get_state() const -> State
Return the current state of the Checkbox as Checkbox::State enum value.
Definition: checkbox.cpp:74
auto get_display() -> Display
Return the look of each Checkbox State.
Definition: checkbox.cpp:114
Checkbox(State initial_state, Display display, bool locked)
Construct a new Checkbox.
Definition: checkbox.cpp:17
void lock()
Lock the Checkbox, it can not be toggled when locked.
Definition: checkbox.cpp:79
sl::Signal< void()> checked
Emitted when box becomes checked.
Definition: checkbox.hpp:42
void unlock()
Unlock the Checkbox, allowing it to be toggled.
Definition: checkbox.cpp:88
void check()
Set the state to be checked.
Definition: checkbox.cpp:38
sl::Signal< void()> toggled
Emitted every time the box changes state.
Definition: checkbox.hpp:48
auto is_locked() const -> bool
Return true if the Checkbox is locked.
Definition: checkbox.cpp:97
auto mouse_press_event(Mouse const &m) -> bool override
Handles Mouse_press_event objects.
Definition: checkbox.cpp:125
Holds a collection of Glyphs with a similar interface to std::string.
Definition: glyph_string.hpp:19
A single line of text with alignment, non-editable.
Definition: label.hpp:22
Label, buffer and Checkbox tuple implementation.
Definition: checkbox.hpp:128
Wraps a Widget_t object with a label.
Definition: label.hpp:171
Definition: checkbox.hpp:432
Definition: checkbox.hpp:459
Definition: checkbox.hpp:484
Definition: checkbox.hpp:507
Definition: checkbox.hpp:530
Definition: checkbox.hpp:555
Definition: checkbox.hpp:580
Definition: checkbox.hpp:603
Definition: checkbox.hpp:626
Definition: checkbox.hpp:651
Definition: checkbox.hpp:188
Definition: checkbox.hpp:683
Definition: checkbox.hpp:231
Definition: checkbox.hpp:265
Definition: checkbox.hpp:290
Definition: checkbox.hpp:313
Definition: checkbox.hpp:336
Definition: checkbox.hpp:361
Definition: checkbox.hpp:386
Definition: checkbox.hpp:409
Definition: checkbox.hpp:29
Definition: checkbox.hpp:34