1 #ifndef TERMOX_WIDGET_WIDGETS_CYCLE_BOX_HPP
2 #define TERMOX_WIDGET_WIDGETS_CYCLE_BOX_HPP
8 #include <signals_light/signal.hpp>
10 #include <termox/painter/glyph.hpp>
11 #include <termox/painter/glyph_string.hpp>
12 #include <termox/system/key.hpp>
13 #include <termox/system/mouse.hpp>
14 #include <termox/widget/align.hpp>
15 #include <termox/widget/growth.hpp>
16 #include <termox/widget/tuple.hpp>
17 #include <termox/widget/widgets/label.hpp>
18 #include <termox/widget/widgets/tile.hpp>
30 Align alignment = Align::Center;
33 Growth growth_strategy = Growth::Static;
76 [[nodiscard]]
auto size() const -> std::
size_t;
89 sl::Signal<void()> enabled = {};
93 std::vector<Option> options_;
94 std::size_t index_ = 0;
98 [[nodiscard]]
auto current_option_label() const -> Glyph_string;
101 [[nodiscard]] auto find(std::
string const& label)
102 -> decltype(options_)::iterator;
109 [[nodiscard]] auto cycle_box(
Cycle_box::Parameters = {})
110 -> std::unique_ptr<Cycle_box>;
120 HLabel& label = this->get<0>();
121 Tile& div = this->get<1>();
131 [[nodiscard]]
auto labeled_cycle_box(
Glyph_string label = U
"")
132 -> std::unique_ptr<Labeled_cycle_box>;
136 -> std::unique_ptr<Labeled_cycle_box>;
142 [[nodiscard]]
auto add_option(Cycle_box& cb) -> sl::Slot<void(Glyph_string)>;
144 [[nodiscard]]
auto add_option(Cycle_box& cb, Glyph_string
const& label)
147 [[nodiscard]]
auto remove_option(Cycle_box& cb)
148 -> sl::Slot<void(std::string
const&)>;
150 [[nodiscard]]
auto remove_option(Cycle_box& cb, std::string
const& label)
153 [[nodiscard]]
auto next(Cycle_box& cb) -> sl::Slot<void()>;
155 [[nodiscard]]
auto previous(Cycle_box& cb) -> sl::Slot<void()>;
A rotating set of labels, emitting a Signal when the label is changed.
Definition: cycle_box.hpp:27
sl::Signal< void(std::string)> option_changed
Emitted when the option is changed, sends the new option's string rep.
Definition: cycle_box.hpp:38
Cycle_box(Align alignment=Align::Center, int extra_left=0, int extra_right=0, Growth growth_strategy=Growth::Static)
Given Label parameters are applied to each option's display.
Definition: cycle_box.cpp:42
void set_current_option(std::string const &label)
Set the current option to the option with label identifier.
Definition: cycle_box.cpp:89
auto mouse_wheel_event(Mouse const &m) -> bool override
Handles Mouse_wheel_event objects.
Definition: cycle_box.cpp:114
auto size() const -> std::size_t
Return the number of options in the Cycle_box.
Definition: cycle_box.cpp:102
auto mouse_press_event(Mouse const &m) -> bool override
Handles Mouse_press_event objects.
Definition: cycle_box.cpp:104
auto add_option(Glyph_string label) -> sl::Signal< void()> &
Add an option/label to the Cycle_box using Label constructor parameters.
Definition: cycle_box.cpp:55
auto key_press_event(Key k) -> bool override
Handles Key_press_event objects.
Definition: cycle_box.cpp:124
void next()
Move forward one option.
Definition: cycle_box.cpp:73
void previous()
Move backward one option.
Definition: cycle_box.cpp:81
void remove_option(Glyph_string const &label)
Remove an option/label identified by its text.
Definition: cycle_box.cpp:63
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
auto alignment() const noexcept -> Align
Return the Align given to set_alignment().
Definition: label.cpp:111
auto extra_left() const noexcept -> int
Return the amount given to set_extra_left().
Definition: label.cpp:124
auto extra_right() const noexcept -> int
Return the amount given to set_extra_right().
Definition: label.cpp:137
auto growth_strategy() const noexcept -> Growth
Return the value given to set_growth_strategy().
Definition: label.cpp:155
A label on the left and a Cycle_box on the right.
Definition: cycle_box.hpp:113
A unit width/height Widget that can display a single Glyph.
Definition: tile.hpp:12
Heterogeneous collection of Widgets within a Layout_t.
Definition: tuple.hpp:17
Definition: cycle_box.hpp:29
Definition: cycle_box.hpp:115