Use Vector* component-wise min/max/clamp functions where applicable

This commit is contained in:
A Thousand Ships
2024-03-03 12:49:08 +01:00
parent fe01776f05
commit 79ba22a73f
53 changed files with 95 additions and 176 deletions

View File

@@ -35,15 +35,13 @@
Size2 ProgressBar::get_minimum_size() const {
Size2 minimum_size = theme_cache.background_style->get_minimum_size();
minimum_size.height = MAX(minimum_size.height, theme_cache.fill_style->get_minimum_size().height);
minimum_size.width = MAX(minimum_size.width, theme_cache.fill_style->get_minimum_size().width);
minimum_size = minimum_size.max(theme_cache.fill_style->get_minimum_size());
if (show_percentage) {
String txt = "100%";
TextLine tl = TextLine(txt, theme_cache.font, theme_cache.font_size);
minimum_size.height = MAX(minimum_size.height, theme_cache.background_style->get_minimum_size().height + tl.get_size().y);
} else { // this is needed, else the progressbar will collapse
minimum_size.width = MAX(minimum_size.width, 1);
minimum_size.height = MAX(minimum_size.height, 1);
minimum_size = minimum_size.max(Size2(1, 1));
}
return minimum_size;
}