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

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

Issue 2724963002: Remove non-MD code from AudioDetailedView (Closed)
Patch Set: Rebased Created 3 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
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/common/system/tray/hover_highlight_view.h" 5 #include "ash/common/system/tray/hover_highlight_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/system/tray/fixed_sized_image_view.h" 8 #include "ash/common/system/tray/fixed_sized_image_view.h"
9 #include "ash/common/system/tray/tray_constants.h" 9 #include "ash/common/system/tray/tray_constants.h"
10 #include "ash/common/system/tray/tray_popup_utils.h" 10 #include "ash/common/system/tray/tray_popup_utils.h"
11 #include "ash/common/system/tray/tri_view.h" 11 #include "ash/common/system/tray/tri_view.h"
12 #include "ash/common/system/tray/view_click_listener.h" 12 #include "ash/common/system/tray/view_click_listener.h"
13 #include "ash/resources/vector_icons/vector_icons.h" 13 #include "ash/resources/vector_icons/vector_icons.h"
14 #include "ui/accessibility/ax_node_data.h" 14 #include "ui/accessibility/ax_node_data.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/font_list.h" 17 #include "ui/gfx/font_list.h"
18 #include "ui/gfx/paint_vector_icon.h" 18 #include "ui/gfx/paint_vector_icon.h"
19 #include "ui/resources/grit/ui_resources.h" 19 #include "ui/resources/grit/ui_resources.h"
20 #include "ui/views/border.h" 20 #include "ui/views/border.h"
21 #include "ui/views/controls/image_view.h" 21 #include "ui/views/controls/image_view.h"
22 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
23 #include "ui/views/layout/box_layout.h" 23 #include "ui/views/layout/box_layout.h"
24 #include "ui/views/layout/fill_layout.h" 24 #include "ui/views/layout/fill_layout.h"
25 #include "ui/views/resources/grit/views_resources.h" 25 #include "ui/views/resources/grit/views_resources.h"
26 26
27 namespace { 27 namespace {
28 28
29 const int kCheckLabelPadding = 4;
30
31 const gfx::FontList& GetFontList(bool highlight) { 29 const gfx::FontList& GetFontList(bool highlight) {
32 return ui::ResourceBundle::GetSharedInstance().GetFontList( 30 return ui::ResourceBundle::GetSharedInstance().GetFontList(
33 highlight ? ui::ResourceBundle::BoldFont : ui::ResourceBundle::BaseFont); 31 highlight ? ui::ResourceBundle::BoldFont : ui::ResourceBundle::BaseFont);
34 } 32 }
35 33
36 } // namespace 34 } // namespace
37 35
38 namespace ash { 36 namespace ash {
39 37
40 HoverHighlightView::HoverHighlightView(ViewClickListener* listener) 38 HoverHighlightView::HoverHighlightView(ViewClickListener* listener)
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (text_default_color_) 245 if (text_default_color_)
248 text_label_->SetEnabledColor(text_default_color_); 246 text_label_->SetEnabledColor(text_default_color_);
249 text_label_->SetEnabled(enabled()); 247 text_label_->SetEnabled(enabled());
250 AddChildView(text_label_); 248 AddChildView(text_label_);
251 box_layout_->SetFlexForView(text_label_, 1); 249 box_layout_->SetFlexForView(text_label_, 1);
252 250
253 SetAccessibleName(text); 251 SetAccessibleName(text);
254 return text_label_; 252 return text_label_;
255 } 253 }
256 254
257 views::Label* HoverHighlightView::AddCheckableLabel(const base::string16& text,
258 bool highlight,
259 bool checked) {
260 DCHECK(!MaterialDesignController::IsSystemTrayMenuMaterial());
261
262 if (checked) {
263 accessibility_state_ = AccessibilityState::CHECKED_CHECKBOX;
264 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
265 const gfx::ImageSkia* check =
266 rb.GetImageNamed(IDR_MENU_CHECK).ToImageSkia();
267 int margin = kTrayPopupPaddingHorizontal +
268 kTrayPopupDetailsLabelExtraLeftMargin - kCheckLabelPadding;
269 box_layout_ = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 3,
270 kCheckLabelPadding);
271 SetLayoutManager(box_layout_);
272 views::ImageView* image_view = new FixedSizedImageView(margin, 0);
273 image_view->SetImage(check);
274 image_view->SetHorizontalAlignment(views::ImageView::TRAILING);
275 image_view->SetEnabled(enabled());
276 AddChildView(image_view);
277
278 text_label_ = new views::Label(text);
279 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
280 text_label_->SetFontList(GetFontList(highlight));
281 text_label_->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0));
282 if (text_default_color_)
283 text_label_->SetEnabledColor(text_default_color_);
284 text_label_->SetEnabled(enabled());
285 AddChildView(text_label_);
286
287 SetAccessibleName(text);
288 return text_label_;
289 }
290
291 accessibility_state_ = AccessibilityState::UNCHECKED_CHECKBOX;
292 return AddLabel(text, gfx::ALIGN_LEFT, highlight);
293 }
294
295 void HoverHighlightView::AddLabelRowMd(const base::string16& text) { 255 void HoverHighlightView::AddLabelRowMd(const base::string16& text) {
296 DCHECK(MaterialDesignController::IsSystemTrayMenuMaterial()); 256 DCHECK(MaterialDesignController::IsSystemTrayMenuMaterial());
297 257
298 SetLayoutManager(new views::FillLayout); 258 SetLayoutManager(new views::FillLayout);
299 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); 259 tri_view_ = TrayPopupUtils::CreateDefaultRowView();
300 AddChildView(tri_view_); 260 AddChildView(tri_view_);
301 261
302 text_label_ = TrayPopupUtils::CreateDefaultLabel(); 262 text_label_ = TrayPopupUtils::CreateDefaultLabel();
303 text_label_->SetText(text); 263 text_label_->SetText(text);
304 264
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 void HoverHighlightView::OnPaintBackground(gfx::Canvas* canvas) { 387 void HoverHighlightView::OnPaintBackground(gfx::Canvas* canvas) {
428 canvas->DrawColor(hover_ ? highlight_color_ : default_color_); 388 canvas->DrawColor(hover_ ? highlight_color_ : default_color_);
429 } 389 }
430 390
431 void HoverHighlightView::OnFocus() { 391 void HoverHighlightView::OnFocus() {
432 ScrollRectToVisible(gfx::Rect(gfx::Point(), size())); 392 ScrollRectToVisible(gfx::Rect(gfx::Point(), size()));
433 ActionableView::OnFocus(); 393 ActionableView::OnFocus();
434 } 394 }
435 395
436 } // namespace ash 396 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/hover_highlight_view.h ('k') | ui/views/resources/default_100_percent/cros/menu_check.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698