OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/tray_details_view.h" | 5 #include "ash/system/tray/tray_details_view.h" |
6 | 6 |
7 #include "ash/ash_view_ids.h" | 7 #include "ash/ash_view_ids.h" |
8 #include "ash/shell.h" | |
8 #include "ash/strings/grit/ash_strings.h" | 9 #include "ash/strings/grit/ash_strings.h" |
9 #include "ash/system/tray/hover_highlight_view.h" | 10 #include "ash/system/tray/hover_highlight_view.h" |
10 #include "ash/system/tray/system_menu_button.h" | 11 #include "ash/system/tray/system_menu_button.h" |
11 #include "ash/system/tray/system_tray.h" | 12 #include "ash/system/tray/system_tray.h" |
13 #include "ash/system/tray/system_tray_controller.h" | |
12 #include "ash/system/tray/system_tray_item.h" | 14 #include "ash/system/tray/system_tray_item.h" |
13 #include "ash/system/tray/tray_constants.h" | 15 #include "ash/system/tray/tray_constants.h" |
14 #include "ash/system/tray/tray_popup_item_style.h" | 16 #include "ash/system/tray/tray_popup_item_style.h" |
15 #include "ash/system/tray/tray_popup_utils.h" | 17 #include "ash/system/tray/tray_popup_utils.h" |
16 #include "ash/system/tray/tri_view.h" | 18 #include "ash/system/tray/tri_view.h" |
17 #include "base/containers/adapters.h" | 19 #include "base/containers/adapters.h" |
18 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
19 #include "third_party/skia/include/core/SkDrawLooper.h" | 21 #include "third_party/skia/include/core/SkDrawLooper.h" |
20 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 const int kTitleRowPaddingTop = kTitleRowVerticalPadding; | 236 const int kTitleRowPaddingTop = kTitleRowVerticalPadding; |
235 const int kTitleRowPaddingBottom = | 237 const int kTitleRowPaddingBottom = |
236 kTitleRowVerticalPadding - kTitleRowProgressBarHeight; | 238 kTitleRowVerticalPadding - kTitleRowProgressBarHeight; |
237 | 239 |
238 } // namespace | 240 } // namespace |
239 | 241 |
240 //////////////////////////////////////////////////////////////////////////////// | 242 //////////////////////////////////////////////////////////////////////////////// |
241 // TrayDetailsView::InfoLabel: | 243 // TrayDetailsView::InfoLabel: |
242 | 244 |
243 TrayDetailsView::InfoLabel::InfoLabel(int message_id) | 245 TrayDetailsView::InfoLabel::InfoLabel(int message_id) |
244 : label_(TrayPopupUtils::CreateDefaultLabel()) { | 246 : ActionableView(nullptr, TrayPopupInkDropStyle::FILL_BOUNDS), |
Kyle Horimoto
2017/06/27 19:36:57
/* owner */
| |
247 label_(TrayPopupUtils::CreateDefaultLabel()) { | |
245 SetLayoutManager(new views::FillLayout); | 248 SetLayoutManager(new views::FillLayout); |
246 | 249 |
247 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SYSTEM_INFO); | |
248 style.SetupLabel(label_); | |
249 | |
250 TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView(); | 250 TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView(); |
251 tri_view->SetInsets(gfx::Insets(0, | 251 tri_view->SetInsets(gfx::Insets(0, |
252 kMenuExtraMarginFromLeftEdge + | 252 kMenuExtraMarginFromLeftEdge + |
253 kTrayPopupPaddingHorizontal - | 253 kTrayPopupPaddingHorizontal - |
254 kTrayPopupLabelHorizontalPadding, | 254 kTrayPopupLabelHorizontalPadding, |
255 0, kTrayPopupPaddingHorizontal)); | 255 0, kTrayPopupPaddingHorizontal)); |
256 tri_view->SetContainerVisible(TriView::Container::START, false); | 256 tri_view->SetContainerVisible(TriView::Container::START, false); |
257 tri_view->SetContainerVisible(TriView::Container::END, false); | 257 tri_view->SetContainerVisible(TriView::Container::END, false); |
258 tri_view->AddView(TriView::Container::CENTER, label_); | 258 tri_view->AddView(TriView::Container::CENTER, label_); |
259 AddChildView(tri_view); | 259 AddChildView(tri_view); |
260 | 260 |
261 Update(message_id); | |
262 } | |
263 | |
264 void TrayDetailsView::InfoLabel::Update(int message_id) { | |
265 SetAction(message_id); | |
266 SetStyle(); | |
261 SetMessage(message_id); | 267 SetMessage(message_id); |
262 } | 268 } |
263 | 269 |
264 TrayDetailsView::InfoLabel::~InfoLabel() {} | 270 void TrayDetailsView::InfoLabel::SetAction(int message_id) { |
271 if (message_id == IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH) | |
tdanderson
2017/06/27 19:33:21
TrayDetailsView::InfoLabel is a class used (or can
| |
272 action_ = Action::OPEN_BLUETOOTH_SETTINGS; | |
273 else | |
274 action_ = Action::NONE; | |
275 | |
276 if (action_ == Action::NONE) | |
Kyle Horimoto
2017/06/27 19:36:57
Just put these SetInkDropMode() calls in the if/el
| |
277 SetInkDropMode(InkDropHostView::InkDropMode::OFF); | |
278 else | |
279 SetInkDropMode(InkDropHostView::InkDropMode::ON); | |
280 } | |
281 | |
282 void TrayDetailsView::InfoLabel::SetStyle() { | |
283 TrayPopupItemStyle::FontStyle font_style; | |
284 | |
285 if (action_ == Action::NONE) | |
Kyle Horimoto
2017/06/27 19:36:56
You can also just merge this into the above functi
| |
286 font_style = TrayPopupItemStyle::FontStyle::SYSTEM_INFO; | |
287 else | |
288 font_style = TrayPopupItemStyle::FontStyle::CLICKABLE_SYSTEM_INFO; | |
289 | |
290 TrayPopupItemStyle style(font_style); | |
291 style.SetupLabel(label_); | |
292 } | |
265 | 293 |
266 void TrayDetailsView::InfoLabel::SetMessage(int message_id) { | 294 void TrayDetailsView::InfoLabel::SetMessage(int message_id) { |
267 label_->SetText(l10n_util::GetStringUTF16(message_id)); | 295 label_->SetText(l10n_util::GetStringUTF16(message_id)); |
268 } | 296 } |
269 | 297 |
298 bool TrayDetailsView::InfoLabel::PerformAction(const ui::Event& event) { | |
299 switch (action_) { | |
300 case Action::OPEN_BLUETOOTH_SETTINGS: | |
tdanderson
2017/06/27 19:33:21
Side note: please check with your PM as to whether
Kyle Horimoto
2017/06/27 19:36:57
You can just use an if() instead of a switch() sin
Kyle Horimoto
2017/06/27 20:37:10
Good point. Leslie, please talk to hansberry@ rega
lesliewatkins
2017/07/07 16:19:19
Sent him a message, will follow up when I get a re
| |
301 Shell::Get()->system_tray_controller()->ShowBluetoothSettings(); | |
302 break; | |
303 case Action::NONE: | |
304 default: | |
305 break; | |
306 } | |
307 return true; | |
308 } | |
309 | |
270 //////////////////////////////////////////////////////////////////////////////// | 310 //////////////////////////////////////////////////////////////////////////////// |
271 // TrayDetailsView: | 311 // TrayDetailsView: |
272 | 312 |
273 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) | 313 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) |
274 : owner_(owner), | 314 : owner_(owner), |
275 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical)), | 315 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical)), |
276 scroller_(nullptr), | 316 scroller_(nullptr), |
277 scroll_content_(nullptr), | 317 scroll_content_(nullptr), |
278 progress_bar_(nullptr), | 318 progress_bar_(nullptr), |
279 tri_view_(nullptr), | 319 tri_view_(nullptr), |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
501 if (bounds().IsEmpty()) | 541 if (bounds().IsEmpty()) |
502 return views::View::GetHeightForWidth(width); | 542 return views::View::GetHeightForWidth(width); |
503 | 543 |
504 // The height of the bubble that contains this detailed view is set to | 544 // The height of the bubble that contains this detailed view is set to |
505 // the preferred height of the default view, and that determines the | 545 // the preferred height of the default view, and that determines the |
506 // initial height of |this|. Always request to stay the same height. | 546 // initial height of |this|. Always request to stay the same height. |
507 return height(); | 547 return height(); |
508 } | 548 } |
509 | 549 |
510 } // namespace ash | 550 } // namespace ash |
OLD | NEW |