| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { | 58 void HoverHighlightView::SetSubText(const base::string16& sub_text) { |
| 59 DCHECK(text_label_); | 59 DCHECK(text_label_); |
| 60 DCHECK(!sub_text.empty()); |
| 60 | 61 |
| 61 if (!sub_text_label_) { | 62 if (!sub_text_label_) { |
| 62 sub_text_label_ = TrayPopupUtils::CreateDefaultLabel(); | 63 sub_text_label_ = TrayPopupUtils::CreateDefaultLabel(); |
| 63 tri_view_->AddView(TriView::Container::CENTER, sub_text_label_); | 64 tri_view_->AddView(TriView::Container::CENTER, sub_text_label_); |
| 64 } | 65 } |
| 66 |
| 65 TrayPopupItemStyle sub_style(TrayPopupItemStyle::FontStyle::CAPTION); | 67 TrayPopupItemStyle sub_style(TrayPopupItemStyle::FontStyle::CAPTION); |
| 66 sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); | 68 sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); |
| 67 sub_style.SetupLabel(sub_text_label_); | 69 sub_style.SetupLabel(sub_text_label_); |
| 68 sub_text_label_->SetText(sub_text); | 70 sub_text_label_->SetText(sub_text); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image, | 73 void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image, |
| 72 const base::string16& text) { | 74 const base::string16& text) { |
| 73 DoAddIconAndLabel(image, text, | 75 DoAddIconAndLabel(image, text, |
| 74 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); | 76 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 left_icon_->SetEnabled(enabled()); | 112 left_icon_->SetEnabled(enabled()); |
| 111 tri_view_->AddView(TriView::Container::START, left_icon_); | 113 tri_view_->AddView(TriView::Container::START, left_icon_); |
| 112 | 114 |
| 113 text_label_ = TrayPopupUtils::CreateDefaultLabel(); | 115 text_label_ = TrayPopupUtils::CreateDefaultLabel(); |
| 114 text_label_->SetText(text); | 116 text_label_->SetText(text); |
| 115 text_label_->SetEnabled(enabled()); | 117 text_label_->SetEnabled(enabled()); |
| 116 TrayPopupItemStyle style(font_style); | 118 TrayPopupItemStyle style(font_style); |
| 117 style.SetupLabel(text_label_); | 119 style.SetupLabel(text_label_); |
| 118 tri_view_->AddView(TriView::Container::CENTER, text_label_); | 120 tri_view_->AddView(TriView::Container::CENTER, text_label_); |
| 119 | 121 |
| 120 SetSubText(sub_text); | 122 if (!sub_text.empty()) |
| 123 SetSubText(sub_text); |
| 121 | 124 |
| 122 tri_view_->SetContainerVisible(TriView::Container::END, false); | 125 tri_view_->SetContainerVisible(TriView::Container::END, false); |
| 123 | 126 |
| 124 SetAccessibleName(text); | 127 SetAccessibleName(text); |
| 125 } | 128 } |
| 126 | 129 |
| 127 void HoverHighlightView::AddLabelRow(const base::string16& text) { | 130 void HoverHighlightView::AddLabelRow(const base::string16& text) { |
| 128 SetLayoutManager(new views::FillLayout); | 131 SetLayoutManager(new views::FillLayout); |
| 129 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); | 132 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); |
| 130 AddChildView(tri_view_); | 133 AddChildView(tri_view_); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 if (right_view_) | 201 if (right_view_) |
| 199 right_view_->SetEnabled(enabled()); | 202 right_view_->SetEnabled(enabled()); |
| 200 } | 203 } |
| 201 | 204 |
| 202 void HoverHighlightView::OnFocus() { | 205 void HoverHighlightView::OnFocus() { |
| 203 ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); | 206 ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); |
| 204 ActionableView::OnFocus(); | 207 ActionableView::OnFocus(); |
| 205 } | 208 } |
| 206 | 209 |
| 207 } // namespace ash | 210 } // namespace ash |
| OLD | NEW |