Added a new PaintSidebar and PaintSidebarModule classes to the paint module.

This commit is contained in:
Relintai 2022-11-15 17:58:00 +01:00
parent 0963538827
commit 229677acf5
7 changed files with 233 additions and 2 deletions

View File

@ -30,6 +30,9 @@ 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/paint_sidebar.cpp")
module_env.add_source_files(env.modules_sources,"ui/paint_sidebar_module.cpp")
module_env.add_source_files(env.modules_sources,"paint_utilities.cpp") module_env.add_source_files(env.modules_sources,"paint_utilities.cpp")
module_env.add_source_files(env.modules_sources,"bush_prefabs.cpp") module_env.add_source_files(env.modules_sources,"bush_prefabs.cpp")

View File

@ -27,7 +27,10 @@ def get_doc_classes():
"PaintNode", "PaintNode",
"PaintCanvas", "PaintCanvas",
"PaintProject" "PaintProject",
"PaintSidebar",
"PaintSidebarModule",
] ]
def get_doc_path(): def get_doc_path():

View File

@ -44,8 +44,11 @@ SOFTWARE.
#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 "nodes/paint_node.h" #include "ui/paint_sidebar.h"
#include "ui/paint_sidebar_module.h"
#include "nodes/paint_canvas.h" #include "nodes/paint_canvas.h"
#include "nodes/paint_node.h"
#include "nodes/paint_project.h" #include "nodes/paint_project.h"
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
@ -76,6 +79,9 @@ void register_paint_types() {
ClassDB::register_class<PaintSelectionBox>(); ClassDB::register_class<PaintSelectionBox>();
ClassDB::register_class<PaintVisualGrid>(); ClassDB::register_class<PaintVisualGrid>();
ClassDB::register_class<PaintSidebar>();
ClassDB::register_class<PaintSidebarModule>();
ClassDB::register_class<PaintNode>(); ClassDB::register_class<PaintNode>();
ClassDB::register_class<PaintCanvas>(); ClassDB::register_class<PaintCanvas>();
ClassDB::register_class<PaintProject>(); ClassDB::register_class<PaintProject>();

View File

@ -0,0 +1,75 @@
/*
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

@ -0,0 +1,54 @@
#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

@ -0,0 +1,45 @@
/*
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_module.h"
void PaintSidebarModule::on_paint_node_selected(PaintNode *paint_node) {
call("_on_paint_node_selected", paint_node);
}
void PaintSidebarModule::on_paint_node_selected_bind(Node *paint_node) {
call("_on_paint_node_selected", paint_node);
}
void PaintSidebarModule::_on_paint_node_selected(Node *paint_node) {
}
PaintSidebarModule::PaintSidebarModule() {
}
PaintSidebarModule::~PaintSidebarModule() {
}
void PaintSidebarModule::_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);
}

View File

@ -0,0 +1,45 @@
#ifndef PAINT_SIDEBAR_MODULE_H
#define PAINT_SIDEBAR_MODULE_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 PaintNode;
class PaintSidebarModule : public PanelContainer {
GDCLASS(PaintSidebarModule, PanelContainer);
public:
void on_paint_node_selected(PaintNode *paint_node);
void on_paint_node_selected_bind(Node *paint_node);
virtual void _on_paint_node_selected(Node *paint_node);
PaintSidebarModule();
~PaintSidebarModule();
protected:
static void _bind_methods();
};
#endif