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

Side by Side Diff: ash/common/system/chromeos/palette/common_palette_tool.cc

Issue 2264383002: More closely align palette to spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tool-magnifier
Patch Set: Use 48x48 icon as source Created 4 years, 3 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/chromeos/palette/common_palette_tool.h" 5 #include "ash/common/system/chromeos/palette/common_palette_tool.h"
6 6
7 #include "ash/common/shelf/shelf_constants.h" 7 #include "ash/common/shelf/shelf_constants.h"
8 #include "ash/common/system/chromeos/palette/palette_ids.h" 8 #include "ash/common/system/chromeos/palette/palette_ids.h"
9 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" 9 #include "ash/common/system/chromeos/palette/palette_tool_manager.h"
10 #include "ash/common/system/tray/hover_highlight_view.h" 10 #include "ash/common/system/tray/hover_highlight_view.h"
11 #include "ash/common/system/tray/view_click_listener.h" 11 #include "ash/common/system/tray/view_click_listener.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "grit/ash_resources.h" 14 #include "grit/ash_resources.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/color_palette.h" 16 #include "ui/gfx/color_palette.h"
17 #include "ui/gfx/paint_vector_icon.h" 17 #include "ui/gfx/paint_vector_icon.h"
18 #include "ui/views/border.h"
18 19
19 namespace ash { 20 namespace ash {
21 namespace {
22
23 // Size of the icons in DP.
24 const int kIconSize = 20;
25
26 // Distance between the icon and the check from the egdes in DP.
27 const int kMarginFromEdges = 14;
28
29 // Extra distance between the icon and the left edge in DP.
30 const int kExtraMarginFromLeftEdge = 4;
31
32 // Distance between the icon and the name of the tool in DP.
33 const int kMarginBetweenIconAndText = 18;
34
35 } // namespace
20 36
21 CommonPaletteTool::CommonPaletteTool(Delegate* delegate) 37 CommonPaletteTool::CommonPaletteTool(Delegate* delegate)
22 : PaletteTool(delegate) {} 38 : PaletteTool(delegate) {}
23 39
24 CommonPaletteTool::~CommonPaletteTool() {} 40 CommonPaletteTool::~CommonPaletteTool() {}
25 41
26 views::View* CommonPaletteTool::CreateView() { 42 views::View* CommonPaletteTool::CreateView() {
27 // TODO(jdufault): Use real strings. 43 // TODO(jdufault): Use real strings.
28 return CreateDefaultView( 44 return CreateDefaultView(
29 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId()))); 45 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId())));
(...skipping 22 matching lines...) Expand all
52 } 68 }
53 69
54 void CommonPaletteTool::OnViewClicked(views::View* sender) { 70 void CommonPaletteTool::OnViewClicked(views::View* sender) {
55 if (enabled()) 71 if (enabled())
56 delegate()->DisableTool(GetToolId()); 72 delegate()->DisableTool(GetToolId());
57 else 73 else
58 delegate()->EnableTool(GetToolId()); 74 delegate()->EnableTool(GetToolId());
59 } 75 }
60 76
61 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { 77 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) {
78 gfx::ImageSkia icon =
79 CreateVectorIcon(GetPaletteIconId(), kIconSize, gfx::kChromeIconGrey);
80 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE,
81 kIconSize, gfx::kGoogleGreen700);
82
62 highlight_view_ = new HoverHighlightView(this); 83 highlight_view_ = new HoverHighlightView(this);
63 84 highlight_view_->SetBorder(
64 // TODO(jdufault): Use real colors (SK_ColorBLACK?) 85 views::Border::CreateEmptyBorder(0, kExtraMarginFromLeftEdge, 0, 0));
65 gfx::ImageSkia image = CreateVectorIcon(GetPaletteIconId(), SK_ColorBLACK); 86 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kIconSize,
66 gfx::ImageSkia checkbox = 87 kMarginFromEdges,
67 CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700); 88 kMarginBetweenIconAndText);
68 89 highlight_view_->AddRightIcon(check, kIconSize);
69 highlight_view_->AddIndentedIconAndLabel(image, name, false);
70 highlight_view_->AddRightIcon(checkbox);
71 90
72 if (enabled()) 91 if (enabled())
73 highlight_view_->SetHighlight(true); 92 highlight_view_->SetHighlight(true);
74 else 93 else
75 highlight_view_->SetRightIconVisible(false); 94 highlight_view_->SetRightIconVisible(false);
76 95
77 return highlight_view_; 96 return highlight_view_;
78 } 97 }
79 98
80 } // namespace ash 99 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698