Profile editor - Fix undoing profile editor commands

- Undoing a change to an existing keyframe's value restores the value instead of deleting the keyframe
- Undoing "remove effect" puts the effect back in its place instead of below the next one
- Undoing "toggle keyframes" restores what it was before
- Undoing a brush change on a layer that had no brush removes the brush again, using the new Layer.RemoveLayerBrush
- Undoing "add element" disables the element again
- Undoing an event path change back to no path goes back to an event start node, like a new condition
- MoveProfileElement says "Move folder" for folders
- UpdateLayerProperty without a time no longer calls itself "Add ... keyframe"
This commit is contained in:
RobertBeekman committed 2026-10-20 09:47:43 +02:00
1 parent 504845c7d2
commit 0920cf8917
14 files changed
+80 -71

No files matched your search

@@ -114,7 +114,7 @@ public class LayerPropertyCommandTests : ProfileEditorTestBase
}
[Fact]
public void UpdateLayerProperty_WithOriginalValue_OnAKeyframe_RemovesTheKeyframeOnUndo()
public void UpdateLayerProperty_WithOriginalValue_OnAKeyframe_RestoresTheKeyframeOnUndo()
{
AddKeyframe(0, 0);
LayerPropertyKeyframe<float> keyframe = AddKeyframe(60, 1);
@@ -124,12 +124,10 @@ public class LayerPropertyCommandTests : ProfileEditorTestBase
keyframe.Value.ShouldBe(40);
command.Undo();
// Pinned as-is: this constructor never checks whether there already is a keyframe at the time. When keyframes are
// enabled, Execute treats the existing keyframe that SetCurrentValue updated as a new one, and Undo removes it
// instead of restoring its value. Changing a keyframe through a property input and undoing deletes the keyframe
_opacity.Keyframes.ShouldNotContain(keyframe);
_opacity.Keyframes.Count.ShouldBe(1);
command.DisplayName.ShouldBe("Add Opacity keyframe");
_opacity.Keyframes.ShouldContain(keyframe);
_opacity.Keyframes.Count.ShouldBe(2);
keyframe.Value.ShouldBe(60);
command.DisplayName.ShouldBe("Update Opacity");
}
[Fact]
@@ -142,9 +140,7 @@ public class LayerPropertyCommandTests : ProfileEditorTestBase
_opacity.BaseValue.ShouldBe(40);
_opacity.Keyframes.Count.ShouldBe(1);
// Pinned as-is: with keyframes enabled the command expects to add a keyframe and renames itself, even though
// without a time no keyframe is added
command.DisplayName.ShouldBe("Add Opacity keyframe");
command.DisplayName.ShouldBe("Update Opacity");
command.Undo();
_opacity.BaseValue.ShouldBe(0, 0.01f);