From 25d219a4a07b9f2fb8798a31e79abdd7ec6ca929 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 16 Apr 2022 02:35:03 +0200 Subject: [PATCH] Const qualifiers and references for the paint module. --- modules/paint/actions/brighten_action.cpp | 2 +- modules/paint/actions/brighten_action.h | 2 +- modules/paint/actions/brush_action.cpp | 2 +- modules/paint/actions/brush_action.h | 2 +- modules/paint/actions/bucket_action.cpp | 2 +- modules/paint/actions/bucket_action.h | 2 +- modules/paint/actions/cut_action.cpp | 2 +- modules/paint/actions/cut_action.h | 2 +- modules/paint/actions/darken_action.cpp | 2 +- modules/paint/actions/darken_action.h | 2 +- modules/paint/actions/line_action.cpp | 2 +- modules/paint/actions/line_action.h | 2 +- modules/paint/actions/multiline_action.cpp | 2 +- modules/paint/actions/multiline_action.h | 2 +- modules/paint/actions/paint_action.cpp | 10 +-- modules/paint/actions/paint_action.h | 10 +-- modules/paint/actions/paste_cut_action.cpp | 2 +- modules/paint/actions/paste_cut_action.h | 2 +- modules/paint/actions/pencil_action.cpp | 2 +- modules/paint/actions/pencil_action.h | 2 +- modules/paint/actions/rainbow_action.cpp | 2 +- modules/paint/actions/rainbow_action.h | 2 +- modules/paint/actions/rect_action.cpp | 2 +- modules/paint/actions/rect_action.h | 2 +- modules/paint/bush_prefabs.cpp | 2 +- modules/paint/bush_prefabs.h | 2 +- .../paint/dialogs/paint_load_file_dialog.cpp | 2 +- .../paint/dialogs/paint_load_file_dialog.h | 2 +- .../paint/dialogs/paint_save_file_dialog.cpp | 2 +- .../paint/dialogs/paint_save_file_dialog.h | 2 +- modules/paint/paint_canvas.cpp | 64 +++++++++---------- modules/paint/paint_canvas.h | 64 +++++++++---------- modules/paint/paint_canvas_layer.cpp | 10 +-- modules/paint/paint_canvas_layer.h | 10 +-- modules/paint/paint_canvas_outline.cpp | 2 +- modules/paint/paint_canvas_outline.h | 2 +- modules/paint/paint_editor_plugin.cpp | 2 +- modules/paint/paint_editor_plugin.h | 2 +- modules/paint/paint_navbar.cpp | 16 ++--- modules/paint/paint_navbar.h | 16 ++--- modules/paint/paint_selection_box.cpp | 2 +- modules/paint/paint_selection_box.h | 2 +- modules/paint/paint_settings.cpp | 4 +- modules/paint/paint_settings.h | 4 +- modules/paint/paint_text_info.h | 4 +- modules/paint/paint_window.cpp | 26 ++++---- modules/paint/paint_window.h | 26 ++++---- 47 files changed, 166 insertions(+), 166 deletions(-) diff --git a/modules/paint/actions/brighten_action.cpp b/modules/paint/actions/brighten_action.cpp index 1930d2865..5aa60846a 100644 --- a/modules/paint/actions/brighten_action.cpp +++ b/modules/paint/actions/brighten_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "brighten_action.h" -void BrightenAction::do_action(PaintCanvas *canvas, Array data) { +void BrightenAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/brighten_action.h b/modules/paint/actions/brighten_action.h index d06cb2002..40d9d8526 100644 --- a/modules/paint/actions/brighten_action.h +++ b/modules/paint/actions/brighten_action.h @@ -33,7 +33,7 @@ class BrightenAction : public PaintAction { GDCLASS(BrightenAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/brush_action.cpp b/modules/paint/actions/brush_action.cpp index 75fbb1d4e..ea89c0e70 100644 --- a/modules/paint/actions/brush_action.cpp +++ b/modules/paint/actions/brush_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "brush_action.h" -void BrushAction::do_action(PaintCanvas *canvas, Array data) { +void BrushAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/brush_action.h b/modules/paint/actions/brush_action.h index b2e4f6895..25b425ad0 100644 --- a/modules/paint/actions/brush_action.h +++ b/modules/paint/actions/brush_action.h @@ -33,7 +33,7 @@ class BrushAction : public PaintAction { GDCLASS(BrushAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/bucket_action.cpp b/modules/paint/actions/bucket_action.cpp index 253a4a4e9..d5c70d86f 100644 --- a/modules/paint/actions/bucket_action.cpp +++ b/modules/paint/actions/bucket_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "bucket_action.h" -void BucketAction::do_action(PaintCanvas *canvas, Array data) { +void BucketAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/bucket_action.h b/modules/paint/actions/bucket_action.h index 472e589ba..96c5e7db6 100644 --- a/modules/paint/actions/bucket_action.h +++ b/modules/paint/actions/bucket_action.h @@ -33,7 +33,7 @@ class BucketAction : public PaintAction { GDCLASS(BucketAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/cut_action.cpp b/modules/paint/actions/cut_action.cpp index d098579f1..c1d4e1408 100644 --- a/modules/paint/actions/cut_action.cpp +++ b/modules/paint/actions/cut_action.cpp @@ -28,7 +28,7 @@ bool CutAction::can_commit() { return false; //ugly way of handling a cut } -void CutAction::do_action(PaintCanvas *canvas, Array data) { +void CutAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/cut_action.h b/modules/paint/actions/cut_action.h index 264f69841..f8f85d189 100644 --- a/modules/paint/actions/cut_action.h +++ b/modules/paint/actions/cut_action.h @@ -35,7 +35,7 @@ class CutAction : public PaintAction { public: bool can_commit(); - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/darken_action.cpp b/modules/paint/actions/darken_action.cpp index 785341a91..861785f29 100644 --- a/modules/paint/actions/darken_action.cpp +++ b/modules/paint/actions/darken_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "darken_action.h" -void DarkenAction::do_action(PaintCanvas *canvas, Array data) { +void DarkenAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/darken_action.h b/modules/paint/actions/darken_action.h index a5957d8e7..a8c110a14 100644 --- a/modules/paint/actions/darken_action.h +++ b/modules/paint/actions/darken_action.h @@ -33,7 +33,7 @@ class DarkenAction : public PaintAction { GDCLASS(DarkenAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/line_action.cpp b/modules/paint/actions/line_action.cpp index 286057ac1..d2ec5d46f 100644 --- a/modules/paint/actions/line_action.cpp +++ b/modules/paint/actions/line_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "line_action.h" -void LineAction::do_action(PaintCanvas *canvas, Array data) { +void LineAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/line_action.h b/modules/paint/actions/line_action.h index 7033a99b6..c43f0cd0c 100644 --- a/modules/paint/actions/line_action.h +++ b/modules/paint/actions/line_action.h @@ -33,7 +33,7 @@ class LineAction : public PaintAction { GDCLASS(LineAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/multiline_action.cpp b/modules/paint/actions/multiline_action.cpp index e0248e9c6..324e449c3 100644 --- a/modules/paint/actions/multiline_action.cpp +++ b/modules/paint/actions/multiline_action.cpp @@ -28,7 +28,7 @@ bool MultiLineAction::can_commit() { return false; } -void MultiLineAction::do_action(PaintCanvas *canvas, Array data) { +void MultiLineAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/multiline_action.h b/modules/paint/actions/multiline_action.h index 3eeffc234..ad54aeb26 100644 --- a/modules/paint/actions/multiline_action.h +++ b/modules/paint/actions/multiline_action.h @@ -35,7 +35,7 @@ class MultiLineAction : public PaintAction { public: bool can_commit(); - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/paint_action.cpp b/modules/paint/actions/paint_action.cpp index f42de09be..019fed14b 100644 --- a/modules/paint/actions/paint_action.cpp +++ b/modules/paint/actions/paint_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "paint_action.h" -void PaintAction::do_action(PaintCanvas *canvas, Array data) { +void PaintAction::do_action(PaintCanvas *canvas, const Array &data) { if (!action_data_redo.has("cells")) { action_data_redo["cells"] = Array(); action_data_redo["colors"] = Array(); @@ -58,7 +58,7 @@ bool PaintAction::can_commit() { return !action_data_redo.empty(); } -PoolVector2iArray PaintAction::get_x_sym_points(int canvas_width, Vector2i pixel) { +PoolVector2iArray PaintAction::get_x_sym_points(const int canvas_width, const Vector2i &pixel) { int p = canvas_width - pixel.x; PoolVector2iArray points; @@ -67,7 +67,7 @@ PoolVector2iArray PaintAction::get_x_sym_points(int canvas_width, Vector2i pixel return points; } -PoolVector2iArray PaintAction::get_y_sym_points(int canvas_height, Vector2i pixel) { +PoolVector2iArray PaintAction::get_y_sym_points(const int canvas_height, const Vector2i &pixel) { int p = canvas_height - pixel.y; PoolVector2iArray points; @@ -76,7 +76,7 @@ PoolVector2iArray PaintAction::get_y_sym_points(int canvas_height, Vector2i pixe return points; } -PoolVector2iArray PaintAction::get_xy_sym_points(int canvas_width, int canvas_height, Vector2i pixel) { +PoolVector2iArray PaintAction::get_xy_sym_points(const int canvas_width, const int canvas_height, const Vector2i &pixel) { PoolVector2iArray all_points; PoolVector2iArray xpoints = get_x_sym_points(canvas_width, pixel); @@ -102,7 +102,7 @@ PoolVector2iArray PaintAction::get_xy_sym_points(int canvas_width, int canvas_he return points; } -PoolVector2iArray PaintAction::get_points(PaintCanvas *canvas, Vector2i pixel) { +PoolVector2iArray PaintAction::get_points(PaintCanvas *canvas, const Vector2i &pixel) { /* PoolVector2iArray points; if canvas.symmetry_x and canvas.symmetry_y: diff --git a/modules/paint/actions/paint_action.h b/modules/paint/actions/paint_action.h index 4e62595dc..0c8ff6fe1 100644 --- a/modules/paint/actions/paint_action.h +++ b/modules/paint/actions/paint_action.h @@ -41,17 +41,17 @@ class PaintAction : public Reference { GDCLASS(PaintAction, Reference); public: - virtual void do_action(PaintCanvas *canvas, Array data); + virtual void do_action(PaintCanvas *canvas, const Array &data); virtual void commit_action(PaintCanvas *canvas); virtual void undo_action(PaintCanvas *canvas); virtual void redo_action(PaintCanvas *canvas); virtual bool can_commit(); - virtual PoolVector2iArray get_x_sym_points(int canvas_width, Vector2i pixel); - virtual PoolVector2iArray get_y_sym_points(int canvas_height, Vector2i pixel); - virtual PoolVector2iArray get_xy_sym_points(int canvas_width, int canvas_height, Vector2i pixel); - virtual PoolVector2iArray get_points(PaintCanvas *canvas, Vector2i pixel); + virtual PoolVector2iArray get_x_sym_points(const int canvas_width, const Vector2i &pixel); + virtual PoolVector2iArray get_y_sym_points(const int canvas_height, const Vector2i &pixel); + virtual PoolVector2iArray get_xy_sym_points(const int canvas_width, const int canvas_height, const Vector2i &pixel); + virtual PoolVector2iArray get_points(PaintCanvas *canvas, const Vector2i &pixel); PaintAction(); ~PaintAction(); diff --git a/modules/paint/actions/paste_cut_action.cpp b/modules/paint/actions/paste_cut_action.cpp index c04468a05..4e98c983a 100644 --- a/modules/paint/actions/paste_cut_action.cpp +++ b/modules/paint/actions/paste_cut_action.cpp @@ -28,7 +28,7 @@ SOFTWARE. //data[3] = selection_color //data[4] = cut pos //data[5] = cut size -void PasteCutAction::do_action(PaintCanvas *canvas, Array data) { +void PasteCutAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/paste_cut_action.h b/modules/paint/actions/paste_cut_action.h index f9f294623..30deac68b 100644 --- a/modules/paint/actions/paste_cut_action.h +++ b/modules/paint/actions/paste_cut_action.h @@ -33,7 +33,7 @@ class PasteCutAction : public PaintAction { GDCLASS(PasteCutAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/pencil_action.cpp b/modules/paint/actions/pencil_action.cpp index 10194c07f..db0bb4230 100644 --- a/modules/paint/actions/pencil_action.cpp +++ b/modules/paint/actions/pencil_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "pencil_action.h" -void PencilAction::do_action(PaintCanvas *canvas, Array data) { +void PencilAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/pencil_action.h b/modules/paint/actions/pencil_action.h index 88d433ce3..1cacdce8f 100644 --- a/modules/paint/actions/pencil_action.h +++ b/modules/paint/actions/pencil_action.h @@ -33,7 +33,7 @@ class PencilAction : public PaintAction { GDCLASS(PencilAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/rainbow_action.cpp b/modules/paint/actions/rainbow_action.cpp index 28cf72dff..52ed220f1 100644 --- a/modules/paint/actions/rainbow_action.cpp +++ b/modules/paint/actions/rainbow_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "rainbow_action.h" -void RainbowAction::do_action(PaintCanvas *canvas, Array data) { +void RainbowAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/rainbow_action.h b/modules/paint/actions/rainbow_action.h index 5a70f525d..40d9e87e2 100644 --- a/modules/paint/actions/rainbow_action.h +++ b/modules/paint/actions/rainbow_action.h @@ -33,7 +33,7 @@ class RainbowAction : public PaintAction { GDCLASS(RainbowAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/actions/rect_action.cpp b/modules/paint/actions/rect_action.cpp index be8a36f87..a322d09ef 100644 --- a/modules/paint/actions/rect_action.cpp +++ b/modules/paint/actions/rect_action.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "rect_action.h" -void RectAction::do_action(PaintCanvas *canvas, Array data) { +void RectAction::do_action(PaintCanvas *canvas, const Array &data) { /* .do_action(canvas, data) diff --git a/modules/paint/actions/rect_action.h b/modules/paint/actions/rect_action.h index ecfc01efa..cf0970fbf 100644 --- a/modules/paint/actions/rect_action.h +++ b/modules/paint/actions/rect_action.h @@ -33,7 +33,7 @@ class RectAction : public PaintAction { GDCLASS(RectAction, PaintAction); public: - void do_action(PaintCanvas *canvas, Array data); + void do_action(PaintCanvas *canvas, const Array &data); void commit_action(PaintCanvas *canvas); void undo_action(PaintCanvas *canvas); diff --git a/modules/paint/bush_prefabs.cpp b/modules/paint/bush_prefabs.cpp index 8482517b7..628dda564 100644 --- a/modules/paint/bush_prefabs.cpp +++ b/modules/paint/bush_prefabs.cpp @@ -44,7 +44,7 @@ const list = [ ] */ -PoolVector3iArray BrushPrefabs::get_brush(BrushPrefabs::Type type, int size) { +PoolVector3iArray BrushPrefabs::get_brush(const BrushPrefabs::Type type, const int size) { /* var pixels = [] if size < 1: diff --git a/modules/paint/bush_prefabs.h b/modules/paint/bush_prefabs.h index 4b333b53c..759ab93a7 100644 --- a/modules/paint/bush_prefabs.h +++ b/modules/paint/bush_prefabs.h @@ -39,7 +39,7 @@ public: CIRCLE, }; - static PoolVector3iArray get_brush(Type type, int size); + static PoolVector3iArray get_brush(const Type type, const int size); BrushPrefabs(); ~BrushPrefabs(); diff --git a/modules/paint/dialogs/paint_load_file_dialog.cpp b/modules/paint/dialogs/paint_load_file_dialog.cpp index a05b88173..83609b417 100644 --- a/modules/paint/dialogs/paint_load_file_dialog.cpp +++ b/modules/paint/dialogs/paint_load_file_dialog.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "paint_load_file_dialog.h" -void PaintLoadFileDialog::_on_LoadFileDialog_file_selected(String path) { +void PaintLoadFileDialog::_on_LoadFileDialog_file_selected(const String &path) { /* file_path = path #print("1ere") diff --git a/modules/paint/dialogs/paint_load_file_dialog.h b/modules/paint/dialogs/paint_load_file_dialog.h index 1d503429f..e05e3132c 100644 --- a/modules/paint/dialogs/paint_load_file_dialog.h +++ b/modules/paint/dialogs/paint_load_file_dialog.h @@ -31,7 +31,7 @@ class PaintLoadFileDialog : public FileDialog { GDCLASS(PaintLoadFileDialog, FileDialog); public: - void _on_LoadFileDialog_file_selected(String path); + void _on_LoadFileDialog_file_selected(const String &path); void _on_LoadFileDialog_confirmed(); void load_img(); void _on_LoadFileDialog_about_to_show(); diff --git a/modules/paint/dialogs/paint_save_file_dialog.cpp b/modules/paint/dialogs/paint_save_file_dialog.cpp index f5178b25b..9e68b09b9 100644 --- a/modules/paint/dialogs/paint_save_file_dialog.cpp +++ b/modules/paint/dialogs/paint_save_file_dialog.cpp @@ -33,7 +33,7 @@ void PaintSaveFileDialog::_ready() { add_filter("*.png ; PNG Images") */ } -void PaintSaveFileDialog::_on_SaveFileDialog_file_selected(String path) { +void PaintSaveFileDialog::_on_SaveFileDialog_file_selected(const String &path) { /* #print("selected file: ", path) file_path = path diff --git a/modules/paint/dialogs/paint_save_file_dialog.h b/modules/paint/dialogs/paint_save_file_dialog.h index cf83d8fb6..642ce4565 100644 --- a/modules/paint/dialogs/paint_save_file_dialog.h +++ b/modules/paint/dialogs/paint_save_file_dialog.h @@ -32,7 +32,7 @@ class PaintSaveFileDialog : public FileDialog { public: void _ready(); - void _on_SaveFileDialog_file_selected(String path); + void _on_SaveFileDialog_file_selected(const String &path); void save_file(); void _on_SaveFileDialog_about_to_show(); void _on_SaveFileDialog_visibility_changed(); diff --git a/modules/paint/paint_canvas.cpp b/modules/paint/paint_canvas.cpp index 3dff03818..50a0d9508 100644 --- a/modules/paint/paint_canvas.cpp +++ b/modules/paint/paint_canvas.cpp @@ -72,7 +72,7 @@ void PaintCanvas::_draw() { */ } -void PaintCanvas::resize(int width, int height) { +void PaintCanvas::resize(const int width, const int height) { /* if width < 0: width = 1 @@ -88,7 +88,7 @@ void PaintCanvas::resize(int width, int height) { layer.resize(width, height) */ } -void PaintCanvas::set_pixel_size(int size) { +void PaintCanvas::set_pixel_size(const int size) { /* pixel_size = size set_grid_size(grid_size) @@ -97,7 +97,7 @@ void PaintCanvas::set_pixel_size(int size) { set_canvas_height(canvas_height) */ } -void PaintCanvas::set_grid_size(int size) { +void PaintCanvas::set_grid_size(const int size) { /* grid_size = size if not find_node("Grid"): @@ -105,7 +105,7 @@ void PaintCanvas::set_grid_size(int size) { find_node("Grid").size = size * pixel_size */ } -void PaintCanvas::set_big_grid_size(int size) { +void PaintCanvas::set_big_grid_size(const int size) { /* big_grid_size = size if not find_node("BigGrid"): @@ -113,19 +113,19 @@ void PaintCanvas::set_big_grid_size(int size) { find_node("BigGrid").size = size * pixel_size */ } -void PaintCanvas::set_canvas_width(int val) { +void PaintCanvas::set_canvas_width(const int val) { /* canvas_width = val rect_size.x = canvas_width * pixel_size */ } -void PaintCanvas::set_canvas_height(int val) { +void PaintCanvas::set_canvas_height(const int val) { /* canvas_height = val rect_size.y = canvas_height * pixel_size */ } -void PaintCanvas::toggle_alpha_locked(String layer_name) { +void PaintCanvas::toggle_alpha_locked(const String &layer_name) { /* var layer = find_layer_by_name(layer_name) layer.toggle_alpha_locked() @@ -196,7 +196,7 @@ void PaintCanvas::clear_preview_layer() { */ } -void PaintCanvas::clear_layer(String layer_name) { +void PaintCanvas::clear_layer(const String &layer_name) { /* for layer in layers: if layer.name == layer_name: @@ -204,7 +204,7 @@ void PaintCanvas::clear_layer(String layer_name) { break */ } -Node *PaintCanvas::remove_layer(String layer_name) { +Node *PaintCanvas::remove_layer(const String &layer_name) { /* # change current layer if the active layer is removed var del_layer = find_layer_by_name(layer_name) @@ -219,7 +219,7 @@ Node *PaintCanvas::remove_layer(String layer_name) { return active_layer */ } -Node *PaintCanvas::add_new_layer(String layer_name) { +Node *PaintCanvas::add_new_layer(const String &layer_name) { /* for layer in layers: if layer.name == layer_name: @@ -247,7 +247,7 @@ Node *PaintCanvas::add_new_layer(String layer_name) { return layer */ } -Node *PaintCanvas::duplicate_layer(String layer_name, String new_layer_name) { +Node *PaintCanvas::duplicate_layer(const String &layer_name, const String &new_layer_name) { /* for layer in layers: if layer.name == new_layer_name: @@ -259,14 +259,14 @@ Node *PaintCanvas::duplicate_layer(String layer_name, String new_layer_name) { return layer */ } -void PaintCanvas::toggle_layer_visibility(String layer_name) { +void PaintCanvas::toggle_layer_visibility(const String &layer_name) { /* for layer in layers: if layer.name == layer_name: layer.visible = not layer.visible */ } -Node *PaintCanvas::find_layer_by_name(String layer_name) { +Node *PaintCanvas::find_layer_by_name(const String &layer_name) { /* for layer in layers: if layer.name == layer_name: @@ -274,7 +274,7 @@ Node *PaintCanvas::find_layer_by_name(String layer_name) { return null */ } -void PaintCanvas::toggle_lock_layer(String layer_name) { +void PaintCanvas::toggle_lock_layer(const String &layer_name) { /* find_layer_by_name(layer_name).toggle_lock() */ @@ -284,21 +284,21 @@ bool PaintCanvas::is_active_layer_locked() { return active_layer.locked */ } -void PaintCanvas::move_layer_forward(String layer_name) { +void PaintCanvas::move_layer_forward(const String &layer_name) { /* var layer = find_layer_by_name(layer_name).texture_rect_ref var new_idx = max(layer.get_index() - 1, 0) canvas_layers.move_child(layer, new_idx) */ } -void PaintCanvas::move_layer_back(String layer_name) { +void PaintCanvas::move_layer_back(const String &layer_name) { /* var layer = find_layer_by_name(layer_name).texture_rect_ref canvas_layers.move_child(layer, layer.get_index() + 1) */ } -void PaintCanvas::select_layer(String layer_name) { +void PaintCanvas::select_layer(const String &layer_name) { /* active_layer = find_layer_by_name(layer_name) */ @@ -313,7 +313,7 @@ void PaintCanvas::_on_mouse_exited() { mouse_on_top = false */ } -bool PaintCanvas::is_inside_canvas(int x, int y) { +bool PaintCanvas::is_inside_canvas(const int x, const int y) { /* if x < 0 or y < 0: return false @@ -326,66 +326,66 @@ bool PaintCanvas::is_inside_canvas(int x, int y) { //Note: Arrays are always passed by reference. To get a copy of an array which // can be modified independently of the original array, use duplicate. // (https://docs.godotengine.org/en/stable/classes/class_array.html) -void PaintCanvas::set_pixel_arr(Array pixels, Color color) { +void PaintCanvas::set_pixel_arr(const Array &pixels, const Color &color) { /* for pixel in pixels: _set_pixel(active_layer, pixel.x, pixel.y, color) */ } -void PaintCanvas::set_pixel_v(Vector2 pos, Color color) { +void PaintCanvas::set_pixel_v(const Vector2 &pos, const Color &color) { /* set_pixel(pos.x, pos.y, color) */ } -void PaintCanvas::set_pixel(int x, int y, Color color) { +void PaintCanvas::set_pixel(const int x, const int y, const Color &color) { /* _set_pixel(active_layer, x, y, color) */ } -void PaintCanvas::_set_pixel_v(PaintCanvasLayer *layer, Vector2 v, Color color) { +void PaintCanvas::_set_pixel_v(PaintCanvasLayer *layer, const Vector2 &v, const Color &color) { /* _set_pixel(layer, v.x, v.y, color) */ } -void PaintCanvas::_set_pixel(PaintCanvasLayer *layer, int x, int y, Color color) { +void PaintCanvas::_set_pixel(PaintCanvasLayer *layer, const int x, const int y, const Color &color) { /* if not is_inside_canvas(x, y): return layer.set_pixel(x, y, color) */ } -Color PaintCanvas::get_pixel_v(Vector2 pos) { +Color PaintCanvas::get_pixel_v(const Vector2 &pos) { /* return get_pixel(pos.x, pos.y) */ } -Color PaintCanvas::get_pixel(int x, int y) { +Color PaintCanvas::get_pixel(const int x, const int y) { /* if active_layer: return active_layer.get_pixel(x, y) return null */ } -void PaintCanvas::set_preview_pixel_v(Vector2 pos, Color color) { +void PaintCanvas::set_preview_pixel_v(const Vector2 &pos, const Color &color) { /* set_preview_pixel(pos.x, pos.y, color) */ } -void PaintCanvas::set_preview_pixel(int x, int y, Color color) { +void PaintCanvas::set_preview_pixel(const int x, const int y, const Color &color) { /* if not is_inside_canvas(x, y): return preview_layer.set_pixel(x, y, color) */ } -Color PaintCanvas::get_preview_pixel_v(Vector2 pos) { +Color PaintCanvas::get_preview_pixel_v(const Vector2 &pos) { /* return get_preview_pixel(pos.x, pos.y) */ } -Color PaintCanvas::get_preview_pixel(int x, int y) { +Color PaintCanvas::get_preview_pixel(const int x, const int y) { /* if not preview_layer: return null @@ -408,7 +408,7 @@ void PaintCanvas::hide_grid() { */ } -Array PaintCanvas::select_color(int x, int y) { +Array PaintCanvas::select_color(const int x, const int y) { /* print("???") var same_color_pixels = [] @@ -421,7 +421,7 @@ Array PaintCanvas::select_color(int x, int y) { return same_color_pixels */ } -Array PaintCanvas::select_same_color(int x, int y) { +Array PaintCanvas::select_same_color(const int x, const int y) { /* return get_neighbouring_pixels(x, y) */ @@ -430,7 +430,7 @@ Array PaintCanvas::select_same_color(int x, int y) { // returns array of Vector2 // yoinked from // https://www.geeksforgeeks.org/flood-fill-algorithm-implement-fill-paint/ -Array PaintCanvas::get_neighbouring_pixels(int pos_x, int pos_y) { +Array PaintCanvas::get_neighbouring_pixels(const int pos_x, const int pos_y) { /* var pixels = [] diff --git a/modules/paint/paint_canvas.h b/modules/paint/paint_canvas.h index c8d325580..538f9368a 100644 --- a/modules/paint/paint_canvas.h +++ b/modules/paint/paint_canvas.h @@ -38,15 +38,15 @@ public: void _process(float delta); void _draw(); - void resize(int width, int height); + void resize(const int width, const int height); - void set_pixel_size(int size); - void set_grid_size(int size); - void set_big_grid_size(int size); - void set_canvas_width(int val); - void set_canvas_height(int val); + void set_pixel_size(const int size); + void set_grid_size(const int size); + void set_big_grid_size(const int size); + void set_canvas_width(const int val); + void set_canvas_height(const int val); - void toggle_alpha_locked(String layer_name); + void toggle_alpha_locked(const String &layer_name); bool is_alpha_locked(); Rect2 get_content_margin(); @@ -56,41 +56,41 @@ public: Node *get_preview_layer(); void clear_active_layer(); void clear_preview_layer(); - void clear_layer(String layer_name); - Node *remove_layer(String layer_name); - Node *add_new_layer(String layer_name); - Node *duplicate_layer(String layer_name, String new_layer_name); - void toggle_layer_visibility(String layer_name); - Node *find_layer_by_name(String layer_name); - void toggle_lock_layer(String layer_name); + void clear_layer(const String &layer_name); + Node *remove_layer(const String &layer_name); + Node *add_new_layer(const String &layer_name); + Node *duplicate_layer(const String &layer_name, const String &new_layer_name); + void toggle_layer_visibility(const String &layer_name); + Node *find_layer_by_name(const String &layer_name); + void toggle_lock_layer(const String &layer_name); bool is_active_layer_locked(); - void move_layer_forward(String layer_name); - void move_layer_back(String layer_name); - void select_layer(String layer_name); + void move_layer_forward(const String &layer_name); + void move_layer_back(const String &layer_name); + void select_layer(const String &layer_name); void _on_mouse_entered(); void _on_mouse_exited(); - bool is_inside_canvas(int x, int y); - void set_pixel_arr(Array pixels, Color color); - void set_pixel_v(Vector2 pos, Color color); - void set_pixel(int x, int y, Color color); - void _set_pixel_v(PaintCanvasLayer *layer, Vector2 v, Color color); - void _set_pixel(PaintCanvasLayer *layer, int x, int y, Color color); - Color get_pixel_v(Vector2 pos); - Color get_pixel(int x, int y); - void set_preview_pixel_v(Vector2 pos, Color color); - void set_preview_pixel(int x, int y, Color color); - Color get_preview_pixel_v(Vector2 pos); - Color get_preview_pixel(int x, int y); + bool is_inside_canvas(const int x, const int y); + void set_pixel_arr(const Array &pixels, const Color &color); + void set_pixel_v(const Vector2 &pos, const Color &color); + void set_pixel(const int x, const int y, const Color &color); + void _set_pixel_v(PaintCanvasLayer *layer, const Vector2 &v, const Color &color); + void _set_pixel(PaintCanvasLayer *layer, const int x, const int y, const Color &color); + Color get_pixel_v(const Vector2 &pos); + Color get_pixel(const int x, const int y); + void set_preview_pixel_v(const Vector2 &pos, const Color &color); + void set_preview_pixel(const int x, const int y, const Color &color); + Color get_preview_pixel_v(const Vector2 &pos); + Color get_preview_pixel(const int x, const int y); void toggle_grid(); void show_grid(); void hide_grid(); - Array select_color(int x, int y); - Array select_same_color(int x, int y); - Array get_neighbouring_pixels(int pos_x, int pos_y); + Array select_color(const int x, const int y); + Array select_same_color(const int x, const int y); + Array get_neighbouring_pixels(const int pos_x, const int pos_y); PaintCanvas(); ~PaintCanvas(); diff --git a/modules/paint/paint_canvas_layer.cpp b/modules/paint/paint_canvas_layer.cpp index 5e29b7bd4..a91f870cc 100644 --- a/modules/paint/paint_canvas_layer.cpp +++ b/modules/paint/paint_canvas_layer.cpp @@ -30,12 +30,12 @@ SOFTWARE. bool PaintCanvasLayer::get_visible() { return _visible; } -void PaintCanvasLayer::set_visible(bool vis) { +void PaintCanvasLayer::set_visible(const bool vis) { _visible = vis; texture_rect_ref->set_visible(_visible); } -void PaintCanvasLayer::create(TextureRect *p_texture_rect_ref, int width, int height) { +void PaintCanvasLayer::create(TextureRect *p_texture_rect_ref, const int width, const int height) { texture_rect_ref = p_texture_rect_ref; layer_width = width; @@ -48,7 +48,7 @@ void PaintCanvasLayer::create(TextureRect *p_texture_rect_ref, int width, int he update_texture(); } -void PaintCanvasLayer::resize(int width, int height) { +void PaintCanvasLayer::resize(const int width, const int height) { PoolColorArray pixel_colors; int prev_width = layer_width; int prev_height = layer_height; @@ -84,12 +84,12 @@ void PaintCanvasLayer::resize(int width, int height) { update_texture(); } -void PaintCanvasLayer::set_pixel(int x, int y, Color color) { +void PaintCanvasLayer::set_pixel(const int x, const int y, const Color &color) { image->lock(); image->set_pixel(x, y, color); image->unlock(); } -Color PaintCanvasLayer::get_pixel(int x, int y) { +Color PaintCanvasLayer::get_pixel(const int x, const int y) { if (x < 0 || y < 0 || x >= image->get_width() || y >= image->get_height()) { return Color(); } diff --git a/modules/paint/paint_canvas_layer.h b/modules/paint/paint_canvas_layer.h index 23e5ee10e..b69b23184 100644 --- a/modules/paint/paint_canvas_layer.h +++ b/modules/paint/paint_canvas_layer.h @@ -49,13 +49,13 @@ public: TextureRect *texture_rect_ref; bool get_visible(); - void set_visible(bool vis); + void set_visible(const bool vis); - void create(TextureRect *p_texture_rect_ref, int width, int height); + void create(TextureRect *p_texture_rect_ref, const int width, const int height); - void resize(int width, int height); - void set_pixel(int x, int y, Color color); - Color get_pixel(int x, int y); + void resize(const int width, const int height); + void set_pixel(const int x, const int y, const Color &color); + Color get_pixel(const int x, const int y); void clear(); void update_texture(); diff --git a/modules/paint/paint_canvas_outline.cpp b/modules/paint/paint_canvas_outline.cpp index e0f35afe1..5d2abf030 100644 --- a/modules/paint/paint_canvas_outline.cpp +++ b/modules/paint/paint_canvas_outline.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "paint_canvas_outline.h" -void PaintCanvasOutline::draw_outline_box(Vector2 pos, Vector2 size, Color color, int width) { +void PaintCanvasOutline::draw_outline_box(const Vector2 &pos, const Vector2 &size, const Color &color, const int width) { //Top line draw_line(pos, pos + Vector2(size.x, 0), color, width); //Left line diff --git a/modules/paint/paint_canvas_outline.h b/modules/paint/paint_canvas_outline.h index 3309dc226..c37d77fb7 100644 --- a/modules/paint/paint_canvas_outline.h +++ b/modules/paint/paint_canvas_outline.h @@ -31,7 +31,7 @@ class PaintCanvasOutline : public Control { GDCLASS(PaintCanvasOutline, Control); public: - void draw_outline_box(Vector2 pos, Vector2 size, Color color, int width); + void draw_outline_box(const Vector2 &pos, const Vector2 &size, const Color &color, const int width); PaintCanvasOutline(); ~PaintCanvasOutline(); diff --git a/modules/paint/paint_editor_plugin.cpp b/modules/paint/paint_editor_plugin.cpp index 8a4598bb1..71f396845 100644 --- a/modules/paint/paint_editor_plugin.cpp +++ b/modules/paint/paint_editor_plugin.cpp @@ -27,7 +27,7 @@ SOFTWARE. #include "mdi_gizmo.h" #include "mdi_gizmo_plugin.h" -void PaintEditorPlugin::make_visible(bool visible) { +void PaintEditorPlugin::make_visible(const bool visible) { /* if editor_scene: editor_scene.visible = visible diff --git a/modules/paint/paint_editor_plugin.h b/modules/paint/paint_editor_plugin.h index d01fda759..2cb72d6f4 100644 --- a/modules/paint/paint_editor_plugin.h +++ b/modules/paint/paint_editor_plugin.h @@ -29,7 +29,7 @@ class PaintEditorPlugin : public EditorPlugin { GDCLASS(PaintEditorPlugin, EditorPlugin); public: - void make_visible(bool visible); + void make_visible(const bool visible); const Ref get_icon() const; bool has_main_screen() const; String get_name() const; diff --git a/modules/paint/paint_navbar.cpp b/modules/paint/paint_navbar.cpp index d4be88d5c..687d19c23 100644 --- a/modules/paint/paint_navbar.cpp +++ b/modules/paint/paint_navbar.cpp @@ -48,7 +48,7 @@ void PaintNavbar::_ready() { i.connect("item_pressed", self, "button_pressed") */ } -void PaintNavbar::button_pressed(String button_name, Node *button_item, int id) { +void PaintNavbar::button_pressed(const String &button_name, Node *button_item, const int id) { /* # print("pressed: ", button_name) # print("pressed item is: '%s'" % button_item) @@ -71,7 +71,7 @@ void PaintNavbar::button_pressed(String button_name, Node *button_item, int id) */ } -void PaintNavbar::handle_file_menu(String pressed_item, int id) { +void PaintNavbar::handle_file_menu(const String &pressed_item, const int id) { /* match pressed_item: "Save": @@ -82,14 +82,14 @@ void PaintNavbar::handle_file_menu(String pressed_item, int id) { owner.get_node("ConfirmationDialog").show() */ } -void PaintNavbar::handle_edit_menu(String pressed_item, int id) { +void PaintNavbar::handle_edit_menu(const String &pressed_item, const int id) { /* match pressed_item: "Add Layer": editor.add_new_layer() */ } -void PaintNavbar::handle_canvas_menu(String pressed_item, int id) { +void PaintNavbar::handle_canvas_menu(const String &pressed_item, const int id) { /* match pressed_item: "Change Size": @@ -98,7 +98,7 @@ void PaintNavbar::handle_canvas_menu(String pressed_item, int id) { owner.paint_canvas.crop_to_content() */ } -void PaintNavbar::handle_layer_menu(String pressed_item, int id) { +void PaintNavbar::handle_layer_menu(const String &pressed_item, const int id) { /* match pressed_item: "Add Layer": @@ -115,7 +115,7 @@ void PaintNavbar::handle_layer_menu(String pressed_item, int id) { owner.find_node("LockAlpha").pressed = $Buttons/Layer.get_popup().is_item_checked(id) */ } -void PaintNavbar::handle_grid_menu(String pressed_item, int id) { +void PaintNavbar::handle_grid_menu(const String &pressed_item, const int id) { /* match pressed_item: "Change Grid Size": @@ -125,14 +125,14 @@ void PaintNavbar::handle_grid_menu(String pressed_item, int id) { */ } -void PaintNavbar::handle_magic_menu(String pressed_item, int id) { +void PaintNavbar::handle_magic_menu(const String &pressed_item, const int id) { /* match pressed_item: "Add Layer": editor.add_new_layer() */ } -void PaintNavbar::handle_editor_menu(String pressed_item, int id) { +void PaintNavbar::handle_editor_menu(const String &pressed_item, const int id) { /* match pressed_item: "Settings": diff --git a/modules/paint/paint_navbar.h b/modules/paint/paint_navbar.h index 0547cfdd2..068c8088e 100644 --- a/modules/paint/paint_navbar.h +++ b/modules/paint/paint_navbar.h @@ -32,16 +32,16 @@ class PaintNavbar : public Control { public: void _ready(); - void button_pressed(String button_name, Node *button_item, int id); + void button_pressed(const String &button_name, Node *button_item, const int id); - void handle_file_menu(String pressed_item, int id); - void handle_edit_menu(String pressed_item, int id); - void handle_canvas_menu(String pressed_item, int id); - void handle_layer_menu(String pressed_item, int id); - void handle_grid_menu(String pressed_item, int id); + void handle_file_menu(const String &pressed_item, const int id); + void handle_edit_menu(const String &pressed_item, const int id); + void handle_canvas_menu(const String &pressed_item, const int id); + void handle_layer_menu(const String &pressed_item, const int id); + void handle_grid_menu(const String &pressed_item, const int id); - void handle_magic_menu(String pressed_item, int id); - void handle_editor_menu(String pressed_item, int id); + void handle_magic_menu(const String &pressed_item, const int id); + void handle_editor_menu(const String &pressed_item, const int id); bool is_any_menu_open(); PaintNavbar(); diff --git a/modules/paint/paint_selection_box.cpp b/modules/paint/paint_selection_box.cpp index 848e25d58..a4db6ef54 100644 --- a/modules/paint/paint_selection_box.cpp +++ b/modules/paint/paint_selection_box.cpp @@ -35,7 +35,7 @@ if not rect_size == Vector2(): draw_outline_box(rect_size, Color.gray, outline_size) */ } -void PaintSelectionBox::draw_outline_box(Vector2 size, Color color, int width) { +void PaintSelectionBox::draw_outline_box(const Vector2 &size, const Color &color, const int width) { /* #Top line draw_line(Vector2(0 + 1, 0), Vector2(size.x, 0), color, width) diff --git a/modules/paint/paint_selection_box.h b/modules/paint/paint_selection_box.h index e49b72f09..725616708 100644 --- a/modules/paint/paint_selection_box.h +++ b/modules/paint/paint_selection_box.h @@ -33,7 +33,7 @@ class PaintSelectionBox : public Control { public: void _process(float delta); void _draw(); - void draw_outline_box(Vector2 size, Color color, int width); + void draw_outline_box(const Vector2 &size, const Color &color, const int width); PaintSelectionBox(); ~PaintSelectionBox(); diff --git a/modules/paint/paint_settings.cpp b/modules/paint/paint_settings.cpp index 169ea6170..75af32ba0 100644 --- a/modules/paint/paint_settings.cpp +++ b/modules/paint/paint_settings.cpp @@ -30,12 +30,12 @@ void PaintTextInfo::_enter_tree() { editor = get_parent() */ } -void PaintTextInfo::_on_ColorPickerButton_color_changed(Color color) { +void PaintTextInfo::_on_ColorPickerButton_color_changed(const Color &color) { /* canvas_outline.color = color */ } -void PaintTextInfo::_on_CheckButton_toggled(bool button_pressed) { +void PaintTextInfo::_on_CheckButton_toggled(const bool button_pressed) { /* canvas_outline.visible = button_pressed */ diff --git a/modules/paint/paint_settings.h b/modules/paint/paint_settings.h index 9c6c1dc1f..f583aef42 100644 --- a/modules/paint/paint_settings.h +++ b/modules/paint/paint_settings.h @@ -32,8 +32,8 @@ class PaintTextInfo : public Control { public: void _enter_tree(); - void _on_ColorPickerButton_color_changed(Color color); - void _on_CheckButton_toggled(bool button_pressed); + void _on_ColorPickerButton_color_changed(const Color &color); + void _on_CheckButton_toggled(const bool button_pressed); void _on_Ok_pressed(); PaintTextInfo(); diff --git a/modules/paint/paint_text_info.h b/modules/paint/paint_text_info.h index 50bf85c46..c849c2289 100644 --- a/modules/paint/paint_text_info.h +++ b/modules/paint/paint_text_info.h @@ -31,8 +31,8 @@ class PaintTextInfo : public Control { GDCLASS(PaintTextInfo, Control); public: - void add_text_info(String text_name, Node *custom_node = nullptr); - void update_text_info(String text_name, Node *text_value = nullptr, Node *node = nullptr, Node *node_target_value = nullptr, Node *node_value = nullptr); + void add_text_info(const String &text_name, Node *custom_node = nullptr); + void update_text_info(const String &text_name, Node *text_value = nullptr, Node *node = nullptr, Node *node_target_value = nullptr, Node *node_value = nullptr); PaintTextInfo(); ~PaintTextInfo(); diff --git a/modules/paint/paint_window.cpp b/modules/paint/paint_window.cpp index 55e3438a6..dc874788f 100644 --- a/modules/paint/paint_window.cpp +++ b/modules/paint/paint_window.cpp @@ -24,7 +24,7 @@ SOFTWARE. #include "paint_window.h" -void PaintWindow::_input(Ref event) { +void PaintWindow::_input(const Ref &event) { /* if is_any_menu_open(): return @@ -131,7 +131,7 @@ void PaintWindow::_process(float delta) { */ } -void PaintWindow::_handle_shortcuts(int scancode) { +void PaintWindow::_handle_shortcuts(const int scancode) { /* match scancode: K_UNDO: @@ -221,7 +221,7 @@ void PaintWindow::_handle_scroll() { */ } -void PaintWindow::_handle_zoom(Ref event) { +void PaintWindow::_handle_zoom(const Ref &event) { /* if not event is InputEventMouseButton: return @@ -361,7 +361,7 @@ void PaintWindow::_on_Save_pressed() { */ } -void PaintWindow::do_action(Array data) { +void PaintWindow::do_action(const Array &data) { /* if _current_action == null: #print("clear redo") @@ -448,12 +448,12 @@ Ref PaintWindow::get_action() { */ } -void PaintWindow::set_selected_color(Color color) { +void PaintWindow::set_selected_color(const Color &color) { /* selected_color = color */ } -void PaintWindow::set_brush(PaintWindow::Tools new_mode) { +void PaintWindow::set_brush(const PaintWindow::Tools new_mode) { /* if brush_mode == new_mode: return @@ -474,7 +474,7 @@ void PaintWindow::set_brush(PaintWindow::Tools new_mode) { */ } -void PaintWindow::change_color(Color new_color) { +void PaintWindow::change_color(const Color &new_color) { /* if new_color.a == 0: return @@ -483,7 +483,7 @@ void PaintWindow::change_color(Color new_color) { */ } -void PaintWindow::_on_ColorPicker_color_changed(Color color) { +void PaintWindow::_on_ColorPicker_color_changed(const Color &color) { /* selected_color = color */ @@ -544,7 +544,7 @@ void PaintWindow::_on_Editor_visibility_changed() { */ } -void PaintWindow::highlight_layer(String layer_name) { +void PaintWindow::highlight_layer(const String &layer_name) { /* for button in layer_buttons.get_children(): if paint_canvas.find_layer_by_name(button.name).locked: @@ -555,20 +555,20 @@ void PaintWindow::highlight_layer(String layer_name) { button.get("custom_styles/panel").set("bg_color", other_layer_highlight) */ } -void PaintWindow::toggle_layer_visibility(Node *button, String layer_name) { +void PaintWindow::toggle_layer_visibility(Node *button, const String &layer_name) { /* #print("toggling: ", layer_name) paint_canvas.toggle_layer_visibility(layer_name) */ } -void PaintWindow::select_layer(String layer_name) { +void PaintWindow::select_layer(const String &layer_name) { /* #print("select layer: ", layer_name) paint_canvas.select_layer(layer_name) highlight_layer(layer_name) */ } -void PaintWindow::lock_layer(Node *button, String layer_name) { +void PaintWindow::lock_layer(Node *button, const String &layer_name) { /* paint_canvas.toggle_lock_layer(layer_name) highlight_layer(paint_canvas.get_active_layer().name) @@ -696,7 +696,7 @@ void PaintWindow::_on_ColorPicker_popup_closed() { */ } -bool PaintWindow::is_position_in_canvas(Vector2 pos) { +bool PaintWindow::is_position_in_canvas(const Vector2 &pos) { /* if Rect2(paint_canvas_container_node.rect_global_position, paint_canvas_container_node.rect_global_position + paint_canvas_container_node.rect_size).has_point(pos): diff --git a/modules/paint/paint_window.h b/modules/paint/paint_window.h index 4e1aa5712..4145d98b8 100644 --- a/modules/paint/paint_window.h +++ b/modules/paint/paint_window.h @@ -71,15 +71,15 @@ public: max_zoom_in = 50, }; - void _input(Ref event); + void _input(const Ref &event); void _process(float delta); - void _handle_shortcuts(int scancode); + void _handle_shortcuts(const int scancode); void _draw_tool_brush(); void _handle_scroll(); - void _handle_zoom(Ref event); + void _handle_zoom(const Ref &event); void _handle_cut(); void brush_process(); @@ -87,19 +87,19 @@ public: void _on_Save_pressed(); - void do_action(Array data); + void do_action(const Array &data); void commit_action(); void redo_action(); void undo_action(); Ref get_action(); - void set_selected_color(Color color); - void set_brush(Tools new_mode); + void set_selected_color(const Color &color); + void set_brush(const Tools new_mode); - void change_color(Color new_color); + void change_color(const Color &new_color); - void _on_ColorPicker_color_changed(Color color); + void _on_ColorPicker_color_changed(const Color &color); void _on_PaintTool_pressed(); void _on_BucketTool_pressed(); void _on_RainbowTool_pressed(); @@ -112,10 +112,10 @@ public: void _on_CutTool_pressed(); void _on_Editor_visibility_changed(); - void highlight_layer(String layer_name); - void toggle_layer_visibility(Node *button, String layer_name); - void select_layer(String layer_name); - void lock_layer(Node *button, String layer_name); + void highlight_layer(const String &layer_name); + void toggle_layer_visibility(Node *button, const String &layer_name); + void select_layer(const String &layer_name); + void lock_layer(Node *button, const String &layer_name); Ref add_new_layer(); void remove_active_layer(); @@ -131,7 +131,7 @@ public: void _on_PaintCanvasContainer_mouse_exited(); void _on_ColorPicker_popup_closed(); - bool is_position_in_canvas(Vector2 pos); + bool is_position_in_canvas(const Vector2 &pos); bool is_mouse_in_canvas();