| 1 | // Aseprite | 
|---|
| 2 | // Copyright (C) 2021  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_H_INCLUDED | 
|---|
| 9 | #define APP_TOOLS_TOOL_H_INCLUDED | 
|---|
| 10 | #pragma once | 
|---|
| 11 |  | 
|---|
| 12 | #include <string> | 
|---|
| 13 |  | 
|---|
| 14 | #include "app/tools/fill.h" | 
|---|
| 15 | #include "app/tools/trace_policy.h" | 
|---|
| 16 |  | 
|---|
| 17 | namespace app { | 
|---|
| 18 | namespace tools { | 
|---|
| 19 |  | 
|---|
| 20 | class Controller; | 
|---|
| 21 | class Ink; | 
|---|
| 22 | class Intertwine; | 
|---|
| 23 | class PointShape; | 
|---|
| 24 | class ToolGroup; | 
|---|
| 25 |  | 
|---|
| 26 | // A drawing tool | 
|---|
| 27 | class Tool { | 
|---|
| 28 | public: | 
|---|
| 29 |  | 
|---|
| 30 | Tool(ToolGroup* group, const std::string& id) | 
|---|
| 31 | : m_group(group) | 
|---|
| 32 | , m_id(id) | 
|---|
| 33 | , m_default_brush_size(1) | 
|---|
| 34 | { } | 
|---|
| 35 |  | 
|---|
| 36 | virtual ~Tool() | 
|---|
| 37 | { } | 
|---|
| 38 |  | 
|---|
| 39 | const ToolGroup* getGroup() const { return m_group; } | 
|---|
| 40 | const std::string& getId() const { return m_id; } | 
|---|
| 41 | const std::string& getText() const { return m_text; } | 
|---|
| 42 | const std::string& getTips() const { return m_tips; } | 
|---|
| 43 | int getDefaultBrushSize() const { return m_default_brush_size; } | 
|---|
| 44 |  | 
|---|
| 45 | void setText(const std::string& text) { m_text = text; } | 
|---|
| 46 | void setTips(const std::string& tips) { m_tips = tips; } | 
|---|
| 47 | void setDefaultBrushSize(const int default_brush_size) { | 
|---|
| 48 | m_default_brush_size = default_brush_size; | 
|---|
| 49 | } | 
|---|
| 50 |  | 
|---|
| 51 | Fill getFill(int button) { return m_button[button].m_fill; } | 
|---|
| 52 | Ink* getInk(int button) { return m_button[button].m_ink; } | 
|---|
| 53 | Controller* getController(int button) { return m_button[button].m_controller; } | 
|---|
| 54 | PointShape* getPointShape(int button) { return m_button[button].m_point_shape; } | 
|---|
| 55 | Intertwine* getIntertwine(int button) { return m_button[button].m_intertwine; } | 
|---|
| 56 | TracePolicy getTracePolicy(int button) { return m_button[button].m_trace_policy; } | 
|---|
| 57 |  | 
|---|
| 58 | void setFill(int button, Fill fill) { m_button[button].m_fill = fill; } | 
|---|
| 59 | void setInk(int button, Ink* ink) { m_button[button].m_ink = ink; } | 
|---|
| 60 | void setController(int button, Controller* controller) { m_button[button].m_controller = controller; } | 
|---|
| 61 | void setPointShape(int button, PointShape* point_shape) { m_button[button].m_point_shape = point_shape; } | 
|---|
| 62 | void setIntertwine(int button, Intertwine* intertwine) { m_button[button].m_intertwine = intertwine; } | 
|---|
| 63 | void setTracePolicy(int button, TracePolicy trace_policy) { m_button[button].m_trace_policy = trace_policy; } | 
|---|
| 64 |  | 
|---|
| 65 | bool prefAlreadyResetFromScript() const { return m_prefAlreadyResetFromScript; } | 
|---|
| 66 | void markPrefAlreadyResetFromScript() { m_prefAlreadyResetFromScript = true; } | 
|---|
| 67 |  | 
|---|
| 68 | private: | 
|---|
| 69 | ToolGroup* m_group; | 
|---|
| 70 | std::string m_id; | 
|---|
| 71 | std::string m_text; | 
|---|
| 72 | std::string m_tips; | 
|---|
| 73 | int m_default_brush_size; | 
|---|
| 74 |  | 
|---|
| 75 | // Flag used to indicate that the preferences of this tool were | 
|---|
| 76 | // already reset from scripts when they are executed in CLI mode | 
|---|
| 77 | // (without GUI). This is needed to reset the preferences only | 
|---|
| 78 | // once, but if the script then modifies the preferences, they | 
|---|
| 79 | // are not reset again. | 
|---|
| 80 | bool m_prefAlreadyResetFromScript = false; | 
|---|
| 81 |  | 
|---|
| 82 | struct { | 
|---|
| 83 | Fill m_fill; | 
|---|
| 84 | Ink* m_ink; | 
|---|
| 85 | Controller* m_controller; | 
|---|
| 86 | PointShape* m_point_shape; | 
|---|
| 87 | Intertwine* m_intertwine; | 
|---|
| 88 | TracePolicy m_trace_policy; | 
|---|
| 89 | } m_button[2]; // Two buttons: [0] left and [1] right | 
|---|
| 90 |  | 
|---|
| 91 | }; | 
|---|
| 92 |  | 
|---|
| 93 | } // namespace tools | 
|---|
| 94 | } // namespace app | 
|---|
| 95 |  | 
|---|
| 96 | #endif  // TOOLS_TOOL_H_INCLUDED | 
|---|
| 97 |  | 
|---|