From 847f43bf1e15320d335438f30a190bdff3346598 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 10 Feb 2019 03:54:36 -0800 Subject: [PATCH] new tool button sizing algorithm, fixes #471 --- panels/timeline.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 4e67d256e..192cc5717 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -535,14 +535,27 @@ void Timeline::resizeEvent(QResizeEvent *) { // resize tool button widget to its contents QList tool_button_children = tool_button_widget->findChildren(); - int total_client_height = 0; - int horizontal_spacing = static_cast(tool_button_widget->layout())->horizontalSpacing(); - int vertical_spacing = static_cast(tool_button_widget->layout())->verticalSpacing(); - for (int i=0;iheight() + vertical_spacing; - } - int comp_height = tool_button_widget->height(); - int cols = qCeil(double(total_client_height)/double(comp_height)); + + int horizontal_spacing = static_cast(tool_button_widget->layout())->horizontalSpacing(); + int vertical_spacing = static_cast(tool_button_widget->layout())->verticalSpacing(); + int total_area = tool_button_widget->height(); + + int button_count = tool_button_children.size(); + int button_height = tool_button_children.at(0)->sizeHint().height() + vertical_spacing; + + int cols = 0; + + int col_height; + + if (button_height < total_area) { + do { + cols++; + col_height = (qCeil(double(button_count)/double(cols))*button_height)-vertical_spacing; + } while (col_height > total_area); + } else { + cols = button_count; + } + tool_button_widget->setFixedWidth((tool_button_children.at(0)->sizeHint().width())*cols + horizontal_spacing*(cols-1) + 1); }