Skip to content

Commit

Permalink
Merge pull request godotengine#55662 from KoBeWi/update_minimum_size_…
Browse files Browse the repository at this point in the history
…changed_to_update_minimum_size
  • Loading branch information
akien-mga authored Dec 6, 2021
2 parents 586c199 + ea7cc1d commit 75ac048
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 91 deletions.
12 changes: 6 additions & 6 deletions doc/classes/Control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,6 @@
Returns [code]true[/code] if layout is right-to-left.
</description>
</method>
<method name="minimum_size_changed">
<return type="void" />
<description>
Invalidates the size cache in this node and in parent nodes up to top_level. Intended to be used with [method get_minimum_size] when the return value is changed. Setting [member rect_min_size] directly calls this method automatically.
</description>
</method>
<method name="release_focus">
<return type="void" />
<description>
Expand Down Expand Up @@ -933,6 +927,12 @@
If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets.
</description>
</method>
<method name="update_minimum_size">
<return type="void" />
<description>
Invalidates the size cache in this node and in parent nodes up to top level. Intended to be used with [method get_minimum_size] when the return value is changed. Setting [member rect_min_size] directly calls this method automatically.
</description>
</method>
<method name="warp_mouse">
<return type="void" />
<argument index="0" name="to_position" type="Vector2" />
Expand Down
2 changes: 1 addition & 1 deletion editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3250,7 +3250,7 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co
node_name = p_name;
node = p_node;
update();
minimum_size_changed();
update_minimum_size();
}

