25 const std::vector<bool>& er,
26 const std::vector<bool>& ec,
31 , combined_padding(cp)
40 update_max(T* t, T value)
50 const std::vector<std::shared_ptr<Widget>>& widgets
57 for(
const auto& w: widgets)
59 const auto& d = w->layout;
60 const auto& s = w->get_preferred_size();
61 update_max(&width[d.column], s.width);
62 update_max(&height[d.row], s.height);
67 std::accumulate(width.begin(), width.end(), 0.0f),
68 std::accumulate(height.begin(), height.end(), 0.0f)
78 std::vector<std::shared_ptr<Widget>>* widgets,
86 for(
const auto& w: *widgets)
88 const auto& d = w->layout;
89 const auto& s = w->get_preferred_size();
90 update_max(&width[d.column], s.width);
91 update_max(&height[d.row], s.height);
94 const float total_width = std::accumulate(width.begin(), width.end(), 0.0f);
95 const float total_height = std::accumulate(height.begin(), height.end(), 0.0f);
97 const float leftover_width = area.
get_width() - total_width;
98 const float leftover_height = area.
get_height() - total_height;
109 if(expandable_rows_count != 0)
111 const float extra = leftover_height /
c_int_to_float(expandable_rows_count);
112 for(
unsigned int row_index = 0; row_index <
expandable_rows.size(); ++row_index)
116 height[row_index] += extra;
121 if(expandable_cols_count != 0)
123 const float extra = leftover_width /
c_int_to_float(expandable_cols_count);
124 for(
unsigned int column_index = 0; column_index <
expandable_cols.size(); ++column_index)
128 width[column_index] += extra;
133 for(
const auto& w: *widgets)
140 for(
int column_index = 0; column_index < d.column; ++column_index)
142 x += width[column_index];
144 for(
int row_index = 0; row_index < d.row; ++row_index)
146 y -= height[row_index];
171 const std::vector<std::shared_ptr<Widget>>& widgets
178 for(
const auto& w: widgets)
180 const auto& s = w->get_preferred_size();
187 update_max(&height, s.height);
198 std::vector<std::shared_ptr<Widget>>* widgets,
204 for(
const auto& w: *widgets)
206 const auto& s = w->get_preferred_size();
int c_sizet_to_int(size_t t)
constexpr float c_int_to_float(int i)
size2f max(const size2f lhs, const size2f rhs)
String utility functions.
vec2f get_top_left() const
static Rectf from_top_left_width_height(const vec2f &topleft, float width, float height)
size2f calc_minimum_area(const std::vector< std::shared_ptr< Widget >> &widgets) const override
void lay_out(std::vector< std::shared_ptr< Widget >> *widgets, const Rectf &area) const override
SingleRowLayout(float padding)
size2f calc_minimum_area(const std::vector< std::shared_ptr< Widget >> &widgets) const override
std::vector< bool > expandable_rows
TableLayout(const std::vector< bool > &er, const std::vector< bool > &ec, float cp)
void lay_out(std::vector< std::shared_ptr< Widget >> *widgets, const Rectf &area) const override
std::vector< bool > expandable_cols
static size2f create_from_width_height(float w, float h)