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

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: 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_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 static void RegisterToolInstances(PaletteToolManager* tool_manager);
38
39 PaletteTool();
40 virtual ~PaletteTool();
41
42 // Initialize the tool. It is assumed this is called from a PaletteToolManager
43 // instance.
44 void Initialize(WmWindow* window,
45 const ToolAction& enable_tool,
46 const ToolAction& disable_tool);
47
48 // The group this tool belongs to. Only one tool per group can be active at
49 // any given time.
50 virtual PaletteGroup group() const = 0;
oshima 2016/07/14 13:58:32 new line in between
jdufault 2016/07/18 20:39:58 Done.
51 // The unique identifier for this tool. This should be the only tool that ever
52 // has this ID.
53 virtual PaletteToolId tool_id() const = 0;
54
55 // Called when the user activates the tool. Only one tool per group can be
56 // active at any given time.
57 virtual void OnEnable();
oshima 2016/07/14 13:58:32 new line in between
jdufault 2016/07/18 20:39:58 Done.
58 // Disable the tool, either because this tool called DisableSelf(), the
59 // user cancelled the tool, or the user activated another tool within the
60 // same group.
61 virtual void OnDisable();
62
63 // Create a view that will be used in the palette. The view is owned by the
64 // caller. ViewDestroyed is called when the view has been deallocated by its
65 // owner.
66 virtual views::View* CreateView() = 0;
67 virtual void ViewDestroyed() = 0;
oshima 2016/07/14 13:58:32 OnViewDestroyed() should be more consistent with t
jdufault 2016/07/18 20:39:57 Done.
68
69 protected:
70 // Enables/disables the tool.
71 bool enabled() const;
72 void EnableSelf();
73 void DisableSelf();
74
75 // Window this tool is associated with.
76 WmWindow* window() const;
77
78 private:
79 bool enabled_ = false;
80 ToolAction enable_tool_;
81 ToolAction disable_tool_;
82 WmWindow* window_;
83 };
84
85 } // namespace ash
86
87 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698