Size2 AnimationTrackEditGroup::get_minimum_size() const {
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ void EditorInspectorSection::_test_unfold() {
void EditorInspectorSection::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
minimum_size_changed();
update_minimum_size();
} break;
case NOTIFICATION_SORT_CHILDREN: {
if (!vbox_added) {
Expand Down Expand Up @@ -1995,7 +1995,7 @@ void EditorInspectorArray::_notification(int p_what) {
prev_page_button->set_icon(get_theme_icon(SNAME("PagePrevious"), SNAME("EditorIcons")));
next_page_button->set_icon(get_theme_icon(SNAME("PageNext"), SNAME("EditorIcons")));
last_page_button->set_icon(get_theme_icon(SNAME("PageLast"), SNAME("EditorIcons")));
minimum_size_changed();
update_minimum_size();
} break;
case NOTIFICATION_DRAG_BEGIN: {
Dictionary dict = get_viewport()->gui_get_drag_data();
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ class EditorPropertyLayersGrid : public Control {
update();
} else if (expand_hovered) {
expanded = !expanded;
minimum_size_changed();
update_minimum_size();
update();
}
}
Expand Down Expand Up @@ -935,7 +935,7 @@ class EditorPropertyLayersGrid : public Control {
}

if ((expansion_rows != prev_expansion_rows) && expanded) {
minimum_size_changed();
update_minimum_size();
}

if ((expansion_rows == 0) && (layer_index == layer_count)) {
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/theme_editor_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void ThemeEditorPreview::add_preview_overlay(Control *p_overlay) {

void ThemeEditorPreview::_propagate_redraw(Control *p_at) {
p_at->notification(NOTIFICATION_THEME_CHANGED);
p_at->minimum_size_changed();
p_at->update_minimum_size();
p_at->update();
for (int i = 0; i < p_at->get_child_count(); i++) {
Control *a = Object::cast_to<Control>(p_at->get_child(i));
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/box_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void BoxContainer::_notification(int p_what) {
_resort();
} break;
case NOTIFICATION_THEME_CHANGED: {
minimum_size_changed();
update_minimum_size();
} break;
case NOTIFICATION_TRANSLATION_CHANGED:
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
Expand Down
14 changes: 7 additions & 7 deletions scene/gui/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ void Button::_notification(int p_what) {
xl_text = atr(text);
_shape();

minimum_size_changed();
update_minimum_size();
update();
} break;
case NOTIFICATION_THEME_CHANGED: {
_shape();

minimum_size_changed();
update_minimum_size();
update();
} break;
case NOTIFICATION_DRAW: {
Expand Down Expand Up @@ -368,7 +368,7 @@ void Button::set_text(const String &p_text) {
_shape();

update();
minimum_size_changed();
update_minimum_size();
}
}

Expand Down Expand Up @@ -428,7 +428,7 @@ void Button::set_icon(const Ref<Texture2D> &p_icon) {
if (icon != p_icon) {
icon = p_icon;
update();
minimum_size_changed();
update_minimum_size();
}
}

Expand All @@ -440,7 +440,7 @@ void Button::set_expand_icon(bool p_enabled) {
if (expand_icon != p_enabled) {
expand_icon = p_enabled;
update();
minimum_size_changed();
update_minimum_size();
}
}

Expand All @@ -463,7 +463,7 @@ void Button::set_clip_text(bool p_enabled) {
if (clip_text != p_enabled) {
clip_text = p_enabled;
update();
minimum_size_changed();
update_minimum_size();
}
}

Expand All @@ -484,7 +484,7 @@ Button::TextAlign Button::get_text_align() const {

void Button::set_icon_align(TextAlign p_align) {
icon_align = p_align;
minimum_size_changed();
update_minimum_size();
update();
}

Expand Down
2 changes: 1 addition & 1 deletion scene/gui/center_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void CenterContainer::set_use_top_left(bool p_enable) {

use_top_left = p_enable;

minimum_size_changed();
update_minimum_size();
queue_sort();
}

Expand Down
8 changes: 4 additions & 4 deletions scene/gui/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
void Container::_child_minsize_changed() {
//Size2 ms = get_combined_minimum_size();
//if (ms.width > get_size().width || ms.height > get_size().height) {
minimum_size_changed();
update_minimum_size();
queue_sort();
}

Expand All @@ -51,7 +51,7 @@ void Container::add_child_notify(Node *p_child) {
control->connect(SNAME("minimum_size_changed"), callable_mp(this, &Container::_child_minsize_changed));
control->connect(SNAME("visibility_changed"), callable_mp(this, &Container::_child_minsize_changed));

minimum_size_changed();
update_minimum_size();
queue_sort();
}

Expand All @@ -62,7 +62,7 @@ void Container::move_child_notify(Node *p_child) {
return;
}

minimum_size_changed();
update_minimum_size();
queue_sort();
}

Expand All @@ -78,7 +78,7 @@ void Container::remove_child_notify(Node *p_child) {
control->disconnect("minimum_size_changed", callable_mp(this, &Container::_child_minsize_changed));
control->disconnect("visibility_changed", callable_mp(this, &Container::_child_minsize_changed));

minimum_size_changed();
update_minimum_size();
queue_sort();
}

Expand Down
12 changes: 6 additions & 6 deletions scene/gui/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void Control::set_custom_minimum_size(const Size2 &p_custom) {
return;
}
data.custom_minimum_size = p_custom;
minimum_size_changed();
update_minimum_size();
}

Size2 Control::get_custom_minimum_size() const {
Expand All @@ -213,7 +213,7 @@ void Control::_update_minimum_size_cache() {
data.minimum_size_valid = true;

if (size_changed) {
minimum_size_changed();
update_minimum_size();
}
}

Expand Down Expand Up @@ -713,7 +713,7 @@ void Control::_notification(int p_notification) {
update();
} break;
case NOTIFICATION_THEME_CHANGED: {
minimum_size_changed();
update_minimum_size();
update();
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
Expand Down Expand Up @@ -2534,7 +2534,7 @@ void Control::grab_click_focus() {
get_viewport()->_gui_grab_click_focus(this);
}

void Control::minimum_size_changed() {
void Control::update_minimum_size() {
if (!is_inside_tree() || data.block_minimum_size_adjust) {
return;
}
Expand Down Expand Up @@ -2696,7 +2696,7 @@ real_t Control::get_rotation() const {
void Control::_override_changed() {
notification(NOTIFICATION_THEME_CHANGED);
emit_signal(SceneStringNames::get_singleton()->theme_changed);
minimum_size_changed(); // overrides are likely to affect minimum size
update_minimum_size(); // Overrides are likely to affect minimum size.
}

void Control::set_pivot_offset(const Vector2 &p_pivot) {
Expand Down Expand Up @@ -2977,7 +2977,7 @@ void Control::_bind_methods() {

ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Control::warp_mouse);

ClassDB::bind_method(D_METHOD("minimum_size_changed"), &Control::minimum_size_changed);
ClassDB::bind_method(D_METHOD("update_minimum_size"), &Control::update_minimum_size);

ClassDB::bind_method(D_METHOD("set_layout_direction", "direction"), &Control::set_layout_direction);
ClassDB::bind_method(D_METHOD("get_layout_direction"), &Control::get_layout_direction);
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class Control : public CanvasItem {
void set_stretch_ratio(real_t p_ratio);
real_t get_stretch_ratio() const;

void minimum_size_changed();
void update_minimum_size();

/* FOCUS */

Expand Down
4 changes: 2 additions & 2 deletions scene/gui/graph_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void GraphNode::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
_shape();

minimum_size_changed();
update_minimum_size();
update();
} break;
}
Expand Down Expand Up @@ -666,7 +666,7 @@ void GraphNode::set_title(const String &p_title) {
_shape();

update();
minimum_size_changed();
update_minimum_size();
}

String GraphNode::get_title() const {
Expand Down
4 changes: 2 additions & 2 deletions scene/gui/grid_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void GridContainer::_notification(int p_what) {

} break;
case NOTIFICATION_THEME_CHANGED: {
minimum_size_changed();
update_minimum_size();
} break;
case NOTIFICATION_TRANSLATION_CHANGED:
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
Expand All @@ -195,7 +195,7 @@ void GridContainer::set_columns(int p_columns) {
ERR_FAIL_COND(p_columns < 1);
columns = p_columns;
queue_sort();
minimum_size_changed();
update_minimum_size();
}

int GridContainer::get_columns() const {
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/item_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ void ItemList::_notification(int p_what) {
}
}

minimum_size_changed();
update_minimum_size();
shape_changed = false;
}

Expand Down
10 changes: 5 additions & 5 deletions scene/gui/label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Label::set_autowrap_mode(Label::AutowrapMode p_mode) {
update();

if (clip || overrun_behavior != OVERRUN_NO_TRIMMING) {
minimum_size_changed();
update_minimum_size();
}
}

Expand Down Expand Up @@ -207,7 +207,7 @@ void Label::_shape() {
_update_visible();

if (autowrap_mode == AUTOWRAP_OFF || !clip || overrun_behavior == OVERRUN_NO_TRIMMING) {
minimum_size_changed();
update_minimum_size();
}
}

Expand Down Expand Up @@ -592,7 +592,7 @@ void Label::set_text(const String &p_string) {
visible_chars = get_total_character_count() * percent_visible;
}
update();
minimum_size_changed();
update_minimum_size();
}

void Label::set_text_direction(Control::TextDirection p_text_direction) {
Expand Down Expand Up @@ -668,7 +668,7 @@ String Label::get_language() const {
void Label::set_clip_text(bool p_clip) {
clip = p_clip;
update();
minimum_size_changed();
update_minimum_size();
}

bool Label::is_clipping_text() const {
Expand All @@ -682,7 +682,7 @@ void Label::set_text_overrun_behavior(Label::OverrunBehavior p_behavior) {
}
update();
if (clip || overrun_behavior != OVERRUN_NO_TRIMMING) {
minimum_size_changed();
update_minimum_size();
}
}

Expand Down
10 changes: 5 additions & 5 deletions scene/gui/line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ void LineEdit::set_editable(bool p_editable) {

editable = p_editable;

minimum_size_changed();
update_minimum_size();
update();
}

Expand Down Expand Up @@ -1948,7 +1948,7 @@ void LineEdit::_editor_settings_changed() {

void LineEdit::set_expand_to_text_length_enabled(bool p_enabled) {
expand_to_text_length = p_enabled;
minimum_size_changed();
update_minimum_size();
set_caret_column(caret_column);
}

Expand All @@ -1962,7 +1962,7 @@ void LineEdit::set_clear_button_enabled(bool p_enabled) {
}
clear_button_enabled = p_enabled;
_fit_to_width();
minimum_size_changed();
update_minimum_size();
update();
}

Expand Down Expand Up @@ -2023,7 +2023,7 @@ void LineEdit::set_right_icon(const Ref<Texture2D> &p_icon) {
}
right_icon = p_icon;
_fit_to_width();
minimum_size_changed();
update_minimum_size();
update();
}

Expand Down Expand Up @@ -2087,7 +2087,7 @@ void LineEdit::_shape() {
Size2 size = TS->shaped_text_get_size(text_rid);

if ((expand_to_text_length && old_size.x != size.x) || (old_size.y != size.y)) {
minimum_size_changed();
update_minimum_size();
}
}

Expand Down
Loading

0 comments on commit 75ac048

Please sign in to comment.