| 1 | // Aseprite Document Library |
| 2 | // Copyright (C) 2020 Igara Studio S.A. |
| 3 | // Copyright (C) 2016-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_SELECTED_LAYERS_H_INCLUDED |
| 9 | #define DOC_SELECTED_LAYERS_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include "layer_list.h" |
| 13 | |
| 14 | #include <iosfwd> |
| 15 | #include <set> |
| 16 | |
| 17 | namespace doc { |
| 18 | |
| 19 | class Layer; |
| 20 | class LayerGroup; |
| 21 | |
| 22 | class SelectedLayers { |
| 23 | public: |
| 24 | typedef std::set<Layer*> Set; |
| 25 | typedef Set::iterator iterator; |
| 26 | typedef Set::const_iterator const_iterator; |
| 27 | |
| 28 | iterator begin() { return m_set.begin(); } |
| 29 | iterator end() { return m_set.end(); } |
| 30 | const_iterator begin() const { return m_set.begin(); } |
| 31 | const_iterator end() const { return m_set.end(); } |
| 32 | |
| 33 | bool empty() const { return m_set.empty(); } |
| 34 | layer_t size() const { return (layer_t)m_set.size(); } |
| 35 | |
| 36 | void clear(); |
| 37 | void insert(Layer* layer); |
| 38 | void erase(const Layer* layer); |
| 39 | |
| 40 | bool contains(const Layer* layer) const; |
| 41 | bool hasSameParent() const; |
| 42 | LayerList toBrowsableLayerList() const; |
| 43 | LayerList toAllLayersList() const; |
| 44 | |
| 45 | void removeChildrenIfParentIsSelected(); |
| 46 | void expandCollapsedGroups(); |
| 47 | void selectAllLayers(LayerGroup* group); |
| 48 | void displace(layer_t layerDelta); |
| 49 | |
| 50 | void propagateSelection(); |
| 51 | |
| 52 | bool operator==(const SelectedLayers& o) const { |
| 53 | return m_set == o.m_set; |
| 54 | } |
| 55 | |
| 56 | bool operator!=(const SelectedLayers& o) const { |
| 57 | return !operator==(o); |
| 58 | } |
| 59 | |
| 60 | bool write(std::ostream& os) const; |
| 61 | bool read(std::istream& is); |
| 62 | |
| 63 | private: |
| 64 | Set m_set; |
| 65 | }; |
| 66 | |
| 67 | } // namespace doc |
| 68 | |
| 69 | #endif // DOC_SELECTED_LAYERS_H_INCLUDED |
| 70 | |