Chromium Code Reviews| 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/tray/tray_popup_item_style.h> | |
| 5 #include "ash/common/system/chromeos/palette/common_palette_tool.h" | 6 #include "ash/common/system/chromeos/palette/common_palette_tool.h" |
| 6 | 7 |
| 7 #include "ash/common/shelf/shelf_constants.h" | 8 #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_ids.h" |
| 9 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" | 10 #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/hover_highlight_view.h" |
| 11 #include "ash/common/system/tray/tray_constants.h" | 12 #include "ash/common/system/tray/tray_constants.h" |
| 12 #include "ash/common/system/tray/view_click_listener.h" | 13 #include "ash/common/system/tray/view_click_listener.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "grit/ash_resources.h" | 17 #include "grit/ash_resources.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/color_palette.h" | 19 #include "ui/gfx/color_palette.h" |
| 19 #include "ui/gfx/paint_vector_icon.h" | 20 #include "ui/gfx/paint_vector_icon.h" |
| 20 #include "ui/gfx/vector_icons_public.h" | 21 #include "ui/gfx/vector_icons_public.h" |
| 21 #include "ui/views/border.h" | 22 #include "ui/views/border.h" |
| 22 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 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) { | 28 void AddHistogramTimes(PaletteToolId id, base::TimeDelta duration) { |
| 35 if (id == PaletteToolId::LASER_POINTER) { | 29 if (id == PaletteToolId::LASER_POINTER) { |
| 36 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InLaserPointerMode", duration, | 30 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InLaserPointerMode", duration, |
| 37 base::TimeDelta::FromMilliseconds(100), | 31 base::TimeDelta::FromMilliseconds(100), |
| 38 base::TimeDelta::FromHours(1), 50); | 32 base::TimeDelta::FromHours(1), 50); |
| 39 } else if (id == PaletteToolId::MAGNIFY) { | 33 } else if (id == PaletteToolId::MAGNIFY) { |
| 40 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InMagnifyMode", duration, | 34 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InMagnifyMode", duration, |
| 41 base::TimeDelta::FromMilliseconds(100), | 35 base::TimeDelta::FromMilliseconds(100), |
| 42 base::TimeDelta::FromHours(1), 50); | 36 base::TimeDelta::FromHours(1), 50); |
| 43 } | 37 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 91 |
| 98 highlight_view_ = new HoverHighlightView(this); | 92 highlight_view_ = new HoverHighlightView(this); |
| 99 highlight_view_->SetBorder( | 93 highlight_view_->SetBorder( |
| 100 views::CreateEmptyBorder(0, kMenuExtraMarginFromLeftEdge, 0, 0)); | 94 views::CreateEmptyBorder(0, kMenuExtraMarginFromLeftEdge, 0, 0)); |
| 101 const int interior_button_padding = (kMenuButtonSize - kMenuIconSize) / 2; | 95 const int interior_button_padding = (kMenuButtonSize - kMenuIconSize) / 2; |
| 102 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kMenuIconSize, | 96 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kMenuIconSize, |
| 103 interior_button_padding, | 97 interior_button_padding, |
| 104 kTrayPopupPaddingHorizontal); | 98 kTrayPopupPaddingHorizontal); |
| 105 highlight_view_->AddRightIcon(check, kMenuIconSize); | 99 highlight_view_->AddRightIcon(check, kMenuIconSize); |
| 106 highlight_view_->set_custom_height(kMenuButtonSize); | 100 highlight_view_->set_custom_height(kMenuButtonSize); |
| 107 highlight_view_->text_label()->SetFontList(GetLabelFont()); | 101 TrayPopupItemStyle style(highlight_view_->GetNativeTheme(), |
| 102 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); | |
| 103 style.SetupLabel(highlight_view_->text_label()); | |
|
tdanderson
2016/11/16 20:44:16
Please move lines 101-103 into a helper called Upd
tdanderson
2016/11/16 20:51:03
Also, would be worth double-checking that after th
jdufault
2016/11/28 17:59:15
Removed this code, I think HoverHighlightView will
| |
| 108 | 104 |
| 109 if (enabled()) { | 105 if (enabled()) { |
| 110 highlight_view_->SetAccessiblityState( | 106 highlight_view_->SetAccessiblityState( |
| 111 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); | 107 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); |
| 112 } else { | 108 } else { |
| 113 highlight_view_->SetRightIconVisible(false); | 109 highlight_view_->SetRightIconVisible(false); |
| 114 highlight_view_->SetAccessiblityState( | 110 highlight_view_->SetAccessiblityState( |
| 115 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); | 111 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); |
| 116 } | 112 } |
| 117 | 113 |
| 118 return highlight_view_; | 114 return highlight_view_; |
| 119 } | 115 } |
| 120 | 116 |
| 121 } // namespace ash | 117 } // namespace ash |
| OLD | NEW |