| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/system/tray/hover_highlight_view.h" | 5 #include "ash/system/tray/hover_highlight_view.h" |
| 6 | 6 |
| 7 #include "ash/resources/vector_icons/vector_icons.h" | 7 #include "ash/resources/vector_icons/vector_icons.h" |
| 8 #include "ash/system/tray/tray_constants.h" | 8 #include "ash/system/tray/tray_constants.h" |
| 9 #include "ash/system/tray/tray_popup_utils.h" | 9 #include "ash/system/tray/tray_popup_utils.h" |
| 10 #include "ash/system/tray/tri_view.h" | 10 #include "ash/system/tray/tri_view.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 void HoverHighlightView::SetRightViewVisible(bool visible) { | 50 void HoverHighlightView::SetRightViewVisible(bool visible) { |
| 51 if (!right_view_) | 51 if (!right_view_) |
| 52 return; | 52 return; |
| 53 | 53 |
| 54 right_view_->SetVisible(visible); | 54 right_view_->SetVisible(visible); |
| 55 Layout(); | 55 Layout(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void HoverHighlightView::SetSubText(const base::string16& sub_text) { |
| 59 DCHECK(text_label_); |
| 60 |
| 61 if (!sub_text_label_) { |
| 62 sub_text_label_ = TrayPopupUtils::CreateDefaultLabel(); |
| 63 tri_view_->AddView(TriView::Container::CENTER, sub_text_label_); |
| 64 } |
| 65 TrayPopupItemStyle sub_style(TrayPopupItemStyle::FontStyle::CAPTION); |
| 66 sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); |
| 67 sub_style.SetupLabel(sub_text_label_); |
| 68 sub_text_label_->SetText(sub_text); |
| 69 } |
| 70 |
| 58 void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image, | 71 void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image, |
| 59 const base::string16& text) { | 72 const base::string16& text) { |
| 60 DoAddIconAndLabel(image, text, | 73 DoAddIconAndLabel(image, text, |
| 61 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); | 74 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); |
| 62 } | 75 } |
| 63 | 76 |
| 64 void HoverHighlightView::AddIconAndLabels(const gfx::ImageSkia& image, | 77 void HoverHighlightView::AddIconAndLabels(const gfx::ImageSkia& image, |
| 65 const base::string16& text, | 78 const base::string16& text, |
| 66 const base::string16& sub_text) { | 79 const base::string16& sub_text) { |
| 67 DoAddIconAndLabels(image, text, | 80 DoAddIconAndLabels(image, text, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 95 left_icon_ = TrayPopupUtils::CreateMainImageView(); | 108 left_icon_ = TrayPopupUtils::CreateMainImageView(); |
| 96 left_icon_->SetImage(image); | 109 left_icon_->SetImage(image); |
| 97 left_icon_->SetEnabled(enabled()); | 110 left_icon_->SetEnabled(enabled()); |
| 98 tri_view_->AddView(TriView::Container::START, left_icon_); | 111 tri_view_->AddView(TriView::Container::START, left_icon_); |
| 99 | 112 |
| 100 text_label_ = TrayPopupUtils::CreateDefaultLabel(); | 113 text_label_ = TrayPopupUtils::CreateDefaultLabel(); |
| 101 text_label_->SetText(text); | 114 text_label_->SetText(text); |
| 102 text_label_->SetEnabled(enabled()); | 115 text_label_->SetEnabled(enabled()); |
| 103 TrayPopupItemStyle style(font_style); | 116 TrayPopupItemStyle style(font_style); |
| 104 style.SetupLabel(text_label_); | 117 style.SetupLabel(text_label_); |
| 118 tri_view_->AddView(TriView::Container::CENTER, text_label_); |
| 105 | 119 |
| 106 tri_view_->AddView(TriView::Container::CENTER, text_label_); | 120 SetSubText(sub_text); |
| 107 if (!sub_text.empty()) { | |
| 108 sub_text_label_ = TrayPopupUtils::CreateDefaultLabel(); | |
| 109 sub_text_label_->SetText(sub_text); | |
| 110 TrayPopupItemStyle sub_style(TrayPopupItemStyle::FontStyle::CAPTION); | |
| 111 sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); | |
| 112 sub_style.SetupLabel(sub_text_label_); | |
| 113 tri_view_->AddView(TriView::Container::CENTER, sub_text_label_); | |
| 114 } | |
| 115 | 121 |
| 116 tri_view_->SetContainerVisible(TriView::Container::END, false); | 122 tri_view_->SetContainerVisible(TriView::Container::END, false); |
| 117 | 123 |
| 118 SetAccessibleName(text); | 124 SetAccessibleName(text); |
| 119 } | 125 } |
| 120 | 126 |
| 121 void HoverHighlightView::AddLabelRow(const base::string16& text) { | 127 void HoverHighlightView::AddLabelRow(const base::string16& text) { |
| 122 SetLayoutManager(new views::FillLayout); | 128 SetLayoutManager(new views::FillLayout); |
| 123 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); | 129 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); |
| 124 AddChildView(tri_view_); | 130 AddChildView(tri_view_); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if (right_view_) | 198 if (right_view_) |
| 193 right_view_->SetEnabled(enabled()); | 199 right_view_->SetEnabled(enabled()); |
| 194 } | 200 } |
| 195 | 201 |
| 196 void HoverHighlightView::OnFocus() { | 202 void HoverHighlightView::OnFocus() { |
| 197 ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); | 203 ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); |
| 198 ActionableView::OnFocus(); | 204 ActionableView::OnFocus(); |
| 199 } | 205 } |
| 200 | 206 |
| 201 } // namespace ash | 207 } // namespace ash |
| OLD | NEW |