1 #ifndef TERMOX_WIDGET_WIDGETS_CYCLE_STACK_HPP
2 #define TERMOX_WIDGET_WIDGETS_CYCLE_STACK_HPP
7 #include <termox/painter/glyph_string.hpp>
8 #include <termox/widget/layouts/stack.hpp>
9 #include <termox/widget/pair.hpp>
10 #include <termox/widget/tuple.hpp>
11 #include <termox/widget/widget.hpp>
12 #include <termox/widget/widgets/button.hpp>
13 #include <termox/widget/widgets/cycle_box.hpp>
15 namespace ox::detail {
20 Button& left_btn = this->get<0>();
22 Button& right_btn = this->get<2>();
32 template <
typename Child = W
idget>
45 std::move(parameters)}
48 template <
typename... Widget_t>
50 std::pair<
Glyph_string, std::unique_ptr<Widget_t>>... children)
55 std::move(children.second)),
63 template <
typename Widget_t = Child,
typename... Args>
66 static_assert(std::is_base_of<Child, Widget_t>::value,
67 "Cycle_stack::make_page: Widget_t must be a Child type");
68 auto child = std::make_unique<Widget_t>(std::forward<Args>(args)...);
69 return static_cast<Widget_t&
>(
70 this->
append_page(std::move(title), std::move(child)));
78 auto& signal = top_row.cycle_box.
add_option(std::move(title));
79 signal.connect(slot::set_active_page(stack, stack.size()));
80 auto& child = stack.append_page(std::move(widget));
81 if (stack.size() == 1)
82 stack.set_active_page(0);
88 template <
typename Child = W
idget>
89 [[nodiscard]]
auto cycle_stack(
90 typename Cycle_stack<Child>::Parameters parameters)
91 -> std::unique_ptr<Cycle_stack<Child>>
93 return std::make_unique<Cycle_stack<Child>>(std::move(parameters));
97 template <
typename Child = Widget,
typename... Widget_t>
98 [[nodiscard]]
auto cycle_stack(
99 std::pair<Glyph_string, std::unique_ptr<Widget_t>>... children)
100 -> std::unique_ptr<Cycle_stack<Child>>
102 return std::make_unique<Cycle_stack<Child>>(std::move(children)...);
A rotating set of labels, emitting a Signal when the label is changed.
Definition: cycle_box.hpp:27
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
A layout::Stack with an interface to cycle through each Widget in the stack.
Definition: cycle_stack.hpp:33
auto make_page(Glyph_string title, Args &&... args) -> Widget_t &
Construct a new Widget_t object and add it to the end of the Stack.
Definition: cycle_stack.hpp:64
auto append_page(Glyph_string title, std::unique_ptr< Child > widget) -> Child &
Append a page to the Stack.
Definition: cycle_stack.hpp:75
Holds a collection of Glyphs with a similar interface to std::string.
Definition: glyph_string.hpp:19
Heterogeneous collection of Widgets within a Layout_t.
Definition: tuple.hpp:17
User interface to cycle through the pages of the Stack.
Definition: cycle_stack.hpp:18
A Layout enabling only a single Widget at a time.
Definition: stack.hpp:29
Heterogeneous pair of Widgets within a Layout.
Definition: pair.hpp:14