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

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: Address comments 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 "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);
oshima 2016/07/14 13:58:32 newline before comment. same for the rest.
jdufault 2016/07/18 20:39:58 Done.
49 // Deactivates the given tool.
50 void DeactivateTool(PaletteToolId tool_id);
51
52 // Optional methods that are not likely to be needed, but will be
53 // implemented if necessary.
54 bool IsToolActive(PaletteToolId tool_id);
55 PaletteToolId GetActiveTool(PaletteGroup group);
56
57 // Create views for all of the registered tools.
58 std::vector<PaletteToolView> CreateViews();
59 // Called when the views returned by CreateViews have been destroyed. This
60 // should clear any (now) stale references.
61 void ViewsDestroyed();
oshima 2016/07/14 13:58:32 NotifyViewsDestroyed ( or NotifyOnViewsDestroyed).
jdufault 2016/07/18 20:39:58 Done.
62
63 private:
64 PaletteTool* FindToolById(PaletteToolId tool_id);
65
66 base::Closure on_tool_changed_;
67 // Unowned pointer to the active tool / group.
68 std::map<PaletteGroup, PaletteTool*> active_tools_;
69 // Owned list of all tools.
70 std::vector<std::unique_ptr<PaletteTool>> tools_;
71 // Window the tool manager is associated with.
72 WmWindow* window_;
73
74 DISALLOW_COPY_AND_ASSIGN(PaletteToolManager);
75 };
76
77 } // namespace ash
78
79 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698