Added a button that adds PaintCanvas to the PaintProjectToolsPropertyInspector.

This commit is contained in:
Relintai 2022-11-20 23:54:58 +01:00
parent 617286dd27
commit 900605e2c9
2 changed files with 14 additions and 0 deletions

View File

@ -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<PaintProject>(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);
}

View File

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