Timeline start/end markers

Right-clicking the numbered row offers Add Start/End Marker Here and
Remove Markers; Shift+Comma / Shift+Period (configurable) set them at the
playhead. Markers are faded playheads, with the numbers outside their
range darkened, and playback loops within them. They are saved as
StartMarker/EndMarker on the editor's copy (SourceDocument) only, as one
undoable edit each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 21:03:00 -04:00
1 parent 24af98a68e
commit 251d04848a
15 files changed
+147 -13

No files matched your search

+9
View File
@@ -368,6 +368,15 @@ namespace anm2ed::model
return length;
}
// The frames playback stays within: [start, end), from the markers (or the whole animation).
glm::ivec2 animation_play_range_get(const Animation& animation)
{
auto length = std::max(animation.frameNum, 1);
auto start = animation.startMarker != -1 ? std::clamp(animation.startMarker, 0, length - 1) : 0;
auto end = animation.endMarker != -1 ? std::clamp(animation.endMarker + 1, start + 1, length) : length;
return {start, end};
}
int animation_length_get(const Animation& animation)
{
int length{};
+4
View File
@@ -96,6 +96,9 @@ namespace anm2ed::model
std::string name{};
int frameNum{1};
bool isLoop{true};
// Playback stays between these frames (inclusive) when set; -1 for none. Saved only in the editor's copy.
int startMarker{-1};
int endMarker{-1};
Track root{.type = ItemType::ROOT, .frames = {Frame{}}};
std::vector<TrackEntry> layers{};
std::vector<TrackEntry> nulls{};
@@ -379,6 +382,7 @@ namespace anm2ed::model
int track_frames_count_get(const Track&);
int track_length_get(const Track&);
int animation_length_get(const Animation&);
glm::ivec2 animation_play_range_get(const Animation&);
const Track* animation_track_get(const Animation&, int, int, int = NONE, int = -1);
Track* animation_track_get(Animation&, int, int, int = NONE, int = -1);
TrackGroup* animation_track_group_get(Animation&, int, int);
+6 -1
View File
@@ -35,7 +35,7 @@ namespace anm2ed::model
constexpr std::string_view KNOWN_ATTRIBUTES[] = {
"Name", "CreatedBy", "CreatedOn", "Binding", "Value", "DefaultAnimation", "Path", "Vertex", "Fragment", "Id",
"LayerId", "NullId", "SpritesheetId", "Fps", "Version", "FrameNum", "Delay", "AtFrame", "EventId", "RegionId",
"ShaderId", "SoundId", "GroupId", "Index", "Loop", "Visible", "ShowRect", "IsExpanded", "Enabled", "Rotation",
"ShaderId", "SoundId", "GroupId", "Index", "Loop", "StartMarker", "EndMarker", "Visible", "ShowRect", "IsExpanded", "Enabled", "Rotation",
"XPivot", "YPivot", "XCrop", "YCrop", "XPosition", "YPosition", "Width", "Height", "XScale", "YScale", "ShearX",
"ShearY", "RedTint", "GreenTint", "BlueTint", "AlphaTint", "RedOffset", "GreenOffset", "BlueOffset",
"Interpolated", "Origin", "BakeInterpolation", "BakeDelay", "BakeCount", "OriginalDelay"};
@@ -423,6 +423,8 @@ namespace anm2ed::model
Animation animation{.name = string_get(element, "Name"),
.frameNum = int_get(element, "FrameNum", 1),
.isLoop = bool_get(element, "Loop", true),
.startMarker = int_get(element, "StartMarker"),
.endMarker = int_get(element, "EndMarker"),
.root = {.type = ItemType::ROOT},
.layout = {},
.extras = extras_read(element)};
@@ -1389,6 +1391,9 @@ namespace anm2ed::model
sink.attribute("Name", animation.name);
sink.attribute("FrameNum", animation.frameNum);
sink.attribute("Loop", animation.isLoop);
if (writer.is(SERIALIZE_EXTENSIONS))
for (auto [name, marker] : {std::pair{"StartMarker", animation.startMarker}, {"EndMarker", animation.endMarker}})
if (marker != -1) sink.attribute(name, marker);
if (groupId != -1 && is_group_id_written(writer)) sink.attribute("GroupId", groupId);
extras_write(sink, animation.extras);