Removed PaintSidebar and renamed PaintSidebarModules to PaintCustomPropertyInspector.

This commit is contained in:
Relintai 2022-11-17 10:05:05 +01:00
parent b9f0429f8c
commit 33c70f7a86
9 changed files with 25 additions and 205 deletions

View File

@ -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,"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/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_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_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/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.cpp")
module_env.add_source_files(env.modules_sources,"ui/paint_sidebar_module.cpp") module_env.add_source_files(env.modules_sources,"ui/paint_sidebar_module.cpp")

View File

@ -26,18 +26,11 @@ SOFTWARE.
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h"
#include "ui/paint_sidebar.h"
#include "ui/property_inspectors/paint_color_grid.h" #include "ui/property_inspectors/paint_color_grid.h"
#include "nodes/paint_node.h" #include "nodes/paint_node.h"
PaintSidebar *PaintEditorPlugin::get_sidebar() {
//return _sidebar;
return NULL;
}
void PaintEditorPlugin::make_visible(const bool visible) { void PaintEditorPlugin::make_visible(const bool visible) {
//_sidebar->set_visible(visible);
} }
String PaintEditorPlugin::get_name() const { String PaintEditorPlugin::get_name() const {
@ -46,8 +39,6 @@ String PaintEditorPlugin::get_name() const {
void PaintEditorPlugin::edit(Object *p_object) { void PaintEditorPlugin::edit(Object *p_object) {
_active_node = Object::cast_to<PaintNode>(p_object); _active_node = Object::cast_to<PaintNode>(p_object);
//_sidebar->on_paint_node_selected(_active_node);
} }
bool PaintEditorPlugin::handles(Object *p_object) const { bool PaintEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("PaintNode"); return p_object->is_class("PaintNode");
@ -76,32 +67,9 @@ PaintEditorPlugin::PaintEditorPlugin(EditorNode *p_node) {
_active_node = NULL; _active_node = NULL;
editor = 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;
}
PaintColorGrid *paint_color_grid = memnew(PaintColorGrid);
_sidebar->add_module(paint_color_grid);
make_visible(false);
Engine::get_singleton()->add_global("PaintEditorPlugin", this);
*/
} }
PaintEditorPlugin::~PaintEditorPlugin() { PaintEditorPlugin::~PaintEditorPlugin() {
//Engine::get_singleton()->remove_global("PaintEditorPlugin");
} }
void PaintEditorPlugin::on_node_removed(Node *node) { void PaintEditorPlugin::on_node_removed(Node *node) {
@ -111,18 +79,6 @@ void PaintEditorPlugin::on_node_removed(Node *node) {
} }
void PaintEditorPlugin::_notification(int p_what) { 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 (p_what == NOTIFICATION_READY) {
if (!get_tree()->is_connected("node_removed", this, "on_node_removed")) { if (!get_tree()->is_connected("node_removed", this, "on_node_removed")) {
get_tree()->connect("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() { 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); ClassDB::bind_method(D_METHOD("on_node_removed", "node"), &PaintEditorPlugin::on_node_removed);
} }

View File

@ -28,16 +28,12 @@ SOFTWARE.
class PaintWindow; class PaintWindow;
class Texture; class Texture;
class PaintSidebar;
class PaintNode; class PaintNode;
class PaintEditorPlugin : public EditorPlugin { class PaintEditorPlugin : public EditorPlugin {
GDCLASS(PaintEditorPlugin, EditorPlugin); GDCLASS(PaintEditorPlugin, EditorPlugin);
public: public:
//maybe the plugin should have sidebars on both sides?
PaintSidebar *get_sidebar();
void make_visible(const bool visible); void make_visible(const bool visible);
String get_name() const; String get_name() const;
void edit(Object *p_object); void edit(Object *p_object);
@ -60,7 +56,6 @@ protected:
static void _bind_methods(); static void _bind_methods();
//PaintSidebar *_sidebar;
PaintNode *_active_node; PaintNode *_active_node;
}; };

View File

@ -40,12 +40,11 @@ SOFTWARE.
#include "ui/paint_canvas_background.h" #include "ui/paint_canvas_background.h"
#include "ui/paint_canvas_outline.h" #include "ui/paint_canvas_outline.h"
#include "ui/property_inspectors/paint_color_grid.h"
#include "ui/paint_selection_box.h" #include "ui/paint_selection_box.h"
#include "ui/paint_visual_grid.h" #include "ui/paint_visual_grid.h"
#include "ui/paint_sidebar.h" #include "ui/property_inspectors/paint_color_grid.h"
#include "ui/paint_sidebar_module.h" #include "ui/property_inspectors/paint_custom_property_inspector.h"
#include "nodes/paint_canvas.h" #include "nodes/paint_canvas.h"
#include "nodes/paint_node.h" #include "nodes/paint_node.h"
@ -75,12 +74,11 @@ void register_paint_types() {
ClassDB::register_class<PaintCanvasBackground>(); ClassDB::register_class<PaintCanvasBackground>();
ClassDB::register_class<PaintCanvasOutline>(); ClassDB::register_class<PaintCanvasOutline>();
ClassDB::register_class<PaintColorGrid>();
ClassDB::register_class<PaintSelectionBox>(); ClassDB::register_class<PaintSelectionBox>();
ClassDB::register_class<PaintVisualGrid>(); ClassDB::register_class<PaintVisualGrid>();
ClassDB::register_class<PaintSidebar>(); ClassDB::register_class<PaintColorGrid>();
ClassDB::register_class<PaintSidebarModule>(); ClassDB::register_class<PaintCustomPropertyInspector>();
ClassDB::register_class<PaintNode>(); ClassDB::register_class<PaintNode>();
ClassDB::register_class<PaintCanvas>(); ClassDB::register_class<PaintCanvas>();

View File

@ -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<PaintSidebarModule>(module);
add_module(m);
}
void PaintSidebar::remove_module_bind(Node *module) {
PaintSidebarModule *m = Object::cast_to<PaintSidebarModule>(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<PaintSidebarModule>(_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<PaintNode>(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);
}

View File

@ -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

View File

@ -25,15 +25,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#include "../paint_sidebar_module.h" #include "paint_custom_property_inspector.h"
#include "core/object/object_id.h" #include "core/object/object_id.h"
class GridContainer; class GridContainer;
class PaintNode; class PaintNode;
class PaintProject; class PaintProject;
class PaintColorGrid : public PaintSidebarModule { class PaintColorGrid : public PaintCustomPropertyInspector {
GDCLASS(PaintColorGrid, PaintSidebarModule); GDCLASS(PaintColorGrid, PaintCustomPropertyInspector);
public: public:
// TODO this should store settings in PaintProjects // TODO this should store settings in PaintProjects

View File

@ -20,28 +20,28 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. 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); 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); 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"))); 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"), &PaintCustomPropertyInspector::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);
} }

View File

@ -1,5 +1,5 @@
#ifndef PAINT_SIDEBAR_MODULE_H #ifndef PAINT_CUSTOM_PROPERTY_INSPECTOR_H
#define PAINT_SIDEBAR_MODULE_H #define PAINT_CUSTOM_PROPERTY_INSPECTOR_H
/* /*
Copyright (c) 2022 Péter Magyar Copyright (c) 2022 Péter Magyar
@ -27,8 +27,8 @@ SOFTWARE.
class PaintNode; class PaintNode;
class PaintSidebarModule : public PanelContainer { class PaintCustomPropertyInspector : public PanelContainer {
GDCLASS(PaintSidebarModule, PanelContainer); GDCLASS(PaintCustomPropertyInspector, PanelContainer);
public: public:
void on_paint_node_selected(PaintNode *paint_node); void on_paint_node_selected(PaintNode *paint_node);
@ -36,8 +36,8 @@ public:
virtual void _on_paint_node_selected(Node *paint_node); virtual void _on_paint_node_selected(Node *paint_node);
PaintSidebarModule(); PaintCustomPropertyInspector();
~PaintSidebarModule(); ~PaintCustomPropertyInspector();
protected: protected:
static void _bind_methods(); static void _bind_methods();