| 1 | // Aseprite | 
| 2 | // Copyright (C) 2020  Igara Studio S.A. | 
| 3 | // Copyright (C) 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_TOOLS_ACTIVE_TOOL_H_INCLUDED | 
| 9 | #define APP_TOOLS_ACTIVE_TOOL_H_INCLUDED | 
| 10 | #pragma once | 
| 11 |  | 
| 12 | #include "app/tools/ink_type.h" | 
| 13 | #include "obs/observable.h" | 
| 14 |  | 
| 15 | namespace app { | 
| 16 | class Color; | 
| 17 |  | 
| 18 | namespace tools { | 
| 19 |  | 
| 20 | class ActiveToolObserver; | 
| 21 | class Ink; | 
| 22 | class Pointer; | 
| 23 | class Tool; | 
| 24 | class ToolBox; | 
| 25 |  | 
| 26 | // Manages the coordination between different UI elements that show | 
| 27 | // information about the active tool. | 
| 28 | class ActiveToolManager : public obs::observable<ActiveToolObserver> { | 
| 29 | public: | 
| 30 |   ActiveToolManager(ToolBox* toolbox); | 
| 31 |  | 
| 32 |   Tool* activeTool() const; | 
| 33 |   Ink* activeInk() const; | 
| 34 |  | 
| 35 |   // Returns the quick tool. | 
| 36 |   Tool* quickTool() const; | 
| 37 |  | 
| 38 |   // Returns the selected tool in the toolbar/box. | 
| 39 |   Tool* selectedTool() const; | 
| 40 |  | 
| 41 |   // These are different events that came from UI elements and | 
| 42 |   // modify the active tool. | 
| 43 |   void newToolSelectedInToolBar(Tool* tool); | 
| 44 |   void newQuickToolSelectedFromEditor(Tool* tool); | 
| 45 |   void regularTipProximity(); | 
| 46 |   void eraserTipProximity(); | 
| 47 |   void pressButton(const Pointer& pointer); | 
| 48 |   void releaseButtons(); | 
| 49 |   void setSelectedTool(Tool* tool); | 
| 50 |  | 
| 51 |   Ink* adjustToolInkDependingOnSelectedInkType( | 
| 52 |     Ink* ink, | 
| 53 |     const InkType inkType, | 
| 54 |     const app::Color& color) const; | 
| 55 |  | 
| 56 | private: | 
| 57 |   static bool isToolAffectedByRightClickMode(Tool* tool); | 
| 58 |  | 
| 59 |   ToolBox* m_toolbox; | 
| 60 |  | 
| 61 |   // Quick tool in the active sprite editor (activated by keyboard | 
| 62 |   // shortuts). | 
| 63 |   Tool* m_quickTool; | 
| 64 |  | 
| 65 |   // Special tool by stylus proximity. | 
| 66 |   bool m_rightClick; | 
| 67 |   Tool* m_rightClickTool; | 
| 68 |   Ink* m_rightClickInk; | 
| 69 |  | 
| 70 |   // Special tool by stylus proximity (e.g. eraser). | 
| 71 |   Tool* m_proximityTool; | 
| 72 |  | 
| 73 |   // Selected tool in the toolbar/toolbox. | 
| 74 |   Tool* m_selectedTool; | 
| 75 | }; | 
| 76 |  | 
| 77 | } // namespace tools | 
| 78 | } // namespace app | 
| 79 |  | 
| 80 | #endif | 
| 81 |  |