1 #ifndef TERMOX_WIDGET_WIDGETS_SELECTABLE_HPP
2 #define TERMOX_WIDGET_WIDGETS_SELECTABLE_HPP
3 #include <termox/painter/trait.hpp>
4 #include <termox/widget/pipe.hpp>
9 template <
typename Widget_t,
10 typename Select_method = void,
11 typename Unselect_method =
void>
16 : Widget_t{}, select_{std::move(s)}, unselect_{std::move(u)}
21 typename Widget_t::Parameters p)
22 : Widget_t{std::move(p)}, select_{std::move(s)}, unselect_{std::move(u)}
33 Select_method select_;
34 Unselect_method unselect_;
38 template <
typename W
idget_t,
typename Select_method,
typename Unselect_method>
39 [[nodiscard]]
auto selectable(Select_method s, Unselect_method u)
40 -> std::unique_ptr<Selectable<Widget_t, Select_method, Unselect_method>>
42 return std::make_unique<
43 Selectable<Widget_t, Select_method, Unselect_method>>(std::move(s),
48 template <
typename W
idget_t,
typename Select_method,
typename Unselect_method>
49 [[nodiscard]]
auto selectable(Select_method s,
51 typename Widget_t::Parameters p)
52 -> std::unique_ptr<Selectable<Widget_t, Select_method, Unselect_method>>
54 return std::make_unique<
55 Selectable<Widget_t, Select_method, Unselect_method>>(
56 std::move(s), std::move(u), std::move(p));
60 template <
typename W
idget_t>
61 class Selectable<Widget_t, void, void> :
public Widget_t {
63 using Parameters =
typename Widget_t::Parameters;
68 Selectable(Parameters p) : Widget_t{std::move(p)} {}
74 *
this | Trait::Inverse;
75 *
this | pipe::descendants() | Trait::Inverse;
81 *
this | pipe::discard(Trait::Inverse);
82 *
this | pipe::descendants() | pipe::discard(Trait::Inverse);
87 template <
typename W
idget_t>
88 [[nodiscard]]
auto selectable() -> std::unique_ptr<Selectable<Widget_t>>
90 return std::make_unique<Selectable<Widget_t>>();
94 template <
typename W
idget_t>
95 [[nodiscard]]
auto selectable(
typename Selectable<Widget_t>::Parameters p)
96 -> std::unique_ptr<Selectable<Widget_t>>
98 return std::make_unique<Selectable<Widget_t>>(std::move(p));
Wraps Widget_t to provide select() and unselect() methods to modify display.
Definition: selectable.hpp:12
void select()
Change visual to mark as selected.
Definition: selectable.hpp:27
void unselect()
Change visual to mark as unselected.
Definition: selectable.hpp:30
Selectable(Select_method s, Unselect_method u)
Provide two methods to modify Widget_t. Signature: void(Widget_t&);.
Definition: selectable.hpp:15