Parcourir la source

Update OptionButton min size when disabling Fit to Longest Item

Haoyu Qiu il y a 2 ans
Parent
commit
5384c1a579
1 fichiers modifiés avec 5 ajouts et 7 suppressions
  1. 5 7
      scene/gui/option_button.cpp

+ 5 - 7
scene/gui/option_button.cpp

@@ -445,13 +445,11 @@ void OptionButton::_select_int(int p_which) {
 void OptionButton::_refresh_size_cache() {
 	cache_refresh_pending = false;
 
-	if (!fit_to_longest_item) {
-		return;
-	}
-
-	_cached_size = Vector2();
-	for (int i = 0; i < get_item_count(); i++) {
-		_cached_size = _cached_size.max(get_minimum_size_for_text_and_icon(popup->get_item_xl_text(i), get_item_icon(i)));
+	if (fit_to_longest_item) {
+		_cached_size = Vector2();
+		for (int i = 0; i < get_item_count(); i++) {
+			_cached_size = _cached_size.max(get_minimum_size_for_text_and_icon(popup->get_item_xl_text(i), get_item_icon(i)));
+		}
 	}
 	update_minimum_size();
 }