Fix StyleBox ignoring region rect and ProgressBar using center size

ProgressBar used the center size of the stylebox to calculate its minimum size, thus disallowing certain setups.
If the old behaviour is wanted, it can be forced by providing a custom minimum size, or by giving proper margins to the stylebox.

Fixes #17779.
This commit is contained in:
Bojidar Marinov
2018-03-28 20:52:55 +03:00
parent 4b4ed9b724
commit 91eb80041d
2 changed files with 7 additions and 4 deletions

View File

@ -33,13 +33,16 @@
Size2 ProgressBar::get_minimum_size() const {
Ref<StyleBox> bg = get_stylebox("bg");
Ref<StyleBox> fg = get_stylebox("fg");
Ref<Font> font = get_font("font");
Size2 ms = bg->get_minimum_size() + bg->get_center_size();
Size2 minimum_size = bg->get_minimum_size();
minimum_size.height = MAX(minimum_size.height, fg->get_minimum_size().height);
minimum_size.width = MAX(minimum_size.width, fg->get_minimum_size().width);
if (percent_visible) {
ms.height = MAX(ms.height, bg->get_minimum_size().height + font->get_height());
minimum_size.height = MAX(minimum_size.height, bg->get_minimum_size().height + font->get_height());
}
return ms;
return minimum_size;
}
void ProgressBar::_notification(int p_what) {