forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop_tag.cpp
45 lines (35 loc) · 938 Bytes
/
loop_tag.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/loop_tag.h"
#include "doc/sprite.h"
#include "doc/frame_tag.h"
namespace app {
const char* kLoopTagName = "Loop";
doc::FrameTag* get_animation_tag(const doc::Sprite* sprite, doc::frame_t frame)
{
doc::FrameTag* tag = sprite->frameTags().innerTag(frame);
if (!tag)
tag = get_loop_tag(sprite);
return tag;
}
doc::FrameTag* get_loop_tag(const doc::Sprite* sprite)
{
// Get tag with special "Loop" name
for (doc::FrameTag* tag : sprite->frameTags())
if (tag->name() == kLoopTagName)
return tag;
return nullptr;
}
doc::FrameTag* create_loop_tag(doc::frame_t from, doc::frame_t to)
{
doc::FrameTag* tag = new doc::FrameTag(from, to);
tag->setName(kLoopTagName);
return tag;
}
} // app