| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_ |
| 6 #define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 #include <vector> |
| 11 |
| 12 #include "ash/ash_export.h" |
| 13 #include "ash/common/system/chromeos/palette/palette_ids.h" |
| 14 #include "base/callback.h" |
| 15 #include "base/macros.h" |
| 16 |
| 17 namespace views { |
| 18 class View; |
| 19 } |
| 20 |
| 21 namespace ash { |
| 22 |
| 23 class PaletteTool; |
| 24 enum class PaletteGroup; |
| 25 enum class PaletteToolId; |
| 26 class WmWindow; |
| 27 |
| 28 struct ASH_EXPORT PaletteToolView { |
| 29 PaletteGroup group; |
| 30 PaletteToolId tool_id; |
| 31 views::View* view; |
| 32 }; |
| 33 |
| 34 class ASH_EXPORT PaletteToolManager { |
| 35 public: |
| 36 // Creates the tool manager. |window| allows tool implementations to fetch |
| 37 // relevant global data. |on_tool_changed| is called whenever the active tool |
| 38 // state is changed. |
| 39 PaletteToolManager(WmWindow* window, const base::Closure& on_tool_changed); |
| 40 ~PaletteToolManager(); |
| 41 |
| 42 // Adds the given |tool| to the tool manager. The tool is assumed to be in a |
| 43 // deactivated state. This class takes ownership over |tool|. |
| 44 void AddTool(std::unique_ptr<PaletteTool> tool); |
| 45 |
| 46 // Activates tool_id and deactivates any other active tool in the same |
| 47 // group as tool_id. |
| 48 void ActivateTool(PaletteToolId tool_id); |
| 49 |
| 50 // Deactivates the given tool. |
| 51 void DeactivateTool(PaletteToolId tool_id); |
| 52 |
| 53 // Optional methods that are not likely to be needed, but will be |
| 54 // implemented if necessary. |
| 55 bool IsToolActive(PaletteToolId tool_id); |
| 56 PaletteToolId GetActiveTool(PaletteGroup group); |
| 57 |
| 58 // Create views for all of the registered tools. |
| 59 std::vector<PaletteToolView> CreateViews(); |
| 60 |
| 61 // Called when the views returned by CreateViews have been destroyed. This |
| 62 // should clear any (now) stale references. |
| 63 void NotifyViewsDestroyed(); |
| 64 |
| 65 private: |
| 66 PaletteTool* FindToolById(PaletteToolId tool_id); |
| 67 |
| 68 base::Closure on_tool_changed_; |
| 69 |
| 70 // Unowned pointer to the active tool / group. |
| 71 std::map<PaletteGroup, PaletteTool*> active_tools_; |
| 72 |
| 73 // Owned list of all tools. |
| 74 std::vector<std::unique_ptr<PaletteTool>> tools_; |
| 75 |
| 76 // Window the tool manager is associated with. |
| 77 WmWindow* window_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(PaletteToolManager); |
| 80 }; |
| 81 |
| 82 } // namespace ash |
| 83 |
| 84 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_ |
| OLD | NEW |