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

Side by Side Diff: ash/common/system/chromeos/screen_security/screen_tray_item.cc

Issue 2512883002: [Chrome OS MD] Update Cast and VPN to follow MD layout (Closed)
Patch Set: address comments, thanks @tdanderson Created 4 years 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
« no previous file with comments | « ash/common/system/chromeos/network/vpn_list_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/screen_security/screen_tray_item.h" 5 #include "ash/common/system/chromeos/screen_security/screen_tray_item.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/shelf/wm_shelf_util.h" 8 #include "ash/common/shelf/wm_shelf_util.h"
9 #include "ash/common/system/tray/fixed_sized_image_view.h" 9 #include "ash/common/system/tray/fixed_sized_image_view.h"
10 #include "ash/common/system/tray/tray_constants.h" 10 #include "ash/common/system/tray/tray_constants.h"
11 #include "ash/common/system/tray/tray_popup_item_style.h" 11 #include "ash/common/system/tray/tray_popup_item_style.h"
12 #include "ash/common/system/tray/tray_popup_utils.h" 12 #include "ash/common/system/tray/tray_popup_utils.h"
13 #include "ash/resources/vector_icons/vector_icons.h" 13 #include "ash/resources/vector_icons/vector_icons.h"
14 #include "grit/ash_resources.h" 14 #include "grit/ash_resources.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/paint_vector_icon.h" 16 #include "ui/gfx/paint_vector_icon.h"
17 #include "ui/message_center/message_center.h" 17 #include "ui/message_center/message_center.h"
18 #include "ui/views/controls/button/label_button.h" 18 #include "ui/views/controls/button/label_button.h"
19 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
20 #include "ui/views/layout/box_layout.h" 20 #include "ui/views/layout/fill_layout.h"
21
22 namespace {
23 const int kStopButtonRightPadding = 18;
24 } // namespace
25 21
26 namespace ash { 22 namespace ash {
27 namespace tray { 23 namespace tray {
28 24
29 // ScreenTrayView implementations. 25 // ScreenTrayView implementations.
30 ScreenTrayView::ScreenTrayView(ScreenTrayItem* screen_tray_item) 26 ScreenTrayView::ScreenTrayView(ScreenTrayItem* screen_tray_item)
31 : TrayItemView(screen_tray_item), screen_tray_item_(screen_tray_item) { 27 : TrayItemView(screen_tray_item), screen_tray_item_(screen_tray_item) {
32 CreateImageView(); 28 CreateImageView();
33 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { 29 if (MaterialDesignController::UseMaterialDesignSystemIcons()) {
34 image_view()->SetImage( 30 image_view()->SetImage(
(...skipping 16 matching lines...) Expand all
51 ScreenStatusView::ScreenStatusView(ScreenTrayItem* screen_tray_item, 47 ScreenStatusView::ScreenStatusView(ScreenTrayItem* screen_tray_item,
52 const base::string16& label_text, 48 const base::string16& label_text,
53 const base::string16& stop_button_text) 49 const base::string16& stop_button_text)
54 : screen_tray_item_(screen_tray_item), 50 : screen_tray_item_(screen_tray_item),
55 icon_(nullptr), 51 icon_(nullptr),
56 label_(nullptr), 52 label_(nullptr),
57 stop_button_(nullptr), 53 stop_button_(nullptr),
58 label_text_(label_text), 54 label_text_(label_text),
59 stop_button_text_(stop_button_text) { 55 stop_button_text_(stop_button_text) {
60 CreateItems(); 56 CreateItems();
57 TriView* tri_view(TrayPopupUtils::CreateDefaultRowView());
58 SetLayoutManager(new views::FillLayout);
59 AddChildView(tri_view);
60 tri_view->AddView(TriView::Container::START, icon_);
61 tri_view->AddView(TriView::Container::CENTER, label_);
62 tri_view->AddView(TriView::Container::END, stop_button_);
63 tri_view->SetContainerBorder(
64 TriView::Container::END,
65 views::CreateEmptyBorder(0, 0, 0, kTrayPopupButtonEndMargin));
61 if (screen_tray_item_) 66 if (screen_tray_item_)
62 UpdateFromScreenTrayItem(); 67 UpdateFromScreenTrayItem();
63 } 68 }
64 69
65 ScreenStatusView::~ScreenStatusView() {} 70 ScreenStatusView::~ScreenStatusView() {}
66 71
67 void ScreenStatusView::ButtonPressed(views::Button* sender, 72 void ScreenStatusView::ButtonPressed(views::Button* sender,
68 const ui::Event& event) { 73 const ui::Event& event) {
69 DCHECK(sender == stop_button_); 74 DCHECK(sender == stop_button_);
70 screen_tray_item_->Stop(); 75 screen_tray_item_->Stop();
71 screen_tray_item_->RecordStoppedFromDefaultViewMetric(); 76 screen_tray_item_->RecordStoppedFromDefaultViewMetric();
72 } 77 }
73 78
74 void ScreenStatusView::CreateItems() { 79 void ScreenStatusView::CreateItems() {
75 const bool use_md = MaterialDesignController::IsSystemTrayMenuMaterial(); 80 const bool use_md = MaterialDesignController::IsSystemTrayMenuMaterial();
76 if (!use_md) 81 icon_ = TrayPopupUtils::CreateMainImageView();
82 icon_->SetImage(gfx::CreateVectorIcon(
83 kSystemMenuScreenShareIcon, TrayPopupItemStyle::GetIconColor(
84 TrayPopupItemStyle::ColorStyle::ACTIVE)));
85 if (!use_md) {
77 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); 86 set_background(views::Background::CreateSolidBackground(kBackgroundColor));
78
79 auto layout =
80 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
81 use_md ? kTrayPopupPaddingBetweenItems : 0);
82 layout->set_cross_axis_alignment(
83 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
84 SetLayoutManager(layout);
85 SetBorder(views::CreateEmptyBorder(
86 0, kTrayPopupPaddingHorizontal, 0,
87 use_md ? kTrayPopupButtonEndMargin : kStopButtonRightPadding));
88
89 icon_ = TrayPopupUtils::CreateMainImageView();
90 if (use_md) {
91 icon_->SetImage(
92 gfx::CreateVectorIcon(kSystemMenuScreenShareIcon, kMenuIconColor));
93 } else {
94 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 87 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
95 icon_->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK) 88 icon_->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK)
96 .ToImageSkia()); 89 .ToImageSkia());
97 } 90 }
98 AddChildView(icon_);
99 91
100 label_ = new views::Label; 92 label_ = TrayPopupUtils::CreateDefaultLabel();
101 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
102 label_->SetMultiLine(true); 93 label_->SetMultiLine(true);
103 label_->SetText(label_text_); 94 label_->SetText(label_text_);
104 if (!use_md) {
105 label_->SetBorder(
106 views::CreateEmptyBorder(0, kTrayPopupPaddingBetweenItems, 0, 0));
107 }
108 AddChildView(label_);
109 layout->SetFlexForView(label_, 1);
110 95
111 stop_button_ = TrayPopupUtils::CreateTrayPopupButton(this, stop_button_text_); 96 stop_button_ = TrayPopupUtils::CreateTrayPopupButton(this, stop_button_text_);
112 AddChildView(stop_button_);
113 } 97 }
114 98
115 void ScreenStatusView::UpdateFromScreenTrayItem() { 99 void ScreenStatusView::UpdateFromScreenTrayItem() {
116 // Hide the notification bubble when the ash tray bubble opens. 100 // Hide the notification bubble when the ash tray bubble opens.
117 screen_tray_item_->HideNotificationView(); 101 screen_tray_item_->HideNotificationView();
118 SetVisible(screen_tray_item_->is_started()); 102 SetVisible(screen_tray_item_->is_started());
119 } 103 }
120 104
121 void ScreenStatusView::OnNativeThemeChanged(const ui::NativeTheme* theme) { 105 void ScreenStatusView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
122 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { 106 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
123 views::View::OnNativeThemeChanged(theme); 107 views::View::OnNativeThemeChanged(theme);
124 return; 108 return;
125 } 109 }
110
126 if (theme) { 111 if (theme) {
127 TrayPopupItemStyle style(theme, 112 TrayPopupItemStyle style(theme,
128 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 113 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
129 style.SetupLabel(label_); 114 style.SetupLabel(label_);
130 } 115 }
131 } 116 }
132 117
133 ScreenNotificationDelegate::ScreenNotificationDelegate( 118 ScreenNotificationDelegate::ScreenNotificationDelegate(
134 ScreenTrayItem* screen_tray) 119 ScreenTrayItem* screen_tray)
135 : screen_tray_(screen_tray) {} 120 : screen_tray_(screen_tray) {}
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 190
206 void ScreenTrayItem::DestroyTrayView() { 191 void ScreenTrayItem::DestroyTrayView() {
207 tray_view_ = nullptr; 192 tray_view_ = nullptr;
208 } 193 }
209 194
210 void ScreenTrayItem::DestroyDefaultView() { 195 void ScreenTrayItem::DestroyDefaultView() {
211 default_view_ = nullptr; 196 default_view_ = nullptr;
212 } 197 }
213 198
214 } // namespace ash 199 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/vpn_list_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698