Chromium Code Reviews| Index: ash/common/system/chromeos/palette/palette_tool_manager.h |
| diff --git a/ash/common/system/chromeos/palette/palette_tool_manager.h b/ash/common/system/chromeos/palette/palette_tool_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f2c897bd0d211e2c838cdbfd7d76f731759c624c |
| --- /dev/null |
| +++ b/ash/common/system/chromeos/palette/palette_tool_manager.h |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_ |
| +#define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_ |
| + |
| +#include <map> |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "ash/ash_export.h" |
| +#include "ash/common/system/chromeos/palette/palette_ids.h" |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| + |
| +namespace views { |
| +class View; |
| +} |
| + |
| +namespace ash { |
| + |
| +class PaletteTool; |
| +enum class PaletteGroup; |
| +enum class PaletteToolId; |
| +class WmWindow; |
| + |
| +struct ASH_EXPORT PaletteToolView { |
| + PaletteGroup group; |
| + PaletteToolId tool_id; |
| + views::View* view; |
| +}; |
| + |
| +class ASH_EXPORT PaletteToolManager { |
| + public: |
| + // Creates the tool manager. |window| allows tool implementations to fetch |
| + // relevant global data. |on_tool_changed| is called whenever the active tool |
| + // state is changed. |
| + PaletteToolManager(WmWindow* window, const base::Closure& on_tool_changed); |
| + ~PaletteToolManager(); |
| + |
| + // Adds the given |tool| to the tool manager. The tool is assumed to be in a |
| + // deactivated state. This class takes ownership over |tool|. |
| + void AddTool(std::unique_ptr<PaletteTool> tool); |
| + |
| + // Activates tool_id and deactivates any other active tool in the same |
| + // group as tool_id. |
| + 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.
|
| + // Deactivates the given tool. |
| + void DeactivateTool(PaletteToolId tool_id); |
| + |
| + // Optional methods that are not likely to be needed, but will be |
| + // implemented if necessary. |
| + bool IsToolActive(PaletteToolId tool_id); |
| + PaletteToolId GetActiveTool(PaletteGroup group); |
| + |
| + // Create views for all of the registered tools. |
| + std::vector<PaletteToolView> CreateViews(); |
| + // Called when the views returned by CreateViews have been destroyed. This |
| + // should clear any (now) stale references. |
| + void ViewsDestroyed(); |
|
oshima
2016/07/14 13:58:32
NotifyViewsDestroyed ( or NotifyOnViewsDestroyed).
jdufault
2016/07/18 20:39:58
Done.
|
| + |
| + private: |
| + PaletteTool* FindToolById(PaletteToolId tool_id); |
| + |
| + base::Closure on_tool_changed_; |
| + // Unowned pointer to the active tool / group. |
| + std::map<PaletteGroup, PaletteTool*> active_tools_; |
| + // Owned list of all tools. |
| + std::vector<std::unique_ptr<PaletteTool>> tools_; |
| + // Window the tool manager is associated with. |
| + WmWindow* window_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PaletteToolManager); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_PALETTE_TOOL_MANAGER_H_ |