| 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/system/tray/system_tray_bubble.h" | 5 #include "ash/system/tray/system_tray_bubble.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
| 9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
| 10 #include "ash/system/tray/system_tray_item.h" | 10 #include "ash/system/tray/system_tray_item.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 DCHECK(layer); | 164 DCHECK(layer); |
| 165 layer->SuppressPaint(); | 165 layer->SuppressPaint(); |
| 166 | 166 |
| 167 // When transitioning from detailed view to default view, animate the | 167 // When transitioning from detailed view to default view, animate the |
| 168 // existing view (slide out towards the right). | 168 // existing view (slide out towards the right). |
| 169 if (bubble_type == BUBBLE_TYPE_DEFAULT) { | 169 if (bubble_type == BUBBLE_TYPE_DEFAULT) { |
| 170 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 170 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 171 settings.AddObserver( | 171 settings.AddObserver( |
| 172 new AnimationObserverDeleteLayer(scoped_layer.release())); | 172 new AnimationObserverDeleteLayer(scoped_layer.release())); |
| 173 settings.SetTransitionDuration(swipe_duration); | 173 settings.SetTransitionDuration(swipe_duration); |
| 174 settings.SetTweenType(ui::Tween::EASE_OUT); | 174 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 175 gfx::Transform transform; | 175 gfx::Transform transform; |
| 176 transform.Translate(layer->bounds().width(), 0.0); | 176 transform.Translate(layer->bounds().width(), 0.0); |
| 177 layer->SetTransform(transform); | 177 layer->SetTransform(transform); |
| 178 } | 178 } |
| 179 | 179 |
| 180 { | 180 { |
| 181 // Add a shadow layer to make the old layer darker as the animation | 181 // Add a shadow layer to make the old layer darker as the animation |
| 182 // progresses. | 182 // progresses. |
| 183 ui::Layer* shadow = new ui::Layer(ui::LAYER_SOLID_COLOR); | 183 ui::Layer* shadow = new ui::Layer(ui::LAYER_SOLID_COLOR); |
| 184 shadow->SetColor(SK_ColorBLACK); | 184 shadow->SetColor(SK_ColorBLACK); |
| 185 shadow->SetOpacity(0.01f); | 185 shadow->SetOpacity(0.01f); |
| 186 shadow->SetBounds(layer->bounds()); | 186 shadow->SetBounds(layer->bounds()); |
| 187 layer->Add(shadow); | 187 layer->Add(shadow); |
| 188 layer->StackAtTop(shadow); | 188 layer->StackAtTop(shadow); |
| 189 { | 189 { |
| 190 // Animate the darkening effect a little longer than the swipe-in. This | 190 // Animate the darkening effect a little longer than the swipe-in. This |
| 191 // is to make sure the darkening animation does not end up finishing | 191 // is to make sure the darkening animation does not end up finishing |
| 192 // early, because the dark layer goes away at the end of the animation, | 192 // early, because the dark layer goes away at the end of the animation, |
| 193 // and there is a brief moment when the old view is still visible, but | 193 // and there is a brief moment when the old view is still visible, but |
| 194 // it does not have the shadow layer on top. | 194 // it does not have the shadow layer on top. |
| 195 ui::ScopedLayerAnimationSettings settings(shadow->GetAnimator()); | 195 ui::ScopedLayerAnimationSettings settings(shadow->GetAnimator()); |
| 196 settings.AddObserver(new AnimationObserverDeleteLayer(shadow)); | 196 settings.AddObserver(new AnimationObserverDeleteLayer(shadow)); |
| 197 settings.SetTransitionDuration(swipe_duration + | 197 settings.SetTransitionDuration(swipe_duration + |
| 198 base::TimeDelta::FromMilliseconds(150)); | 198 base::TimeDelta::FromMilliseconds(150)); |
| 199 settings.SetTweenType(ui::Tween::LINEAR); | 199 settings.SetTweenType(gfx::Tween::LINEAR); |
| 200 shadow->SetOpacity(0.15f); | 200 shadow->SetOpacity(0.15f); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 DestroyItemViews(); | 205 DestroyItemViews(); |
| 206 bubble_view_->RemoveAllChildViews(true); | 206 bubble_view_->RemoveAllChildViews(true); |
| 207 | 207 |
| 208 items_ = items; | 208 items_ = items; |
| 209 bubble_type_ = bubble_type; | 209 bubble_type_ = bubble_type; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 235 gfx::Rect bounds = new_layer->bounds(); | 235 gfx::Rect bounds = new_layer->bounds(); |
| 236 gfx::Transform transform; | 236 gfx::Transform transform; |
| 237 transform.Translate(bounds.width(), 0.0); | 237 transform.Translate(bounds.width(), 0.0); |
| 238 new_layer->SetTransform(transform); | 238 new_layer->SetTransform(transform); |
| 239 { | 239 { |
| 240 ui::ScopedLayerAnimationSettings settings(new_layer->GetAnimator()); | 240 ui::ScopedLayerAnimationSettings settings(new_layer->GetAnimator()); |
| 241 settings.AddObserver( | 241 settings.AddObserver( |
| 242 new AnimationObserverDeleteLayer(scoped_layer.release())); | 242 new AnimationObserverDeleteLayer(scoped_layer.release())); |
| 243 settings.SetTransitionDuration( | 243 settings.SetTransitionDuration( |
| 244 base::TimeDelta::FromMilliseconds(kSwipeDelayMS)); | 244 base::TimeDelta::FromMilliseconds(kSwipeDelayMS)); |
| 245 settings.SetTweenType(ui::Tween::EASE_OUT); | 245 settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 246 new_layer->SetTransform(gfx::Transform()); | 246 new_layer->SetTransform(gfx::Transform()); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 void SystemTrayBubble::InitView(views::View* anchor, | 252 void SystemTrayBubble::InitView(views::View* anchor, |
| 253 user::LoginStatus login_status, | 253 user::LoginStatus login_status, |
| 254 TrayBubbleView::InitParams* init_params) { | 254 TrayBubbleView::InitParams* init_params) { |
| 255 DCHECK(bubble_view_ == NULL); | 255 DCHECK(bubble_view_ == NULL); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // For default view, draw bottom border for each item, except the last | 364 // For default view, draw bottom border for each item, except the last |
| 365 // 2 items, which are the bottom header row and the one just above it. | 365 // 2 items, which are the bottom header row and the one just above it. |
| 366 bubble_view_->AddChildView(new TrayPopupItemContainer( | 366 bubble_view_->AddChildView(new TrayPopupItemContainer( |
| 367 item_views[i], is_default_bubble, | 367 item_views[i], is_default_bubble, |
| 368 is_default_bubble && (i < item_views.size() - 2))); | 368 is_default_bubble && (i < item_views.size() - 2))); |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 | 371 |
| 372 } // namespace internal | 372 } // namespace internal |
| 373 } // namespace ash | 373 } // namespace ash |
| OLD | NEW |