From 33c70f7a86ad99aa53397fa81d31bf144a90bf40 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 17 Nov 2022 10:05:05 +0100 Subject: [PATCH] Removed PaintSidebar and renamed PaintSidebarModules to PaintCustomPropertyInspector. --- modules/paint/SCsub | 3 +- modules/paint/paint_editor_plugin.cpp | 45 ----------- modules/paint/paint_editor_plugin.h | 5 -- modules/paint/register_types.cpp | 10 +-- modules/paint/ui/paint_sidebar.cpp | 75 ------------------- modules/paint/ui/paint_sidebar.h | 54 ------------- .../ui/property_inspectors/paint_color_grid.h | 6 +- .../paint_custom_property_inspector.cpp} | 20 ++--- .../paint_custom_property_inspector.h} | 12 +-- 9 files changed, 25 insertions(+), 205 deletions(-) delete mode 100644 modules/paint/ui/paint_sidebar.cpp delete mode 100644 modules/paint/ui/paint_sidebar.h rename modules/paint/ui/{paint_sidebar_module.cpp => property_inspectors/paint_custom_property_inspector.cpp} (69%) rename modules/paint/ui/{paint_sidebar_module.h => property_inspectors/paint_custom_property_inspector.h} (83%) diff --git a/modules/paint/SCsub b/modules/paint/SCsub index 6cacb0565..cea733e57 100644 --- a/modules/paint/SCsub +++ b/modules/paint/SCsub @@ -25,10 +25,11 @@ module_env.add_source_files(env.modules_sources,"deprecated/dialogs/paint_load_f module_env.add_source_files(env.modules_sources,"deprecated/dialogs/paint_save_file_dialog.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_canvas_outline.cpp") -module_env.add_source_files(env.modules_sources,"ui/property_inspectors/paint_color_grid.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_canvas_background.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_selection_box.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_visual_grid.cpp") +module_env.add_source_files(env.modules_sources,"ui/property_inspectors/paint_color_grid.cpp") +module_env.add_source_files(env.modules_sources,"ui/property_inspectors/paint_custom_property_inspector.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_sidebar.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_sidebar_module.cpp") diff --git a/modules/paint/paint_editor_plugin.cpp b/modules/paint/paint_editor_plugin.cpp index 2e4a42cc0..fb0aeb5aa 100644 --- a/modules/paint/paint_editor_plugin.cpp +++ b/modules/paint/paint_editor_plugin.cpp @@ -26,18 +26,11 @@ SOFTWARE. #include "editor/editor_settings.h" #include "editor/plugins/canvas_item_editor_plugin.h" -#include "ui/paint_sidebar.h" #include "ui/property_inspectors/paint_color_grid.h" #include "nodes/paint_node.h" -PaintSidebar *PaintEditorPlugin::get_sidebar() { - //return _sidebar; - return NULL; -} - void PaintEditorPlugin::make_visible(const bool visible) { - //_sidebar->set_visible(visible); } String PaintEditorPlugin::get_name() const { @@ -46,8 +39,6 @@ String PaintEditorPlugin::get_name() const { void PaintEditorPlugin::edit(Object *p_object) { _active_node = Object::cast_to(p_object); - - //_sidebar->on_paint_node_selected(_active_node); } bool PaintEditorPlugin::handles(Object *p_object) const { return p_object->is_class("PaintNode"); @@ -76,32 +67,9 @@ PaintEditorPlugin::PaintEditorPlugin(EditorNode *p_node) { _active_node = NULL; 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; - } - - PaintColorGrid *paint_color_grid = memnew(PaintColorGrid); - _sidebar->add_module(paint_color_grid); - - make_visible(false); - - Engine::get_singleton()->add_global("PaintEditorPlugin", this); -*/ } PaintEditorPlugin::~PaintEditorPlugin() { - //Engine::get_singleton()->remove_global("PaintEditorPlugin"); } void PaintEditorPlugin::on_node_removed(Node *node) { @@ -111,18 +79,6 @@ void PaintEditorPlugin::on_node_removed(Node *node) { } 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; - } - } else - */ if (p_what == NOTIFICATION_READY) { if (!get_tree()->is_connected("node_removed", this, "on_node_removed")) { get_tree()->connect("node_removed", this, "on_node_removed"); @@ -131,6 +87,5 @@ void PaintEditorPlugin::_notification(int p_what) { } void PaintEditorPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_sidebar"), &PaintEditorPlugin::get_sidebar); ClassDB::bind_method(D_METHOD("on_node_removed", "node"), &PaintEditorPlugin::on_node_removed); } diff --git a/modules/paint/paint_editor_plugin.h b/modules/paint/paint_editor_plugin.h index 5f3b95a75..9048e9cbe 100644 --- a/modules/paint/paint_editor_plugin.h +++ b/modules/paint/paint_editor_plugin.h @@ -28,16 +28,12 @@ SOFTWARE. class PaintWindow; class Texture; -class PaintSidebar; class PaintNode; 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; void edit(Object *p_object); @@ -60,7 +56,6 @@ protected: static void _bind_methods(); - //PaintSidebar *_sidebar; PaintNode *_active_node; }; diff --git a/modules/paint/register_types.cpp b/modules/paint/register_types.cpp index 2cebb93d1..6e1c40f00 100644 --- a/modules/paint/register_types.cpp +++ b/modules/paint/register_types.cpp @@ -40,12 +40,11 @@ SOFTWARE. #include "ui/paint_canvas_background.h" #include "ui/paint_canvas_outline.h" -#include "ui/property_inspectors/paint_color_grid.h" #include "ui/paint_selection_box.h" #include "ui/paint_visual_grid.h" -#include "ui/paint_sidebar.h" -#include "ui/paint_sidebar_module.h" +#include "ui/property_inspectors/paint_color_grid.h" +#include "ui/property_inspectors/paint_custom_property_inspector.h" #include "nodes/paint_canvas.h" #include "nodes/paint_node.h" @@ -75,12 +74,11 @@ void register_paint_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); diff --git a/modules/paint/ui/paint_sidebar.cpp b/modules/paint/ui/paint_sidebar.cpp deleted file mode 100644 index 1fec4e105..000000000 --- a/modules/paint/ui/paint_sidebar.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright (c) 2022 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "paint_sidebar.h" - -#include "../nodes/paint_node.h" -#include "paint_sidebar_module.h" -#include "scene/gui/box_container.h" - -void PaintSidebar::add_module(PaintSidebarModule *module) { - ERR_FAIL_COND(!module); - - _main_container->add_child(module); -} -void PaintSidebar::remove_module(PaintSidebarModule *module) { - ERR_FAIL_COND(!module); - - _main_container->remove_child(module); -} - -void PaintSidebar::add_module_bind(Node *module) { - PaintSidebarModule *m = Object::cast_to(module); - add_module(m); -} -void PaintSidebar::remove_module_bind(Node *module) { - PaintSidebarModule *m = Object::cast_to(module); - remove_module(m); -} - -PaintSidebar::PaintSidebar() { - _main_container = memnew(VBoxContainer); - add_child(_main_container); -} - -void PaintSidebar::on_paint_node_selected(PaintNode *paint_node) { - for (int i = 0; i < _main_container->get_child_count(); ++i) { - PaintSidebarModule *module = Object::cast_to(_main_container->get_child(i)); - - if (module) { - module->on_paint_node_selected(paint_node); - } - } -} -void PaintSidebar::on_paint_node_selected_bind(Node *paint_node) { - PaintNode *m = Object::cast_to(paint_node); - on_paint_node_selected(m); -} - -PaintSidebar::~PaintSidebar() { -} - -void PaintSidebar::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_module", "module"), &PaintSidebar::add_module_bind); - ClassDB::bind_method(D_METHOD("remove_module", "module"), &PaintSidebar::remove_module_bind); - ClassDB::bind_method(D_METHOD("on_paint_node_selected", "paint_node"), &PaintSidebar::on_paint_node_selected_bind); -} diff --git a/modules/paint/ui/paint_sidebar.h b/modules/paint/ui/paint_sidebar.h deleted file mode 100644 index 610b091dc..000000000 --- a/modules/paint/ui/paint_sidebar.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef PAINT_SIDEBAR_H -#define PAINT_SIDEBAR_H - -/* -Copyright (c) 2022 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "scene/gui/panel_container.h" - -class VBoxContainer; -class PaintSidebarModule; -class PaintNode; - -class PaintSidebar : public PanelContainer { - GDCLASS(PaintSidebar, PanelContainer); - -public: - void add_module(PaintSidebarModule *module); - void remove_module(PaintSidebarModule *module); - - void add_module_bind(Node *module); - void remove_module_bind(Node *module); - - void on_paint_node_selected(PaintNode *paint_node); - void on_paint_node_selected_bind(Node *paint_node); - - PaintSidebar(); - ~PaintSidebar(); - -protected: - static void _bind_methods(); - - VBoxContainer *_main_container; -}; - -#endif diff --git a/modules/paint/ui/property_inspectors/paint_color_grid.h b/modules/paint/ui/property_inspectors/paint_color_grid.h index 79336955f..63fb5cac0 100644 --- a/modules/paint/ui/property_inspectors/paint_color_grid.h +++ b/modules/paint/ui/property_inspectors/paint_color_grid.h @@ -25,15 +25,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "../paint_sidebar_module.h" +#include "paint_custom_property_inspector.h" #include "core/object/object_id.h" class GridContainer; class PaintNode; class PaintProject; -class PaintColorGrid : public PaintSidebarModule { - GDCLASS(PaintColorGrid, PaintSidebarModule); +class PaintColorGrid : public PaintCustomPropertyInspector { + GDCLASS(PaintColorGrid, PaintCustomPropertyInspector); public: // TODO this should store settings in PaintProjects diff --git a/modules/paint/ui/paint_sidebar_module.cpp b/modules/paint/ui/property_inspectors/paint_custom_property_inspector.cpp similarity index 69% rename from modules/paint/ui/paint_sidebar_module.cpp rename to modules/paint/ui/property_inspectors/paint_custom_property_inspector.cpp index 094481806..0fb265423 100644 --- a/modules/paint/ui/paint_sidebar_module.cpp +++ b/modules/paint/ui/property_inspectors/paint_custom_property_inspector.cpp @@ -20,28 +20,28 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "paint_sidebar_module.h" +#include "paint_custom_property_inspector.h" -#include "../nodes/paint_node.h" +#include "../../nodes/paint_node.h" -void PaintSidebarModule::on_paint_node_selected(PaintNode *paint_node) { +void PaintCustomPropertyInspector::on_paint_node_selected(PaintNode *paint_node) { call("_on_paint_node_selected", paint_node); } -void PaintSidebarModule::on_paint_node_selected_bind(Node *paint_node) { +void PaintCustomPropertyInspector::on_paint_node_selected_bind(Node *paint_node) { call("_on_paint_node_selected", paint_node); } -void PaintSidebarModule::_on_paint_node_selected(Node *paint_node) { +void PaintCustomPropertyInspector::_on_paint_node_selected(Node *paint_node) { } -PaintSidebarModule::PaintSidebarModule() { +PaintCustomPropertyInspector::PaintCustomPropertyInspector() { } -PaintSidebarModule::~PaintSidebarModule() { +PaintCustomPropertyInspector::~PaintCustomPropertyInspector() { } -void PaintSidebarModule::_bind_methods() { +void PaintCustomPropertyInspector::_bind_methods() { BIND_VMETHOD(MethodInfo("_on_paint_node_selected", PropertyInfo(Variant::OBJECT, "paint_node", PROPERTY_HINT_RESOURCE_TYPE, "PaintNode"))); - ClassDB::bind_method(D_METHOD("on_paint_node_selected", "paint_node"), &PaintSidebarModule::on_paint_node_selected_bind); - ClassDB::bind_method(D_METHOD("_on_paint_node_selected", "paint_node"), &PaintSidebarModule::_on_paint_node_selected); + ClassDB::bind_method(D_METHOD("on_paint_node_selected", "paint_node"), &PaintCustomPropertyInspector::on_paint_node_selected_bind); + ClassDB::bind_method(D_METHOD("_on_paint_node_selected", "paint_node"), &PaintCustomPropertyInspector::_on_paint_node_selected); } diff --git a/modules/paint/ui/paint_sidebar_module.h b/modules/paint/ui/property_inspectors/paint_custom_property_inspector.h similarity index 83% rename from modules/paint/ui/paint_sidebar_module.h rename to modules/paint/ui/property_inspectors/paint_custom_property_inspector.h index 463da024b..2d132b859 100644 --- a/modules/paint/ui/paint_sidebar_module.h +++ b/modules/paint/ui/property_inspectors/paint_custom_property_inspector.h @@ -1,5 +1,5 @@ -#ifndef PAINT_SIDEBAR_MODULE_H -#define PAINT_SIDEBAR_MODULE_H +#ifndef PAINT_CUSTOM_PROPERTY_INSPECTOR_H +#define PAINT_CUSTOM_PROPERTY_INSPECTOR_H /* Copyright (c) 2022 Péter Magyar @@ -27,8 +27,8 @@ SOFTWARE. class PaintNode; -class PaintSidebarModule : public PanelContainer { - GDCLASS(PaintSidebarModule, PanelContainer); +class PaintCustomPropertyInspector : public PanelContainer { + GDCLASS(PaintCustomPropertyInspector, PanelContainer); public: void on_paint_node_selected(PaintNode *paint_node); @@ -36,8 +36,8 @@ public: virtual void _on_paint_node_selected(Node *paint_node); - PaintSidebarModule(); - ~PaintSidebarModule(); + PaintCustomPropertyInspector(); + ~PaintCustomPropertyInspector(); protected: static void _bind_methods();