Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: ash/common/system/chromeos/palette/palette_tool_manager.h

Issue 2140343002: Add palette tool/manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stylus-add-icons
Patch Set: Remove base::Optional, use VECTOR_ICON_NONE instead Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "ash/common/system/chromeos/palette/palette_tool.h"
15 #include "base/callback.h"
16 #include "base/macros.h"
17
18 namespace views {
19 class View;
20 }
21
22 namespace ash {
23
24 class PaletteTool;
25 enum class PaletteGroup;
26 enum class PaletteToolId;
27 class WmWindow;
28
29 struct ASH_EXPORT PaletteToolView {
30 PaletteGroup group;
31 PaletteToolId tool_id;
32 views::View* view;
33 };
34
35 class ASH_EXPORT PaletteToolManager : public PaletteTool::Delegate {
36 public:
37 class Delegate {
38 public:
39 Delegate() {}
40 virtual ~Delegate() {}
41
42 // Hide the palette (if shown).
43 virtual void HidePalette() = 0;
44
45 // Called when the active tool has changed.
46 virtual void OnActiveToolChanged() = 0;
47
48 // Return the window associated with this palette.
49 virtual WmWindow* GetWindow() = 0;
50
51 private:
52 DISALLOW_COPY_AND_ASSIGN(Delegate);
53 };
54
55 // Creates the tool manager.
56 PaletteToolManager(Delegate* delegate);
57 ~PaletteToolManager() override;
58
59 // Adds the given |tool| to the tool manager. The tool is assumed to be in a
60 // deactivated state. This class takes ownership over |tool|.
61 void AddTool(std::unique_ptr<PaletteTool> tool);
62
63 // Activates tool_id and deactivates any other active tool in the same
64 // group as tool_id.
65 void ActivateTool(PaletteToolId tool_id);
66
67 // Deactivates the given tool.
68 void DeactivateTool(PaletteToolId tool_id);
69
70 // Optional methods that are not likely to be needed, but will be
71 // implemented if necessary.
72 bool IsToolActive(PaletteToolId tool_id);
73 PaletteToolId GetActiveTool(PaletteGroup group);
74
75 // Fetch the active tray icon for the given tool. Returns
76 // gfx::VectorIconId::VECTOR_ICON_NONE if not available.
77 gfx::VectorIconId GetActiveTrayIcon(PaletteToolId tool_id);
78
79 // Create views for all of the registered tools.
80 std::vector<PaletteToolView> CreateViews();
81
82 // Called when the views returned by CreateViews have been destroyed. This
83 // should clear any (now) stale references.
84 void NotifyViewsDestroyed();
85
86 private:
87 // PaleteTool::Delegate overrides.
88 void EnableTool(PaletteToolId tool_id) override;
89 void DisableTool(PaletteToolId tool_id) override;
90 void HidePalette() override;
91 WmWindow* GetWindow() override;
92
93 PaletteTool* FindToolById(PaletteToolId tool_id);
94
95 // Unowned pointer to the delegate to provide external functionality.
96 Delegate* delegate_;
97
98 // Unowned pointer to the active tool / group.
99 std::map<PaletteGroup, PaletteTool*> active_tools_;
100
101 // Owned list of all tools.
102 std::vector<std::unique_ptr<PaletteTool>> tools_;
103
104 DISALLOW_COPY_AND_ASSIGN(PaletteToolManager);
105 };
106
107 } // namespace ash
108
109 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/palette/palette_tool.cc ('k') | ash/common/system/chromeos/palette/palette_tool_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698