| 1 | // Aseprite |
| 2 | // Copyright (C) 2018-2020 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 | #ifndef APP_TOOLS_TOOL_BOX_H_INCLUDED |
| 9 | #define APP_TOOLS_TOOL_BOX_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include <list> |
| 13 | #include <map> |
| 14 | #include <string> |
| 15 | |
| 16 | #include "app/i18n/xml_translator.h" |
| 17 | #include "app/tools/tool.h" |
| 18 | |
| 19 | class TiXmlElement; |
| 20 | |
| 21 | namespace app { |
| 22 | namespace tools { |
| 23 | |
| 24 | namespace WellKnownTools { |
| 25 | extern const char* RectangularMarquee; |
| 26 | extern const char* Lasso; |
| 27 | extern const char* Pencil; |
| 28 | extern const char* Eraser; |
| 29 | extern const char* Eyedropper; |
| 30 | extern const char* Hand; |
| 31 | extern const char* Move; |
| 32 | }; |
| 33 | |
| 34 | namespace WellKnownInks { |
| 35 | extern const char* Selection; |
| 36 | extern const char* Paint; |
| 37 | extern const char* PaintFg; |
| 38 | extern const char* PaintBg; |
| 39 | extern const char* PaintAlphaCompositing; |
| 40 | extern const char* PaintCopy; |
| 41 | extern const char* PaintLockAlpha; |
| 42 | extern const char* Shading; |
| 43 | extern const char* Gradient; |
| 44 | extern const char* Eraser; |
| 45 | extern const char* ReplaceFgWithBg; |
| 46 | extern const char* ReplaceBgWithFg; |
| 47 | extern const char* PickFg; |
| 48 | extern const char* PickBg; |
| 49 | extern const char* Zoom; |
| 50 | extern const char* Scroll; |
| 51 | extern const char* Move; |
| 52 | extern const char* SelectLayerAndMove; |
| 53 | extern const char* Slice; |
| 54 | extern const char* MoveSlice; |
| 55 | extern const char* Blur; |
| 56 | extern const char* Jumble; |
| 57 | }; |
| 58 | |
| 59 | namespace WellKnownControllers { |
| 60 | extern const char* Freehand; |
| 61 | extern const char* PointByPoint; |
| 62 | extern const char* OnePoints; |
| 63 | extern const char* TwoPoints; |
| 64 | extern const char* FourPoints; |
| 65 | extern const char* LineFreehand; |
| 66 | }; |
| 67 | |
| 68 | namespace WellKnownIntertwiners { |
| 69 | extern const char* None; |
| 70 | extern const char* FirstPoint; |
| 71 | extern const char* AsLines; |
| 72 | extern const char* AsRectangles; |
| 73 | extern const char* AsEllipses; |
| 74 | extern const char* AsBezier; |
| 75 | extern const char* AsPixelPerfect; |
| 76 | }; |
| 77 | |
| 78 | namespace WellKnownPointShapes { |
| 79 | extern const char* None; |
| 80 | extern const char* Pixel; |
| 81 | extern const char* Tile; |
| 82 | extern const char* Brush; |
| 83 | extern const char* FloodFill; |
| 84 | extern const char* Spray; |
| 85 | }; |
| 86 | |
| 87 | typedef std::list<Tool*> ToolList; |
| 88 | typedef ToolList::iterator ToolIterator; |
| 89 | typedef ToolList::const_iterator ToolConstIterator; |
| 90 | |
| 91 | typedef std::list<ToolGroup*> ToolGroupList; |
| 92 | |
| 93 | // Loads and maintains the group of tools specified in the gui.xml file |
| 94 | class ToolBox { |
| 95 | public: |
| 96 | ToolBox(); |
| 97 | ~ToolBox(); |
| 98 | |
| 99 | ToolGroupList::iterator begin_group() { return m_groups.begin(); } |
| 100 | ToolGroupList::iterator end_group() { return m_groups.end(); } |
| 101 | |
| 102 | ToolIterator begin() { return m_tools.begin(); } |
| 103 | ToolIterator end() { return m_tools.end(); } |
| 104 | ToolConstIterator begin() const { return m_tools.begin(); } |
| 105 | ToolConstIterator end() const { return m_tools.end(); } |
| 106 | |
| 107 | Tool* getToolById(const std::string& id); |
| 108 | Ink* getInkById(const std::string& id); |
| 109 | Controller* getControllerById(const std::string& id); |
| 110 | Intertwine* getIntertwinerById(const std::string& id); |
| 111 | PointShape* getPointShapeById(const std::string& id); |
| 112 | int getGroupsCount() const { return m_groups.size(); } |
| 113 | |
| 114 | private: |
| 115 | void loadTools(); |
| 116 | void loadToolProperties(TiXmlElement* xmlTool, Tool* tool, int button, const std::string& suffix); |
| 117 | |
| 118 | std::map<std::string, Ink*> m_inks; |
| 119 | std::map<std::string, Controller*> m_controllers; |
| 120 | std::map<std::string, PointShape*> m_pointshapers; |
| 121 | std::map<std::string, Intertwine*> m_intertwiners; |
| 122 | |
| 123 | ToolGroupList m_groups; |
| 124 | ToolList m_tools; |
| 125 | XmlTranslator m_xmlTranslator; |
| 126 | }; |
| 127 | |
| 128 | } // namespace tools |
| 129 | } // namespace app |
| 130 | |
| 131 | #endif // TOOLS_TOOL_BOX_H_INCLUDED |
| 132 | |