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

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

Issue 2343603003: [Chrome OS MD] Implement accessibility detailed view for the MD Ash system menu (Closed)
Patch Set: ' 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
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/common/system/tray_accessibility.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tray_constants.h"
11 #include "ash/common/system/tray/view_click_listener.h" 12 #include "ash/common/system/tray/view_click_listener.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "grit/ash_resources.h" 16 #include "grit/ash_resources.h"
16 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/color_palette.h" 18 #include "ui/gfx/color_palette.h"
18 #include "ui/gfx/paint_vector_icon.h" 19 #include "ui/gfx/paint_vector_icon.h"
19 #include "ui/gfx/vector_icons_public.h" 20 #include "ui/gfx/vector_icons_public.h"
20 #include "ui/views/border.h" 21 #include "ui/views/border.h"
21 22
22 namespace ash { 23 namespace ash {
23 namespace { 24 namespace {
24 25
25 // Size of the icons in DP.
26 const int kIconSize = 20;
27
28 // Distance between the icon and the check from the egdes in DP.
29 const int kMarginFromEdges = 14;
30
31 // Extra distance between the icon and the left edge in DP.
32 const int kExtraMarginFromLeftEdge = 4;
33
34 // Distance between the icon and the name of the tool in DP.
35 const int kMarginBetweenIconAndText = 18;
36
37 void AddHistogramTimes(PaletteToolId id, base::TimeDelta duration) { 26 void AddHistogramTimes(PaletteToolId id, base::TimeDelta duration) {
38 if (id == PaletteToolId::LASER_POINTER) { 27 if (id == PaletteToolId::LASER_POINTER) {
39 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InLaserPointerMode", duration, 28 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InLaserPointerMode", duration,
40 base::TimeDelta::FromMilliseconds(100), 29 base::TimeDelta::FromMilliseconds(100),
41 base::TimeDelta::FromHours(1), 50); 30 base::TimeDelta::FromHours(1), 50);
42 } else if (id == PaletteToolId::MAGNIFY) { 31 } else if (id == PaletteToolId::MAGNIFY) {
43 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InMagnifyMode", duration, 32 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InMagnifyMode", duration,
44 base::TimeDelta::FromMilliseconds(100), 33 base::TimeDelta::FromMilliseconds(100),
45 base::TimeDelta::FromHours(1), 50); 34 base::TimeDelta::FromHours(1), 50);
46 } 35 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 delegate()->RecordPaletteModeCancellation( 80 delegate()->RecordPaletteModeCancellation(
92 PaletteToolIdToPaletteModeCancelType(GetToolId(), 81 PaletteToolIdToPaletteModeCancelType(GetToolId(),
93 false /*is_switched*/)); 82 false /*is_switched*/));
94 } else { 83 } else {
95 delegate()->EnableTool(GetToolId()); 84 delegate()->EnableTool(GetToolId());
96 } 85 }
97 } 86 }
98 87
99 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { 88 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) {
100 gfx::ImageSkia icon = 89 gfx::ImageSkia icon =
101 CreateVectorIcon(GetPaletteIcon(), kIconSize, gfx::kChromeIconGrey); 90 CreateVectorIcon(GetPaletteIcon(), kMenuIconSize, gfx::kChromeIconGrey);
102 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, 91 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE,
103 kIconSize, gfx::kGoogleGreen700); 92 kMenuIconSize, gfx::kGoogleGreen700);
104 93
105 highlight_view_ = new HoverHighlightView(this); 94 highlight_view_ = new HoverHighlightView(this);
106 highlight_view_->SetBorder( 95 highlight_view_->SetBorder(
107 views::Border::CreateEmptyBorder(0, kExtraMarginFromLeftEdge, 0, 0)); 96 views::Border::CreateEmptyBorder(0, kMenuSeparatorVerticalPadding, 0, 0));
108 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kIconSize, 97 const int interior_button_padding = (kMenuButtonSize - kMenuIconSize) / 2;
109 kMarginFromEdges, 98 highlight_view_->AddIconAndLabelCustomSize(
110 kMarginBetweenIconAndText); 99 icon, name, false, kMenuIconSize, interior_button_padding,
111 highlight_view_->AddRightIcon(check, kIconSize); 100 interior_button_padding + kMenuSeparatorVerticalPadding);
101 highlight_view_->AddRightIcon(check, kMenuIconSize);
112 102
113 if (enabled()) 103 if (enabled())
114 highlight_view_->SetHighlight(true); 104 highlight_view_->SetHighlight(true);
115 else 105 else
116 highlight_view_->SetRightIconVisible(false); 106 highlight_view_->SetRightIconVisible(false);
117 107
118 return highlight_view_; 108 return highlight_view_;
119 } 109 }
120 110
121 } // namespace ash 111 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/common/system/tray_accessibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698