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

Unified Diff: ui/app_list/views/app_list_view.cc

Issue 429823002: Animate the App List overlay when dialogs are opened (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed the animation observer to take multiple views, and added it to observe hiding the overlay Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/app_list_view.cc
diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc
index 55a3b6529bb42fa62834501cd8d73f266101a5a2..f23fac51032a09f37ad5c874c6594adef23d9c0a 100644
--- a/ui/app_list/views/app_list_view.cc
+++ b/ui/app_list/views/app_list_view.cc
@@ -104,23 +104,22 @@ class AppListOverlayBackground : public views::Background {
} // namespace
-// An animation observer to hide the view at the end of the animation.
+// An animation observer to hide a set of views at the end of the animation.
class HideViewAnimationObserver : public ui::ImplicitAnimationObserver {
public:
- HideViewAnimationObserver()
- : frame_(NULL),
- target_(NULL) {
- }
+ HideViewAnimationObserver() : frame_(NULL) {}
virtual ~HideViewAnimationObserver() {
- if (target_)
+ if (targets_.empty())
StopObservingImplicitAnimations();
}
- void SetTarget(views::View* target) {
- if (!target_)
+ void AddTarget(views::View* target) {
+ if (target)
+ targets_.push_back(target);
+
+ if (targets_.empty())
StopObservingImplicitAnimations();
- target_ = target;
}
void set_frame(views::BubbleFrameView* frame) { frame_ = frame; }
@@ -128,17 +127,18 @@ class HideViewAnimationObserver : public ui::ImplicitAnimationObserver {
private:
// Overridden from ui::ImplicitAnimationObserver:
virtual void OnImplicitAnimationsCompleted() OVERRIDE {
- if (target_) {
- target_->SetVisible(false);
- target_ = NULL;
+ for (size_t i = 0; i < targets_.size(); i++)
+ targets_[i]->SetVisible(false);
- // Should update the background by invoking SchedulePaint().
+ // Should update the background by invoking SchedulePaint().
+ if (!targets_.empty())
frame_->SchedulePaint();
- }
+
+ targets_.clear();
}
views::BubbleFrameView* frame_;
- views::View* target_;
+ std::vector<views::View*> targets_;
DISALLOW_COPY_AND_ASSIGN(HideViewAnimationObserver);
};
@@ -221,7 +221,27 @@ void AppListView::UpdateBounds() {
void AppListView::SetAppListOverlayVisible(bool visible) {
DCHECK(overlay_view_);
- overlay_view_->SetVisible(visible);
+
+ // Display the overlay immediately so we can begin the animation.
+ overlay_view_->SetVisible(true);
+
+ ui::ScopedLayerAnimationSettings settings(
+ overlay_view_->layer()->GetAnimator());
+ settings.SetTweenType(gfx::Tween::LINEAR);
+
+ // If we're dismissing the overlay, hide the view at the end of the animation.
+ if (visible == false) {
calamity 2014/08/04 03:33:47 Use !x over 'x == false'.
sashab 2014/08/04 05:39:16 Done.
+ animation_observer_->set_frame(GetBubbleFrameView());
calamity 2014/08/04 03:33:47 Does the background need to repaint? If not, pass
sashab 2014/08/04 05:39:16 Done.
+ animation_observer_->AddTarget(overlay_view_);
+ settings.AddObserver(animation_observer_.get());
+ }
+
+ const float kOverlayFadeInMilliseconds = 125;
+ settings.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(kOverlayFadeInMilliseconds));
+
+ const float kOverlayOpacity = 0.75f;
+ overlay_view_->layer()->SetOpacity(visible ? kOverlayOpacity : 0.0f);
}
bool AppListView::ShouldCenterWindow() const {
@@ -366,12 +386,11 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
// To make the overlay view, construct a view with a white background, rather
// than a white rectangle in it. This is because we need overlay_view_ to be
// drawn to its own layer (so it appears correctly in the foreground).
- const float kOverlayOpacity = 0.75f;
overlay_view_ = new views::View();
overlay_view_->SetPaintToLayer(true);
- overlay_view_->layer()->SetOpacity(kOverlayOpacity);
overlay_view_->SetBoundsRect(GetContentsBounds());
overlay_view_->SetVisible(false);
+ overlay_view_->layer()->SetOpacity(0.0f);
// On platforms that don't support a shadow, the rounded border of the app
// list is constructed _inside_ the view, so a rectangular background goes
// over the border in the rounded corners. To fix this, give the background a
@@ -541,7 +560,7 @@ void AppListView::OnSpeechRecognitionStateChanged(
ui::ScopedLayerAnimationSettings main_settings(
app_list_main_view_->layer()->GetAnimator());
if (will_appear) {
- animation_observer_->SetTarget(app_list_main_view_);
+ animation_observer_->AddTarget(app_list_main_view_);
main_settings.AddObserver(animation_observer_.get());
}
app_list_main_view_->layer()->SetOpacity(will_appear ? 0.0f : 1.0f);
@@ -551,7 +570,7 @@ void AppListView::OnSpeechRecognitionStateChanged(
ui::ScopedLayerAnimationSettings speech_settings(
speech_view_->layer()->GetAnimator());
if (!will_appear) {
- animation_observer_->SetTarget(speech_view_);
+ animation_observer_->AddTarget(speech_view_);
speech_settings.AddObserver(animation_observer_.get());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698