diff options
author | reduz <reduzio@gmail.com> | 2021-02-10 17:18:45 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2021-02-10 19:31:24 -0300 |
commit | 1aa2823fa32c7a4b41d806418ec99949fc44ffb3 (patch) | |
tree | 7edbd352cf34d87b4d8e604c1730251c38131e19 /scene/gui | |
parent | e8f73124a7d97abc94cea3cf7fe5b5614f61a448 (diff) |
Removed _change_notify
-For inspector refresh, the inspector now detects if a property change by polling a few times per second and then does update the control if so. This process is very cheap.
-For property list refresh, a new signal (property_list_changed) was added to Object. _change_notify() is replaced by notify_property_list_changed()
-Changed all objects using the old method to the signal, or just deleted the calls to _change_notify(<property>) since they are unnecesary now.
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/base_button.cpp | 2 | ||||
-rw-r--r-- | scene/gui/button.cpp | 5 | ||||
-rw-r--r-- | scene/gui/control.cpp | 25 | ||||
-rw-r--r-- | scene/gui/control.h | 1 | ||||
-rw-r--r-- | scene/gui/graph_node.cpp | 3 | ||||
-rw-r--r-- | scene/gui/label.cpp | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 3 | ||||
-rw-r--r-- | scene/gui/link_button.cpp | 2 | ||||
-rw-r--r-- | scene/gui/nine_patch_rect.cpp | 16 | ||||
-rw-r--r-- | scene/gui/range.cpp | 2 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 2 | ||||
-rw-r--r-- | scene/gui/split_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 4 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 1 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 2 |
15 files changed, 7 insertions, 67 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index a7a7022b2e..db13b9b11f 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -199,7 +199,6 @@ void BaseButton::set_disabled(bool p_disabled) { status.pressing_inside = false; } update(); - _change_notify("disabled"); } bool BaseButton::is_disabled() const { @@ -213,7 +212,6 @@ void BaseButton::set_pressed(bool p_pressed) { if (status.pressed == p_pressed) { return; } - _change_notify("pressed"); status.pressed = p_pressed; if (p_pressed) { diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index e50b2d7cfe..37bb17b47d 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -338,7 +338,6 @@ void Button::set_text(const String &p_text) { _shape(); update(); - _change_notify("text"); minimum_size_changed(); } } @@ -399,7 +398,6 @@ void Button::set_icon(const Ref<Texture2D> &p_icon) { if (icon != p_icon) { icon = p_icon; update(); - _change_notify("icon"); minimum_size_changed(); } } @@ -424,7 +422,6 @@ void Button::set_flat(bool p_flat) { if (flat != p_flat) { flat = p_flat; update(); - _change_notify("flat"); } } @@ -474,7 +471,7 @@ bool Button::_set(const StringName &p_name, const Variant &p_value) { update(); } } - _change_notify(); + notify_property_list_changed(); return true; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 6b5d8cb658..cf75365b44 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1275,7 +1275,6 @@ void Control::_size_changed() { } if (pos_changed || size_changed) { item_rect_changed(size_changed); - _change_notify_offsets(); _notify_transform(); } @@ -1315,10 +1314,6 @@ void Control::set_anchor(Side p_side, float p_anchor, bool p_keep_offset, bool p } update(); - _change_notify("anchor_left"); - _change_notify("anchor_right"); - _change_notify("anchor_top"); - _change_notify("anchor_bottom"); } void Control::_set_anchor(Side p_side, float p_anchor) { @@ -1592,16 +1587,6 @@ float Control::get_anchor(Side p_side) const { return data.anchor[p_side]; } -void Control::_change_notify_offsets() { - // this avoids sending the whole object data again on a change - _change_notify("offset_left"); - _change_notify("offset_top"); - _change_notify("offset_right"); - _change_notify("offset_bottom"); - _change_notify("rect_position"); - _change_notify("rect_size"); -} - void Control::set_offset(Side p_side, float p_value) { ERR_FAIL_INDEX((int)p_side, 4); @@ -1699,10 +1684,6 @@ void Control::_set_position(const Size2 &p_point) { void Control::set_position(const Size2 &p_point, bool p_keep_offsets) { if (p_keep_offsets) { _compute_anchors(Rect2(p_point, data.size_cache), data.offset, data.anchor); - _change_notify("anchor_left"); - _change_notify("anchor_right"); - _change_notify("anchor_top"); - _change_notify("anchor_bottom"); } else { _compute_offsets(Rect2(p_point, data.size_cache), data.anchor, data.offset); } @@ -1736,10 +1717,6 @@ void Control::set_size(const Size2 &p_size, bool p_keep_offsets) { if (p_keep_offsets) { _compute_anchors(Rect2(data.pos_cache, new_size), data.offset, data.anchor); - _change_notify("anchor_left"); - _change_notify("anchor_right"); - _change_notify("anchor_top"); - _change_notify("anchor_bottom"); } else { _compute_offsets(Rect2(data.pos_cache, new_size), data.anchor, data.offset); } @@ -2577,7 +2554,6 @@ void Control::set_rotation(float p_radians) { data.rotation = p_radians; update(); _notify_transform(); - _change_notify("rect_rotation"); } float Control::get_rotation() const { @@ -2602,7 +2578,6 @@ void Control::set_pivot_offset(const Vector2 &p_pivot) { data.pivot_offset = p_pivot; update(); _notify_transform(); - _change_notify("rect_pivot_offset"); } Vector2 Control::get_pivot_offset() const { diff --git a/scene/gui/control.h b/scene/gui/control.h index 9f5adf11e3..8b24781287 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -233,7 +233,6 @@ private: void _theme_changed(); - void _change_notify_offsets(); void _update_minimum_size(); void _update_scroll(); diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 0ed3118673..854225af39 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -51,7 +51,7 @@ bool GraphNode::_set(const StringName &p_name, const Variant &p_value) { update(); } } - _change_notify(); + notify_property_list_changed(); return true; } @@ -484,7 +484,6 @@ void GraphNode::set_title(const String &p_title) { _shape(); update(); - _change_notify("title"); minimum_size_changed(); } diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 540d238b74..453ecc802c 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -538,7 +538,6 @@ void Label::set_visible_characters(int p_amount) { if (get_total_character_count() > 0) { percent_visible = (float)p_amount / (float)get_total_character_count(); } - _change_notify("percent_visible"); update(); } @@ -555,7 +554,6 @@ void Label::set_percent_visible(float p_percent) { visible_chars = get_total_character_count() * p_percent; percent_visible = p_percent; } - _change_notify("visible_chars"); update(); } @@ -610,7 +608,7 @@ bool Label::_set(const StringName &p_name, const Variant &p_value) { update(); } } - _change_notify(); + notify_property_list_changed(); return true; } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 087d33cd94..bbe09af3aa 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1958,7 +1958,6 @@ void LineEdit::_text_changed() { void LineEdit::_emit_text_change() { emit_signal("text_changed", text); - _change_notify("text"); text_changed_dirty = false; } @@ -2091,7 +2090,7 @@ bool LineEdit::_set(const StringName &p_name, const Variant &p_value) { update(); } } - _change_notify(); + notify_property_list_changed(); return true; } diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index cbcea13897..c6706aba68 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -231,7 +231,7 @@ bool LinkButton::_set(const StringName &p_name, const Variant &p_value) { update(); } } - _change_notify(); + notify_property_list_changed(); return true; } diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index 64fff5c031..29a38ad5e3 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -98,7 +98,6 @@ void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) { */ minimum_size_changed(); emit_signal("texture_changed"); - _change_notify("texture"); } Ref<Texture2D> NinePatchRect::get_texture() const { @@ -110,20 +109,6 @@ void NinePatchRect::set_patch_margin(Side p_side, int p_size) { margin[p_side] = p_size; update(); minimum_size_changed(); - switch (p_side) { - case SIDE_LEFT: - _change_notify("patch_margin_left"); - break; - case SIDE_TOP: - _change_notify("patch_margin_top"); - break; - case SIDE_RIGHT: - _change_notify("patch_margin_right"); - break; - case SIDE_BOTTOM: - _change_notify("patch_margin_bottom"); - break; - } } int NinePatchRect::get_patch_margin(Side p_side) const { @@ -139,7 +124,6 @@ void NinePatchRect::set_region_rect(const Rect2 &p_region_rect) { region_rect = p_region_rect; item_rect_changed(); - _change_notify("region_rect"); } Rect2 NinePatchRect::get_region_rect() const { diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 86dc583f85..86b775e795 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -47,7 +47,6 @@ void Range::_value_changed_notify() { _value_changed(shared->val); emit_signal("value_changed", shared->val); update(); - _change_notify("value"); } void Range::Shared::emit_value_changed() { @@ -63,7 +62,6 @@ void Range::Shared::emit_value_changed() { void Range::_changed_notify(const char *p_what) { emit_signal("changed"); update(); - _change_notify(p_what); } void Range::Shared::emit_changed(const char *p_what) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 158f433967..f9f8f4f78a 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -3722,7 +3722,6 @@ void RichTextLabel::set_percent_visible(float p_percent) { } main->first_invalid_line = 0; //invalidate ALL _validate_line_caches(main); - _change_notify("visible_characters"); update(); } } @@ -3948,7 +3947,6 @@ void RichTextLabel::set_visible_characters(int p_visible) { percent_visible = (float)p_visible / (float)total_char_count; } } - _change_notify("percent_visible"); update(); } diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 1a7bd8304e..d43e195df1 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -102,7 +102,7 @@ void SplitContainer::_resort() { middle_sep += clamped_split_offset; if (should_clamp_split_offset) { split_offset = clamped_split_offset; - _change_notify("split_offset"); + should_clamp_split_offset = false; } } diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 3377ac62e6..861f66628d 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -747,8 +747,6 @@ void TabContainer::set_current_tab(int p_current) { _repaint(); - _change_notify("current_tab"); - if (pending_previous == current) { emit_signal("tab_selected", current); } else { @@ -967,8 +965,6 @@ void TabContainer::set_tab_align(TabAlign p_align) { ERR_FAIL_INDEX(p_align, 3); align = p_align; update(); - - _change_notify("tab_align"); } TabContainer::TabAlign TabContainer::get_tab_align() const { diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 2ad743e7b4..66f04e5569 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -481,7 +481,6 @@ void Tabs::set_current_tab(int p_current) { previous = current; current = p_current; - _change_notify("current_tab"); _update_cache(); update(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 44c32d4e42..d31d00675e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -6906,7 +6906,7 @@ bool TextEdit::_set(const StringName &p_name, const Variant &p_value) { update(); } } - _change_notify(); + notify_property_list_changed(); return true; } |