Fix theming update in several editor classes

This commit is contained in:
Yuri Roubinsky 2022-01-16 10:59:02 +03:00
parent 1cff9a2e49
commit 5003d4351e
12 changed files with 69 additions and 41 deletions

View File

@ -922,8 +922,14 @@ void ConnectionsDock::_connect_pressed() {
} }
void ConnectionsDock::_notification(int p_what) { void ConnectionsDock::_notification(int p_what) {
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { switch (p_what) {
update_tree(); case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
update_tree();
} break;
} }
} }
@ -1135,7 +1141,6 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
search_box = memnew(LineEdit); search_box = memnew(LineEdit);
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_box->set_placeholder(TTR("Filter signals")); search_box->set_placeholder(TTR("Filter signals"));
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
search_box->set_clear_button_enabled(true); search_box->set_clear_button_enabled(true);
search_box->connect("text_changed", callable_mp(this, &ConnectionsDock::_filter_changed)); search_box->connect("text_changed", callable_mp(this, &ConnectionsDock::_filter_changed));
vbc->add_child(search_box); vbc->add_child(search_box);

View File

@ -367,13 +367,16 @@ void CreateDialog::_sbox_input(const Ref<InputEvent> &p_ie) {
} }
} }
void CreateDialog::_update_theme() {
search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
favorite->set_icon(search_options->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")));
}
void CreateDialog::_notification(int p_what) { void CreateDialog::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); connect("confirmed", callable_mp(this, &CreateDialog::_confirmed));
search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); _update_theme();
search_box->set_clear_button_enabled(true);
favorite->set_icon(search_options->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")));
} break; } break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); disconnect("confirmed", callable_mp(this, &CreateDialog::_confirmed));
@ -386,6 +389,9 @@ void CreateDialog::_notification(int p_what) {
EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", Rect2(get_position(), get_size())); EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", Rect2(get_position(), get_size()));
} }
} break; } break;
case NOTIFICATION_THEME_CHANGED: {
_update_theme();
} break;
} }
} }
@ -711,6 +717,7 @@ CreateDialog::CreateDialog() {
hsc->add_child(vbc); hsc->add_child(vbc);
search_box = memnew(LineEdit); search_box = memnew(LineEdit);
search_box->set_clear_button_enabled(true);
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_box->connect("text_changed", callable_mp(this, &CreateDialog::_text_changed)); search_box->connect("text_changed", callable_mp(this, &CreateDialog::_text_changed));
search_box->connect("gui_input", callable_mp(this, &CreateDialog::_sbox_input)); search_box->connect("gui_input", callable_mp(this, &CreateDialog::_sbox_input));

View File

@ -95,6 +95,8 @@ class CreateDialog : public ConfirmationDialog {
bool _is_class_disabled_by_feature_profile(const StringName &p_class) const; bool _is_class_disabled_by_feature_profile(const StringName &p_class) const;
void _load_favorites_and_history(); void _load_favorites_and_history();
void _update_theme();
protected: protected:
void _notification(int p_what); void _notification(int p_what);
static void _bind_methods(); static void _bind_methods();

View File

@ -84,6 +84,7 @@ void EditorLog::_update_theme() {
copy_button->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); copy_button->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")));
collapse_button->set_icon(get_theme_icon(SNAME("CombineLines"), SNAME("EditorIcons"))); collapse_button->set_icon(get_theme_icon(SNAME("CombineLines"), SNAME("EditorIcons")));
show_search_button->set_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); show_search_button->set_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
} }
void EditorLog::_notification(int p_what) { void EditorLog::_notification(int p_what) {
@ -348,7 +349,6 @@ EditorLog::EditorLog() {
search_box = memnew(LineEdit); search_box = memnew(LineEdit);
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_box->set_placeholder(TTR("Filter messages")); search_box->set_placeholder(TTR("Filter messages"));
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
search_box->set_clear_button_enabled(true); search_box->set_clear_button_enabled(true);
search_box->set_visible(true); search_box->set_visible(true);
search_box->connect("text_changed", callable_mp(this, &EditorLog::_search_changed)); search_box->connect("text_changed", callable_mp(this, &EditorLog::_search_changed));

View File

@ -370,7 +370,8 @@ void GroupDialog::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED:
case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
if (is_layout_rtl()) { if (is_layout_rtl()) {
add_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); add_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons")));
remove_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); remove_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")));

View File

@ -193,7 +193,8 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
void EditorAssetLibraryItemDescription::_notification(int p_what) { void EditorAssetLibraryItemDescription::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox(SNAME("normal"), SNAME("TextEdit"))); previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox(SNAME("normal"), SNAME("TextEdit")));
} break; } break;
} }
@ -398,7 +399,8 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse
void EditorAssetLibraryItemDownload::_notification(int p_what) { void EditorAssetLibraryItemDownload::_notification(int p_what) {
switch (p_what) { switch (p_what) {
// FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used. // FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used.
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer")));
dismiss->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); dismiss->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
} break; } break;
@ -562,11 +564,15 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
void EditorAssetLibrary::_notification(int p_what) { void EditorAssetLibrary::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
error_label->raise();
} break;
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
filter->set_clear_button_enabled(true); library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
error_label->raise(); error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
} break; } break;
case NOTIFICATION_VISIBILITY_CHANGED: { case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible()) { if (is_visible()) {
@ -596,14 +602,6 @@ void EditorAssetLibrary::_notification(int p_what) {
} }
} break; } break;
case NOTIFICATION_THEME_CHANGED: {
library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
filter->set_clear_button_enabled(true);
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_repository_options(); _update_repository_options();
} break; } break;
@ -1354,6 +1352,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
} else { } else {
filter->set_placeholder(TTR("Search assets (excluding templates, projects, and demos)")); filter->set_placeholder(TTR("Search assets (excluding templates, projects, and demos)"));
} }
filter->set_clear_button_enabled(true);
search_hb->add_child(filter); search_hb->add_child(filter);
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->connect("text_changed", callable_mp(this, &EditorAssetLibrary::_search_text_changed)); filter->connect("text_changed", callable_mp(this, &EditorAssetLibrary::_search_text_changed));
@ -1495,7 +1494,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
error_hb = memnew(HBoxContainer); error_hb = memnew(HBoxContainer);
library_main->add_child(error_hb); library_main->add_child(error_hb);
error_label = memnew(Label); error_label = memnew(Label);
error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
error_hb->add_child(error_label); error_hb->add_child(error_label);
error_tr = memnew(TextureRect); error_tr = memnew(TextureRect);
error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER); error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER);

