| OLD | NEW |
| 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/tray_constants.h" |
| 12 #include "ash/common/system/tray/view_click_listener.h" | 12 #include "ash/common/system/tray/view_click_listener.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "grit/ash_resources.h" | 16 #include "grit/ash_resources.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/color_palette.h" | 18 #include "ui/gfx/color_palette.h" |
| 19 #include "ui/gfx/paint_vector_icon.h" | 19 #include "ui/gfx/paint_vector_icon.h" |
| 20 #include "ui/gfx/vector_icons_public.h" | 20 #include "ui/gfx/vector_icons_public.h" |
| 21 #include "ui/views/border.h" | 21 #include "ui/views/border.h" |
| 22 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Returns the font used by any displayed labels. | |
| 28 const gfx::FontList& GetLabelFont() { | |
| 29 // TODO(tdanderson|jdufault): Use TrayPopupItemStyle instead. | |
| 30 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( | |
| 31 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM); | |
| 32 } | |
| 33 | |
| 34 void AddHistogramTimes(PaletteToolId id, base::TimeDelta duration) { | 27 void AddHistogramTimes(PaletteToolId id, base::TimeDelta duration) { |
| 35 if (id == PaletteToolId::LASER_POINTER) { | 28 if (id == PaletteToolId::LASER_POINTER) { |
| 36 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InLaserPointerMode", duration, | 29 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InLaserPointerMode", duration, |
| 37 base::TimeDelta::FromMilliseconds(100), | 30 base::TimeDelta::FromMilliseconds(100), |
| 38 base::TimeDelta::FromHours(1), 50); | 31 base::TimeDelta::FromHours(1), 50); |
| 39 } else if (id == PaletteToolId::MAGNIFY) { | 32 } else if (id == PaletteToolId::MAGNIFY) { |
| 40 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InMagnifyMode", duration, | 33 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InMagnifyMode", duration, |
| 41 base::TimeDelta::FromMilliseconds(100), | 34 base::TimeDelta::FromMilliseconds(100), |
| 42 base::TimeDelta::FromHours(1), 50); | 35 base::TimeDelta::FromHours(1), 50); |
| 43 } | 36 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 90 |
| 98 highlight_view_ = new HoverHighlightView(this); | 91 highlight_view_ = new HoverHighlightView(this); |
| 99 highlight_view_->SetBorder( | 92 highlight_view_->SetBorder( |
| 100 views::CreateEmptyBorder(0, kMenuExtraMarginFromLeftEdge, 0, 0)); | 93 views::CreateEmptyBorder(0, kMenuExtraMarginFromLeftEdge, 0, 0)); |
| 101 const int interior_button_padding = (kMenuButtonSize - kMenuIconSize) / 2; | 94 const int interior_button_padding = (kMenuButtonSize - kMenuIconSize) / 2; |
| 102 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kMenuIconSize, | 95 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kMenuIconSize, |
| 103 interior_button_padding, | 96 interior_button_padding, |
| 104 kTrayPopupPaddingHorizontal); | 97 kTrayPopupPaddingHorizontal); |
| 105 highlight_view_->AddRightIcon(check, kMenuIconSize); | 98 highlight_view_->AddRightIcon(check, kMenuIconSize); |
| 106 highlight_view_->set_custom_height(kMenuButtonSize); | 99 highlight_view_->set_custom_height(kMenuButtonSize); |
| 107 highlight_view_->text_label()->SetFontList(GetLabelFont()); | |
| 108 | 100 |
| 109 if (enabled()) { | 101 if (enabled()) { |
| 110 highlight_view_->SetAccessiblityState( | 102 highlight_view_->SetAccessiblityState( |
| 111 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); | 103 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); |
| 112 } else { | 104 } else { |
| 113 highlight_view_->SetRightViewVisible(false); | 105 highlight_view_->SetRightViewVisible(false); |
| 114 highlight_view_->SetAccessiblityState( | 106 highlight_view_->SetAccessiblityState( |
| 115 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); | 107 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); |
| 116 } | 108 } |
| 117 | 109 |
| 118 return highlight_view_; | 110 return highlight_view_; |
| 119 } | 111 } |
| 120 | 112 |
| 121 } // namespace ash | 113 } // namespace ash |
| OLD | NEW |