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