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

Side by Side Diff: ash/system/tray/hover_highlight_view.cc

Issue 2831023003: Refactor AddScrollListItem() in system menu detailed views (Closed)
Patch Set: Cleanup Created 3 years, 8 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
OLDNEW
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
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) {
tdanderson 2017/04/24 15:43:39 As far as I can tell, right now there are no place
mohsen 2017/04/25 05:10:01 Done.
59 DCHECK(text_label_);
60
61 if (sub_text.empty()) {
62 if (!sub_text_label_)
63 return;
64 tri_view_->RemoveView(TriView::Container::CENTER, sub_text_label_);
65 delete sub_text_label_;
66 sub_text_label_ = nullptr;
67 } else {
68 if (!sub_text_label_) {
69 sub_text_label_ = TrayPopupUtils::CreateDefaultLabel();
70 tri_view_->AddView(TriView::Container::CENTER, sub_text_label_);
71 }
72 TrayPopupItemStyle sub_style(TrayPopupItemStyle::FontStyle::CAPTION);
73 sub_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE);
74 sub_style.SetupLabel(sub_text_label_);
75 sub_text_label_->SetText(sub_text);
76 }
77 }
78
58 void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image, 79 void HoverHighlightView::AddIconAndLabel(const gfx::ImageSkia& image,
59 const base::string16& text) { 80 const base::string16& text) {
60 DoAddIconAndLabel(image, text, 81 DoAddIconAndLabel(image, text,
61 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); 82 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
62 } 83 }
63 84
64 void HoverHighlightView::AddIconAndLabels(const gfx::ImageSkia& image, 85 void HoverHighlightView::AddIconAndLabels(const gfx::ImageSkia& image,
65 const base::string16& text, 86 const base::string16& text,
66 const base::string16& sub_text) { 87 const base::string16& sub_text) {
67 DoAddIconAndLabels(image, text, 88 DoAddIconAndLabels(image, text,
(...skipping 27 matching lines...) Expand all
95 left_icon_ = TrayPopupUtils::CreateMainImageView(); 116 left_icon_ = TrayPopupUtils::CreateMainImageView();
96 left_icon_->SetImage(image); 117 left_icon_->SetImage(image);
97 left_icon_->SetEnabled(enabled()); 118 left_icon_->SetEnabled(enabled());
98 tri_view_->AddView(TriView::Container::START, left_icon_); 119 tri_view_->AddView(TriView::Container::START, left_icon_);
99 120
100 text_label_ = TrayPopupUtils::CreateDefaultLabel(); 121 text_label_ = TrayPopupUtils::CreateDefaultLabel();
101 text_label_->SetText(text); 122 text_label_->SetText(text);
102 text_label_->SetEnabled(enabled()); 123 text_label_->SetEnabled(enabled());
103 TrayPopupItemStyle style(font_style); 124 TrayPopupItemStyle style(font_style);
104 style.SetupLabel(text_label_); 125 style.SetupLabel(text_label_);
126 tri_view_->AddView(TriView::Container::CENTER, text_label_);
105 127
106 tri_view_->AddView(TriView::Container::CENTER, text_label_); 128 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 129
116 tri_view_->SetContainerVisible(TriView::Container::END, false); 130 tri_view_->SetContainerVisible(TriView::Container::END, false);
117 131
118 SetAccessibleName(text); 132 SetAccessibleName(text);
119 } 133 }
120 134
121 void HoverHighlightView::AddLabelRow(const base::string16& text) { 135 void HoverHighlightView::AddLabelRow(const base::string16& text) {
122 SetLayoutManager(new views::FillLayout); 136 SetLayoutManager(new views::FillLayout);
123 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); 137 tri_view_ = TrayPopupUtils::CreateDefaultRowView();
124 AddChildView(tri_view_); 138 AddChildView(tri_view_);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (right_view_) 206 if (right_view_)
193 right_view_->SetEnabled(enabled()); 207 right_view_->SetEnabled(enabled());
194 } 208 }
195 209
196 void HoverHighlightView::OnFocus() { 210 void HoverHighlightView::OnFocus() {
197 ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); 211 ScrollRectToVisible(gfx::Rect(gfx::Point(), size()));
198 ActionableView::OnFocus(); 212 ActionableView::OnFocus();
199 } 213 }
200 214
201 } // namespace ash 215 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698