-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added license comment. * Enhance undo/redo for path deformation and drawable editing. * - remember and undo "isSet" flags for undo/redo of DeformationParameterBinding. - Undo work well with path deformation across different keypoints.
- Loading branch information
Showing
5 changed files
with
354 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
Copyright © 2020,2022 Inochi2D Project | ||
Distributed under the 2-Clause BSD License, see LICENSE file. | ||
*/ | ||
module creator.actions.drawable; | ||
import creator.core.actionstack; | ||
import creator.actions; | ||
import creator; | ||
import inochi2d; | ||
import std.format; | ||
import i18n; | ||
|
||
/** | ||
Action to add parameter to active puppet. | ||
*/ | ||
class DrawableChangeAction : GroupAction, LazyBoundAction { | ||
private: | ||
void copy(ref MeshData src, ref MeshData dst) { | ||
dst.vertices = src.vertices.dup; | ||
dst.uvs = src.uvs.dup; | ||
dst.indices = src.indices.dup; | ||
dst.origin = src.origin; | ||
} | ||
public: | ||
Drawable self; | ||
string name; | ||
|
||
MeshData oldMesh; | ||
MeshData newMesh; | ||
|
||
this(string name, Drawable self) { | ||
super(); | ||
this.name = name; | ||
this.self = self; | ||
copy(self.getMesh(), oldMesh); | ||
} | ||
|
||
override | ||
void updateNewState() { | ||
copy(self.getMesh(), newMesh); | ||
} | ||
|
||
void addBinding(Parameter param, ParameterBinding binding) { | ||
addAction(new ParameterBindingRemoveAction(param, binding)); | ||
} | ||
|
||
/** | ||
Rollback | ||
*/ | ||
override | ||
void rollback() { | ||
self.rebuffer(oldMesh); | ||
super.rollback(); | ||
} | ||
|
||
/** | ||
Redo | ||
*/ | ||
override | ||
void redo() { | ||
self.rebuffer(newMesh); | ||
super.redo(); | ||
} | ||
|
||
/** | ||
Describe the action | ||
*/ | ||
override | ||
string describe() { | ||
return _("Changed drawable mesh of %s").format(self.name); | ||
} | ||
|
||
/** | ||
Describe the action | ||
*/ | ||
override | ||
string describeUndo() { | ||
return _("Drawable %s was changed").format(self.name); | ||
} | ||
|
||
/** | ||
Gets name of this action | ||
*/ | ||
override | ||
string getName() { | ||
return this.stringof; | ||
} | ||
|
||
override bool merge(Action other) { return false; } | ||
override bool canMerge(Action other) { return false; } | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.