Expose force_update_list_size

Rename ItemList::_check_shape_changed to force_update_list_size

`force_update_list_size` is especially useful for updating the auto_height_value early
This commit is contained in:
George L. Albany 2022-07-29 12:49:14 -04:00 committed by Spartan322
parent 787259441a
commit 421e8c5455
No known key found for this signature in database
GPG Key ID: 5CBC2DF92079812E
3 changed files with 12 additions and 3 deletions

View File

@ -57,6 +57,12 @@
Ensure current selection is visible, adjusting the scroll position as necessary. Ensure current selection is visible, adjusting the scroll position as necessary.
</description> </description>
</method> </method>
<method name="force_update_list_size">
<return type="void" />
<description>
Forces an update to the list size based on its items. This happens automatically whenever size of the items, or other relevant settings like [member auto_height], change. The method can be used to trigger the update ahead of next drawing pass.
</description>
</method>
<method name="get_item_at_position" qualifiers="const"> <method name="get_item_at_position" qualifiers="const">
<return type="int" /> <return type="int" />
<param index="0" name="position" type="Vector2" /> <param index="0" name="position" type="Vector2" />

View File

@ -1011,7 +1011,7 @@ void ItemList::_notification(int p_what) {
} break; } break;
case NOTIFICATION_DRAW: { case NOTIFICATION_DRAW: {
_check_shape_changed(); force_update_list_size();
int scroll_bar_minwidth = scroll_bar->get_minimum_size().x; int scroll_bar_minwidth = scroll_bar->get_minimum_size().x;
scroll_bar->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -scroll_bar_minwidth); scroll_bar->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -scroll_bar_minwidth);
@ -1314,7 +1314,7 @@ void ItemList::_notification(int p_what) {
} }
} }
void ItemList::_check_shape_changed() { void ItemList::force_update_list_size() {
if (!shape_changed) { if (!shape_changed) {
return; return;
} }
@ -1855,6 +1855,8 @@ void ItemList::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_text_overrun_behavior", "overrun_behavior"), &ItemList::set_text_overrun_behavior); ClassDB::bind_method(D_METHOD("set_text_overrun_behavior", "overrun_behavior"), &ItemList::set_text_overrun_behavior);
ClassDB::bind_method(D_METHOD("get_text_overrun_behavior"), &ItemList::get_text_overrun_behavior); ClassDB::bind_method(D_METHOD("get_text_overrun_behavior"), &ItemList::get_text_overrun_behavior);
ClassDB::bind_method(D_METHOD("force_update_list_size"), &ItemList::force_update_list_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "select_mode", PROPERTY_HINT_ENUM, "Single,Multi"), "set_select_mode", "get_select_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "select_mode", PROPERTY_HINT_ENUM, "Single,Multi"), "set_select_mode", "get_select_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_reselect"), "set_allow_reselect", "get_allow_reselect"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_reselect"), "set_allow_reselect", "get_allow_reselect");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_rmb_select"), "set_allow_rmb_select", "get_allow_rmb_select"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_rmb_select"), "set_allow_rmb_select", "get_allow_rmb_select");

View File

@ -148,7 +148,6 @@ private:
} theme_cache; } theme_cache;
void _scroll_changed(double); void _scroll_changed(double);
void _check_shape_changed();
void _shape_text(int p_idx); void _shape_text(int p_idx);
void _mouse_exited(); void _mouse_exited();
@ -281,6 +280,8 @@ public:
void set_autoscroll_to_bottom(const bool p_enable); void set_autoscroll_to_bottom(const bool p_enable);
void force_update_list_size();
VScrollBar *get_v_scroll_bar() { return scroll_bar; } VScrollBar *get_v_scroll_bar() { return scroll_bar; }
ItemList(); ItemList();