| 1 | // Aseprite |
| 2 | // Copyright (C) 2021 Igara Studio S.A. |
| 3 | // Copyright (C) 2001-2016 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifndef APP_APP_BRUSHES_H_INCLUDED |
| 9 | #define APP_APP_BRUSHES_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include "app/brush_slot.h" |
| 13 | #include "doc/brushes.h" |
| 14 | #include "obs/signal.h" |
| 15 | |
| 16 | #include <string> |
| 17 | #include <vector> |
| 18 | |
| 19 | namespace app { |
| 20 | |
| 21 | class AppBrushes { |
| 22 | public: |
| 23 | // Number of slot (a range from 1 to AppBrushes::size() inclusive) |
| 24 | typedef int slot_id; |
| 25 | typedef std::vector<BrushSlot> BrushSlots; |
| 26 | |
| 27 | AppBrushes(); |
| 28 | ~AppBrushes(); |
| 29 | |
| 30 | // Adds a new brush and returns the slot number where the brush |
| 31 | // is now available. |
| 32 | slot_id addBrushSlot(const BrushSlot& brush); |
| 33 | void removeBrushSlot(slot_id slot); |
| 34 | void removeAllBrushSlots(); |
| 35 | bool hasBrushSlot(slot_id slot) const; |
| 36 | const doc::Brushes& getStandardBrushes() { return m_standard; } |
| 37 | BrushSlot getBrushSlot(slot_id slot) const; |
| 38 | void setBrushSlot(slot_id slot, const BrushSlot& brush); |
| 39 | const BrushSlots& getBrushSlots() const { return m_slots; } |
| 40 | |
| 41 | void lockBrushSlot(slot_id slot); |
| 42 | void unlockBrushSlot(slot_id slot); |
| 43 | bool isBrushSlotLocked(slot_id slot) const; |
| 44 | |
| 45 | obs::signal<void()> ItemsChange; |
| 46 | |
| 47 | private: |
| 48 | void load(const std::string& filename); |
| 49 | void save(const std::string& filename) const; |
| 50 | static std::string userBrushesFilename(); |
| 51 | |
| 52 | doc::Brushes m_standard; |
| 53 | BrushSlots m_slots; |
| 54 | std::string m_userBrushesFilename; |
| 55 | }; |
| 56 | |
| 57 | } // namespace app |
| 58 | |
| 59 | #endif |
| 60 | |