Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 class ASH_EXPORT PaletteTool { | |
|
Evan Stade
2016/07/13 18:34:01
class needs docs
jdufault
2016/07/13 19:22:39
Done.
| |
| 29 public: | |
| 30 using ToolAction = base::Callback<void(PaletteToolId)>; | |
| 31 | |
| 32 static void RegisterToolInstances(PaletteToolManager* tool_manager); | |
| 33 | |
| 34 PaletteTool(); | |
| 35 virtual ~PaletteTool(); | |
| 36 | |
| 37 // Initialize the tool. It is assumed this is called from a PaletteToolManager | |
| 38 // instance. | |
| 39 void Initialize(WmWindow* window, | |
| 40 const ToolAction& enable_tool, | |
| 41 const ToolAction& disable_tool); | |
| 42 | |
| 43 virtual PaletteGroup group() const = 0; | |
| 44 virtual PaletteToolId tool_id() const = 0; | |
| 45 | |
| 46 // Called when the user activates the tool. Only one tool per group can be | |
| 47 // active at any given time. | |
| 48 virtual void OnEnable(); | |
| 49 // Disable the tool, either because this tool called DisableSelf(), the | |
| 50 // user cancelled the tool, or the user activated another tool within the | |
| 51 // same group. | |
| 52 virtual void OnDisable(); | |
| 53 | |
| 54 // Create a view that will be used in the palette. The view is owned by the | |
| 55 // caller. DestroyView is called when the view has been deallocated by its | |
| 56 // owner. | |
| 57 virtual views::View* CreateView() = 0; | |
| 58 virtual void DestroyView() = 0; | |
|
Evan Stade
2016/07/13 18:34:01
more like ViewDestroyed
jdufault
2016/07/13 19:22:39
Done - the idea was to mirror SystemTrayItem, but
| |
| 59 | |
| 60 protected: | |
| 61 // Enables/disables the tool. | |
| 62 bool enabled() const; | |
| 63 void EnableSelf(); | |
| 64 void DisableSelf(); | |
| 65 | |
| 66 // Window this tool is associated with. | |
| 67 WmWindow* window() const; | |
| 68 | |
| 69 private: | |
| 70 bool enabled_ = false; | |
| 71 ToolAction enable_tool_; | |
| 72 ToolAction disable_tool_; | |
| 73 WmWindow* window_; | |
| 74 }; | |
| 75 | |
| 76 } // namespace ash | |
| 77 | |
| 78 #endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_H_ | |
| OLD | NEW |