| 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 #include "ash/common/system/chromeos/palette/common_palette_tool.h" |
| 6 |
| 7 #include "ash/common/shelf/shelf_constants.h" |
| 8 #include "ash/common/system/chromeos/palette/palette_ids.h" |
| 9 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
| 10 #include "ash/common/system/tray/hover_highlight_view.h" |
| 11 #include "ash/common/system/tray/view_click_listener.h" |
| 12 #include "base/logging.h" |
| 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "grit/ash_resources.h" |
| 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/color_palette.h" |
| 17 #include "ui/gfx/paint_vector_icon.h" |
| 18 |
| 19 namespace ash { |
| 20 |
| 21 CommonPaletteTool::CommonPaletteTool(Delegate* delegate) |
| 22 : PaletteTool(delegate) {} |
| 23 |
| 24 CommonPaletteTool::~CommonPaletteTool() {} |
| 25 |
| 26 views::View* CommonPaletteTool::CreateView() { |
| 27 // TODO(jdufault): Use real strings. |
| 28 return CreateDefaultView( |
| 29 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId()))); |
| 30 } |
| 31 |
| 32 void CommonPaletteTool::OnViewDestroyed() { |
| 33 highlight_view_ = nullptr; |
| 34 } |
| 35 |
| 36 void CommonPaletteTool::OnEnable() { |
| 37 PaletteTool::OnEnable(); |
| 38 |
| 39 if (highlight_view_) { |
| 40 highlight_view_->SetHighlight(true); |
| 41 highlight_view_->SetRightIconVisible(true); |
| 42 } |
| 43 } |
| 44 |
| 45 void CommonPaletteTool::OnDisable() { |
| 46 PaletteTool::OnDisable(); |
| 47 |
| 48 if (highlight_view_) { |
| 49 highlight_view_->SetHighlight(false); |
| 50 highlight_view_->SetRightIconVisible(false); |
| 51 } |
| 52 } |
| 53 |
| 54 void CommonPaletteTool::OnViewClicked(views::View* sender) { |
| 55 if (enabled()) |
| 56 delegate()->DisableTool(GetToolId()); |
| 57 else |
| 58 delegate()->EnableTool(GetToolId()); |
| 59 } |
| 60 |
| 61 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { |
| 62 highlight_view_ = new HoverHighlightView(this); |
| 63 |
| 64 // TODO(jdufault): Use real colors (SK_ColorBLACK?) |
| 65 gfx::ImageSkia image = CreateVectorIcon(GetPaletteIconId(), SK_ColorBLACK); |
| 66 gfx::ImageSkia checkbox = |
| 67 CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700); |
| 68 |
| 69 highlight_view_->AddIndentedIconAndLabel(image, name, false); |
| 70 highlight_view_->AddRightIcon(checkbox); |
| 71 |
| 72 if (enabled()) |
| 73 highlight_view_->SetHighlight(true); |
| 74 else |
| 75 highlight_view_->SetRightIconVisible(false); |
| 76 |
| 77 return highlight_view_; |
| 78 } |
| 79 |
| 80 } // namespace ash |
| OLD | NEW |