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

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

Issue 2140343002: Add palette tool/manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stylus-add-icons
Patch Set: 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_H_
6 #define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_H_
7
8 #include <map>
9 #include <memory>
10 #include <vector>
11
12 #include "ash/ash_export.h"
13 #include "base/callback.h"
14 #include "base/macros.h"
15
16 namespace views {
17 class View;
18 }
19
20 namespace ash {
21
22 class WmWindow;
23
24 enum class PaletteGroup;
25 enum class PaletteToolId;
26 class PaletteToolManager;
27
28 // A PaletteTool is a generalized action inside of the palette menu in the
29 // shelf. Only one tool per group is active at any given time. When the tool is
30 // active, it should be showing some specializied UI. The tool is no longer
31 // active if it completes its action, if the user selects another tool with the
32 // same group, or if the user just cancels the action from the palette.
33 class ASH_EXPORT PaletteTool {
34 public:
35 using ToolAction = base::Callback<void(PaletteToolId)>;
36
37 // Adds all available PaletteTool instances to the tool_manager.
38 static void RegisterToolInstances(PaletteToolManager* tool_manager);
39
40 PaletteTool();
41 virtual ~PaletteTool();
42
43 // Initialize the tool. It is assumed this is called from a PaletteToolManager
44 // instance.
45 void Initialize(WmWindow* window,
46 const ToolAction& enable_tool,
47 const ToolAction& disable_tool);
48
49 // The group this tool belongs to. Only one tool per group can be active at
50 // any given time.
51 virtual PaletteGroup group() const = 0;
oshima 2016/07/19 00:08:53 nit: GetGroup()
jdufault 2016/07/19 18:06:20 Done.
52
53 // The unique identifier for this tool. This should be the only tool that ever
54 // has this ID.
55 virtual PaletteToolId tool_id() const = 0;
oshima 2016/07/19 00:08:53 nit: GetToolId()
jdufault 2016/07/19 18:06:21 Done.
56
57 // Called when the user activates the tool. Only one tool per group can be
58 // active at any given time.
59 virtual void OnEnable();
60
61 // Disable the tool, either because this tool called DisableSelf(), the
62 // user cancelled the tool, or the user activated another tool within the
63 // same group.
64 virtual void OnDisable();
65
66 // Create a view that will be used in the palette. The view is owned by the
67 // caller. OnViewDestroyed is called when the view has been deallocated by its
68 // owner.
69 virtual views::View* CreateView() = 0;
70 virtual void OnViewDestroyed() = 0;
71
72 protected:
73 // Enables/disables the tool.
74 bool enabled() const { return enabled_; }
75
76 void EnableSelf();
77 void DisableSelf();
78
79 // Window this tool is associated with.
80 WmWindow* window() const { return window_; }
oshima 2016/07/19 00:08:53 a method that returns internal state as non const
jdufault 2016/07/19 18:06:20 Done.
81
82 private:
83 bool enabled_ = false;
84 ToolAction enable_tool_;
85 ToolAction disable_tool_;
86 WmWindow* window_;
87 };
oshima 2016/07/19 00:08:53 DISALLOW_COPY_AND_ASSIGN
jdufault 2016/07/19 18:06:20 Done.
88
89 } // namespace ash
90
91 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698