View File

@ -467,6 +467,14 @@ void ProjectSettingsEditor::_update_action_map_editor() {
action_map->update_action_list(actions); action_map->update_action_list(actions);
} }
void ProjectSettingsEditor::_update_theme() {
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")));
restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
}
void ProjectSettingsEditor::_notification(int p_what) { void ProjectSettingsEditor::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: { case NOTIFICATION_VISIBILITY_CHANGED: {
@ -476,21 +484,12 @@ void ProjectSettingsEditor::_notification(int p_what) {
} break; } break;
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
inspector->edit(ps); inspector->edit(ps);
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
search_box->set_clear_button_enabled(true);
restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")));
restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
_update_action_map_editor(); _update_action_map_editor();
_update_theme();
} break; } break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { case NOTIFICATION_THEME_CHANGED:
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); _update_theme();
search_box->set_clear_button_enabled(true); break;
} break;
} }
} }
@ -524,6 +523,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
search_box = memnew(LineEdit); search_box = memnew(LineEdit);
search_box->set_placeholder(TTR("Filter Settings")); search_box->set_placeholder(TTR("Filter Settings"));
search_box->set_clear_button_enabled(true);
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search_bar->add_child(search_box); search_bar->add_child(search_box);

View File

@ -99,6 +99,7 @@ class ProjectSettingsEditor : public AcceptDialog {
void _action_renamed(const String &p_old_name, const String &p_new_name); void _action_renamed(const String &p_old_name, const String &p_new_name);
void _action_reordered(const String &p_action_name, const String &p_relative_to, bool p_before); void _action_reordered(const String &p_action_name, const String &p_relative_to, bool p_before);
void _update_action_map_editor(); void _update_action_map_editor();
void _update_theme();
protected: protected:
void _notification(int p_what); void _notification(int p_what);

View File

@ -1256,6 +1256,10 @@ void SceneTreeDialog::popup_scenetree_dialog() {
popup_centered_clamped(Size2(350, 700) * EDSCALE); popup_centered_clamped(Size2(350, 700) * EDSCALE);
} }
void SceneTreeDialog::_update_theme() {
filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
}
void SceneTreeDialog::_notification(int p_what) { void SceneTreeDialog::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: { case NOTIFICATION_VISIBILITY_CHANGED: {
@ -1265,8 +1269,10 @@ void SceneTreeDialog::_notification(int p_what) {
} break; } break;
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
connect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); connect("confirmed", callable_mp(this, &SceneTreeDialog::_select));
filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); _update_theme();
filter->set_clear_button_enabled(true); } break;
case NOTIFICATION_THEME_CHANGED: {
_update_theme();
} break; } break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
disconnect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); disconnect("confirmed", callable_mp(this, &SceneTreeDialog::_select));
@ -1303,6 +1309,7 @@ SceneTreeDialog::SceneTreeDialog() {
filter = memnew(LineEdit); filter = memnew(LineEdit);
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->set_placeholder(TTR("Filter nodes")); filter->set_placeholder(TTR("Filter nodes"));
filter->set_clear_button_enabled(true);
filter->add_theme_constant_override("minimum_character_width", 0); filter->add_theme_constant_override("minimum_character_width", 0);
filter->connect("text_changed", callable_mp(this, &SceneTreeDialog::_filter_changed)); filter->connect("text_changed", callable_mp(this, &SceneTreeDialog::_filter_changed));
vbc->add_child(filter); vbc->add_child(filter);

View File

@ -174,6 +174,7 @@ class SceneTreeDialog : public ConfirmationDialog {
void _select(); void _select();
void _cancel(); void _cancel();
void _filter_changed(const String &p_filter); void _filter_changed(const String &p_filter);
void _update_theme();
protected: protected:
void _notification(int p_what); void _notification(int p_what);

View File

@ -1028,6 +1028,13 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
} }
} }
void GridMapEditor::_update_theme() {
options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons")));
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
mode_thumbnail->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons")));
mode_list->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons")));
}
void GridMapEditor::_notification(int p_what) { void GridMapEditor::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
@ -1048,6 +1055,7 @@ void GridMapEditor::_notification(int p_what) {
_update_selection_transform(); _update_selection_transform();
_update_paste_indicator(); _update_paste_indicator();
_update_theme();
} break; } break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
@ -1088,8 +1096,7 @@ void GridMapEditor::_notification(int p_what) {
} break; } break;
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {
options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons"))); _update_theme();
search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
} break; } break;
case NOTIFICATION_APPLICATION_FOCUS_OUT: { case NOTIFICATION_APPLICATION_FOCUS_OUT: {
@ -1250,7 +1257,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
mode_thumbnail->set_flat(true); mode_thumbnail->set_flat(true);
mode_thumbnail->set_toggle_mode(true); mode_thumbnail->set_toggle_mode(true);
mode_thumbnail->set_pressed(true); mode_thumbnail->set_pressed(true);
mode_thumbnail->set_icon(p_editor->get_gui_base()->get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons")));
hb->add_child(mode_thumbnail); hb->add_child(mode_thumbnail);
mode_thumbnail->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_THUMBNAIL)); mode_thumbnail->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_THUMBNAIL));
@ -1258,7 +1264,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
mode_list->set_flat(true); mode_list->set_flat(true);
mode_list->set_toggle_mode(true); mode_list->set_toggle_mode(true);
mode_list->set_pressed(false); mode_list->set_pressed(false);
mode_list->set_icon(p_editor->get_gui_base()->get_theme_icon(SNAME("FileList"), SNAME("EditorIcons")));
hb->add_child(mode_list); hb->add_child(mode_list);
mode_list->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_LIST)); mode_list->connect("pressed", callable_mp(this, &GridMapEditor::_set_display_mode), varray(DISPLAY_LIST));

View File

@ -201,6 +201,7 @@ class GridMapEditor : public VBoxContainer {
void _update_cursor_transform(); void _update_cursor_transform();
void _update_cursor_instance(); void _update_cursor_instance();
void _update_clip(); void _update_clip();
void _update_theme();
void _text_changed(const String &p_text); void _text_changed(const String &p_text);
void _sbox_input(const Ref<InputEvent> &p_ie); void _sbox_input(const Ref<InputEvent> &p_ie);