1 #ifndef TERMOX_WIDGET_LAYOUTS_DETAIL_UNIQUE_SPACE_HPP
2 #define TERMOX_WIDGET_LAYOUTS_DETAIL_UNIQUE_SPACE_HPP
7 #include <termox/widget/widget.hpp>
9 namespace ox::layout::detail {
12 template <
typename Parameters>
15 using Length_list = std::vector<int>;
16 using Position_list = std::vector<int>;
19 [[nodiscard]]
auto calculate_lengths(
Widget& parent) -> Length_list
21 auto result = Length_list{};
22 auto const limit =
typename Parameters::Secondary::get_length{}(parent);
24 auto begin = std::next(std::begin(children), offset_);
25 auto const end = std::end(children);
27 for (; begin != end; ++begin) {
29 typename Parameters::Secondary::get_policy{}(*begin);
30 if (limit > policy.max())
31 result.push_back(policy.max());
32 else if (limit < policy.min() && !policy.can_ignore_min())
35 result.push_back(limit);
40 [[nodiscard]]
auto calculate_positions(Length_list
const& lengths)
43 return Position_list(lengths.size(), 0);
47 [[nodiscard]]
auto get_offset() const -> std::
size_t {
return offset_; }
53 std::size_t offset_ = 0;
Gives space to child Widgets where each gets full use of the length.
Definition: unique_space.hpp:13
void set_offset(std::size_t index)
Sets the child Widget offset, does not do bounds checking.
Definition: unique_space.hpp:50
auto get_offset() const -> std::size_t
Return the child Widget offset, the first widget included in the layout.
Definition: unique_space.hpp:47