diff --git a/src/layout.cpp b/src/layout.cpp index fe061eb..ee08fd6 100644 --- a/src/layout.cpp +++ b/src/layout.cpp @@ -57,6 +57,9 @@ auto HorizontalLayout ::relayout(Position position, const Size size) -> void { } else { recommended_size.width = hint.width; } + if (hint.height > 0) { + recommended_size.height = hint.height; + } position.x += padding.start; if (auto item = item_iterator.lock()) { item->relayout(position, recommended_size); @@ -77,8 +80,12 @@ auto HorizontalLayout::size_hint() const -> Size { } found++; auto item_hint = item->size_hint(); - hint.height = std::max(item_hint.height, hint.height); - hint.width = std::max(item_hint.width, hint.width); + if (hint.height > 0) { + hint.height = std::max(item_hint.height, hint.height); + } + if (hint.width > 0) { + hint.width = std::max(item_hint.width, hint.width); + } } } @@ -144,6 +151,10 @@ auto VerticalLayout::relayout(Position position, const Size size) -> void { } else { recommended_size.height = hint.height; } + // TODO - this breaks the display. I think the type hints is borked. + if (hint.width > 0) { + // recommended_size.width = hint.width; + } position.y += padding.top; if (auto item = item_iterator.lock()) { item->relayout(position, recommended_size); @@ -161,8 +172,12 @@ auto VerticalLayout::size_hint() const -> Size { if (auto item = item_iterator.lock()) { found++; auto item_hint = item->size_hint(); - hint.height = std::max(item_hint.height, hint.height); - hint.width = std::max(item_hint.width, hint.width); + if (hint.height > 0) { + hint.height = std::max(item_hint.height, hint.height); + } + if (hint.width > 0) { + hint.width = std::max(item_hint.width, hint.width); + } } } diff --git a/src/main.cxx b/src/main.cxx index 109f026..7d9356f 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -157,13 +157,13 @@ int main() { spdlog::info("Selected item {} with text {}", index, button.text); }; rb->radio_buttons[1]->is_enabled = false; - w1->add_new(Position{10, 280}, 200, - std::vector{ - "Spring", - "Summer", - "Autumn/Fall", - "Winter", - }); + w1->add_new_to_layout(l1, Position{10, 280}, 200, + std::vector{ + "Spring", + "Summer", + "Autumn/Fall", + "Winter", + }); // w1->add_new_to_layout