| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/wm/overview/window_selector_item.h" | 5 #include "ash/wm/overview/window_selector_item.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/overview/scoped_transform_overview_window.h" | 10 #include "ash/wm/overview/scoped_transform_overview_window.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 WindowSelectorItem::WindowSelectorItem() | 75 WindowSelectorItem::WindowSelectorItem() |
| 76 : root_window_(NULL), | 76 : root_window_(NULL), |
| 77 in_bounds_update_(false) { | 77 in_bounds_update_(false) { |
| 78 } | 78 } |
| 79 | 79 |
| 80 WindowSelectorItem::~WindowSelectorItem() { | 80 WindowSelectorItem::~WindowSelectorItem() { |
| 81 } | 81 } |
| 82 | 82 |
| 83 void WindowSelectorItem::SetBounds(aura::Window* root_window, | 83 void WindowSelectorItem::SetBounds(aura::Window* root_window, |
| 84 const gfx::Rect& target_bounds) { | 84 const gfx::Rect& target_bounds, |
| 85 bool animate) { |
| 85 if (in_bounds_update_) | 86 if (in_bounds_update_) |
| 86 return; | 87 return; |
| 87 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 88 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
| 88 root_window_ = root_window; | 89 root_window_ = root_window; |
| 89 target_bounds_ = target_bounds; | 90 target_bounds_ = target_bounds; |
| 90 SetItemBounds(root_window, target_bounds, true); | 91 SetItemBounds(root_window, target_bounds, animate); |
| 91 // TODO(nsatragno): Handle window title updates. | 92 // TODO(nsatragno): Handle window title updates. |
| 92 UpdateWindowLabels(target_bounds, root_window); | 93 UpdateWindowLabels(target_bounds, root_window, animate); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void WindowSelectorItem::RecomputeWindowTransforms() { | 96 void WindowSelectorItem::RecomputeWindowTransforms() { |
| 96 if (in_bounds_update_ || target_bounds_.IsEmpty()) | 97 if (in_bounds_update_ || target_bounds_.IsEmpty()) |
| 97 return; | 98 return; |
| 98 DCHECK(root_window_); | 99 DCHECK(root_window_); |
| 99 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 100 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
| 100 SetItemBounds(root_window_, target_bounds_, false); | 101 SetItemBounds(root_window_, target_bounds_, false); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void WindowSelectorItem::UpdateWindowLabels(const gfx::Rect& window_bounds, | 104 void WindowSelectorItem::UpdateWindowLabels(const gfx::Rect& window_bounds, |
| 104 aura::Window* root_window) { | 105 aura::Window* root_window, |
| 106 bool animate) { |
| 105 gfx::Rect converted_bounds = ScreenUtil::ConvertRectFromScreen(root_window, | 107 gfx::Rect converted_bounds = ScreenUtil::ConvertRectFromScreen(root_window, |
| 106 window_bounds); | 108 window_bounds); |
| 107 gfx::Rect label_bounds(converted_bounds.x(), | 109 gfx::Rect label_bounds(converted_bounds.x(), |
| 108 converted_bounds.bottom(), | 110 converted_bounds.bottom(), |
| 109 converted_bounds.width(), | 111 converted_bounds.width(), |
| 110 0); | 112 0); |
| 111 | 113 |
| 112 // If the root window has changed, force the window label to be recreated | 114 // If the root window has changed, force the window label to be recreated |
| 113 // and faded in on the new root window. | 115 // and faded in on the new root window. |
| 114 if (window_label_ && | 116 if (window_label_ && |
| (...skipping 17 matching lines...) Expand all Loading... |
| 132 ScopedTransformOverviewWindow::kTransitionMilliseconds), | 134 ScopedTransformOverviewWindow::kTransitionMilliseconds), |
| 133 ui::LayerAnimationElement::OPACITY); | 135 ui::LayerAnimationElement::OPACITY); |
| 134 | 136 |
| 135 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 137 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 136 settings.SetPreemptionStrategy( | 138 settings.SetPreemptionStrategy( |
| 137 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 139 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 138 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 140 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 139 kFadeInMilliseconds)); | 141 kFadeInMilliseconds)); |
| 140 layer->SetOpacity(1); | 142 layer->SetOpacity(1); |
| 141 } else { | 143 } else { |
| 142 ui::ScopedLayerAnimationSettings settings( | |
| 143 window_label_->GetNativeWindow()->layer()->GetAnimator()); | |
| 144 settings.SetPreemptionStrategy( | |
| 145 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 146 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | |
| 147 ScopedTransformOverviewWindow::kTransitionMilliseconds)); | |
| 148 label_bounds.set_height(window_label_-> | 144 label_bounds.set_height(window_label_-> |
| 149 GetContentsView()->GetPreferredSize().height()); | 145 GetContentsView()->GetPreferredSize().height()); |
| 150 window_label_->GetNativeWindow()->SetBounds(label_bounds); | 146 if (animate) { |
| 147 ui::ScopedLayerAnimationSettings settings( |
| 148 window_label_->GetNativeWindow()->layer()->GetAnimator()); |
| 149 settings.SetPreemptionStrategy( |
| 150 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 151 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 152 ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
| 153 window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| 154 } else { |
| 155 window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| 156 } |
| 151 } | 157 } |
| 152 | 158 |
| 153 } | 159 } |
| 154 | 160 |
| 155 } // namespace ash | 161 } // namespace ash |
| OLD | NEW |