mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-26 02:49:18 +01:00
Renamed PaintCanvas to PaintCanvasOld.
This commit is contained in:
parent
dbeb522d8b
commit
334b4ae3f8
@ -35,7 +35,7 @@ void BrightenAction::set_brighten_color(const float val) {
|
|||||||
brighten_color = val;
|
brighten_color = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrightenAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void BrightenAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class BrightenAction : public PaintAction {
|
class BrightenAction : public PaintAction {
|
||||||
GDCLASS(BrightenAction, PaintAction);
|
GDCLASS(BrightenAction, PaintAction);
|
||||||
@ -36,7 +36,7 @@ public:
|
|||||||
float get_brighten_color();
|
float get_brighten_color();
|
||||||
void set_brighten_color(const float val);
|
void set_brighten_color(const float val);
|
||||||
|
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
|
|
||||||
BrightenAction();
|
BrightenAction();
|
||||||
~BrightenAction();
|
~BrightenAction();
|
||||||
|
@ -29,7 +29,7 @@ SOFTWARE.
|
|||||||
#include "../deprecated/paint_canvas_layer.h"
|
#include "../deprecated/paint_canvas_layer.h"
|
||||||
#include "../paint_utilities.h"
|
#include "../paint_utilities.h"
|
||||||
|
|
||||||
void BrushAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void BrushAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
||||||
|
@ -27,13 +27,13 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class BrushAction : public PaintAction {
|
class BrushAction : public PaintAction {
|
||||||
GDCLASS(BrushAction, PaintAction);
|
GDCLASS(BrushAction, PaintAction);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
|
|
||||||
BrushAction();
|
BrushAction();
|
||||||
~BrushAction();
|
~BrushAction();
|
||||||
|
@ -28,7 +28,7 @@ SOFTWARE.
|
|||||||
#include "../deprecated/paint_canvas_layer.h"
|
#include "../deprecated/paint_canvas_layer.h"
|
||||||
#include "../paint_utilities.h"
|
#include "../paint_utilities.h"
|
||||||
|
|
||||||
void BucketAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void BucketAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
Vector2i pos = data[0];
|
Vector2i pos = data[0];
|
||||||
|
@ -27,13 +27,13 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class BucketAction : public PaintAction {
|
class BucketAction : public PaintAction {
|
||||||
GDCLASS(BucketAction, PaintAction);
|
GDCLASS(BucketAction, PaintAction);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
|
|
||||||
BucketAction();
|
BucketAction();
|
||||||
~BucketAction();
|
~BucketAction();
|
||||||
|
@ -60,7 +60,7 @@ bool CutAction::can_commit() {
|
|||||||
return false; //ugly way of handling a cut
|
return false; //ugly way of handling a cut
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void CutAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
if (!mouse_start_pos_set) {
|
if (!mouse_start_pos_set) {
|
||||||
@ -91,7 +91,7 @@ void CutAction::do_action(PaintCanvas *canvas, const Array &data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutAction::commit_action(PaintCanvas *canvas) {
|
void CutAction::commit_action(PaintCanvasOld *canvas) {
|
||||||
canvas->clear_preview_layer();
|
canvas->clear_preview_layer();
|
||||||
Vector2i p = mouse_start_pos;
|
Vector2i p = mouse_start_pos;
|
||||||
Vector2i s = mouse_end_pos - mouse_start_pos;
|
Vector2i s = mouse_end_pos - mouse_start_pos;
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class CutAction : public PaintAction {
|
class CutAction : public PaintAction {
|
||||||
GDCLASS(CutAction, PaintAction);
|
GDCLASS(CutAction, PaintAction);
|
||||||
@ -47,8 +47,8 @@ public:
|
|||||||
|
|
||||||
bool can_commit();
|
bool can_commit();
|
||||||
|
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
void commit_action(PaintCanvas *canvas);
|
void commit_action(PaintCanvasOld *canvas);
|
||||||
|
|
||||||
CutAction();
|
CutAction();
|
||||||
~CutAction();
|
~CutAction();
|
||||||
|
@ -35,7 +35,7 @@ void DarkenAction::set_dark_factor(const float val) {
|
|||||||
dark_factor = val;
|
dark_factor = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DarkenAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void DarkenAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class DarkenAction : public PaintAction {
|
class DarkenAction : public PaintAction {
|
||||||
GDCLASS(DarkenAction, PaintAction);
|
GDCLASS(DarkenAction, PaintAction);
|
||||||
@ -36,7 +36,7 @@ public:
|
|||||||
float get_dark_factor();
|
float get_dark_factor();
|
||||||
void set_dark_factor(const float val);
|
void set_dark_factor(const float val);
|
||||||
|
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
|
|
||||||
DarkenAction();
|
DarkenAction();
|
||||||
~DarkenAction();
|
~DarkenAction();
|
||||||
|
@ -42,7 +42,7 @@ void LineAction::set_mouse_start_pos_set(const bool val) {
|
|||||||
mouse_start_pos_set = val;
|
mouse_start_pos_set = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void LineAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
if (!mouse_start_pos_set) {
|
if (!mouse_start_pos_set) {
|
||||||
@ -74,7 +74,7 @@ void LineAction::do_action(PaintCanvas *canvas, const Array &data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineAction::commit_action(PaintCanvas *canvas) {
|
void LineAction::commit_action(PaintCanvasOld *canvas) {
|
||||||
canvas->clear_preview_layer();
|
canvas->clear_preview_layer();
|
||||||
|
|
||||||
for (int i = 0; i < preview_cells.size(); ++i) {
|
for (int i = 0; i < preview_cells.size(); ++i) {
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class LineAction : public PaintAction {
|
class LineAction : public PaintAction {
|
||||||
GDCLASS(LineAction, PaintAction);
|
GDCLASS(LineAction, PaintAction);
|
||||||
@ -39,8 +39,8 @@ public:
|
|||||||
bool get_mouse_start_pos_set();
|
bool get_mouse_start_pos_set();
|
||||||
void set_mouse_start_pos_set(const bool val);
|
void set_mouse_start_pos_set(const bool val);
|
||||||
|
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
void commit_action(PaintCanvas *canvas);
|
void commit_action(PaintCanvasOld *canvas);
|
||||||
bool can_commit();
|
bool can_commit();
|
||||||
|
|
||||||
LineAction();
|
LineAction();
|
||||||
|
@ -32,7 +32,7 @@ bool MultiLineAction::can_commit() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiLineAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void MultiLineAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class MultiLineAction : public PaintAction {
|
class MultiLineAction : public PaintAction {
|
||||||
GDCLASS(MultiLineAction, PaintAction);
|
GDCLASS(MultiLineAction, PaintAction);
|
||||||
@ -35,8 +35,8 @@ class MultiLineAction : public PaintAction {
|
|||||||
public:
|
public:
|
||||||
bool can_commit();
|
bool can_commit();
|
||||||
|
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
//void commit_action(PaintCanvas *canvas);
|
//void commit_action(PaintCanvasOld *canvas);
|
||||||
|
|
||||||
MultiLineAction();
|
MultiLineAction();
|
||||||
~MultiLineAction();
|
~MultiLineAction();
|
||||||
|
@ -105,18 +105,18 @@ void PaintAction::set_action_data(const Dictionary &val) {
|
|||||||
action_data = val;
|
action_data = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void PaintAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
layer = canvas->get_active_layer();
|
layer = canvas->get_active_layer();
|
||||||
}
|
}
|
||||||
void PaintAction::commit_action(PaintCanvas *canvas) {
|
void PaintAction::commit_action(PaintCanvasOld *canvas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintAction::undo_action(PaintCanvas *canvas) {
|
void PaintAction::undo_action(PaintCanvasOld *canvas) {
|
||||||
for (int idx = 0; idx < undo_cells.size(); ++idx) {
|
for (int idx = 0; idx < undo_cells.size(); ++idx) {
|
||||||
canvas->_set_pixel_v(layer, undo_cells[idx], undo_colors[idx]);
|
canvas->_set_pixel_v(layer, undo_cells[idx], undo_colors[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void PaintAction::redo_action(PaintCanvas *canvas) {
|
void PaintAction::redo_action(PaintCanvasOld *canvas) {
|
||||||
for (int idx = 0; idx < redo_cells.size(); ++idx) {
|
for (int idx = 0; idx < redo_cells.size(); ++idx) {
|
||||||
canvas->_set_pixel_v(layer, redo_cells[idx], redo_colors[idx]);
|
canvas->_set_pixel_v(layer, redo_cells[idx], redo_colors[idx]);
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ PoolVector2iArray PaintAction::get_xy_sym_points(const int canvas_width, const i
|
|||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolVector2iArray PaintAction::get_points(PaintCanvas *canvas, const Vector2i &pixel) {
|
PoolVector2iArray PaintAction::get_points(PaintCanvasOld *canvas, const Vector2i &pixel) {
|
||||||
PoolVector2iArray points;
|
PoolVector2iArray points;
|
||||||
|
|
||||||
if (canvas->symmetry_x && canvas->symmetry_y) {
|
if (canvas->symmetry_x && canvas->symmetry_y) {
|
||||||
@ -239,7 +239,7 @@ PoolVector2iArray PaintAction::get_points(PaintCanvas *canvas, const Vector2i &p
|
|||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintAction::draw_points(PaintCanvas *canvas, const PoolVector2iArray &point_arr, const PoolColorArray &color_arr) {
|
void PaintAction::draw_points(PaintCanvasOld *canvas, const PoolVector2iArray &point_arr, const PoolColorArray &color_arr) {
|
||||||
for (int i = 0; i < point_arr.size(); ++i) {
|
for (int i = 0; i < point_arr.size(); ++i) {
|
||||||
Vector2i pixel = point_arr[i];
|
Vector2i pixel = point_arr[i];
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ SOFTWARE.
|
|||||||
#include "core/containers/pool_vector.h"
|
#include "core/containers/pool_vector.h"
|
||||||
#include "core/variant/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
class PaintCanvasLayer;
|
class PaintCanvasLayer;
|
||||||
|
|
||||||
class PaintAction : public Resource {
|
class PaintAction : public Resource {
|
||||||
@ -73,19 +73,19 @@ public:
|
|||||||
Dictionary get_action_data();
|
Dictionary get_action_data();
|
||||||
void set_action_data(const Dictionary &val);
|
void set_action_data(const Dictionary &val);
|
||||||
|
|
||||||
virtual void do_action(PaintCanvas *canvas, const Array &data);
|
virtual void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
virtual void commit_action(PaintCanvas *canvas);
|
virtual void commit_action(PaintCanvasOld *canvas);
|
||||||
|
|
||||||
virtual void undo_action(PaintCanvas *canvas);
|
virtual void undo_action(PaintCanvasOld *canvas);
|
||||||
virtual void redo_action(PaintCanvas *canvas);
|
virtual void redo_action(PaintCanvasOld *canvas);
|
||||||
virtual bool can_commit();
|
virtual bool can_commit();
|
||||||
|
|
||||||
virtual PoolVector2iArray get_x_sym_points(const int canvas_width, const 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_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_xy_sym_points(const int canvas_width, const int canvas_height, const Vector2i &pixel);
|
||||||
virtual PoolVector2iArray get_points(PaintCanvas *canvas, const Vector2i &pixel);
|
virtual PoolVector2iArray get_points(PaintCanvasOld *canvas, const Vector2i &pixel);
|
||||||
|
|
||||||
void draw_points(PaintCanvas *canvas, const PoolVector2iArray &point_arr, const PoolColorArray &color_arr);
|
void draw_points(PaintCanvasOld *canvas, const PoolVector2iArray &point_arr, const PoolColorArray &color_arr);
|
||||||
|
|
||||||
PaintAction();
|
PaintAction();
|
||||||
~PaintAction();
|
~PaintAction();
|
||||||
|
@ -34,7 +34,7 @@ SOFTWARE.
|
|||||||
//arr.append(_selection_colors);
|
//arr.append(_selection_colors);
|
||||||
//arr.append(_cut_pos);
|
//arr.append(_cut_pos);
|
||||||
//arr.append(_cut_size);
|
//arr.append(_cut_size);
|
||||||
void PasteCutAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void PasteCutAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
||||||
|
@ -27,13 +27,13 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class PasteCutAction : public PaintAction {
|
class PasteCutAction : public PaintAction {
|
||||||
GDCLASS(PasteCutAction, PaintAction);
|
GDCLASS(PasteCutAction, PaintAction);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
|
|
||||||
PasteCutAction();
|
PasteCutAction();
|
||||||
~PasteCutAction();
|
~PasteCutAction();
|
||||||
|
@ -29,7 +29,7 @@ SOFTWARE.
|
|||||||
#include "../paint_utilities.h"
|
#include "../paint_utilities.h"
|
||||||
#include "core/string/print_string.h"
|
#include "core/string/print_string.h"
|
||||||
|
|
||||||
void PencilAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void PencilAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
Color c = data[2];
|
Color c = data[2];
|
||||||
@ -49,7 +49,7 @@ void PencilAction::do_action(PaintCanvas *canvas, const Array &data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PencilAction::_set_pixel(PaintCanvas *canvas, Vector2i pixel, Color color) {
|
void PencilAction::_set_pixel(PaintCanvasOld *canvas, Vector2i pixel, Color color) {
|
||||||
undo_colors.append(canvas->get_pixel_v(pixel));
|
undo_colors.append(canvas->get_pixel_v(pixel));
|
||||||
undo_cells.append(pixel);
|
undo_cells.append(pixel);
|
||||||
|
|
||||||
|
@ -27,15 +27,15 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class PencilAction : public PaintAction {
|
class PencilAction : public PaintAction {
|
||||||
GDCLASS(PencilAction, PaintAction);
|
GDCLASS(PencilAction, PaintAction);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
|
|
||||||
void _set_pixel(PaintCanvas *canvas, Vector2i pixel, Color color);
|
void _set_pixel(PaintCanvasOld *canvas, Vector2i pixel, Color color);
|
||||||
|
|
||||||
PencilAction();
|
PencilAction();
|
||||||
~PencilAction();
|
~PencilAction();
|
||||||
|
@ -28,7 +28,7 @@ SOFTWARE.
|
|||||||
#include "../deprecated/paint_canvas_layer.h"
|
#include "../deprecated/paint_canvas_layer.h"
|
||||||
#include "../paint_utilities.h"
|
#include "../paint_utilities.h"
|
||||||
|
|
||||||
void RainbowAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void RainbowAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
PoolVector2iArray pixels = PaintUtilities::get_pixels_in_line(data[0], data[1]);
|
||||||
|
@ -27,13 +27,13 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class RainbowAction : public PaintAction {
|
class RainbowAction : public PaintAction {
|
||||||
GDCLASS(RainbowAction, PaintAction);
|
GDCLASS(RainbowAction, PaintAction);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
|
|
||||||
RainbowAction();
|
RainbowAction();
|
||||||
~RainbowAction();
|
~RainbowAction();
|
||||||
|
@ -42,7 +42,7 @@ void RectAction::set_mouse_start_pos_set(const bool val) {
|
|||||||
mouse_start_pos_set = val;
|
mouse_start_pos_set = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectAction::do_action(PaintCanvas *canvas, const Array &data) {
|
void RectAction::do_action(PaintCanvasOld *canvas, const Array &data) {
|
||||||
PaintAction::do_action(canvas, data);
|
PaintAction::do_action(canvas, data);
|
||||||
|
|
||||||
if (!mouse_start_pos_set) {
|
if (!mouse_start_pos_set) {
|
||||||
@ -89,7 +89,7 @@ void RectAction::do_action(PaintCanvas *canvas, const Array &data) {
|
|||||||
preview_colors.append(tc);
|
preview_colors.append(tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RectAction::commit_action(PaintCanvas *canvas) {
|
void RectAction::commit_action(PaintCanvasOld *canvas) {
|
||||||
canvas->clear_preview_layer();
|
canvas->clear_preview_layer();
|
||||||
|
|
||||||
for (int idx = 0; idx < preview_cells.size(); ++idx) {
|
for (int idx = 0; idx < preview_cells.size(); ++idx) {
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "paint_action.h"
|
#include "paint_action.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class RectAction : public PaintAction {
|
class RectAction : public PaintAction {
|
||||||
GDCLASS(RectAction, PaintAction);
|
GDCLASS(RectAction, PaintAction);
|
||||||
@ -39,8 +39,8 @@ public:
|
|||||||
bool get_mouse_start_pos_set();
|
bool get_mouse_start_pos_set();
|
||||||
void set_mouse_start_pos_set(const bool val);
|
void set_mouse_start_pos_set(const bool val);
|
||||||
|
|
||||||
void do_action(PaintCanvas *canvas, const Array &data);
|
void do_action(PaintCanvasOld *canvas, const Array &data);
|
||||||
void commit_action(PaintCanvas *canvas);
|
void commit_action(PaintCanvasOld *canvas);
|
||||||
bool can_commit();
|
bool can_commit();
|
||||||
|
|
||||||
RectAction();
|
RectAction();
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "scene/gui/file_dialog.h"
|
#include "scene/gui/file_dialog.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
class PaintWindow;
|
class PaintWindow;
|
||||||
|
|
||||||
class PaintLoadFileDialog : public FileDialog {
|
class PaintLoadFileDialog : public FileDialog {
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
String file_path;
|
String file_path;
|
||||||
|
|
||||||
PaintCanvas *canvas;
|
PaintCanvasOld *canvas;
|
||||||
PaintWindow *window;
|
PaintWindow *window;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "scene/gui/file_dialog.h"
|
#include "scene/gui/file_dialog.h"
|
||||||
|
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
|
|
||||||
class PaintSaveFileDialog : public FileDialog {
|
class PaintSaveFileDialog : public FileDialog {
|
||||||
GDCLASS(PaintSaveFileDialog, FileDialog);
|
GDCLASS(PaintSaveFileDialog, FileDialog);
|
||||||
@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
String file_path;
|
String file_path;
|
||||||
|
|
||||||
PaintCanvas *canvas;
|
PaintCanvasOld *canvas;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
@ -59,7 +59,7 @@ static Ref<Texture> make_icon(T p_src) {
|
|||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::_process(float delta) {
|
void PaintCanvasOld::_process(float delta) {
|
||||||
if (!is_visible_in_tree()) {
|
if (!is_visible_in_tree()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ void PaintCanvas::_process(float delta) {
|
|||||||
Rect2 rect = Rect2(Vector2(0, 0), get_size());
|
Rect2 rect = Rect2(Vector2(0, 0), get_size());
|
||||||
mouse_in_region = rect.has_point(mouse_position);
|
mouse_in_region = rect.has_point(mouse_position);
|
||||||
}
|
}
|
||||||
void PaintCanvas::_draw() {
|
void PaintCanvasOld::_draw() {
|
||||||
for (int i = 0; i < layers.size(); ++i) {
|
for (int i = 0; i < layers.size(); ++i) {
|
||||||
Ref<PaintCanvasLayer> layer = layers[i];
|
Ref<PaintCanvasLayer> layer = layers[i];
|
||||||
|
|
||||||
@ -81,11 +81,11 @@ void PaintCanvas::_draw() {
|
|||||||
tool_layer->update_texture();
|
tool_layer->update_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaintCanvas::get_pixel_size() const {
|
int PaintCanvasOld::get_pixel_size() const {
|
||||||
return _pixel_size;
|
return _pixel_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::set_pixel_size(const int size) {
|
void PaintCanvasOld::set_pixel_size(const int size) {
|
||||||
_pixel_size = size;
|
_pixel_size = size;
|
||||||
set_grid_size(_grid_size);
|
set_grid_size(_grid_size);
|
||||||
set_big_grid_size(_big_grid_size);
|
set_big_grid_size(_big_grid_size);
|
||||||
@ -93,10 +93,10 @@ void PaintCanvas::set_pixel_size(const int size) {
|
|||||||
set_canvas_height(_canvas_height);
|
set_canvas_height(_canvas_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaintCanvas::get_grid_size() const {
|
int PaintCanvasOld::get_grid_size() const {
|
||||||
return _grid_size;
|
return _grid_size;
|
||||||
}
|
}
|
||||||
void PaintCanvas::set_grid_size(const int size) {
|
void PaintCanvasOld::set_grid_size(const int size) {
|
||||||
_grid_size = size;
|
_grid_size = size;
|
||||||
|
|
||||||
if (grid) {
|
if (grid) {
|
||||||
@ -105,10 +105,10 @@ void PaintCanvas::set_grid_size(const int size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaintCanvas::get_big_grid_size() const {
|
int PaintCanvasOld::get_big_grid_size() const {
|
||||||
return _big_grid_size;
|
return _big_grid_size;
|
||||||
}
|
}
|
||||||
void PaintCanvas::set_big_grid_size(const int size) {
|
void PaintCanvasOld::set_big_grid_size(const int size) {
|
||||||
_big_grid_size = size;
|
_big_grid_size = size;
|
||||||
|
|
||||||
if (big_grid) {
|
if (big_grid) {
|
||||||
@ -117,10 +117,10 @@ void PaintCanvas::set_big_grid_size(const int size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaintCanvas::get_canvas_width() const {
|
int PaintCanvasOld::get_canvas_width() const {
|
||||||
return _canvas_width;
|
return _canvas_width;
|
||||||
}
|
}
|
||||||
void PaintCanvas::set_canvas_width(const int val) {
|
void PaintCanvasOld::set_canvas_width(const int val) {
|
||||||
_canvas_width = val;
|
_canvas_width = val;
|
||||||
|
|
||||||
Size2 s = get_size();
|
Size2 s = get_size();
|
||||||
@ -128,31 +128,31 @@ void PaintCanvas::set_canvas_width(const int val) {
|
|||||||
set_size(s);
|
set_size(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaintCanvas::get_canvas_height() const {
|
int PaintCanvasOld::get_canvas_height() const {
|
||||||
return _canvas_height;
|
return _canvas_height;
|
||||||
}
|
}
|
||||||
void PaintCanvas::set_canvas_height(const int val) {
|
void PaintCanvasOld::set_canvas_height(const int val) {
|
||||||
_canvas_height = val;
|
_canvas_height = val;
|
||||||
|
|
||||||
Size2 s = get_size();
|
Size2 s = get_size();
|
||||||
s.y = _canvas_height * _pixel_size;
|
s.y = _canvas_height * _pixel_size;
|
||||||
set_size(s);
|
set_size(s);
|
||||||
}
|
}
|
||||||
void PaintCanvas::toggle_alpha_locked(const String &layer_name) {
|
void PaintCanvasOld::toggle_alpha_locked(const String &layer_name) {
|
||||||
Ref<PaintCanvasLayer> layer = find_layer_by_name(layer_name);
|
Ref<PaintCanvasLayer> layer = find_layer_by_name(layer_name);
|
||||||
|
|
||||||
if (layer.is_valid()) {
|
if (layer.is_valid()) {
|
||||||
layer->toggle_alpha_locked();
|
layer->toggle_alpha_locked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool PaintCanvas::is_alpha_locked() {
|
bool PaintCanvasOld::is_alpha_locked() {
|
||||||
if (!active_layer.is_valid()) {
|
if (!active_layer.is_valid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return active_layer->alpha_locked;
|
return active_layer->alpha_locked;
|
||||||
}
|
}
|
||||||
Rect2 PaintCanvas::get_content_margin() {
|
Rect2 PaintCanvasOld::get_content_margin() {
|
||||||
Rect2 rect = Rect2(999999, 999999, -999999, -999999);
|
Rect2 rect = Rect2(999999, 999999, -999999, -999999);
|
||||||
|
|
||||||
for (int i = 0; i < layers.size(); ++i) {
|
for (int i = 0; i < layers.size(); ++i) {
|
||||||
@ -181,7 +181,7 @@ Rect2 PaintCanvas::get_content_margin() {
|
|||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
void PaintCanvas::crop_to_content() {
|
void PaintCanvasOld::crop_to_content() {
|
||||||
/*
|
/*
|
||||||
var rect = get_content_margin()
|
var rect = get_content_margin()
|
||||||
|
|
||||||
@ -199,22 +199,22 @@ void PaintCanvas::crop_to_content() {
|
|||||||
# layer.resize(width, height)
|
# layer.resize(width, height)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
Ref<PaintCanvasLayer> PaintCanvas::get_active_layer() {
|
Ref<PaintCanvasLayer> PaintCanvasOld::get_active_layer() {
|
||||||
return active_layer;
|
return active_layer;
|
||||||
}
|
}
|
||||||
Ref<PaintCanvasLayer> PaintCanvas::get_preview_layer() {
|
Ref<PaintCanvasLayer> PaintCanvasOld::get_preview_layer() {
|
||||||
return preview_layer;
|
return preview_layer;
|
||||||
}
|
}
|
||||||
void PaintCanvas::clear_active_layer() {
|
void PaintCanvasOld::clear_active_layer() {
|
||||||
if (active_layer.is_valid()) {
|
if (active_layer.is_valid()) {
|
||||||
active_layer->clear();
|
active_layer->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void PaintCanvas::clear_preview_layer() {
|
void PaintCanvasOld::clear_preview_layer() {
|
||||||
preview_layer->clear();
|
preview_layer->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::clear_layer(const String &layer_name) {
|
void PaintCanvasOld::clear_layer(const String &layer_name) {
|
||||||
for (int i = 0; i < layers.size(); ++i) {
|
for (int i = 0; i < layers.size(); ++i) {
|
||||||
Ref<PaintCanvasLayer> l = layers[i];
|
Ref<PaintCanvasLayer> l = layers[i];
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ void PaintCanvas::clear_layer(const String &layer_name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ref<PaintCanvasLayer> PaintCanvas::remove_layer(const String &layer_name) {
|
Ref<PaintCanvasLayer> PaintCanvasOld::remove_layer(const String &layer_name) {
|
||||||
// change current layer if the active layer is removed
|
// change current layer if the active layer is removed
|
||||||
Ref<PaintCanvasLayer> del_layer = find_layer_by_name(layer_name);
|
Ref<PaintCanvasLayer> del_layer = find_layer_by_name(layer_name);
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ Ref<PaintCanvasLayer> PaintCanvas::remove_layer(const String &layer_name) {
|
|||||||
|
|
||||||
return active_layer;
|
return active_layer;
|
||||||
}
|
}
|
||||||
Ref<PaintCanvasLayer> PaintCanvas::add_new_layer(const String &layer_name) {
|
Ref<PaintCanvasLayer> PaintCanvasOld::add_new_layer(const String &layer_name) {
|
||||||
for (int i = 0; i < layers.size(); ++i) {
|
for (int i = 0; i < layers.size(); ++i) {
|
||||||
Ref<PaintCanvasLayer> layer = layers[i];
|
Ref<PaintCanvasLayer> layer = layers[i];
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ Ref<PaintCanvasLayer> PaintCanvas::add_new_layer(const String &layer_name) {
|
|||||||
|
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
Ref<PaintCanvasLayer> PaintCanvas::duplicate_layer(const String &layer_name, const String &new_layer_name) {
|
Ref<PaintCanvasLayer> PaintCanvasOld::duplicate_layer(const String &layer_name, const String &new_layer_name) {
|
||||||
for (int i = 0; i < layers.size(); ++i) {
|
for (int i = 0; i < layers.size(); ++i) {
|
||||||
Ref<PaintCanvasLayer> layer = layers[i];
|
Ref<PaintCanvasLayer> layer = layers[i];
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ Ref<PaintCanvasLayer> PaintCanvas::duplicate_layer(const String &layer_name, con
|
|||||||
|
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
void PaintCanvas::toggle_layer_visibility(const String &layer_name) {
|
void PaintCanvasOld::toggle_layer_visibility(const String &layer_name) {
|
||||||
for (int i = 0; i < layers.size(); ++i) {
|
for (int i = 0; i < layers.size(); ++i) {
|
||||||
Ref<PaintCanvasLayer> layer = layers[i];
|
Ref<PaintCanvasLayer> layer = layers[i];
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ void PaintCanvas::toggle_layer_visibility(const String &layer_name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ref<PaintCanvasLayer> PaintCanvas::find_layer_by_name(const String &layer_name) {
|
Ref<PaintCanvasLayer> PaintCanvasOld::find_layer_by_name(const String &layer_name) {
|
||||||
for (int i = 0; i < layers.size(); ++i) {
|
for (int i = 0; i < layers.size(); ++i) {
|
||||||
Ref<PaintCanvasLayer> layer = layers[i];
|
Ref<PaintCanvasLayer> layer = layers[i];
|
||||||
|
|
||||||
@ -332,32 +332,32 @@ Ref<PaintCanvasLayer> PaintCanvas::find_layer_by_name(const String &layer_name)
|
|||||||
|
|
||||||
return Ref<PaintCanvasLayer>();
|
return Ref<PaintCanvasLayer>();
|
||||||
}
|
}
|
||||||
void PaintCanvas::toggle_lock_layer(const String &layer_name) {
|
void PaintCanvasOld::toggle_lock_layer(const String &layer_name) {
|
||||||
find_layer_by_name(layer_name)->toggle_lock();
|
find_layer_by_name(layer_name)->toggle_lock();
|
||||||
}
|
}
|
||||||
bool PaintCanvas::is_active_layer_locked() {
|
bool PaintCanvasOld::is_active_layer_locked() {
|
||||||
return active_layer->locked;
|
return active_layer->locked;
|
||||||
}
|
}
|
||||||
void PaintCanvas::move_layer_forward(const String &layer_name) {
|
void PaintCanvasOld::move_layer_forward(const String &layer_name) {
|
||||||
TextureRect *layer = find_layer_by_name(layer_name)->texture_rect_ref;
|
TextureRect *layer = find_layer_by_name(layer_name)->texture_rect_ref;
|
||||||
int new_idx = MAX(layer->get_index() - 1, 0);
|
int new_idx = MAX(layer->get_index() - 1, 0);
|
||||||
canvas_layers->move_child(layer, new_idx);
|
canvas_layers->move_child(layer, new_idx);
|
||||||
}
|
}
|
||||||
void PaintCanvas::move_layer_back(const String &layer_name) {
|
void PaintCanvasOld::move_layer_back(const String &layer_name) {
|
||||||
TextureRect *layer = find_layer_by_name(layer_name)->texture_rect_ref;
|
TextureRect *layer = find_layer_by_name(layer_name)->texture_rect_ref;
|
||||||
canvas_layers->move_child(layer, layer->get_index() + 1);
|
canvas_layers->move_child(layer, layer->get_index() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::select_layer(const String &layer_name) {
|
void PaintCanvasOld::select_layer(const String &layer_name) {
|
||||||
active_layer = find_layer_by_name(layer_name);
|
active_layer = find_layer_by_name(layer_name);
|
||||||
}
|
}
|
||||||
void PaintCanvas::_on_mouse_entered() {
|
void PaintCanvasOld::_on_mouse_entered() {
|
||||||
mouse_on_top = true;
|
mouse_on_top = true;
|
||||||
}
|
}
|
||||||
void PaintCanvas::_on_mouse_exited() {
|
void PaintCanvasOld::_on_mouse_exited() {
|
||||||
mouse_on_top = false;
|
mouse_on_top = false;
|
||||||
}
|
}
|
||||||
bool PaintCanvas::is_inside_canvas(const int x, const int y) {
|
bool PaintCanvasOld::is_inside_canvas(const int x, const int y) {
|
||||||
if (x < 0 || y < 0) {
|
if (x < 0 || y < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ bool PaintCanvas::is_inside_canvas(const int x, const int y) {
|
|||||||
//Note: Arrays are always passed by reference. To get a copy of an array which
|
//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.
|
// can be modified independently of the original array, use duplicate.
|
||||||
// (https://docs.godotengine.org/en/stable/classes/class_array.html)
|
// (https://docs.godotengine.org/en/stable/classes/class_array.html)
|
||||||
void PaintCanvas::set_pixel_arr(const PoolVector2iArray &pixels, const Color &color) {
|
void PaintCanvasOld::set_pixel_arr(const PoolVector2iArray &pixels, const Color &color) {
|
||||||
PoolVector2iArray::Read r = pixels.read();
|
PoolVector2iArray::Read r = pixels.read();
|
||||||
|
|
||||||
for (int i = 0; i < pixels.size(); ++i) {
|
for (int i = 0; i < pixels.size(); ++i) {
|
||||||
@ -380,52 +380,52 @@ void PaintCanvas::set_pixel_arr(const PoolVector2iArray &pixels, const Color &co
|
|||||||
_set_pixel(active_layer, pixel.x, pixel.y, color);
|
_set_pixel(active_layer, pixel.x, pixel.y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void PaintCanvas::set_pixel_v(const Vector2i &pos, const Color &color) {
|
void PaintCanvasOld::set_pixel_v(const Vector2i &pos, const Color &color) {
|
||||||
set_pixel(pos.x, pos.y, color);
|
set_pixel(pos.x, pos.y, color);
|
||||||
}
|
}
|
||||||
void PaintCanvas::set_pixel(const int x, const int y, const Color &color) {
|
void PaintCanvasOld::set_pixel(const int x, const int y, const Color &color) {
|
||||||
_set_pixel(active_layer, x, y, color);
|
_set_pixel(active_layer, x, y, color);
|
||||||
}
|
}
|
||||||
void PaintCanvas::_set_pixel_v(Ref<PaintCanvasLayer> layer, const Vector2i &v, const Color &color) {
|
void PaintCanvasOld::_set_pixel_v(Ref<PaintCanvasLayer> layer, const Vector2i &v, const Color &color) {
|
||||||
_set_pixel(layer, v.x, v.y, color);
|
_set_pixel(layer, v.x, v.y, color);
|
||||||
}
|
}
|
||||||
void PaintCanvas::_set_pixel(Ref<PaintCanvasLayer> layer, const int x, const int y, const Color &color) {
|
void PaintCanvasOld::_set_pixel(Ref<PaintCanvasLayer> layer, const int x, const int y, const Color &color) {
|
||||||
if (!is_inside_canvas(x, y)) {
|
if (!is_inside_canvas(x, y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
layer->set_pixel(x, y, color);
|
layer->set_pixel(x, y, color);
|
||||||
}
|
}
|
||||||
Color PaintCanvas::get_pixel_v(const Vector2i &pos) {
|
Color PaintCanvasOld::get_pixel_v(const Vector2i &pos) {
|
||||||
return get_pixel(pos.x, pos.y);
|
return get_pixel(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
Color PaintCanvas::get_pixel(const int x, const int y) {
|
Color PaintCanvasOld::get_pixel(const int x, const int y) {
|
||||||
if (active_layer.is_valid()) {
|
if (active_layer.is_valid()) {
|
||||||
return active_layer->get_pixel(x, y);
|
return active_layer->get_pixel(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Color();
|
return Color();
|
||||||
}
|
}
|
||||||
void PaintCanvas::set_preview_pixel_v(const Vector2i &pos, const Color &color) {
|
void PaintCanvasOld::set_preview_pixel_v(const Vector2i &pos, const Color &color) {
|
||||||
set_preview_pixel(pos.x, pos.y, color);
|
set_preview_pixel(pos.x, pos.y, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::set_preview_pixel(const int x, const int y, const Color &color) {
|
void PaintCanvasOld::set_preview_pixel(const int x, const int y, const Color &color) {
|
||||||
if (!is_inside_canvas(x, y)) {
|
if (!is_inside_canvas(x, y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
preview_layer->set_pixel(x, y, color);
|
preview_layer->set_pixel(x, y, color);
|
||||||
}
|
}
|
||||||
Color PaintCanvas::get_preview_pixel_v(const Vector2i &pos) {
|
Color PaintCanvasOld::get_preview_pixel_v(const Vector2i &pos) {
|
||||||
return get_preview_pixel(pos.x, pos.y);
|
return get_preview_pixel(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color PaintCanvas::get_preview_pixel(const int x, const int y) {
|
Color PaintCanvasOld::get_preview_pixel(const int x, const int y) {
|
||||||
return preview_layer->get_pixel(x, y);
|
return preview_layer->get_pixel(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PaintCanvas::validate_pixel_v(const Vector2i &pos) const {
|
bool PaintCanvasOld::validate_pixel_v(const Vector2i &pos) const {
|
||||||
if (active_layer.is_valid()) {
|
if (active_layer.is_valid()) {
|
||||||
return active_layer->validate_pixel_v(pos);
|
return active_layer->validate_pixel_v(pos);
|
||||||
}
|
}
|
||||||
@ -433,17 +433,17 @@ bool PaintCanvas::validate_pixel_v(const Vector2i &pos) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::toggle_grid() {
|
void PaintCanvasOld::toggle_grid() {
|
||||||
grid->set_visible(!grid->is_visible());
|
grid->set_visible(!grid->is_visible());
|
||||||
}
|
}
|
||||||
void PaintCanvas::show_grid() {
|
void PaintCanvasOld::show_grid() {
|
||||||
grid->show();
|
grid->show();
|
||||||
}
|
}
|
||||||
void PaintCanvas::hide_grid() {
|
void PaintCanvasOld::hide_grid() {
|
||||||
grid->hide();
|
grid->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolVector2iArray PaintCanvas::select_color(const int p_x, const int p_y) {
|
PoolVector2iArray PaintCanvasOld::select_color(const int p_x, const int p_y) {
|
||||||
PoolVector2iArray same_color_pixels;
|
PoolVector2iArray same_color_pixels;
|
||||||
|
|
||||||
Color color = get_pixel(p_x, p_y);
|
Color color = get_pixel(p_x, p_y);
|
||||||
@ -458,14 +458,14 @@ PoolVector2iArray PaintCanvas::select_color(const int p_x, const int p_y) {
|
|||||||
|
|
||||||
return same_color_pixels;
|
return same_color_pixels;
|
||||||
}
|
}
|
||||||
PoolVector2iArray PaintCanvas::select_same_color(const int p_x, const int p_y) {
|
PoolVector2iArray PaintCanvasOld::select_same_color(const int p_x, const int p_y) {
|
||||||
return get_neighbouring_pixels(p_x, p_y);
|
return get_neighbouring_pixels(p_x, p_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns array of Vector2
|
// returns array of Vector2
|
||||||
// yoinked from
|
// yoinked from
|
||||||
// https://www.geeksforgeeks.org/flood-fill-algorithm-implement-fill-paint/
|
// https://www.geeksforgeeks.org/flood-fill-algorithm-implement-fill-paint/
|
||||||
PoolVector2iArray PaintCanvas::get_neighbouring_pixels(const int pos_x, const int pos_y) {
|
PoolVector2iArray PaintCanvasOld::get_neighbouring_pixels(const int pos_x, const int pos_y) {
|
||||||
PoolVector2iArray pixels;
|
PoolVector2iArray pixels;
|
||||||
|
|
||||||
PoolIntArray to_check_queue;
|
PoolIntArray to_check_queue;
|
||||||
@ -524,7 +524,7 @@ PoolVector2iArray PaintCanvas::get_neighbouring_pixels(const int pos_x, const in
|
|||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::resize(int width, int height) {
|
void PaintCanvasOld::resize(int width, int height) {
|
||||||
//if (get_canvas_width() == width && get_canvas_height() == height) {
|
//if (get_canvas_width() == width && get_canvas_height() == height) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
@ -559,7 +559,7 @@ void PaintCanvas::resize(int width, int height) {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::_notification(int p_what) {
|
void PaintCanvasOld::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_POSTINITIALIZE: {
|
case NOTIFICATION_POSTINITIALIZE: {
|
||||||
connect("mouse_entered", this, "_on_mouse_entered");
|
connect("mouse_entered", this, "_on_mouse_entered");
|
||||||
@ -588,7 +588,7 @@ void PaintCanvas::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintCanvas::PaintCanvas() {
|
PaintCanvasOld::PaintCanvasOld() {
|
||||||
big_grid = nullptr;
|
big_grid = nullptr;
|
||||||
|
|
||||||
_pixel_size = 16;
|
_pixel_size = 16;
|
||||||
@ -646,10 +646,10 @@ PaintCanvas::PaintCanvas() {
|
|||||||
tool_layer->create(tool_preview_layer_rect, _canvas_width, _canvas_height);
|
tool_layer->create(tool_preview_layer_rect, _canvas_width, _canvas_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintCanvas::~PaintCanvas() {
|
PaintCanvasOld::~PaintCanvasOld() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintCanvas::_bind_methods() {
|
void PaintCanvasOld::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("_on_mouse_entered"), &PaintCanvas::_on_mouse_entered);
|
ClassDB::bind_method(D_METHOD("_on_mouse_entered"), &PaintCanvasOld::_on_mouse_entered);
|
||||||
ClassDB::bind_method(D_METHOD("_on_mouse_exited"), &PaintCanvas::_on_mouse_exited);
|
ClassDB::bind_method(D_METHOD("_on_mouse_exited"), &PaintCanvasOld::_on_mouse_exited);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef PAINT_CANVAS_H
|
#ifndef PAINT_CANVAS_OLD_H
|
||||||
#define PAINT_CANVAS_H
|
#define PAINT_CANVAS_OLD_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2019 Flairieve
|
Copyright (c) 2019 Flairieve
|
||||||
@ -39,8 +39,8 @@ class PaintCanvasLayer;
|
|||||||
class PaintCanvasBackground;
|
class PaintCanvasBackground;
|
||||||
|
|
||||||
//class_name GECanvas
|
//class_name GECanvas
|
||||||
class PaintCanvas : public MarginContainer {
|
class PaintCanvasOld : public MarginContainer {
|
||||||
GDCLASS(PaintCanvas, MarginContainer);
|
GDCLASS(PaintCanvasOld, MarginContainer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void _process(float delta);
|
void _process(float delta);
|
||||||
@ -111,8 +111,8 @@ public:
|
|||||||
|
|
||||||
void resize(int width, int height);
|
void resize(int width, int height);
|
||||||
|
|
||||||
PaintCanvas();
|
PaintCanvasOld();
|
||||||
~PaintCanvas();
|
~PaintCanvasOld();
|
||||||
|
|
||||||
Vector<Ref<PaintCanvasLayer>> layers;
|
Vector<Ref<PaintCanvasLayer>> layers;
|
||||||
Ref<PaintCanvasLayer> active_layer;
|
Ref<PaintCanvasLayer> active_layer;
|
||||||
|
@ -28,7 +28,7 @@ SOFTWARE.
|
|||||||
#include "scene/gui/box_container.h"
|
#include "scene/gui/box_container.h"
|
||||||
|
|
||||||
class PaintWindow;
|
class PaintWindow;
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
class MenuButton;
|
class MenuButton;
|
||||||
|
|
||||||
class PaintNavbar : public BoxContainer {
|
class PaintNavbar : public BoxContainer {
|
||||||
@ -74,7 +74,7 @@ public:
|
|||||||
~PaintNavbar();
|
~PaintNavbar();
|
||||||
|
|
||||||
PaintWindow *paint_window;
|
PaintWindow *paint_window;
|
||||||
PaintCanvas *canvas;
|
PaintCanvasOld *canvas;
|
||||||
|
|
||||||
MenuButton *file_menu_button;
|
MenuButton *file_menu_button;
|
||||||
MenuButton *edit_menu_button;
|
MenuButton *edit_menu_button;
|
||||||
|
@ -1438,7 +1438,7 @@ PaintWindow::PaintWindow() {
|
|||||||
paint_canvas_container->connect("mouse_exited", this, "_on_PaintCanvasContainer_mouse_exited");
|
paint_canvas_container->connect("mouse_exited", this, "_on_PaintCanvasContainer_mouse_exited");
|
||||||
app_mid_container->add_child(paint_canvas_container);
|
app_mid_container->add_child(paint_canvas_container);
|
||||||
|
|
||||||
paint_canvas = memnew(PaintCanvas);
|
paint_canvas = memnew(PaintCanvasOld);
|
||||||
paint_canvas->set_pixel_size(4);
|
paint_canvas->set_pixel_size(4);
|
||||||
paint_canvas->set_canvas_width(64);
|
paint_canvas->set_canvas_width(64);
|
||||||
paint_canvas->set_canvas_height(64);
|
paint_canvas->set_canvas_height(64);
|
||||||
|
@ -34,7 +34,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
class PaintAction;
|
class PaintAction;
|
||||||
class PaintCanvasLayer;
|
class PaintCanvasLayer;
|
||||||
class PaintCanvas;
|
class PaintCanvasOld;
|
||||||
class InputEvent;
|
class InputEvent;
|
||||||
class PaintCanvasDialog;
|
class PaintCanvasDialog;
|
||||||
class PaintChangeGridSizeDialog;
|
class PaintChangeGridSizeDialog;
|
||||||
@ -227,7 +227,7 @@ public:
|
|||||||
PanelContainer *bottom_content_panel;
|
PanelContainer *bottom_content_panel;
|
||||||
|
|
||||||
Control *paint_canvas_container;
|
Control *paint_canvas_container;
|
||||||
PaintCanvas *paint_canvas;
|
PaintCanvasOld *paint_canvas;
|
||||||
|
|
||||||
Button *paint_tool_button;
|
Button *paint_tool_button;
|
||||||
Button *brush_tool_button;
|
Button *brush_tool_button;
|
||||||
|
Loading…
Reference in New Issue
Block a user