diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-20 15:12:11 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-20 15:12:11 +0200 |
| commit | 68a183a2d91709537fe5cab3ed989f97a590845c (patch) | |
| tree | feb3978a5c4444a01bc5b3d5f72b8eda2c140cf6 /scene/gui | |
| parent | 55fc347efd50d297de3b92a5bfc141e52e57c90f (diff) | |
| parent | 215e036600809fd588ec67b8d39efe12ae1ff4c5 (diff) | |
| download | redot-engine-68a183a2d91709537fe5cab3ed989f97a590845c.tar.gz | |
Merge pull request #83626 from YuriSizov/control-less-is-more-as-in-less-excessive-notifications-is-more-performance
Add bulk change guards to successive theme overrides in Editor and GUI
Diffstat (limited to 'scene/gui')
| -rw-r--r-- | scene/gui/color_picker.cpp | 10 | ||||
| -rw-r--r-- | scene/gui/file_dialog.cpp | 10 | ||||
| -rw-r--r-- | scene/gui/popup_menu.cpp | 2 | ||||
| -rw-r--r-- | scene/gui/tab_container.cpp | 4 |
4 files changed, 26 insertions, 0 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index c2512bed66..761298c51c 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -77,9 +77,11 @@ void ColorPicker::_notification(int p_what) { alpha_label->add_theme_constant_override(SNAME("center_grabber"), theme_cache.center_slider_grabbers); for (int i = 0; i < MODE_BUTTON_COUNT; i++) { + mode_btns[i]->begin_bulk_theme_override(); mode_btns[i]->add_theme_style_override(SNAME("pressed"), theme_cache.mode_button_pressed); mode_btns[i]->add_theme_style_override(SNAME("normal"), theme_cache.mode_button_normal); mode_btns[i]->add_theme_style_override(SNAME("hover"), theme_cache.mode_button_hover); + mode_btns[i]->end_bulk_theme_override(); } shape_popup->set_item_icon(shape_popup->get_item_index(SHAPE_HSV_RECTANGLE), theme_cache.shape_rect); @@ -87,10 +89,12 @@ void ColorPicker::_notification(int p_what) { shape_popup->set_item_icon(shape_popup->get_item_index(SHAPE_VHS_CIRCLE), theme_cache.shape_circle); shape_popup->set_item_icon(shape_popup->get_item_index(SHAPE_OKHSL_CIRCLE), theme_cache.shape_circle); + internal_margin->begin_bulk_theme_override(); internal_margin->add_theme_constant_override(SNAME("margin_bottom"), theme_cache.content_margin); internal_margin->add_theme_constant_override(SNAME("margin_left"), theme_cache.content_margin); internal_margin->add_theme_constant_override(SNAME("margin_right"), theme_cache.content_margin); internal_margin->add_theme_constant_override(SNAME("margin_top"), theme_cache.content_margin); + internal_margin->end_bulk_theme_override(); _reset_sliders_theme(); @@ -521,20 +525,26 @@ void ColorPicker::_reset_sliders_theme() { Ref<StyleBoxFlat> style_box_flat(memnew(StyleBoxFlat)); style_box_flat->set_content_margin(SIDE_TOP, 16 * theme_cache.base_scale); style_box_flat->set_bg_color(Color(0.2, 0.23, 0.31).lerp(Color(0, 0, 0, 1), 0.3).clamp()); + for (int i = 0; i < SLIDER_COUNT; i++) { + sliders[i]->begin_bulk_theme_override(); sliders[i]->add_theme_icon_override("grabber", theme_cache.bar_arrow); sliders[i]->add_theme_icon_override("grabber_highlight", theme_cache.bar_arrow); sliders[i]->add_theme_constant_override("grabber_offset", 8 * theme_cache.base_scale); if (!colorize_sliders) { sliders[i]->add_theme_style_override("slider", style_box_flat); } + sliders[i]->end_bulk_theme_override(); } + + alpha_slider->begin_bulk_theme_override(); alpha_slider->add_theme_icon_override("grabber", theme_cache.bar_arrow); alpha_slider->add_theme_icon_override("grabber_highlight", theme_cache.bar_arrow); alpha_slider->add_theme_constant_override("grabber_offset", 8 * theme_cache.base_scale); if (!colorize_sliders) { alpha_slider->add_theme_style_override("slider", style_box_flat); } + alpha_slider->end_bulk_theme_override(); } void ColorPicker::_html_submitted(const String &p_html) { diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 2d2e964449..d721ee3ec3 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -144,30 +144,40 @@ void FileDialog::_notification(int p_what) { refresh->set_icon(theme_cache.reload); show_hidden->set_icon(theme_cache.toggle_hidden); + dir_up->begin_bulk_theme_override(); dir_up->add_theme_color_override("icon_normal_color", theme_cache.icon_normal_color); dir_up->add_theme_color_override("icon_hover_color", theme_cache.icon_hover_color); dir_up->add_theme_color_override("icon_focus_color", theme_cache.icon_focus_color); dir_up->add_theme_color_override("icon_pressed_color", theme_cache.icon_pressed_color); + dir_up->end_bulk_theme_override(); + dir_prev->begin_bulk_theme_override(); dir_prev->add_theme_color_override("icon_color_normal", theme_cache.icon_normal_color); dir_prev->add_theme_color_override("icon_color_hover", theme_cache.icon_hover_color); dir_prev->add_theme_color_override("icon_focus_color", theme_cache.icon_focus_color); dir_prev->add_theme_color_override("icon_color_pressed", theme_cache.icon_pressed_color); + dir_prev->end_bulk_theme_override(); + dir_next->begin_bulk_theme_override(); dir_next->add_theme_color_override("icon_color_normal", theme_cache.icon_normal_color); dir_next->add_theme_color_override("icon_color_hover", theme_cache.icon_hover_color); dir_next->add_theme_color_override("icon_focus_color", theme_cache.icon_focus_color); dir_next->add_theme_color_override("icon_color_pressed", theme_cache.icon_pressed_color); + dir_next->end_bulk_theme_override(); + refresh->begin_bulk_theme_override(); refresh->add_theme_color_override("icon_normal_color", theme_cache.icon_normal_color); refresh->add_theme_color_override("icon_hover_color", theme_cache.icon_hover_color); refresh->add_theme_color_override("icon_focus_color", theme_cache.icon_focus_color); refresh->add_theme_color_override("icon_pressed_color", theme_cache.icon_pressed_color); + refresh->end_bulk_theme_override(); + show_hidden->begin_bulk_theme_override(); show_hidden->add_theme_color_override("icon_normal_color", theme_cache.icon_normal_color); show_hidden->add_theme_color_override("icon_hover_color", theme_cache.icon_hover_color); show_hidden->add_theme_color_override("icon_focus_color", theme_cache.icon_focus_color); show_hidden->add_theme_color_override("icon_pressed_color", theme_cache.icon_pressed_color); + show_hidden->end_bulk_theme_override(); invalidate(); } break; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 28f5ed7dfd..dfaf7d88b7 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -1108,10 +1108,12 @@ void PopupMenu::_notification(int p_what) { } // Set margin on the margin container + margin_container->begin_bulk_theme_override(); margin_container->add_theme_constant_override("margin_left", theme_cache.panel_style->get_margin(Side::SIDE_LEFT)); margin_container->add_theme_constant_override("margin_top", theme_cache.panel_style->get_margin(Side::SIDE_TOP)); margin_container->add_theme_constant_override("margin_right", theme_cache.panel_style->get_margin(Side::SIDE_RIGHT)); margin_container->add_theme_constant_override("margin_bottom", theme_cache.panel_style->get_margin(Side::SIDE_BOTTOM)); + margin_container->end_bulk_theme_override(); } } break; } diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index b757b516d1..481f8f4131 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -191,6 +191,8 @@ void TabContainer::_on_theme_changed() { return; } + tab_bar->begin_bulk_theme_override(); + tab_bar->add_theme_style_override(SNAME("tab_unselected"), theme_cache.tab_unselected_style); tab_bar->add_theme_style_override(SNAME("tab_hovered"), theme_cache.tab_hovered_style); tab_bar->add_theme_style_override(SNAME("tab_selected"), theme_cache.tab_selected_style); @@ -217,6 +219,8 @@ void TabContainer::_on_theme_changed() { tab_bar->add_theme_constant_override(SNAME("icon_max_width"), theme_cache.icon_max_width); tab_bar->add_theme_constant_override(SNAME("outline_size"), theme_cache.outline_size); + tab_bar->end_bulk_theme_override(); + _update_margins(); if (get_tab_count() > 0) { _repaint(); |
