| 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/common/system/tray/tray_details_view.h" | 5 #include "ash/common/system/tray/tray_details_view.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_view_ids.h" | 7 #include "ash/common/ash_view_ids.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
| 10 #include "ash/common/system/tray/system_menu_button.h" | 10 #include "ash/common/system/tray/system_menu_button.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) | 289 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) |
| 290 : owner_(owner), | 290 : owner_(owner), |
| 291 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)), | 291 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)), |
| 292 title_row_(nullptr), | 292 title_row_(nullptr), |
| 293 scroller_(nullptr), | 293 scroller_(nullptr), |
| 294 scroll_content_(nullptr), | 294 scroll_content_(nullptr), |
| 295 progress_bar_(nullptr), | 295 progress_bar_(nullptr), |
| 296 scroll_border_(nullptr), | 296 scroll_border_(nullptr), |
| 297 tri_view_(nullptr), | 297 tri_view_(nullptr), |
| 298 label_(nullptr), | |
| 299 back_button_(nullptr) { | 298 back_button_(nullptr) { |
| 300 SetLayoutManager(box_layout_); | 299 SetLayoutManager(box_layout_); |
| 301 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 300 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| 302 } | 301 } |
| 303 | 302 |
| 304 TrayDetailsView::~TrayDetailsView() {} | 303 TrayDetailsView::~TrayDetailsView() {} |
| 305 | 304 |
| 306 void TrayDetailsView::OnViewClicked(views::View* sender) { | 305 void TrayDetailsView::OnViewClicked(views::View* sender) { |
| 307 if (!UseMd() && title_row_ && sender == title_row_->content()) { | 306 if (!UseMd() && title_row_ && sender == title_row_->content()) { |
| 308 TransitionToDefaultView(); | 307 TransitionToDefaultView(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 326 DCHECK(!tri_view_); | 325 DCHECK(!tri_view_); |
| 327 DCHECK(!title_row_); | 326 DCHECK(!title_row_); |
| 328 | 327 |
| 329 if (UseMd()) { | 328 if (UseMd()) { |
| 330 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); | 329 tri_view_ = TrayPopupUtils::CreateDefaultRowView(); |
| 331 | 330 |
| 332 back_button_ = CreateBackButton(); | 331 back_button_ = CreateBackButton(); |
| 333 tri_view_->AddView(TriView::Container::START, back_button_); | 332 tri_view_->AddView(TriView::Container::START, back_button_); |
| 334 | 333 |
| 335 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 334 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 336 label_ = TrayPopupUtils::CreateDefaultLabel(); | 335 auto label = TrayPopupUtils::CreateDefaultLabel(); |
| 337 label_->SetText(rb.GetLocalizedString(string_id)); | 336 label->SetText(rb.GetLocalizedString(string_id)); |
| 338 UpdateStyle(); | 337 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE); |
| 339 tri_view_->AddView(TriView::Container::CENTER, label_); | 338 style.SetupLabel(label); |
| 339 tri_view_->AddView(TriView::Container::CENTER, label); |
| 340 | 340 |
| 341 tri_view_->SetContainerVisible(TriView::Container::END, false); | 341 tri_view_->SetContainerVisible(TriView::Container::END, false); |
| 342 | 342 |
| 343 tri_view_->SetBorder(views::CreateEmptyBorder(kTitleRowPaddingTop, 0, | 343 tri_view_->SetBorder(views::CreateEmptyBorder(kTitleRowPaddingTop, 0, |
| 344 kTitleRowPaddingBottom, 0)); | 344 kTitleRowPaddingBottom, 0)); |
| 345 AddChildViewAt(tri_view_, 0); | 345 AddChildViewAt(tri_view_, 0); |
| 346 views::Separator* separator = | 346 views::Separator* separator = |
| 347 new views::Separator(views::Separator::HORIZONTAL); | 347 new views::Separator(views::Separator::HORIZONTAL); |
| 348 separator->SetColor(kHorizontalSeparatorColor); | 348 separator->SetColor(kHorizontalSeparatorColor); |
| 349 separator->SetPreferredSize(kSeparatorWidth); | 349 separator->SetPreferredSize(kSeparatorWidth); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 scroll_content_->AddChildView(new ScrollSeparator); | 392 scroll_content_->AddChildView(new ScrollSeparator); |
| 393 } | 393 } |
| 394 | 394 |
| 395 void TrayDetailsView::Reset() { | 395 void TrayDetailsView::Reset() { |
| 396 RemoveAllChildViews(true); | 396 RemoveAllChildViews(true); |
| 397 title_row_ = nullptr; | 397 title_row_ = nullptr; |
| 398 scroller_ = nullptr; | 398 scroller_ = nullptr; |
| 399 scroll_content_ = nullptr; | 399 scroll_content_ = nullptr; |
| 400 progress_bar_ = nullptr; | 400 progress_bar_ = nullptr; |
| 401 back_button_ = nullptr; | 401 back_button_ = nullptr; |
| 402 label_ = nullptr; | |
| 403 tri_view_ = nullptr; | 402 tri_view_ = nullptr; |
| 404 } | 403 } |
| 405 | 404 |
| 406 void TrayDetailsView::ShowProgress(double value, bool visible) { | 405 void TrayDetailsView::ShowProgress(double value, bool visible) { |
| 407 DCHECK(UseMd()); | 406 DCHECK(UseMd()); |
| 408 DCHECK(tri_view_); | 407 DCHECK(tri_view_); |
| 409 if (!progress_bar_) { | 408 if (!progress_bar_) { |
| 410 progress_bar_ = new views::ProgressBar(kTitleRowProgressBarHeight); | 409 progress_bar_ = new views::ProgressBar(kTitleRowProgressBarHeight); |
| 411 progress_bar_->SetVisible(false); | 410 progress_bar_->SetVisible(false); |
| 412 AddChildViewAt(progress_bar_, kTitleRowSeparatorIndex + 1); | 411 AddChildViewAt(progress_bar_, kTitleRowSeparatorIndex + 1); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 430 views::CustomButton* TrayDetailsView::CreateHelpButton(LoginStatus status) { | 429 views::CustomButton* TrayDetailsView::CreateHelpButton(LoginStatus status) { |
| 431 DCHECK(UseMd()); | 430 DCHECK(UseMd()); |
| 432 SystemMenuButton* button = | 431 SystemMenuButton* button = |
| 433 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, | 432 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, |
| 434 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP); | 433 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP); |
| 435 if (!TrayPopupUtils::CanOpenWebUISettings(status)) | 434 if (!TrayPopupUtils::CanOpenWebUISettings(status)) |
| 436 button->SetEnabled(false); | 435 button->SetEnabled(false); |
| 437 return button; | 436 return button; |
| 438 } | 437 } |
| 439 | 438 |
| 440 void TrayDetailsView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | |
| 441 if (UseMd()) | |
| 442 UpdateStyle(); | |
| 443 } | |
| 444 | |
| 445 void TrayDetailsView::UpdateStyle() { | |
| 446 if (!GetNativeTheme() || !label_) | |
| 447 return; | |
| 448 | |
| 449 TrayPopupItemStyle style(GetNativeTheme(), | |
| 450 TrayPopupItemStyle::FontStyle::TITLE); | |
| 451 style.SetupLabel(label_); | |
| 452 } | |
| 453 | |
| 454 void TrayDetailsView::HandleViewClicked(views::View* view) { | 439 void TrayDetailsView::HandleViewClicked(views::View* view) { |
| 455 NOTREACHED(); | 440 NOTREACHED(); |
| 456 } | 441 } |
| 457 | 442 |
| 458 void TrayDetailsView::HandleButtonPressed(views::Button* sender, | 443 void TrayDetailsView::HandleButtonPressed(views::Button* sender, |
| 459 const ui::Event& event) { | 444 const ui::Event& event) { |
| 460 NOTREACHED(); | 445 NOTREACHED(); |
| 461 } | 446 } |
| 462 | 447 |
| 463 void TrayDetailsView::CreateExtraTitleRowButtons() {} | 448 void TrayDetailsView::CreateExtraTitleRowButtons() {} |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if (index < child_count() - 1 && child_at(index + 1) != title_row_) | 543 if (index < child_count() - 1 && child_at(index + 1) != title_row_) |
| 559 scroll_border_->set_visible(true); | 544 scroll_border_->set_visible(true); |
| 560 else | 545 else |
| 561 scroll_border_->set_visible(false); | 546 scroll_border_->set_visible(false); |
| 562 } | 547 } |
| 563 | 548 |
| 564 views::View::OnPaintBorder(canvas); | 549 views::View::OnPaintBorder(canvas); |
| 565 } | 550 } |
| 566 | 551 |
| 567 } // namespace ash | 552 } // namespace ash |
| OLD | NEW |