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

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 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
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_);
tdanderson 2016/11/25 00:45:41 Do you also need to call tri_view->SetContainerVis
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 if (!use_md) {
77 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); 83 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(); 84 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
95 icon_->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK) 85 icon_->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE_DARK)
96 .ToImageSkia()); 86 .ToImageSkia());
97 } 87 }
98 AddChildView(icon_);
99 88
100 label_ = new views::Label; 89 label_ = TrayPopupUtils::CreateDefaultLabel();
101 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
102 label_->SetMultiLine(true); 90 label_->SetMultiLine(true);
103 label_->SetText(label_text_); 91 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 92
111 stop_button_ = TrayPopupUtils::CreateTrayPopupButton(this, stop_button_text_); 93 stop_button_ = TrayPopupUtils::CreateTrayPopupButton(this, stop_button_text_);
112 AddChildView(stop_button_);
113 } 94 }
114 95
115 void ScreenStatusView::UpdateFromScreenTrayItem() { 96 void ScreenStatusView::UpdateFromScreenTrayItem() {
116 // Hide the notification bubble when the ash tray bubble opens. 97 // Hide the notification bubble when the ash tray bubble opens.
117 screen_tray_item_->HideNotificationView(); 98 screen_tray_item_->HideNotificationView();
118 SetVisible(screen_tray_item_->is_started()); 99 SetVisible(screen_tray_item_->is_started());
119 } 100 }
120 101
121 void ScreenStatusView::OnNativeThemeChanged(const ui::NativeTheme* theme) { 102 void ScreenStatusView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
122 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { 103 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
123 views::View::OnNativeThemeChanged(theme); 104 views::View::OnNativeThemeChanged(theme);
124 return; 105 return;
125 } 106 }
107
126 if (theme) { 108 if (theme) {
127 TrayPopupItemStyle style(theme, 109 TrayPopupItemStyle style(theme,
128 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 110 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
111 icon_->SetImage(gfx::CreateVectorIcon(kSystemMenuScreenShareIcon,
tdanderson 2016/11/25 00:45:41 As discussed remove this line, and after line 81 i
112 style.GetIconColor()));
129 style.SetupLabel(label_); 113 style.SetupLabel(label_);
130 } 114 }
131 } 115 }
132 116
133 ScreenNotificationDelegate::ScreenNotificationDelegate( 117 ScreenNotificationDelegate::ScreenNotificationDelegate(
134 ScreenTrayItem* screen_tray) 118 ScreenTrayItem* screen_tray)
135 : screen_tray_(screen_tray) {} 119 : screen_tray_(screen_tray) {}
136 120
137 ScreenNotificationDelegate::~ScreenNotificationDelegate() {} 121 ScreenNotificationDelegate::~ScreenNotificationDelegate() {}
138 122
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 189
206 void ScreenTrayItem::DestroyTrayView() { 190 void ScreenTrayItem::DestroyTrayView() {
207 tray_view_ = nullptr; 191 tray_view_ = nullptr;
208 } 192 }
209 193
210 void ScreenTrayItem::DestroyDefaultView() { 194 void ScreenTrayItem::DestroyDefaultView() {
211 default_view_ = nullptr; 195 default_view_ = nullptr;
212 } 196 }
213 197
214 } // namespace ash 198 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698