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