| 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 "ui/app_list/views/app_list_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 : frame_(NULL), | 111 : frame_(NULL), |
| 112 target_(NULL) { | 112 target_(NULL) { |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual ~HideViewAnimationObserver() { | 115 virtual ~HideViewAnimationObserver() { |
| 116 if (target_) | 116 if (target_) |
| 117 StopObservingImplicitAnimations(); | 117 StopObservingImplicitAnimations(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void SetTarget(views::View* target) { | 120 void SetTarget(views::View* target) { |
| 121 if (!target_) | 121 if (target_) |
| 122 StopObservingImplicitAnimations(); | 122 StopObservingImplicitAnimations(); |
| 123 target_ = target; | 123 target_ = target; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void set_frame(views::BubbleFrameView* frame) { frame_ = frame; } | 126 void set_frame(views::BubbleFrameView* frame) { frame_ = frame; } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 // Overridden from ui::ImplicitAnimationObserver: | 129 // Overridden from ui::ImplicitAnimationObserver: |
| 130 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 130 virtual void OnImplicitAnimationsCompleted() OVERRIDE { |
| 131 if (target_) { | 131 if (target_) { |
| 132 target_->SetVisible(false); | 132 target_->SetVisible(false); |
| 133 target_ = NULL; | 133 target_ = NULL; |
| 134 | 134 |
| 135 // Should update the background by invoking SchedulePaint(). | 135 // Should update the background by invoking SchedulePaint(). |
| 136 frame_->SchedulePaint(); | 136 if (frame_) |
| 137 frame_->SchedulePaint(); |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 | 140 |
| 140 views::BubbleFrameView* frame_; | 141 views::BubbleFrameView* frame_; |
| 141 views::View* target_; | 142 views::View* target_; |
| 142 | 143 |
| 143 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); | 144 DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver); |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 //////////////////////////////////////////////////////////////////////////////// | 147 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 app_list_main_view_->Close(); | 215 app_list_main_view_->Close(); |
| 215 delegate_->Dismiss(); | 216 delegate_->Dismiss(); |
| 216 } | 217 } |
| 217 | 218 |
| 218 void AppListView::UpdateBounds() { | 219 void AppListView::UpdateBounds() { |
| 219 SizeToContents(); | 220 SizeToContents(); |
| 220 } | 221 } |
| 221 | 222 |
| 222 void AppListView::SetAppListOverlayVisible(bool visible) { | 223 void AppListView::SetAppListOverlayVisible(bool visible) { |
| 223 DCHECK(overlay_view_); | 224 DCHECK(overlay_view_); |
| 224 overlay_view_->SetVisible(visible); | 225 |
| 226 // Display the overlay immediately so we can begin the animation. |
| 227 overlay_view_->SetVisible(true); |
| 228 |
| 229 ui::ScopedLayerAnimationSettings settings( |
| 230 overlay_view_->layer()->GetAnimator()); |
| 231 settings.SetTweenType(gfx::Tween::LINEAR); |
| 232 |
| 233 // If we're dismissing the overlay, hide the view at the end of the animation. |
| 234 if (!visible) { |
| 235 // Since only one animation is visible at a time, it's safe to re-use |
| 236 // animation_observer_ here. |
| 237 animation_observer_->set_frame(NULL); |
| 238 animation_observer_->SetTarget(overlay_view_); |
| 239 settings.AddObserver(animation_observer_.get()); |
| 240 } |
| 241 |
| 242 const float kOverlayFadeInMilliseconds = 125; |
| 243 settings.SetTransitionDuration( |
| 244 base::TimeDelta::FromMilliseconds(kOverlayFadeInMilliseconds)); |
| 245 |
| 246 const float kOverlayOpacity = 0.75f; |
| 247 overlay_view_->layer()->SetOpacity(visible ? kOverlayOpacity : 0.0f); |
| 225 } | 248 } |
| 226 | 249 |
| 227 bool AppListView::ShouldCenterWindow() const { | 250 bool AppListView::ShouldCenterWindow() const { |
| 228 return delegate_->ShouldCenterWindow(); | 251 return delegate_->ShouldCenterWindow(); |
| 229 } | 252 } |
| 230 | 253 |
| 231 gfx::Size AppListView::GetPreferredSize() const { | 254 gfx::Size AppListView::GetPreferredSize() const { |
| 232 return app_list_main_view_->GetPreferredSize(); | 255 return app_list_main_view_->GetPreferredSize(); |
| 233 } | 256 } |
| 234 | 257 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 // to be shown independently in odd situations. Explicitly hide the bubble | 382 // to be shown independently in odd situations. Explicitly hide the bubble |
| 360 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the | 383 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the |
| 361 // window manager do not have the SWP_SHOWWINDOW flag set which would cause | 384 // window manager do not have the SWP_SHOWWINDOW flag set which would cause |
| 362 // the border to be shown. See http://crbug.com/231687 . | 385 // the border to be shown. See http://crbug.com/231687 . |
| 363 GetWidget()->Hide(); | 386 GetWidget()->Hide(); |
| 364 #endif | 387 #endif |
| 365 | 388 |
| 366 // To make the overlay view, construct a view with a white background, rather | 389 // To make the overlay view, construct a view with a white background, rather |
| 367 // than a white rectangle in it. This is because we need overlay_view_ to be | 390 // than a white rectangle in it. This is because we need overlay_view_ to be |
| 368 // drawn to its own layer (so it appears correctly in the foreground). | 391 // drawn to its own layer (so it appears correctly in the foreground). |
| 369 const float kOverlayOpacity = 0.75f; | |
| 370 overlay_view_ = new views::View(); | 392 overlay_view_ = new views::View(); |
| 371 overlay_view_->SetPaintToLayer(true); | 393 overlay_view_->SetPaintToLayer(true); |
| 372 overlay_view_->layer()->SetOpacity(kOverlayOpacity); | |
| 373 overlay_view_->SetBoundsRect(GetContentsBounds()); | 394 overlay_view_->SetBoundsRect(GetContentsBounds()); |
| 374 overlay_view_->SetVisible(false); | 395 overlay_view_->SetVisible(false); |
| 396 overlay_view_->layer()->SetOpacity(0.0f); |
| 375 // On platforms that don't support a shadow, the rounded border of the app | 397 // On platforms that don't support a shadow, the rounded border of the app |
| 376 // list is constructed _inside_ the view, so a rectangular background goes | 398 // list is constructed _inside_ the view, so a rectangular background goes |
| 377 // over the border in the rounded corners. To fix this, give the background a | 399 // over the border in the rounded corners. To fix this, give the background a |
| 378 // corner radius 1px smaller than the outer border, so it just reaches but | 400 // corner radius 1px smaller than the outer border, so it just reaches but |
| 379 // doesn't cover it. | 401 // doesn't cover it. |
| 380 const int kOverlayCornerRadius = | 402 const int kOverlayCornerRadius = |
| 381 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); | 403 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); |
| 382 overlay_view_->set_background(new AppListOverlayBackground( | 404 overlay_view_->set_background(new AppListOverlayBackground( |
| 383 kOverlayCornerRadius - (SupportsShadow() ? 0 : 1))); | 405 kOverlayCornerRadius - (SupportsShadow() ? 0 : 1))); |
| 384 AddChildView(overlay_view_); | 406 AddChildView(overlay_view_); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 speech_view_->layer()->SetTransform(speech_transform); | 584 speech_view_->layer()->SetTransform(speech_transform); |
| 563 } | 585 } |
| 564 | 586 |
| 565 if (will_appear) | 587 if (will_appear) |
| 566 speech_view_->SetVisible(true); | 588 speech_view_->SetVisible(true); |
| 567 else | 589 else |
| 568 app_list_main_view_->SetVisible(true); | 590 app_list_main_view_->SetVisible(true); |
| 569 } | 591 } |
| 570 | 592 |
| 571 } // namespace app_list | 593 } // namespace app_list |
| OLD | NEW |