| 1 | // Aseprite Document Library | 
|---|---|
| 2 | // Copyright (C) 2018 Igara Studio S.A. | 
| 3 | // Copyright (c) 2001-2018 David Capello | 
| 4 | // | 
| 5 | // This file is released under the terms of the MIT license. | 
| 6 | // Read LICENSE.txt for more information. | 
| 7 | |
| 8 | #ifndef DOC_SPRITES_H_INCLUDED | 
| 9 | #define DOC_SPRITES_H_INCLUDED | 
| 10 | #pragma once | 
| 11 | |
| 12 | #include "base/disable_copying.h" | 
| 13 | #include "doc/color_mode.h" | 
| 14 | #include "doc/object_id.h" | 
| 15 | #include "doc/sprite.h" | 
| 16 | |
| 17 | #include <vector> | 
| 18 | |
| 19 | namespace doc { | 
| 20 | class Document; | 
| 21 | |
| 22 | class Sprites { | 
| 23 | public: | 
| 24 | typedef std::vector<Sprite*>::iterator iterator; | 
| 25 | typedef std::vector<Sprite*>::const_iterator const_iterator; | 
| 26 | |
| 27 | Sprites(Document* doc); | 
| 28 | ~Sprites(); | 
| 29 | |
| 30 | iterator begin() { return m_sprites.begin(); } | 
| 31 | iterator end() { return m_sprites.end(); } | 
| 32 | const_iterator begin() const { return m_sprites.begin(); } | 
| 33 | const_iterator end() const { return m_sprites.end(); } | 
| 34 | |
| 35 | Sprite* front() const { return m_sprites.front(); } | 
| 36 | Sprite* back() const { return m_sprites.back(); } | 
| 37 | |
| 38 | int size() const { return (int)m_sprites.size(); } | 
| 39 | bool empty() const { return m_sprites.empty(); } | 
| 40 | |
| 41 | Sprite* add(Sprite* spr); | 
| 42 | void remove(Sprite* spr); | 
| 43 | void move(Sprite* spr, int index); | 
| 44 | |
| 45 | Sprite* operator[](int index) const { return m_sprites[index]; } | 
| 46 | |
| 47 | private: | 
| 48 | // Deletes all sprites in the list (calling "delete" operation). | 
| 49 | void deleteAll(); | 
| 50 | |
| 51 | Document* m_doc; | 
| 52 | std::vector<Sprite*> m_sprites; | 
| 53 | |
| 54 | DISABLE_COPYING(Sprites); | 
| 55 | }; | 
| 56 | |
| 57 | } // namespace doc | 
| 58 | |
| 59 | #endif | 
| 60 | 
