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

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: Nit 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.
76 base::Optional<gfx::VectorIconId> GetActiveTrayIcon(PaletteToolId tool_id);
77
78 // Create views for all of the registered tools.
79 std::vector<PaletteToolView> CreateViews();
80
81 // Called when the views returned by CreateViews have been destroyed. This
82 // should clear any (now) stale references.
83 void NotifyViewsDestroyed();
84
85 private:
86 // PaleteTool::Delegate overrides.
87 void EnableTool(PaletteToolId tool_id) override;
88 void DisableTool(PaletteToolId tool_id) override;
89 void HidePalette() override;
90 WmWindow* GetWindow() override;
91
92 PaletteTool* FindToolById(PaletteToolId tool_id);
93
94 // Unowned pointer to the delegate to provide external functionality.
95 Delegate* delegate_;
96
97 // Unowned pointer to the active tool / group.
98 std::map<PaletteGroup, PaletteTool*> active_tools_;
99
100 // Owned list of all tools.
101 std::vector<std::unique_ptr<PaletteTool>> tools_;
102
103 DISALLOW_COPY_AND_ASSIGN(PaletteToolManager);
104 };
105
106 } // namespace ash
107
108 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698