diff --git a/modules/paint/ui/property_inspectors/paint_project_tools_property_inspector.cpp b/modules/paint/ui/property_inspectors/paint_project_tools_property_inspector.cpp index 249645689..0c8589bd6 100644 --- a/modules/paint/ui/property_inspectors/paint_project_tools_property_inspector.cpp +++ b/modules/paint/ui/property_inspectors/paint_project_tools_property_inspector.cpp @@ -31,6 +31,7 @@ SOFTWARE. #include "core/os/dir_access.h" +#include "../../nodes/paint_canvas.h" #include "../../nodes/paint_node.h" #include "../../nodes/paint_project.h" @@ -113,6 +114,7 @@ PaintProjectToolsPropertyInspector::PaintProjectToolsPropertyInspector() { add_action_button("_on_set_colors_as_default_pressed", "Set Colors as Default", "Theme", "EditorIcons"); add_action_button("_on_add_paint_visual_grid_pressed", "Add Paint Visual Grid", "PaintVisualGrid", "EditorIcons"); add_action_button("_on_add_paint_canvas_background_pressed", "Add Paint Canvas Background", "PaintCanvasBackground", "EditorIcons"); + add_action_button("_on_add_paint_canvas_pressed", "Add Paint Canvas Background", "PaintCanvas", "EditorIcons"); } PaintProjectToolsPropertyInspector::~PaintProjectToolsPropertyInspector() { @@ -187,6 +189,16 @@ void PaintProjectToolsPropertyInspector::_on_add_paint_canvas_background_pressed paint_project->add_paint_canvas_backgorund(); } +void PaintProjectToolsPropertyInspector::_on_add_paint_canvas_pressed() { + PaintProject *paint_project = Object::cast_to(ObjectDB::get_instance(_current_paint_project)); + + ERR_FAIL_COND(!paint_project); + + PaintCanvas *canvas = memnew(PaintCanvas); + paint_project->add_child(canvas); + canvas->set_owner(paint_project->get_tree()->get_edited_scene_root()); +} + //void PaintProjectToolsPropertyInspector::_notification(int p_what) { //if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { //_add_color_button->set_icon(get_theme_icon("Add", "EditorIcons")); @@ -202,4 +214,5 @@ void PaintProjectToolsPropertyInspector::_bind_methods() { ClassDB::bind_method(D_METHOD("_on_set_colors_as_default_pressed"), &PaintProjectToolsPropertyInspector::_on_set_colors_as_default_pressed); ClassDB::bind_method(D_METHOD("_on_add_paint_visual_grid_pressed"), &PaintProjectToolsPropertyInspector::_on_add_paint_visual_grid_pressed); ClassDB::bind_method(D_METHOD("_on_add_paint_canvas_background_pressed"), &PaintProjectToolsPropertyInspector::_on_add_paint_canvas_background_pressed); + ClassDB::bind_method(D_METHOD("_on_add_paint_canvas_pressed"), &PaintProjectToolsPropertyInspector::_on_add_paint_canvas_pressed); } diff --git a/modules/paint/ui/property_inspectors/paint_project_tools_property_inspector.h b/modules/paint/ui/property_inspectors/paint_project_tools_property_inspector.h index a3be85518..a409ea494 100644 --- a/modules/paint/ui/property_inspectors/paint_project_tools_property_inspector.h +++ b/modules/paint/ui/property_inspectors/paint_project_tools_property_inspector.h @@ -53,6 +53,7 @@ protected: void _on_set_colors_as_default_pressed(); void _on_add_paint_visual_grid_pressed(); void _on_add_paint_canvas_background_pressed(); + void _on_add_paint_canvas_pressed(); //void _notification(int p_what);