Add theme contexts to various parts of the editor

This change defines additional theme contexts for editor
branches to prevent theme leaking between the default
theme, the project theme, and the editor theme.

- Both editor window and EditorNode define an editor-specific
context with the editor theme and the default theme.
- The 2D viewport defines a project-specific context with
the project theme and the default theme.
- Theme editor preview tabs define the default-only context
with the default theme.

Additionally, the default theme context now only includes
the project theme for running projects (both export and debug).
This prevents the project theme from leaking into the editor.

This commit also does a little clean up on the theming aspects
of the EditorNode.
This commit is contained in:
Yuri Sizov 2023-09-06 16:11:05 +02:00
parent 58126e479c
commit 512182f147
9 changed files with 181 additions and 150 deletions

View file

@ -1612,6 +1612,8 @@ void ScriptEditor::_notification(int p_what) {
case NOTIFICATION_TRANSLATION_CHANGED:
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_THEME_CHANGED: {
tab_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("ScriptEditor"), EditorStringName(EditorStyles)));
help_search->set_icon(get_editor_theme_icon(SNAME("HelpSearch")));
site_search->set_icon(get_editor_theme_icon(SNAME("ExternalLink")));
@ -1628,7 +1630,7 @@ void ScriptEditor::_notification(int p_what) {
filter_scripts->set_right_icon(get_editor_theme_icon(SNAME("Search")));
filter_methods->set_right_icon(get_editor_theme_icon(SNAME("Search")));
filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")));
filename->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")));
recent_scripts->reset_size();
@ -1639,6 +1641,9 @@ void ScriptEditor::_notification(int p_what) {
} break;
case NOTIFICATION_READY: {
// Can't set own styles in NOTIFICATION_THEME_CHANGED, so for now this will do.
add_theme_style_override("panel", get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles")));
get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed));
InspectorDock::get_singleton()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open));
EditorNode::get_singleton()->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search));
@ -4139,9 +4144,6 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
ScriptServer::edit_request_func = _open_script_request;
add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), EditorStringName(EditorStyles)));
tab_container->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), EditorStringName(EditorStyles)));
Ref<EditorJSONSyntaxHighlighter> json_syntax_highlighter;
json_syntax_highlighter.instantiate();
register_syntax_highlighter(json_syntax_highlighter);