OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_SYSTEM_PALETTE_PALETTE_TOOL_MANAGER_H_ | 5 #ifndef ASH_SYSTEM_PALETTE_PALETTE_TOOL_MANAGER_H_ |
6 #define ASH_SYSTEM_PALETTE_PALETTE_TOOL_MANAGER_H_ | 6 #define ASH_SYSTEM_PALETTE_PALETTE_TOOL_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
13 #include "ash/system/palette/palette_ids.h" | 13 #include "ash/system/palette/palette_ids.h" |
14 #include "ash/system/palette/palette_tool.h" | 14 #include "ash/system/palette/palette_tool.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 | 17 |
18 namespace aura { | |
19 class Window; | |
20 } | |
21 | |
18 namespace views { | 22 namespace views { |
19 class View; | 23 class View; |
20 } | 24 } |
21 | 25 |
22 namespace ash { | 26 namespace ash { |
23 | 27 |
24 class PaletteTool; | 28 class PaletteTool; |
25 enum class PaletteGroup; | 29 enum class PaletteGroup; |
26 enum class PaletteToolId; | 30 enum class PaletteToolId; |
27 class WmWindow; | |
28 | 31 |
29 struct ASH_EXPORT PaletteToolView { | 32 struct ASH_EXPORT PaletteToolView { |
30 PaletteGroup group; | 33 PaletteGroup group; |
31 PaletteToolId tool_id; | 34 PaletteToolId tool_id; |
32 views::View* view; | 35 views::View* view; |
33 }; | 36 }; |
34 | 37 |
35 class ASH_EXPORT PaletteToolManager : public PaletteTool::Delegate { | 38 class ASH_EXPORT PaletteToolManager : public PaletteTool::Delegate { |
36 public: | 39 public: |
37 class Delegate { | 40 class Delegate { |
msw
2017/05/22 18:37:11
aside: Sigh, this PaletteTool::Delegate subclass h
| |
38 public: | 41 public: |
39 Delegate() {} | |
40 virtual ~Delegate() {} | |
41 | |
42 // Hide the palette (if shown). | 42 // Hide the palette (if shown). |
43 virtual void HidePalette() = 0; | 43 virtual void HidePalette() = 0; |
44 | 44 |
45 // Hide the palette immediately, ie, do not display a hide animation. | 45 // Hide the palette immediately, ie, do not display a hide animation. |
46 virtual void HidePaletteImmediately() = 0; | 46 virtual void HidePaletteImmediately() = 0; |
47 | 47 |
48 // Called when the active tool has changed. | 48 // Called when the active tool has changed. |
49 virtual void OnActiveToolChanged() = 0; | 49 virtual void OnActiveToolChanged() = 0; |
50 | 50 |
51 // Return the window associated with this palette. | 51 // Return the window associated with this palette. |
52 virtual WmWindow* GetWindow() = 0; | 52 virtual aura::Window* GetWindow() = 0; |
53 | 53 |
54 // Record usage of each pen palette option. | 54 // Record usage of each pen palette option. |
55 virtual void RecordPaletteOptionsUsage(ash::PaletteTrayOptions option) = 0; | 55 virtual void RecordPaletteOptionsUsage(PaletteTrayOptions option) = 0; |
56 | 56 |
57 // Record mode cancellation of pen palette. | 57 // Record mode cancellation of pen palette. |
58 virtual void RecordPaletteModeCancellation(PaletteModeCancelType type) = 0; | 58 virtual void RecordPaletteModeCancellation(PaletteModeCancelType type) = 0; |
59 | 59 |
60 private: | 60 protected: |
61 DISALLOW_COPY_AND_ASSIGN(Delegate); | 61 virtual ~Delegate() {} |
62 }; | 62 }; |
63 | 63 |
64 // Creates the tool manager. | 64 // Creates the tool manager. |
65 PaletteToolManager(Delegate* delegate); | 65 PaletteToolManager(Delegate* delegate); |
66 ~PaletteToolManager() override; | 66 ~PaletteToolManager() override; |
67 | 67 |
68 // Adds the given |tool| to the tool manager. The tool is assumed to be in a | 68 // Adds the given |tool| to the tool manager. The tool is assumed to be in a |
69 // deactivated state. This class takes ownership over |tool|. | 69 // deactivated state. This class takes ownership over |tool|. |
70 void AddTool(std::unique_ptr<PaletteTool> tool); | 70 void AddTool(std::unique_ptr<PaletteTool> tool); |
71 | 71 |
(...skipping 23 matching lines...) Expand all Loading... | |
95 | 95 |
96 // Helper method to disable any active tool in the given |group|. | 96 // Helper method to disable any active tool in the given |group|. |
97 void DisableActiveTool(PaletteGroup group); | 97 void DisableActiveTool(PaletteGroup group); |
98 | 98 |
99 private: | 99 private: |
100 // PaleteTool::Delegate overrides. | 100 // PaleteTool::Delegate overrides. |
101 void EnableTool(PaletteToolId tool_id) override; | 101 void EnableTool(PaletteToolId tool_id) override; |
102 void DisableTool(PaletteToolId tool_id) override; | 102 void DisableTool(PaletteToolId tool_id) override; |
103 void HidePalette() override; | 103 void HidePalette() override; |
104 void HidePaletteImmediately() override; | 104 void HidePaletteImmediately() override; |
105 WmWindow* GetWindow() override; | 105 aura::Window* GetWindow() override; |
106 void RecordPaletteOptionsUsage(ash::PaletteTrayOptions option) override; | 106 void RecordPaletteOptionsUsage(ash::PaletteTrayOptions option) override; |
107 void RecordPaletteModeCancellation(PaletteModeCancelType type) override; | 107 void RecordPaletteModeCancellation(PaletteModeCancelType type) override; |
108 | 108 |
109 PaletteTool* FindToolById(PaletteToolId tool_id) const; | 109 PaletteTool* FindToolById(PaletteToolId tool_id) const; |
110 | 110 |
111 // Unowned pointer to the delegate to provide external functionality. | 111 // Unowned pointer to the delegate to provide external functionality. |
112 Delegate* delegate_; | 112 Delegate* delegate_; |
113 | 113 |
114 // Unowned pointer to the active tool / group. | 114 // Unowned pointer to the active tool / group. |
115 std::map<PaletteGroup, PaletteTool*> active_tools_; | 115 std::map<PaletteGroup, PaletteTool*> active_tools_; |
116 | 116 |
117 // Owned list of all tools. | 117 // Owned list of all tools. |
118 std::vector<std::unique_ptr<PaletteTool>> tools_; | 118 std::vector<std::unique_ptr<PaletteTool>> tools_; |
119 | 119 |
120 DISALLOW_COPY_AND_ASSIGN(PaletteToolManager); | 120 DISALLOW_COPY_AND_ASSIGN(PaletteToolManager); |
121 }; | 121 }; |
122 | 122 |
123 } // namespace ash | 123 } // namespace ash |
124 | 124 |
125 #endif // ASH_SYSTEM_PALETTE_PALETTE_TOOL_MANAGER_H_ | 125 #endif // ASH_SYSTEM_PALETTE_PALETTE_TOOL_MANAGER_H_ |
OLD | NEW |