diff --git a/modules/paint/nodes/paint_canvas.cpp b/modules/paint/nodes/paint_canvas.cpp index b8c5d8904..53e686ca3 100644 --- a/modules/paint/nodes/paint_canvas.cpp +++ b/modules/paint/nodes/paint_canvas.cpp @@ -39,6 +39,13 @@ void PaintCanvas::set_brush_size(const int val) { _brush_size = val; } +int PaintCanvas::get_current_tool() const { + return _current_tool; +} +void PaintCanvas::set_current_tool(const int val) { + _current_tool = val; +} + bool PaintCanvas::validate_pixel_v(const Vector2i &pos) const { if (pos.x < 0 || pos.y < 0 || pos.x >= _image->get_width() || pos.y >= _image->get_height()) { return false; @@ -298,6 +305,7 @@ PaintCanvas::PaintCanvas() { _alpha_locked = false; _brush_prefab = 0; _brush_size = 1; + _current_tool = 0; _image.instance(); _preview_image.instance(); @@ -339,6 +347,10 @@ void PaintCanvas::_bind_methods() { ClassDB::bind_method(D_METHOD("set_brush_size", "val"), &PaintCanvas::set_brush_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "brush_size"), "set_brush_size", "get_brush_size"); + ClassDB::bind_method(D_METHOD("get_current_tool"), &PaintCanvas::get_current_tool); + ClassDB::bind_method(D_METHOD("set_current_tool", "val"), &PaintCanvas::set_current_tool); + ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tool"), "set_current_tool", "get_current_tool"); + ClassDB::bind_method(D_METHOD("is_inside_canvas", "x", "y"), &PaintCanvas::is_inside_canvas); ClassDB::bind_method(D_METHOD("set_pixel_arr", "pixels", "color"), &PaintCanvas::set_pixel_arr); diff --git a/modules/paint/nodes/paint_canvas.h b/modules/paint/nodes/paint_canvas.h index 61d73761a..106596baa 100644 --- a/modules/paint/nodes/paint_canvas.h +++ b/modules/paint/nodes/paint_canvas.h @@ -41,6 +41,9 @@ public: int get_brush_size() const; void set_brush_size(const int val); + int get_current_tool() const; + void set_current_tool(const int val); + bool is_inside_canvas(const int x, const int y); void set_pixel_arr(const PoolVector2iArray &pixels, const Color &color); @@ -89,6 +92,7 @@ protected: bool _alpha_locked; int _brush_prefab; int _brush_size; + int _current_tool; Ref _image; Ref _preview_image;