Improved copying the data from an action to an another. I'll try an another solution though.

This commit is contained in:
Relintai 2022-06-21 17:02:39 +02:00
parent 004bf8e812
commit 2f647c1561
3 changed files with 23 additions and 1 deletions

View File

@ -181,6 +181,25 @@ void PaintAction::draw_points(PaintCanvas *canvas, const PoolVector2iArray &poin
}
}
void PaintAction::copy_data_from(const Ref<PaintAction> &other) {
action_data_undo = other->action_data_undo.duplicate(true);
action_data_redo = other->action_data_redo.duplicate(true);
action_data_preview = other->action_data_preview.duplicate(true);
undo_cells.append_array(other->undo_cells);
undo_colors.append_array(other->undo_colors);
redo_cells.append_array(other->redo_cells);
redo_colors.append_array(other->redo_colors);
preview_cells.append_array(other->preview_cells);
preview_colors.append_array(other->preview_colors);
layer = other->layer;
action_data = other->action_data.duplicate(true);
}
PaintAction::PaintAction() {
}

View File

@ -56,6 +56,8 @@ public:
void draw_points(PaintCanvas *canvas, const PoolVector2iArray &point_arr, const PoolColorArray &color_arr);
void copy_data_from(const Ref<PaintAction> &other);
PaintAction();
~PaintAction();

View File

@ -609,7 +609,8 @@ void PaintWindow::commit_action() {
//print("commit action")
_current_action->commit_action(paint_canvas);
Ref<PaintAction> action = get_action();
action->action_data = _current_action->action_data.duplicate(true);
action->copy_data_from(_current_action);
_actions_history.push_back(action);
_redo_history.clear();