From 1f3ef7782f70c203b40e5b4e6b01f4639778d897 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 21 Jun 2022 18:47:22 +0200 Subject: [PATCH] Bindings for the rest of the actions. --- modules/paint/actions/brighten_action.cpp | 10 ++++++ modules/paint/actions/brighten_action.h | 5 ++- modules/paint/actions/cut_action.cpp | 43 +++++++++++++++++++++++ modules/paint/actions/cut_action.h | 12 +++++++ modules/paint/actions/darken_action.cpp | 10 ++++++ modules/paint/actions/darken_action.h | 3 ++ modules/paint/actions/line_action.cpp | 21 +++++++++++ modules/paint/actions/line_action.h | 6 ++++ modules/paint/actions/rect_action.cpp | 21 +++++++++++ modules/paint/actions/rect_action.h | 6 ++++ 10 files changed, 136 insertions(+), 1 deletion(-) diff --git a/modules/paint/actions/brighten_action.cpp b/modules/paint/actions/brighten_action.cpp index 9a61c9502..c7533dc6a 100644 --- a/modules/paint/actions/brighten_action.cpp +++ b/modules/paint/actions/brighten_action.cpp @@ -28,6 +28,13 @@ SOFTWARE. #include "../paint_canvas_layer.h" #include "../paint_utilities.h" +float BrightenAction::get_brighten_color() { + return brighten_color; +} +void BrightenAction::set_brighten_color(const float val) { + brighten_color = val; +} + void BrightenAction::do_action(PaintCanvas *canvas, const Array &data) { PaintAction::do_action(canvas, data); @@ -69,4 +76,7 @@ BrightenAction::~BrightenAction() { } void BrightenAction::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_brighten_color"), &BrightenAction::get_brighten_color); + ClassDB::bind_method(D_METHOD("set_brighten_color", "value"), &BrightenAction::set_brighten_color); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "brighten_color"), "set_", "get_brighten_color"); } diff --git a/modules/paint/actions/brighten_action.h b/modules/paint/actions/brighten_action.h index e9a03beee..3ea14efb0 100644 --- a/modules/paint/actions/brighten_action.h +++ b/modules/paint/actions/brighten_action.h @@ -33,8 +33,11 @@ class BrightenAction : public PaintAction { GDCLASS(BrightenAction, PaintAction); public: + float get_brighten_color(); + void set_brighten_color(const float val); + void do_action(PaintCanvas *canvas, const Array &data); - + BrightenAction(); ~BrightenAction(); diff --git a/modules/paint/actions/cut_action.cpp b/modules/paint/actions/cut_action.cpp index c429b2f90..b3ed92b5f 100644 --- a/modules/paint/actions/cut_action.cpp +++ b/modules/paint/actions/cut_action.cpp @@ -28,6 +28,34 @@ SOFTWARE. #include "../paint_canvas_layer.h" #include "../paint_utilities.h" +Color CutAction::get_selection_color() { + return selection_color; +} +void CutAction::set_selection_color(const Color &val) { + selection_color = val; +} + +Vector2i CutAction::get_mouse_start_pos() { + return mouse_start_pos; +} +void CutAction::set_mouse_start_pos(const Vector2i &val) { + mouse_start_pos = val; +} + +Vector2i CutAction::get_mouse_end_pos() { + return mouse_end_pos; +} +void CutAction::set_mouse_end_pos(const Vector2i &val) { + mouse_end_pos = val; +} + +bool CutAction::get_mouse_start_pos_set() { + return mouse_start_pos_set; +} +void CutAction::set_mouse_start_pos_set(const bool val) { + mouse_start_pos_set = val; +} + bool CutAction::can_commit() { return false; //ugly way of handling a cut } @@ -116,4 +144,19 @@ CutAction::~CutAction() { } void CutAction::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_selection_color"), &CutAction::get_selection_color); + ClassDB::bind_method(D_METHOD("set_selection_color", "value"), &CutAction::set_selection_color); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "selection_color"), "set_selection_color", "get_selection_color"); + + ClassDB::bind_method(D_METHOD("get_mouse_start_pos"), &CutAction::get_mouse_start_pos); + ClassDB::bind_method(D_METHOD("set_mouse_start_pos", "value"), &CutAction::set_mouse_start_pos); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "mouse_start_pos"), "set_mouse_start_pos", "get_mouse_start_pos"); + + ClassDB::bind_method(D_METHOD("get_mouse_end_pos"), &CutAction::get_mouse_end_pos); + ClassDB::bind_method(D_METHOD("set_mouse_end_pos", "value"), &CutAction::set_mouse_end_pos); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "mouse_end_pos"), "set_mouse_end_pos", "get_mouse_end_pos"); + + ClassDB::bind_method(D_METHOD("get_mouse_start_pos_set"), &CutAction::get_mouse_start_pos_set); + ClassDB::bind_method(D_METHOD("set_mouse_start_pos_set", "value"), &CutAction::set_mouse_start_pos_set); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "mouse_start_pos_set"), "set_mouse_start_pos_set", "get_mouse_start_pos_set"); } diff --git a/modules/paint/actions/cut_action.h b/modules/paint/actions/cut_action.h index 139da06c6..ccbae0898 100644 --- a/modules/paint/actions/cut_action.h +++ b/modules/paint/actions/cut_action.h @@ -33,6 +33,18 @@ class CutAction : public PaintAction { GDCLASS(CutAction, PaintAction); public: + Color get_selection_color(); + void set_selection_color(const Color &val); + + Vector2i get_mouse_start_pos(); + void set_mouse_start_pos(const Vector2i &val); + + Vector2i get_mouse_end_pos(); + void set_mouse_end_pos(const Vector2i &val); + + bool get_mouse_start_pos_set(); + void set_mouse_start_pos_set(const bool val); + bool can_commit(); void do_action(PaintCanvas *canvas, const Array &data); diff --git a/modules/paint/actions/darken_action.cpp b/modules/paint/actions/darken_action.cpp index f580fff6a..c341a89b7 100644 --- a/modules/paint/actions/darken_action.cpp +++ b/modules/paint/actions/darken_action.cpp @@ -28,6 +28,13 @@ SOFTWARE. #include "../paint_canvas_layer.h" #include "../paint_utilities.h" +float DarkenAction::get_dark_factor() { + return dark_factor; +} +void DarkenAction::set_dark_factor(const float val) { + dark_factor = val; +} + void DarkenAction::do_action(PaintCanvas *canvas, const Array &data) { PaintAction::do_action(canvas, data); @@ -70,4 +77,7 @@ DarkenAction::~DarkenAction() { } void DarkenAction::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_dark_factor"), &DarkenAction::get_dark_factor); + ClassDB::bind_method(D_METHOD("set_dark_factor", "value"), &DarkenAction::set_dark_factor); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "dark_factor"), "set_dark_factor", "get_dark_factor"); } diff --git a/modules/paint/actions/darken_action.h b/modules/paint/actions/darken_action.h index 018fd45bc..3ab645b81 100644 --- a/modules/paint/actions/darken_action.h +++ b/modules/paint/actions/darken_action.h @@ -33,6 +33,9 @@ class DarkenAction : public PaintAction { GDCLASS(DarkenAction, PaintAction); public: + float get_dark_factor(); + void set_dark_factor(const float val); + void do_action(PaintCanvas *canvas, const Array &data); DarkenAction(); diff --git a/modules/paint/actions/line_action.cpp b/modules/paint/actions/line_action.cpp index 25b9c8ccc..07191e49e 100644 --- a/modules/paint/actions/line_action.cpp +++ b/modules/paint/actions/line_action.cpp @@ -28,6 +28,20 @@ SOFTWARE. #include "../paint_canvas_layer.h" #include "../paint_utilities.h" +Vector2i LineAction::get_mouse_start_pos() { + return mouse_start_pos; +} +void LineAction::set_mouse_start_pos(const Vector2i &val) { + mouse_start_pos = val; +} + +bool LineAction::get_mouse_start_pos_set() { + return mouse_start_pos_set; +} +void LineAction::set_mouse_start_pos_set(const bool val) { + mouse_start_pos_set = val; +} + void LineAction::do_action(PaintCanvas *canvas, const Array &data) { PaintAction::do_action(canvas, data); @@ -96,4 +110,11 @@ LineAction::~LineAction() { } void LineAction::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_mouse_start_pos"), &LineAction::get_mouse_start_pos); + ClassDB::bind_method(D_METHOD("set_mouse_start_pos", "value"), &LineAction::set_mouse_start_pos); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "mouse_start_pos"), "set_mouse_start_pos", "get_mouse_start_pos"); + + ClassDB::bind_method(D_METHOD("get_mouse_start_pos_set"), &LineAction::get_mouse_start_pos_set); + ClassDB::bind_method(D_METHOD("set_mouse_start_pos_set", "value"), &LineAction::set_mouse_start_pos_set); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "mouse_start_pos_set"), "set_mouse_start_pos_set", "get_mouse_start_pos_set"); } diff --git a/modules/paint/actions/line_action.h b/modules/paint/actions/line_action.h index 7bf80900a..a6b696335 100644 --- a/modules/paint/actions/line_action.h +++ b/modules/paint/actions/line_action.h @@ -33,6 +33,12 @@ class LineAction : public PaintAction { GDCLASS(LineAction, PaintAction); public: + Vector2i get_mouse_start_pos(); + void set_mouse_start_pos(const Vector2i &val); + + bool get_mouse_start_pos_set(); + void set_mouse_start_pos_set(const bool val); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); bool can_commit(); diff --git a/modules/paint/actions/rect_action.cpp b/modules/paint/actions/rect_action.cpp index 40ad6bdcd..9b6397401 100644 --- a/modules/paint/actions/rect_action.cpp +++ b/modules/paint/actions/rect_action.cpp @@ -28,6 +28,20 @@ SOFTWARE. #include "../paint_canvas_layer.h" #include "../paint_utilities.h" +Vector2i RectAction::get_mouse_start_pos() { + return mouse_start_pos; +} +void RectAction::set_mouse_start_pos(const Vector2i &val) { + mouse_start_pos = val; +} + +bool RectAction::get_mouse_start_pos_set() { + return mouse_start_pos_set; +} +void RectAction::set_mouse_start_pos_set(const bool val) { + mouse_start_pos_set = val; +} + void RectAction::do_action(PaintCanvas *canvas, const Array &data) { PaintAction::do_action(canvas, data); @@ -103,4 +117,11 @@ RectAction::~RectAction() { } void RectAction::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_mouse_start_pos"), &RectAction::get_mouse_start_pos); + ClassDB::bind_method(D_METHOD("set_mouse_start_pos", "value"), &RectAction::set_mouse_start_pos); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "mouse_start_pos"), "set_mouse_start_pos", "get_mouse_start_pos"); + + ClassDB::bind_method(D_METHOD("get_mouse_start_pos_set"), &RectAction::get_mouse_start_pos_set); + ClassDB::bind_method(D_METHOD("set_mouse_start_pos_set", "value"), &RectAction::set_mouse_start_pos_set); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "mouse_start_pos_set"), "set_mouse_start_pos_set", "get_mouse_start_pos_set"); } diff --git a/modules/paint/actions/rect_action.h b/modules/paint/actions/rect_action.h index f8843b918..fe30f0429 100644 --- a/modules/paint/actions/rect_action.h +++ b/modules/paint/actions/rect_action.h @@ -33,6 +33,12 @@ class RectAction : public PaintAction { GDCLASS(RectAction, PaintAction); public: + Vector2i get_mouse_start_pos(); + void set_mouse_start_pos(const Vector2i &val); + + bool get_mouse_start_pos_set(); + void set_mouse_start_pos_set(const bool val); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); bool can_commit();