diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 22:19:17 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 22:19:17 +0000 |
commit | bd1ad684dee1355226c5f6946034369b98186a55 (patch) | |
tree | f96a5a2e95a8a14aa35dd07a94578d5cc66d0c02 /chrome/browser/views | |
parent | f363a3a828686f6aad65501abe7b33b0d4d13d32 (diff) | |
download | chromium_src-bd1ad684dee1355226c5f6946034369b98186a55.zip chromium_src-bd1ad684dee1355226c5f6946034369b98186a55.tar.gz chromium_src-bd1ad684dee1355226c5f6946034369b98186a55.tar.bz2 |
GTK: Add download shelf first show animation.
http://crbug.com/8631
Review URL: http://codereview.chromium.org/113428
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/browser_views.vcproj | 6 | ||||
-rw-r--r-- | chrome/browser/views/download_started_animation.h | 63 | ||||
-rw-r--r-- | chrome/browser/views/download_started_animation_win.cc (renamed from chrome/browser/views/download_started_animation.cc) | 79 |
3 files changed, 71 insertions, 77 deletions
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj index d2594d0..75e2939 100644 --- a/chrome/browser/views/browser_views.vcproj +++ b/chrome/browser/views/browser_views.vcproj @@ -546,11 +546,7 @@ > </File> <File - RelativePath=".\download_started_animation.cc" - > - </File> - <File - RelativePath=".\download_started_animation.h" + RelativePath=".\download_started_animation_win.cc" > </File> <File diff --git a/chrome/browser/views/download_started_animation.h b/chrome/browser/views/download_started_animation.h deleted file mode 100644 index ec84244..0000000 --- a/chrome/browser/views/download_started_animation.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_VIEWS_DOWNLOAD_STARTED_ANIMATION_H_ -#define CHROME_BROWSER_VIEWS_DOWNLOAD_STARTED_ANIMATION_H_ - -#include "app/animation.h" -#include "base/gfx/rect.h" -#include "chrome/common/notification_registrar.h" -#include "views/controls/image_view.h" - -namespace views { -class WidgetWin; -}; -class TabContents; - -// DownloadStartAnimation creates an animation (which begins running -// immediately) that animates an image downward from the center of the frame -// provided on the constructor, while simultaneously fading it out. To use, -// simply call "new DownloadStartAnimation"; the class cleans itself up when it -// finishes animating. -class DownloadStartedAnimation : public Animation, - public NotificationObserver, - public views::ImageView { - public: - DownloadStartedAnimation(TabContents* tab_contents); - - private: - // Move the animation to wherever it should currently be. - void Reposition(); - - // Shut down the animation cleanly. - void Close(); - - // Animation - virtual void AnimateToState(double state); - - // NotificationObserver - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - // We use a HWND for the popup so that it may float above any HWNDs in our UI. - views::WidgetWin* popup_; - - // The content area holding us. - TabContents* tab_contents_; - - // The content area at the start of the animation. We store this so that the - // download shelf's resizing of the content area doesn't cause the animation - // to move around. This means that once started, the animation won't move - // with the parent window, but it's so fast that this shouldn't cause too - // much heartbreak. - gfx::Rect tab_contents_bounds_; - - // A scoped container for notification registries. - NotificationRegistrar registrar_; - - DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimation); -}; - -#endif // CHROME_BROWSER_VIEWS_DOWNLOAD_STARTED_ANIMATION_H_ diff --git a/chrome/browser/views/download_started_animation.cc b/chrome/browser/views/download_started_animation_win.cc index 3fddcd4..6ae160b 100644 --- a/chrome/browser/views/download_started_animation.cc +++ b/chrome/browser/views/download_started_animation_win.cc @@ -1,13 +1,17 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/views/download_started_animation.h" +#include "chrome/browser/download/download_started_animation.h" +#include "app/animation.h" #include "app/resource_bundle.h" +#include "base/gfx/rect.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" #include "grit/theme_resources.h" +#include "views/controls/image_view.h" #include "views/widget/widget_win.h" // How long to spend moving downwards and fading out after waiting. @@ -21,7 +25,55 @@ static const int kFrameRateHz = 60; // the frame. static const double kMoveFraction = 1.0 / 3.0; -DownloadStartedAnimation::DownloadStartedAnimation(TabContents* tab_contents) +namespace { + +// DownloadStartAnimation creates an animation (which begins running +// immediately) that animates an image downward from the center of the frame +// provided on the constructor, while simultaneously fading it out. To use, +// simply call "new DownloadStartAnimation"; the class cleans itself up when it +// finishes animating. +class DownloadStartedAnimationWin : public Animation, + public NotificationObserver, + public views::ImageView { + public: + DownloadStartedAnimationWin(TabContents* tab_contents); + + private: + // Move the animation to wherever it should currently be. + void Reposition(); + + // Shut down the animation cleanly. + void Close(); + + // Animation + virtual void AnimateToState(double state); + + // NotificationObserver + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + // We use a HWND for the popup so that it may float above any HWNDs in our UI. + views::WidgetWin* popup_; + + // The content area holding us. + TabContents* tab_contents_; + + // The content area at the start of the animation. We store this so that the + // download shelf's resizing of the content area doesn't cause the animation + // to move around. This means that once started, the animation won't move + // with the parent window, but it's so fast that this shouldn't cause too + // much heartbreak. + gfx::Rect tab_contents_bounds_; + + // A scoped container for notification registries. + NotificationRegistrar registrar_; + + DISALLOW_COPY_AND_ASSIGN(DownloadStartedAnimationWin); +}; + +DownloadStartedAnimationWin::DownloadStartedAnimationWin( + TabContents* tab_contents) : Animation(kMoveTimeMs, kFrameRateHz, NULL), popup_(NULL), tab_contents_(tab_contents) { @@ -62,7 +114,7 @@ DownloadStartedAnimation::DownloadStartedAnimation(TabContents* tab_contents) Start(); } -void DownloadStartedAnimation::Reposition() { +void DownloadStartedAnimationWin::Reposition() { if (!tab_contents_) return; @@ -77,7 +129,7 @@ void DownloadStartedAnimation::Reposition() { size.height()); } -void DownloadStartedAnimation::Close() { +void DownloadStartedAnimationWin::Close() { if (!tab_contents_) return; @@ -93,7 +145,7 @@ void DownloadStartedAnimation::Close() { popup_->Close(); } -void DownloadStartedAnimation::AnimateToState(double state) { +void DownloadStartedAnimationWin::AnimateToState(double state) { if (state >= 1.0) { Close(); } else { @@ -110,8 +162,17 @@ void DownloadStartedAnimation::AnimateToState(double state) { } } -void DownloadStartedAnimation::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { +void DownloadStartedAnimationWin::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { Close(); } + +} // namespace + +// static +void DownloadStartedAnimation::Show(TabContents* tab_contents) { + // The animation will delete itself when it's finished or when the tab + // contents is hidden or destroyed. + new DownloadStartedAnimationWin(tab_contents); +} |