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

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 danakj@ 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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 463 }
463 464
464 void TrayDetailsView::HandleButtonPressed(views::Button* sender, 465 void TrayDetailsView::HandleButtonPressed(views::Button* sender,
465 const ui::Event& event) { 466 const ui::Event& event) {
466 NOTREACHED(); 467 NOTREACHED();
467 } 468 }
468 469
469 void TrayDetailsView::CreateExtraTitleRowButtons() {} 470 void TrayDetailsView::CreateExtraTitleRowButtons() {}
470 471
471 void TrayDetailsView::TransitionToDefaultView() { 472 void TrayDetailsView::TransitionToDefaultView() {
473 if (UseMd()) {
474 if (back_button_ && back_button_->HasFocus())
475 owner_->set_restore_focus(true);
476 } else {
477 if (title_row_ && title_row_->content() &&
478 title_row_->content()->HasFocus()) {
479 owner_->set_restore_focus(true);
480 }
481 DoTransitionToDefaultView();
482 return;
483 }
484
485 const int transition_delay =
486 GetTrayConstant(TRAY_POPUP_TRANSITION_TO_DEFAULT_DELAY);
487 if (transition_delay <= 0) {
488 DoTransitionToDefaultView();
489 return;
490 }
491
492 transition_delay_timer_.reset(new base::OneShotTimer());
493 transition_delay_timer_->Start(
494 FROM_HERE, base::TimeDelta::FromMilliseconds(transition_delay), this,
495 &TrayDetailsView::DoTransitionToDefaultView);
496 }
497
498 void TrayDetailsView::DoTransitionToDefaultView() {
499 transition_delay_timer_.reset();
500
472 // Cache pointer to owner in this function scope. TrayDetailsView will be 501 // Cache pointer to owner in this function scope. TrayDetailsView will be
473 // deleted after called ShowDefaultView. 502 // deleted after called ShowDefaultView.
474 SystemTrayItem* owner = owner_; 503 SystemTrayItem* owner = owner_;
475 if (UseMd()) {
476 if (back_button_ && back_button_->HasFocus())
477 owner->set_restore_focus(true);
478 } else {
479 if (title_row_ && title_row_->content() &&
480 title_row_->content()->HasFocus()) {
481 owner->set_restore_focus(true);
482 }
483 }
484 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 504 owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
485 owner->set_restore_focus(false); 505 owner->set_restore_focus(false);
486 } 506 }
487 507
488 views::Button* TrayDetailsView::CreateBackButton() { 508 views::Button* TrayDetailsView::CreateBackButton() {
489 DCHECK(UseMd()); 509 DCHECK(UseMd());
490 SystemMenuButton* button = new SystemMenuButton( 510 SystemMenuButton* button = new SystemMenuButton(
491 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuArrowBackIcon, 511 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuArrowBackIcon,
492 IDS_ASH_STATUS_TRAY_PREVIOUS_MENU); 512 IDS_ASH_STATUS_TRAY_PREVIOUS_MENU);
493 return button; 513 return button;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (index < child_count() - 1 && child_at(index + 1) != title_row_) 565 if (index < child_count() - 1 && child_at(index + 1) != title_row_)
546 scroll_border_->set_visible(true); 566 scroll_border_->set_visible(true);
547 else 567 else
548 scroll_border_->set_visible(false); 568 scroll_border_->set_visible(false);
549 } 569 }
550 570
551 views::View::OnPaintBorder(canvas); 571 views::View::OnPaintBorder(canvas);
552 } 572 }
553 573
554 } // namespace ash 574 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_details_view.h ('k') | ash/common/system/tray/tray_details_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698