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

Side by Side Diff: ash/system/tray/tray_background_view.cc

Issue 281793002: Revert animation of Overview Button Tray (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months 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
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/system/tray/tray_background_view.h" 5 #include "ash/system/tray/tray_background_view.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
11 #include "ash/shelf/shelf_widget.h" 11 #include "ash/shelf/shelf_widget.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/shell_window_ids.h" 13 #include "ash/shell_window_ids.h"
14 #include "ash/system/status_area_widget.h" 14 #include "ash/system/status_area_widget.h"
15 #include "ash/system/status_area_widget_delegate.h" 15 #include "ash/system/status_area_widget_delegate.h"
16 #include "ash/system/tray/system_tray.h" 16 #include "ash/system/tray/system_tray.h"
17 #include "ash/system/tray/tray_constants.h" 17 #include "ash/system/tray/tray_constants.h"
18 #include "ash/system/tray/tray_event_filter.h" 18 #include "ash/system/tray/tray_event_filter.h"
19 #include "ash/wm/window_animations.h" 19 #include "ash/wm/window_animations.h"
20 #include "grit/ash_resources.h" 20 #include "grit/ash_resources.h"
21 #include "ui/accessibility/ax_view_state.h" 21 #include "ui/accessibility/ax_view_state.h"
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 #include "ui/aura/window_event_dispatcher.h" 23 #include "ui/aura/window_event_dispatcher.h"
24 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/compositor/layer.h"
26 #include "ui/compositor/layer_animation_element.h"
27 #include "ui/compositor/scoped_layer_animation_settings.h"
28 #include "ui/gfx/animation/tween.h"
29 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
30 #include "ui/gfx/image/image_skia.h" 26 #include "ui/gfx/image/image_skia.h"
31 #include "ui/gfx/image/image_skia_operations.h" 27 #include "ui/gfx/image/image_skia_operations.h"
32 #include "ui/gfx/rect.h" 28 #include "ui/gfx/rect.h"
33 #include "ui/gfx/screen.h" 29 #include "ui/gfx/screen.h"
34 #include "ui/gfx/skia_util.h" 30 #include "ui/gfx/skia_util.h"
35 #include "ui/gfx/transform.h"
36 #include "ui/views/background.h" 31 #include "ui/views/background.h"
37 #include "ui/views/layout/box_layout.h" 32 #include "ui/views/layout/box_layout.h"
38 33
39 namespace { 34 namespace {
40 35
41 const int kTrayBackgroundAlpha = 100; 36 const int kTrayBackgroundAlpha = 100;
42 const int kTrayBackgroundHoverAlpha = 150; 37 const int kTrayBackgroundHoverAlpha = 150;
43 const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244); 38 const SkColor kTrayBackgroundPressedColor = SkColorSetRGB(66, 129, 244);
44 39
45 const int kAnimationDurationForPopupMs = 200; 40 const int kAnimationDurationForPopupMS = 200;
46
47 // Duration of opacity animation for visibility changes.
48 const int kAnimationDurationForVisibilityMs = 250;
49
50 // When becoming visible delay the animation so that StatusAreaWidgetDelegate
51 // can animate sibling views out of the position to be occuped by the
52 // TrayBackgroundView.
53 const int kShowAnimationDelayMs = 100;
54 41
55 } // namespace 42 } // namespace
56 43
57 using views::TrayBubbleView; 44 using views::TrayBubbleView;
58 45
59 namespace ash { 46 namespace ash {
60 47
61 // static 48 // static
62 const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView"; 49 const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView";
63 50
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 300
314 // Initially we want to paint the background, but without the hover effect. 301 // Initially we want to paint the background, but without the hover effect.
315 hide_background_animator_.SetPaintsBackground( 302 hide_background_animator_.SetPaintsBackground(
316 true, BACKGROUND_CHANGE_IMMEDIATE); 303 true, BACKGROUND_CHANGE_IMMEDIATE);
317 hover_background_animator_.SetPaintsBackground( 304 hover_background_animator_.SetPaintsBackground(
318 false, BACKGROUND_CHANGE_IMMEDIATE); 305 false, BACKGROUND_CHANGE_IMMEDIATE);
319 306
320 tray_container_ = new TrayContainer(shelf_alignment_); 307 tray_container_ = new TrayContainer(shelf_alignment_);
321 SetContents(tray_container_); 308 SetContents(tray_container_);
322 tray_event_filter_.reset(new TrayEventFilter); 309 tray_event_filter_.reset(new TrayEventFilter);
323
324 SetPaintToLayer(true);
325 SetFillsBoundsOpaquely(false);
326 } 310 }
327 311
328 TrayBackgroundView::~TrayBackgroundView() { 312 TrayBackgroundView::~TrayBackgroundView() {
329 if (GetWidget()) 313 if (GetWidget())
330 GetWidget()->RemoveObserver(widget_observer_.get()); 314 GetWidget()->RemoveObserver(widget_observer_.get());
331 } 315 }
332 316
333 void TrayBackgroundView::Initialize() { 317 void TrayBackgroundView::Initialize() {
334 GetWidget()->AddObserver(widget_observer_.get()); 318 GetWidget()->AddObserver(widget_observer_.get());
335 SetTrayBorder(); 319 SetTrayBorder();
336 } 320 }
337 321
338 void TrayBackgroundView::SetVisible(bool visible) {
339 if (visible == this->visible())
340 return;
341
342 if (visible) {
343 // The alignment of the shelf can change while the TrayBackgroundView is
344 // hidden. Reset the offscreen transform so that the animation to becoming
345 // visible reflects the current layout.
346 HideTransformation();
347 // SetVisible(false) is defered until the animation for hiding is done.
348 // Otherwise the view is immediately hidden and the animation does not
349 // render.
350 views::View::SetVisible(visible);
351 }
352
353 layer()->GetAnimator()->StopAnimating();
354 ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator());
355 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
356 kAnimationDurationForVisibilityMs));
357 animation.SetPreemptionStrategy(
358 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
359
360 if (visible) {
361 animation.SetTweenType(gfx::Tween::EASE_OUT);
362 // Show is delayed so as to allow time for other children of
363 // StatusAreaWidget to begin animating to their new positions.
364 layer()->GetAnimator()->SchedulePauseForProperties(
365 base::TimeDelta::FromMilliseconds(kShowAnimationDelayMs),
366 ui::LayerAnimationElement::OPACITY |
367 ui::LayerAnimationElement::TRANSFORM);
368 // layer()->SetVisible(true) is handled by views::View::SetVisible(true) so
369 // we do not need to apply that change while becoming visible.
370 layer()->SetOpacity(1.0f);
371 gfx::Transform transform;
372 transform.Translate(0.0f, 0.0f);
373 layer()->SetTransform(transform);
374 } else {
375 // Listen only to the hide animation. As we cannot turn off visibility
376 // until the animation is over.
377 animation.AddObserver(this);
378 animation.SetTweenType(gfx::Tween::EASE_IN);
379 layer()->SetOpacity(0.0f);
380 layer()->SetVisible(false);
381 HideTransformation();
382 }
383 }
384
385 const char* TrayBackgroundView::GetClassName() const { 322 const char* TrayBackgroundView::GetClassName() const {
386 return kViewClassName; 323 return kViewClassName;
387 } 324 }
388 325
389 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { 326 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
390 hovered_ = true; 327 hovered_ = true;
391 } 328 }
392 329
393 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { 330 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) {
394 hovered_ = false; 331 hovered_ = false;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 top_edge = 0; 413 top_edge = 0;
477 left_edge = ShelfLayoutManager::kShelfItemInset; 414 left_edge = ShelfLayoutManager::kShelfItemInset;
478 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; 415 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0;
479 right_edge = kShelfSize - 416 right_edge = kShelfSize -
480 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; 417 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight;
481 } 418 }
482 SetBorder(views::Border::CreateEmptyBorder( 419 SetBorder(views::Border::CreateEmptyBorder(
483 top_edge, left_edge, bottom_edge, right_edge)); 420 top_edge, left_edge, bottom_edge, right_edge));
484 } 421 }
485 422
486 void TrayBackgroundView::OnImplicitAnimationsCompleted() {
487 views::View::SetVisible(false);
488 }
489
490 void TrayBackgroundView::HideTransformation() {
491 gfx::Transform transform;
492 if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM ||
493 shelf_alignment_ == SHELF_ALIGNMENT_TOP)
494 transform.Translate(width(), 0.0f);
495 else
496 transform.Translate(0.0f, height());
497 layer()->SetTransform(transform);
498 }
499
500 void TrayBackgroundView::InitializeBubbleAnimations( 423 void TrayBackgroundView::InitializeBubbleAnimations(
501 views::Widget* bubble_widget) { 424 views::Widget* bubble_widget) {
502 wm::SetWindowVisibilityAnimationType( 425 wm::SetWindowVisibilityAnimationType(
503 bubble_widget->GetNativeWindow(), 426 bubble_widget->GetNativeWindow(),
504 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 427 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
505 wm::SetWindowVisibilityAnimationTransition( 428 wm::SetWindowVisibilityAnimationTransition(
506 bubble_widget->GetNativeWindow(), 429 bubble_widget->GetNativeWindow(),
507 wm::ANIMATE_HIDE); 430 wm::ANIMATE_HIDE);
508 wm::SetWindowVisibilityAnimationDuration( 431 wm::SetWindowVisibilityAnimationDuration(
509 bubble_widget->GetNativeWindow(), 432 bubble_widget->GetNativeWindow(),
510 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMs)); 433 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS));
511 } 434 }
512 435
513 aura::Window* TrayBackgroundView::GetBubbleWindowContainer() const { 436 aura::Window* TrayBackgroundView::GetBubbleWindowContainer() const {
514 return ash::Shell::GetContainer( 437 return ash::Shell::GetContainer(
515 tray_container()->GetWidget()->GetNativeWindow()->GetRootWindow(), 438 tray_container()->GetWidget()->GetNativeWindow()->GetRootWindow(),
516 ash::kShellWindowId_SettingBubbleContainer); 439 ash::kShellWindowId_SettingBubbleContainer);
517 } 440 }
518 441
519 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( 442 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect(
520 views::Widget* anchor_widget, 443 views::Widget* anchor_widget,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 background_->set_alpha(kTrayBackgroundAlpha); 519 background_->set_alpha(kTrayBackgroundAlpha);
597 SchedulePaint(); 520 SchedulePaint();
598 } 521 }
599 522
600 void TrayBackgroundView::UpdateBubbleViewArrow( 523 void TrayBackgroundView::UpdateBubbleViewArrow(
601 views::TrayBubbleView* bubble_view) { 524 views::TrayBubbleView* bubble_view) {
602 // Nothing to do here. 525 // Nothing to do here.
603 } 526 }
604 527
605 } // namespace ash 528 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698