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

Unified Diff: ash/common/system/chromeos/palette/palette_tool.cc

Issue 2147783002: Add common palette tray implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stylus-tool-structure
Patch Set: Some palette tool stubs 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/chromeos/palette/palette_tool.cc
diff --git a/ash/common/system/chromeos/palette/palette_tool.cc b/ash/common/system/chromeos/palette/palette_tool.cc
index 579ed7c60b39d12e998c357d6518a510d6671cf0..a3cd186af061470b47dba6e1db1d05c68a6e367c 100644
--- a/ash/common/system/chromeos/palette/palette_tool.cc
+++ b/ash/common/system/chromeos/palette/palette_tool.cc
@@ -17,8 +17,172 @@
namespace ash {
+namespace {
+
+// A PaletteTool implementation with a standard view support.
+class CommonPaletteTool : public PaletteTool, public ash::ViewClickListener {
+ protected:
+ views::View* CreateDefaultView(const std::string& message) {
+ highlight_view_ = new HoverHighlightView(this);
+
+ gfx::ImageSkia image = CreateVectorIcon(icon_id(), SK_ColorBLACK);
+ gfx::ImageSkia checkbox =
+ CreateVectorIcon(gfx::VectorIconId::CHECK, SK_ColorGREEN);
Evan Stade 2016/07/13 18:33:55 Are these the right colors? If not can you add a T
jdufault 2016/07/13 19:29:01 Added TODO.
+
+ const base::string16& name = base::ASCIIToUTF16(message);
Evan Stade 2016/07/13 18:33:55 this is not right, presumably message can contain
jdufault 2016/07/13 19:29:01 Right, these are stub tool implementations to prov
+
+ highlight_view_->AddIndentedIconAndLabel(image, name, false);
+ highlight_view_->AddRightIcon(checkbox);
+
+ if (enabled())
+ highlight_view_->SetHighlight(true);
+ else
+ highlight_view_->SetRightIconVisible(false);
+
+ return highlight_view_;
+ }
+
+ views::View* CreateView() override {
+ return CreateDefaultView("[TODO] " + PaletteToolIdToString(tool_id()));
+ }
+ void DestroyView() override { highlight_view_ = nullptr; }
+
+ void OnEnable() override {
+ PaletteTool::OnEnable();
+
+ if (highlight_view_) {
+ highlight_view_->SetHighlight(true);
+ highlight_view_->SetRightIconVisible(true);
+ }
+ }
+
+ void OnDisable() override {
+ PaletteTool::OnDisable();
+
+ if (highlight_view_) {
+ highlight_view_->SetHighlight(false);
+ highlight_view_->SetRightIconVisible(false);
+ }
+ }
+
+ // ViewClickListener overrides.
+ void OnViewClicked(views::View* sender) override {
+ if (enabled())
+ DisableSelf();
+ else
+ EnableSelf();
+ }
+
+ protected:
+ virtual gfx::VectorIconId icon_id() = 0;
+
+ private:
+ HoverHighlightView* highlight_view_ = nullptr;
+};
+
+class CreateNoteAction : public CommonPaletteTool {
+ public:
+ CreateNoteAction() {}
+ ~CreateNoteAction() override {}
+
+ private:
+ // PaletteTool overrides.
+ PaletteGroup group() const override { return PaletteGroup::ACTION; }
+ PaletteToolId tool_id() const override {
+ return PaletteToolId::CREATE_NEW_NOTE;
+ }
+
+ gfx::VectorIconId icon_id() override {
+ return gfx::VectorIconId::PALETTE_CAPTURE_SCREEN;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(CreateNoteAction);
+};
+
+class CaptureRegionAction : public CommonPaletteTool {
+ public:
+ CaptureRegionAction() {}
+ ~CaptureRegionAction() override {}
+
+ private:
+ // PaletteTool overrides.
+ PaletteGroup group() const override { return PaletteGroup::ACTION; }
+ PaletteToolId tool_id() const override {
+ return PaletteToolId::CAPTURE_REGION;
+ }
+
+ gfx::VectorIconId icon_id() override {
+ return gfx::VectorIconId::PALETTE_CAPTURE_REGION;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(CaptureRegionAction);
+};
+
+class ScreenshotAction : public CommonPaletteTool {
+ public:
+ ScreenshotAction() {}
+ ~ScreenshotAction() override {}
+
+ private:
+ // PaletteTool overrides.
+ PaletteGroup group() const override { return PaletteGroup::ACTION; }
+ PaletteToolId tool_id() const override { return PaletteToolId::SCREENSHOT; }
+ void OnEnable() override {
+ CommonPaletteTool::OnEnable();
+ DisableSelf();
+ }
+
+ gfx::VectorIconId icon_id() override {
+ return gfx::VectorIconId::PALETTE_CAPTURE_SCREEN;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenshotAction);
+};
+
+class PresentationMode : public CommonPaletteTool {
+ public:
+ PresentationMode() {}
+ ~PresentationMode() override {}
+
+ private:
+ // PaletteTool overrides.
+ PaletteGroup group() const override { return PaletteGroup::MODE; }
+ PaletteToolId tool_id() const override { return PaletteToolId::PRESENTATION; }
+
+ gfx::VectorIconId icon_id() override {
+ return gfx::VectorIconId::PALETTE_PRESENTATION_MODE;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(PresentationMode);
+};
+
+class MagnifierMode : public CommonPaletteTool {
+ public:
+ MagnifierMode() {}
+ ~MagnifierMode() override {}
+
+ private:
+ // PaletteTool overrides.
+ PaletteGroup group() const override { return PaletteGroup::MODE; }
+ PaletteToolId tool_id() const override { return PaletteToolId::MAGNIFY; }
+
+ gfx::VectorIconId icon_id() override {
+ return gfx::VectorIconId::PALETTE_MAGNIFY_MODE;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(MagnifierMode);
+};
+
+} // namespace
+
// static
-void PaletteTool::RegisterToolInstances(PaletteToolManager* tool_manager) {}
+void PaletteTool::RegisterToolInstances(PaletteToolManager* tool_manager) {
+ tool_manager->AddTool(base::WrapUnique(new CreateNoteAction()));
+ tool_manager->AddTool(base::WrapUnique(new CaptureRegionAction()));
+ tool_manager->AddTool(base::WrapUnique(new ScreenshotAction()));
+ tool_manager->AddTool(base::WrapUnique(new PresentationMode()));
+ tool_manager->AddTool(base::WrapUnique(new MagnifierMode()));
+}
PaletteTool::PaletteTool() {}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698