1 #ifndef TERMOX_WIDGET_LAYOUT_FLOAT_HPP
2 #define TERMOX_WIDGET_LAYOUT_FLOAT_HPP
6 #include <termox/widget/layouts/horizontal.hpp>
7 #include <termox/widget/layouts/vertical.hpp>
8 #include <termox/widget/widget.hpp>
17 template <
template <
typename>
typename Layout_t,
typename Widget_t>
18 class Float :
public Layout_t<Widget> {
20 using Base_t = Layout_t<Widget>;
28 template <
typename... Args>
30 : buffer_1{this->
template make_child()},
32 this->
template make_child<Widget_t>(std::forward<Args>(args)...)},
33 buffer_2{this->
template make_child()}
35 this->update_policy();
39 auto child_polished_event(
Widget& child) ->
bool override
41 if (&child == &widget)
42 this->update_policy();
43 return Base_t::child_polished_event(child);
49 if constexpr (layout::is_horizontal_v<Base_t>)
50 this->height_policy = widget.height_policy;
52 this->width_policy = widget.width_policy;
56 template <
typename W
idget_t>
59 template <
typename Widget_t,
typename... Args>
60 [[nodiscard]]
inline auto vfloat(Args&&... args)
61 -> std::unique_ptr<VFloat<Widget_t>>
63 return std::make_unique<VFloat<Widget_t>>(std::forward<Args>(args)...);
66 template <
typename W
idget_t>
67 using HFloat = Float<layout::Horizontal, Widget_t>;
69 template <
typename Widget_t,
typename... Args>
70 [[nodiscard]]
inline auto hfloat(Args&&... args)
71 -> std::unique_ptr<HFloat<Widget_t>>
73 return std::make_unique<HFloat<Widget_t>>(std::forward<Args>(args)...);
76 template <
typename W
idget_t>
77 using Float_2d = VFloat<HFloat<Widget_t>>;
79 template <
typename Widget_t,
typename... Args>
80 [[nodiscard]]
inline auto float_2d(Args&&... args)
81 -> std::unique_ptr<Float_2d<Widget_t>>
83 return std::make_unique<Float_2d<Widget_t>>(std::forward<Args>(args)...);
Holds a given Widget_t object between two empty 'buffer' Widgets.
Definition: float.hpp:18