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

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

Issue 2494943005: [ash-md] Added a delay between system menu default/detailed view transitions. (Closed)
Patch Set: Addressed gab@'s comments. Created 4 years, 1 month 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 (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"
11 #include "ash/common/system/tray/system_tray.h" 11 #include "ash/common/system/tray/system_tray.h"
12 #include "ash/common/system/tray/system_tray_item.h" 12 #include "ash/common/system/tray/system_tray_item.h"
13 #include "ash/common/system/tray/tray_constants.h" 13 #include "ash/common/system/tray/tray_constants.h"
14 #include "ash/common/system/tray/tray_popup_item_style.h" 14 #include "ash/common/system/tray/tray_popup_item_style.h"
15 #include "ash/common/system/tray/tray_popup_utils.h" 15 #include "ash/common/system/tray/tray_popup_utils.h"
16 #include "ash/common/system/tray/tri_view.h" 16 #include "ash/common/system/tray/tri_view.h"
17 #include "base/containers/adapters.h" 17 #include "base/containers/adapters.h"
18 #include "base/timer/timer.h"
18 #include "grit/ash_strings.h" 19 #include "grit/ash_strings.h"
19 #include "third_party/skia/include/core/SkDrawLooper.h" 20 #include "third_party/skia/include/core/SkDrawLooper.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/compositor/paint_context.h" 22 #include "ui/compositor/paint_context.h"
22 #include "ui/compositor/paint_recorder.h" 23 #include "ui/compositor/paint_recorder.h"
23 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
24 #include "ui/gfx/skia_util.h" 25 #include "ui/gfx/skia_util.h"
25 #include "ui/views/background.h" 26 #include "ui/views/background.h"
26 #include "ui/views/border.h" 27 #include "ui/views/border.h"
27 #include "ui/views/controls/label.h" 28 #include "ui/views/controls/label.h"
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 449 }
449 450
450 void TrayDetailsView::HandleButtonPressed(views::Button* sender, 451 void TrayDetailsView::HandleButtonPressed(views::Button* sender,
451 const ui::Event& event) { 452 const ui::Event& event) {
452 NOTREACHED(); 453 NOTREACHED();
453 } 454 }
454 455
455 void TrayDetailsView::CreateExtraTitleRowButtons() {} 456 void TrayDetailsView::CreateExtraTitleRowButtons() {}
456 457
457 void TrayDetailsView::TransitionToDefaultView() { 458 void TrayDetailsView::TransitionToDefaultView() {
459 if (UseMd()) {
460 if (back_button_ && back_button_->HasFocus())
461 owner_->set_restore_focus(true);
462 } else {
463 if (title_row_ && title_row_->content() &&
464 title_row_->content()->HasFocus()) {
465 owner_->set_restore_focus(true);
466 }
467 DoTransitionToDefaultView();
468 return;
469 }
470
471 const int transition_delay =
472 GetTrayConstant(TRAY_POPUP_TRANSITION_TO_DEFAULT_DELAY);
473 if (transition_delay <= 0) {
474 DoTransitionToDefaultView();
475 return;
476 }
477
478 transition_delay_timer_.reset(new base::OneShotTimer());
479 transition_delay_timer_->Start(
480 FROM_HERE, base::TimeDelta::FromMilliseconds(transition_delay), this,
481 &TrayDetailsView::DoTransitionToDefaultView);
482 }
483
484 void TrayDetailsView::DoTransitionToDefaultView() {
485 transition_delay_timer_.reset();
486
458 // Cache pointer to owner in this function scope. TrayDetailsView will be 487 // Cache pointer to owner in this function scope. TrayDetailsView will be
459 // deleted after called ShowDefaultView. 488 // deleted after called ShowDefaultView.
460 SystemTrayItem* owner = owner_; 489 SystemTrayItem* owner = owner_;
461 if (UseMd()) {
462 if (back_button_ && back_button_->HasFocus())
463 owner->set_restore_focus(true);
464 } else {
465 if (title_row_ && title_row_->content() &&
466 title_row_->content()->HasFocus()) {
467 owner->set_restore_focus(true);
468 }
469 }
470 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 490 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
471 owner->set_restore_focus(false); 491 owner->set_restore_focus(false);
472 } 492 }
473 493
474 views::Button* TrayDetailsView::CreateBackButton() { 494 views::Button* TrayDetailsView::CreateBackButton() {
475 DCHECK(UseMd()); 495 DCHECK(UseMd());
476 SystemMenuButton* button = new SystemMenuButton( 496 SystemMenuButton* button = new SystemMenuButton(
477 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuArrowBackIcon, 497 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuArrowBackIcon,
478 IDS_ASH_STATUS_TRAY_PREVIOUS_MENU); 498 IDS_ASH_STATUS_TRAY_PREVIOUS_MENU);
479 return button; 499 return button;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 if (index < child_count() - 1 && child_at(index + 1) != title_row_) 550 if (index < child_count() - 1 && child_at(index + 1) != title_row_)
531 scroll_border_->set_visible(true); 551 scroll_border_->set_visible(true);
532 else 552 else
533 scroll_border_->set_visible(false); 553 scroll_border_->set_visible(false);
534 } 554 }
535 555
536 views::View::OnPaintBorder(canvas); 556 views::View::OnPaintBorder(canvas);
537 } 557 }
538 558
539 } // namespace ash 559 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698