1 #ifndef TERMOX_WIDGET_WIDGETS_HIDEABLE_HPP
2 #define TERMOX_WIDGET_WIDGETS_HIDEABLE_HPP
5 #include <termox/widget/layouts/stack.hpp>
6 #include <termox/widget/pair.hpp>
7 #include <termox/widget/widget.hpp>
12 template <
typename W
idget_t>
15 using Parameters =
typename Widget_t::Parameter;
18 Widget_t& w = this->second;
23 this->set_active_page(widget_index_);
24 this->give_focus_on_change(
false);
31 this->set_active_page(widget_index_);
32 this->give_focus_on_change(
false);
37 void show() { this->set_active_page(widget_index_); }
40 void hide() { this->set_active_page(blank_index_); }
45 return this->active_page_index() == blank_index_;
49 static constexpr
auto blank_index_ = 0uL;
50 static constexpr
auto widget_index_ = 1uL;
54 template <
typename W
idget_t>
55 [[nodiscard]]
auto hideable() -> std::unique_ptr<Hideable<Widget_t>>
57 return std::make_unique<Hideable<Widget_t>>();
61 template <
typename W
idget_t>
62 [[nodiscard]]
auto hideable(
typename Hideable<Widget_t>::Parameters p)
63 -> std::unique_ptr<Hideable<Widget_t>>
65 return std::make_unique<Hideable<Widget_t>>(std::move(p));
Policy to make any Widget or Layout hideable with a hide() and show() method.
Definition: hideable.hpp:13
auto is_hidden() const -> bool
Return if w is hidden.
Definition: hideable.hpp:43
void hide()
Display nothing on the widget space.
Definition: hideable.hpp:40
void show()
Display the held widget.
Definition: hideable.hpp:37
Hideable(Parameters p)
Forward constructor Parameters for the Widget_t that is being wrapped.
Definition: hideable.hpp:29
Heterogeneous pair of Widgets within a Layout.
Definition: pair.hpp:14