Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose and rename ItemList's _check_shape_changed to force_update_list_size #63634

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/classes/ItemList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
Ensure current selection is visible, adjusting the scroll position as necessary.
</description>
</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">
<return type="int" />
<param index="0" name="position" type="Vector2" />
Expand Down
6 changes: 4 additions & 2 deletions scene/gui/item_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ void ItemList::_notification(int p_what) {
} break;

case NOTIFICATION_DRAW: {
_check_shape_changed();
force_update_list_size();

int scroll_bar_minwidth = scroll_bar->get_minimum_size().x;
scroll_bar->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -scroll_bar_minwidth);
Expand Down Expand Up @@ -1314,7 +1314,7 @@ void ItemList::_notification(int p_what) {
}
}

void ItemList::_check_shape_changed() {
void ItemList::force_update_list_size() {
if (!shape_changed) {
return;
}
Expand Down Expand Up @@ -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("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::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");
Expand Down
3 changes: 2 additions & 1 deletion scene/gui/item_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ class ItemList : public Control {
} theme_cache;

void _scroll_changed(double);
void _check_shape_changed();
void _shape_text(int p_idx);
void _mouse_exited();

Expand Down Expand Up @@ -281,6 +280,8 @@ class ItemList : public Control {

void set_autoscroll_to_bottom(const bool p_enable);

void force_update_list_size();

VScrollBar *get_v_scroll_bar() { return scroll_bar; }

ItemList();
Expand Down