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

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

Issue 210903003: Implemented system tray UI for new account management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Created 6 years, 9 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 | Annotate | Revision Log
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/system/tray/fixed_sized_image_view.h" 7 #include "ash/system/tray/fixed_sized_image_view.h"
8 #include "ash/system/tray/tray_constants.h" 8 #include "ash/system/tray/tray_constants.h"
9 #include "ash/system/tray/view_click_listener.h" 9 #include "ash/system/tray/view_click_listener.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 58 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
59 text_label_->SetFontList(text_label_->font_list().DeriveWithStyle(style)); 59 text_label_->SetFontList(text_label_->font_list().DeriveWithStyle(style));
60 if (text_default_color_) 60 if (text_default_color_)
61 text_label_->SetEnabledColor(text_default_color_); 61 text_label_->SetEnabledColor(text_default_color_);
62 AddChildView(text_label_); 62 AddChildView(text_label_);
63 63
64 SetAccessibleName(text); 64 SetAccessibleName(text);
65 } 65 }
66 66
67 views::Label* HoverHighlightView::AddLabel(const base::string16& text, 67 views::Label* HoverHighlightView::AddLabel(const base::string16& text,
68 gfx::HorizontalAlignment alignment,
68 gfx::Font::FontStyle style) { 69 gfx::Font::FontStyle style) {
69 SetLayoutManager(new views::FillLayout()); 70 SetLayoutManager(new views::FillLayout());
70 text_label_ = new views::Label(text); 71 text_label_ = new views::Label(text);
71 int margin = kTrayPopupPaddingHorizontal + 72 int left_margin = kTrayPopupPaddingHorizontal;
72 kTrayPopupDetailsLabelExtraLeftMargin; 73 int right_margin = kTrayPopupPaddingHorizontal;
73 int left_margin = 0; 74 if (alignment != gfx::ALIGN_CENTER) {
74 int right_margin = 0; 75 if (base::i18n::IsRTL())
75 if (base::i18n::IsRTL()) 76 right_margin += kTrayPopupDetailsLabelExtraLeftMargin;
76 right_margin = margin; 77 else
77 else 78 left_margin += kTrayPopupDetailsLabelExtraLeftMargin;
78 left_margin = margin; 79 }
79 text_label_->SetBorder( 80 text_label_->SetBorder(
80 views::Border::CreateEmptyBorder(5, left_margin, 5, right_margin)); 81 views::Border::CreateEmptyBorder(5, left_margin, 5, right_margin));
81 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 82 text_label_->SetHorizontalAlignment(alignment);
82 text_label_->SetFontList(text_label_->font_list().DeriveWithStyle(style)); 83 text_label_->SetFontList(text_label_->font_list().DeriveWithStyle(style));
83 // Do not set alpha value in disable color. It will have issue with elide 84 // Do not set alpha value in disable color. It will have issue with elide
84 // blending filter in disabled state for rendering label text color. 85 // blending filter in disabled state for rendering label text color.
85 text_label_->SetDisabledColor(SkColorSetARGB(255, 127, 127, 127)); 86 text_label_->SetDisabledColor(SkColorSetARGB(255, 127, 127, 127));
86 if (text_default_color_) 87 if (text_default_color_)
87 text_label_->SetEnabledColor(text_default_color_); 88 text_label_->SetEnabledColor(text_default_color_);
88 AddChildView(text_label_); 89 AddChildView(text_label_);
89 90
90 SetAccessibleName(text); 91 SetAccessibleName(text);
91 return text_label_; 92 return text_label_;
(...skipping 21 matching lines...) Expand all
113 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 114 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
114 text_label_->SetFontList(text_label_->font_list().DeriveWithStyle(style)); 115 text_label_->SetFontList(text_label_->font_list().DeriveWithStyle(style));
115 text_label_->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0)); 116 text_label_->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0));
116 if (text_default_color_) 117 if (text_default_color_)
117 text_label_->SetEnabledColor(text_default_color_); 118 text_label_->SetEnabledColor(text_default_color_);
118 AddChildView(text_label_); 119 AddChildView(text_label_);
119 120
120 SetAccessibleName(text); 121 SetAccessibleName(text);
121 return text_label_; 122 return text_label_;
122 } 123 }
123 return AddLabel(text, style); 124 return AddLabel(text, gfx::ALIGN_LEFT, style);
124 } 125 }
125 126
126 void HoverHighlightView::SetExpandable(bool expandable) { 127 void HoverHighlightView::SetExpandable(bool expandable) {
127 if (expandable != expandable_) { 128 if (expandable != expandable_) {
128 expandable_ = expandable; 129 expandable_ = expandable;
129 InvalidateLayout(); 130 InvalidateLayout();
130 } 131 }
131 } 132 }
132 133
133 bool HoverHighlightView::PerformAction(const ui::Event& event) { 134 bool HoverHighlightView::PerformAction(const ui::Event& event) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 canvas->DrawColor(hover_ ? highlight_color_ : default_color_); 181 canvas->DrawColor(hover_ ? highlight_color_ : default_color_);
181 } 182 }
182 183
183 void HoverHighlightView::OnFocus() { 184 void HoverHighlightView::OnFocus() {
184 ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); 185 ScrollRectToVisible(gfx::Rect(gfx::Point(), size()));
185 ActionableView::OnFocus(); 186 ActionableView::OnFocus();
186 } 187 }
187 188
188 } // namespace internal 189 } // namespace internal
189 } // namespace ash 190 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698