summaryrefslogtreecommitdiffstats
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.h1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp30
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h16
-rw-r--r--editor/plugins/editor_preview_plugins.cpp1
-rw-r--r--editor/plugins/editor_resource_conversion_plugin.h1
-rw-r--r--editor/plugins/editor_resource_tooltip_plugins.h1
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.cpp1
-rw-r--r--editor/plugins/script_editor_plugin.cpp10
-rw-r--r--editor/plugins/script_editor_plugin.h1
-rw-r--r--editor/plugins/theme_editor_plugin.cpp2
-rw-r--r--editor/plugins/theme_editor_preview.cpp13
-rw-r--r--editor/plugins/theme_editor_preview.h1
12 files changed, 67 insertions, 11 deletions
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h
index afb3394238..90fb42cd7a 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.h
+++ b/editor/plugins/animation_blend_tree_editor_plugin.h
@@ -31,6 +31,7 @@
#ifndef ANIMATION_BLEND_TREE_EDITOR_PLUGIN_H
#define ANIMATION_BLEND_TREE_EDITOR_PLUGIN_H
+#include "core/object/script_language.h"
#include "editor/plugins/animation_tree_editor_plugin.h"
#include "scene/animation/animation_blend_tree.h"
#include "scene/gui/button.h"
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index b2f4e43018..703cd7ef81 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -1034,6 +1034,22 @@ void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) {
viewport->queue_redraw();
}
+void CanvasItemEditor::_switch_theme_preview(int p_mode) {
+ view_menu->get_popup()->hide();
+
+ if (theme_preview == p_mode) {
+ return;
+ }
+ theme_preview = (ThemePreviewMode)p_mode;
+ EditorSettings::get_singleton()->set_project_metadata("2d_editor", "theme_preview", theme_preview);
+
+ for (int i = 0; i < THEME_PREVIEW_MAX; i++) {
+ theme_menu->set_item_checked(i, i == theme_preview);
+ }
+
+ EditorNode::get_singleton()->update_preview_themes(theme_preview);
+}
+
bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_event) {
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
Ref<InputEventMouseButton> b = p_event;
@@ -5322,6 +5338,20 @@ CanvasItemEditor::CanvasItemEditor() {
p->add_separator();
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale")), PREVIEW_CANVAS_SCALE);
+ theme_menu = memnew(PopupMenu);
+ theme_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_switch_theme_preview));
+ theme_menu->set_name("ThemeMenu");
+ theme_menu->add_radio_check_item(TTR("Project theme"), THEME_PREVIEW_PROJECT);
+ theme_menu->add_radio_check_item(TTR("Editor theme"), THEME_PREVIEW_EDITOR);
+ theme_menu->add_radio_check_item(TTR("Default theme"), THEME_PREVIEW_DEFAULT);
+ p->add_child(theme_menu);
+ p->add_submenu_item(TTR("Preview Theme"), "ThemeMenu");
+
+ theme_preview = (ThemePreviewMode)(int)EditorSettings::get_singleton()->get_project_metadata("2d_editor", "theme_preview", THEME_PREVIEW_PROJECT);
+ for (int i = 0; i < THEME_PREVIEW_MAX; i++) {
+ theme_menu->set_item_checked(i, i == theme_preview);
+ }
+
main_menu_hbox->add_child(memnew(VSeparator));
// Contextual toolbars.
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 74f150fd65..674f38c8c0 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -325,6 +325,7 @@ private:
Button *override_camera_button = nullptr;
MenuButton *view_menu = nullptr;
PopupMenu *grid_menu = nullptr;
+ PopupMenu *theme_menu = nullptr;
HBoxContainer *animation_hb = nullptr;
MenuButton *animation_menu = nullptr;
@@ -404,6 +405,19 @@ private:
void _prepare_grid_menu();
void _on_grid_menu_id_pressed(int p_id);
+public:
+ enum ThemePreviewMode {
+ THEME_PREVIEW_PROJECT,
+ THEME_PREVIEW_EDITOR,
+ THEME_PREVIEW_DEFAULT,
+
+ THEME_PREVIEW_MAX // The number of options for enumerating.
+ };
+
+private:
+ ThemePreviewMode theme_preview = THEME_PREVIEW_PROJECT;
+ void _switch_theme_preview(int p_mode);
+
List<CanvasItem *> _get_edited_canvas_items(bool retrieve_locked = false, bool remove_canvas_item_if_parent_in_selection = true) const;
Rect2 _get_encompassing_rect_from_list(List<CanvasItem *> p_list);
void _expand_encompassing_rect_using_children(Rect2 &r_rect, const Node *p_node, bool &r_first, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D(), bool include_locked_nodes = true);
@@ -558,6 +572,8 @@ public:
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
+ ThemePreviewMode get_theme_preview() const { return theme_preview; }
+
EditorSelection *editor_selection = nullptr;
CanvasItemEditor();
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index fba45e5372..1872857130 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -33,6 +33,7 @@
#include "core/config/project_settings.h"
#include "core/io/file_access_memory.h"
#include "core/io/resource_loader.h"
+#include "core/object/script_language.h"
#include "core/os/os.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
diff --git a/editor/plugins/editor_resource_conversion_plugin.h b/editor/plugins/editor_resource_conversion_plugin.h
index 32e05585ee..1f8aad51ff 100644
--- a/editor/plugins/editor_resource_conversion_plugin.h
+++ b/editor/plugins/editor_resource_conversion_plugin.h
@@ -33,7 +33,6 @@
#include "core/io/resource.h"
#include "core/object/gdvirtual.gen.inc"
-#include "core/object/script_language.h"
class EditorResourceConversionPlugin : public RefCounted {
GDCLASS(EditorResourceConversionPlugin, RefCounted);
diff --git a/editor/plugins/editor_resource_tooltip_plugins.h b/editor/plugins/editor_resource_tooltip_plugins.h
index 3720396842..e3a27de0bb 100644
--- a/editor/plugins/editor_resource_tooltip_plugins.h
+++ b/editor/plugins/editor_resource_tooltip_plugins.h
@@ -33,7 +33,6 @@
#include "core/object/gdvirtual.gen.inc"
#include "core/object/ref_counted.h"
-#include "core/object/script_language.h"
#include <scene/gui/control.h>
class Control;
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.cpp b/editor/plugins/packed_scene_translation_parser_plugin.cpp
index 83d7778196..7cb5244af9 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.cpp
+++ b/editor/plugins/packed_scene_translation_parser_plugin.cpp
@@ -31,6 +31,7 @@
#include "packed_scene_translation_parser_plugin.h"
#include "core/io/resource_loader.h"
+#include "core/object/script_language.h"
#include "scene/gui/option_button.h"
#include "scene/resources/packed_scene.h"
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 0c3decb7b4..2fe607a08c 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -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);
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index a33c877d2d..0241ca0e3e 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -31,6 +31,7 @@
#ifndef SCRIPT_EDITOR_PLUGIN_H
#define SCRIPT_EDITOR_PLUGIN_H
+#include "core/object/script_language.h"
#include "editor/editor_plugin.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/panel_container.h"
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 5a1a50848f..ffe6c01ef0 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -1217,7 +1217,7 @@ void ThemeItemEditorDialog::_dialog_about_to_show() {
import_default_theme_items->reset_item_tree();
import_editor_theme_items->set_edited_theme(edited_theme);
- import_editor_theme_items->set_base_theme(EditorNode::get_singleton()->get_theme_base()->get_theme());
+ import_editor_theme_items->set_base_theme(EditorNode::get_singleton()->get_editor_theme());
import_editor_theme_items->reset_item_tree();
import_other_theme_items->set_edited_theme(edited_theme);
diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp
index 72127f7440..61bce0a89c 100644
--- a/editor/plugins/theme_editor_preview.cpp
+++ b/editor/plugins/theme_editor_preview.cpp
@@ -202,8 +202,14 @@ void ThemeEditorPreview::_notification(int p_what) {
}
connect("visibility_changed", callable_mp(this, &ThemeEditorPreview::_preview_visibility_changed));
- [[fallthrough]];
- }
+ } break;
+
+ case NOTIFICATION_READY: {
+ List<Ref<Theme>> preview_themes;
+ preview_themes.push_back(ThemeDB::get_singleton()->get_default_theme());
+ ThemeDB::get_singleton()->create_theme_context(preview_root, preview_themes);
+ } break;
+
case NOTIFICATION_THEME_CHANGED: {
picker_button->set_icon(get_editor_theme_icon(SNAME("ColorPick")));
@@ -247,9 +253,8 @@ ThemeEditorPreview::ThemeEditorPreview() {
preview_container = memnew(ScrollContainer);
preview_body->add_child(preview_container);
- MarginContainer *preview_root = memnew(MarginContainer);
+ preview_root = memnew(MarginContainer);
preview_container->add_child(preview_root);
- preview_root->set_theme(ThemeDB::get_singleton()->get_default_theme());
preview_root->set_clip_contents(true);
preview_root->set_custom_minimum_size(Size2(450, 0) * EDSCALE);
preview_root->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/plugins/theme_editor_preview.h b/editor/plugins/theme_editor_preview.h
index bd9663904a..ed888e6c14 100644
--- a/editor/plugins/theme_editor_preview.h
+++ b/editor/plugins/theme_editor_preview.h
@@ -44,6 +44,7 @@ class ThemeEditorPreview : public VBoxContainer {
GDCLASS(ThemeEditorPreview, VBoxContainer);
ScrollContainer *preview_container = nullptr;
+ MarginContainer *preview_root = nullptr;
ColorRect *preview_bg = nullptr;
MarginContainer *preview_overlay = nullptr;
Control *picker_overlay = nullptr;