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. | |
calamity
2014/08/04 06:50:17
Call animation_observer_->set_frame_view(NULL) her
sashab
2014/08/05 01:17:55
It's not necessary (NULL is the default), but I se
| |
237 animation_observer_->SetTarget(overlay_view_); | |
238 settings.AddObserver(animation_observer_.get()); | |
239 } | |
240 | |
241 const float kOverlayFadeInMilliseconds = 125; | |
242 settings.SetTransitionDuration( | |
243 base::TimeDelta::FromMilliseconds(kOverlayFadeInMilliseconds)); | |
244 | |
245 const float kOverlayOpacity = 0.75f; | |
246 overlay_view_->layer()->SetOpacity(visible ? kOverlayOpacity : 0.0f); | |
225 } | 247 } |
226 | 248 |
227 bool AppListView::ShouldCenterWindow() const { | 249 bool AppListView::ShouldCenterWindow() const { |
228 return delegate_->ShouldCenterWindow(); | 250 return delegate_->ShouldCenterWindow(); |
229 } | 251 } |
230 | 252 |
231 gfx::Size AppListView::GetPreferredSize() const { | 253 gfx::Size AppListView::GetPreferredSize() const { |
232 return app_list_main_view_->GetPreferredSize(); | 254 return app_list_main_view_->GetPreferredSize(); |
233 } | 255 } |
234 | 256 |
(...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 | 381 // to be shown independently in odd situations. Explicitly hide the bubble |
360 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the | 382 // 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 | 383 // window manager do not have the SWP_SHOWWINDOW flag set which would cause |
362 // the border to be shown. See http://crbug.com/231687 . | 384 // the border to be shown. See http://crbug.com/231687 . |
363 GetWidget()->Hide(); | 385 GetWidget()->Hide(); |
364 #endif | 386 #endif |
365 | 387 |
366 // To make the overlay view, construct a view with a white background, rather | 388 // 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 | 389 // 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). | 390 // drawn to its own layer (so it appears correctly in the foreground). |
369 const float kOverlayOpacity = 0.75f; | |
370 overlay_view_ = new views::View(); | 391 overlay_view_ = new views::View(); |
371 overlay_view_->SetPaintToLayer(true); | 392 overlay_view_->SetPaintToLayer(true); |
372 overlay_view_->layer()->SetOpacity(kOverlayOpacity); | |
373 overlay_view_->SetBoundsRect(GetContentsBounds()); | 393 overlay_view_->SetBoundsRect(GetContentsBounds()); |
374 overlay_view_->SetVisible(false); | 394 overlay_view_->SetVisible(false); |
395 overlay_view_->layer()->SetOpacity(0.0f); | |
375 // On platforms that don't support a shadow, the rounded border of the app | 396 // 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 | 397 // 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 | 398 // 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 | 399 // corner radius 1px smaller than the outer border, so it just reaches but |
379 // doesn't cover it. | 400 // doesn't cover it. |
380 const int kOverlayCornerRadius = | 401 const int kOverlayCornerRadius = |
381 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); | 402 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); |
382 overlay_view_->set_background(new AppListOverlayBackground( | 403 overlay_view_->set_background(new AppListOverlayBackground( |
383 kOverlayCornerRadius - (SupportsShadow() ? 0 : 1))); | 404 kOverlayCornerRadius - (SupportsShadow() ? 0 : 1))); |
384 AddChildView(overlay_view_); | 405 AddChildView(overlay_view_); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 speech_view_->layer()->SetTransform(speech_transform); | 583 speech_view_->layer()->SetTransform(speech_transform); |
563 } | 584 } |
564 | 585 |
565 if (will_appear) | 586 if (will_appear) |
566 speech_view_->SetVisible(true); | 587 speech_view_->SetVisible(true); |
567 else | 588 else |
568 app_list_main_view_->SetVisible(true); | 589 app_list_main_view_->SetVisible(true); |
569 } | 590 } |
570 | 591 |
571 } // namespace app_list | 592 } // namespace app_list |
OLD | NEW |