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