diff --git a/modules/paint/paint_editor_plugin.cpp b/modules/paint/paint_editor_plugin.cpp index 5dcd552ea..4391d90e0 100644 --- a/modules/paint/paint_editor_plugin.cpp +++ b/modules/paint/paint_editor_plugin.cpp @@ -23,6 +23,14 @@ SOFTWARE. #include "paint_editor_plugin.h" #include "core/config/engine.h" +#include "editor/editor_settings.h" +#include "editor/plugins/canvas_item_editor_plugin.h" + +#include "ui/paint_sidebar.h" + +PaintSidebar *PaintEditorPlugin::get_sidebar() { + return _sidebar; +} void PaintEditorPlugin::make_visible(const bool visible) { } @@ -34,6 +42,19 @@ String PaintEditorPlugin::get_name() const { PaintEditorPlugin::PaintEditorPlugin(EditorNode *p_node) { editor = p_node; + EDITOR_DEF("editors/paint/editor_side", 0); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/paint/editor_side", PROPERTY_HINT_ENUM, "Left,Right")); + + _sidebar = memnew(PaintSidebar); + switch ((int)EditorSettings::get_singleton()->get("editors/paint/editor_side")) { + case 0: { // Left. + add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_LEFT, _sidebar); + } break; + case 1: { // Right. + add_control_to_container(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, _sidebar); + } break; + } + make_visible(false); Engine::get_singleton()->add_global("PaintEditorPlugin", this); @@ -43,5 +64,19 @@ PaintEditorPlugin::~PaintEditorPlugin() { Engine::get_singleton()->remove_global("PaintEditorPlugin"); } -void PaintEditorPlugin::_bind_methods() { +void PaintEditorPlugin::_notification(int p_what) { + if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { + switch ((int)EditorSettings::get_singleton()->get("editors/paint/editor_side")) { + case 0: { // Left. + CanvasItemEditor::get_singleton()->move_control_to_left_panel(_sidebar); + } break; + case 1: { // Right. + CanvasItemEditor::get_singleton()->move_control_to_right_panel(_sidebar); + } break; + } + } +} + +void PaintEditorPlugin::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_sidebar"), &PaintEditorPlugin::get_sidebar); } diff --git a/modules/paint/paint_editor_plugin.h b/modules/paint/paint_editor_plugin.h index 7114373be..8552e16e6 100644 --- a/modules/paint/paint_editor_plugin.h +++ b/modules/paint/paint_editor_plugin.h @@ -28,11 +28,15 @@ SOFTWARE. class PaintWindow; class Texture; +class PaintSidebar; class PaintEditorPlugin : public EditorPlugin { GDCLASS(PaintEditorPlugin, EditorPlugin); public: + //maybe the plugin should have sidebars on both sides? + PaintSidebar *get_sidebar(); + void make_visible(const bool visible); String get_name() const; @@ -42,7 +46,11 @@ public: EditorNode *editor; protected: + void _notification(int p_what); + static void _bind_methods(); + + PaintSidebar *_sidebar; }; #endif