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

Unified Diff: chrome/browser/ui/search/toolbar_search_animator.h

Issue 10816027: alternate ntp: toolbar background and separator animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android build break Created 8 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 | « chrome/browser/ui/search/search_tab_helper.cc ('k') | chrome/browser/ui/search/toolbar_search_animator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/toolbar_search_animator.h
diff --git a/chrome/browser/ui/search/toolbar_search_animator.h b/chrome/browser/ui/search/toolbar_search_animator.h
index 6041cf89da3004acf61c28562284ff9fc6a5aced..261ccc47e6f832e45c1cfe43ae53973ad29722fd 100644
--- a/chrome/browser/ui/search/toolbar_search_animator.h
+++ b/chrome/browser/ui/search/toolbar_search_animator.h
@@ -7,14 +7,14 @@
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
-#include "base/timer.h"
#include "chrome/browser/ui/search/search_model_observer.h"
+#include "chrome/browser/ui/search/search_types.h"
#include "ui/base/animation/animation_delegate.h"
class TabContents;
namespace ui {
-class SlideAnimation;
+class MultiAnimation;
}
namespace chrome {
@@ -23,37 +23,23 @@ namespace search {
class SearchModel;
class ToolbarSearchAnimatorObserver;
-// ToolbarSearchAnimator is used to track the background state of the toolbar
-// and related classes. To use ToolbarSearchAnimator, add a
+// ToolbarSearchAnimator is used to track the gradient background state of the
+// toolbar and related classes. To use ToolbarSearchAnimator, add a
// ToolbarSearchAnimatorObserver. The ToolbarSearchAnimatorObserver is then
// notified appropriately.
class ToolbarSearchAnimator : public SearchModelObserver,
public ui::AnimationDelegate {
public:
- // State of background to paint by observers, only applicable for
- // |MODE_SEARCH|.
- enum BackgroundState {
- // Background state is not applicable.
- BACKGROUND_STATE_DEFAULT = 0,
- // Show background for |MODE_NTP|.
- BACKGROUND_STATE_NTP = 0x01,
- // Show background for |MODE_SEARCH|.
- BACKGROUND_STATE_SEARCH = 0x02,
- // Show backgrounds for both |MODE_NTP| and |MODE_SEARCH|.
- BACKGROUND_STATE_NTP_SEARCH = BACKGROUND_STATE_NTP |
- BACKGROUND_STATE_SEARCH,
- };
-
explicit ToolbarSearchAnimator(SearchModel* search_model);
virtual ~ToolbarSearchAnimator();
- // Get the current background state to paint.
- // |search_background_opacity| contains a valid opacity value only if
- // background for |MODE_SEARCH| needs to be shown i.e. |background_state| is
- // BACKGROUND_STATE_SEARCH or BACKGROUND_STATE_NTP_SEARCH.
- // Only call this for |MODE_SEARCH|.
- void GetCurrentBackgroundState(BackgroundState* background_state,
- double* search_background_opacity) const;
+ // Get the gradient background opacity to paint for toolbar and active tab, a
+ // value between 0f and 1f inclusive:
+ // - 0f: only paint flat background
+ // - < 1f: paint flat background at full opacity and gradient background at
+ // specified opacity
+ // - 1f: only paint gradient background at full opacity
+ double GetGradientOpacity() const;
// Called from SearchDelegate::StopObservingTab() when a tab is deactivated or
// closing or detached, to jump to the end state of the animation.
@@ -66,28 +52,27 @@ class ToolbarSearchAnimator : public SearchModelObserver,
void RemoveObserver(ToolbarSearchAnimatorObserver* observer);
// Overridden from SearchModelObserver:
- virtual void ModeChanged(const Mode& mode) OVERRIDE;
+ virtual void ModeChanged(const Mode& old_mode, const Mode& new_mode) OVERRIDE;
// Overridden from ui::AnimationDelegate:
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
private:
- // State of animation.
- enum AnimateState {
- ANIMATE_STATE_NONE, // Doing nothing.
- ANIMATE_STATE_WAITING, // Waiting to run background animation.
- ANIMATE_STATE_RUNNING, // Running background animation.
- };
-
- // Callback for |background_change_timer_| to actually start the background
- // change animation.
+ friend class ToolbarSearchAnimatorTest;
+ friend class ToolbarSearchAnimatorTestObserver;
+
+ // Helper function to initialize background animation with its parts.
+ void InitBackgroundAnimation();
+
+ // Helper function to start animation for gradient background change.
void StartBackgroundChange();
- // Reset state of animator: reset animate_state_, stop timer or animation,
- // If we're waiting to animate or animating, i.e. |animate_state| is not
- // ANIMATE_STAET_NONE, wwe'll notify observers via
- // ToolbarSearchAnimatorObserver::BackgroundChangeCanceled.
+ // Reset animations by stopping them.
+ // If we're animating background or separator, we'll notify observers via
+ // ToolbarSearchAnimatorObserver::OnToolbarBackgroundAnimatorCanceled or
+ // ToolbarSearchAnimatorObserver::OnToolbarSeparatorAnimatorCanceled
+ // respectively.
// Pass in |tab_contents| if animation is canceled because of deactivating or
// detaching or closing a tab.
void Reset(TabContents* tab_contents);
@@ -95,15 +80,12 @@ class ToolbarSearchAnimator : public SearchModelObserver,
// Weak. Owned by Browser. Non-NULL.
SearchModel* search_model_;
- // State of animation.
- AnimateState animate_state_;
-
- // The background fade animation.
- scoped_ptr<ui::SlideAnimation> background_animation_;
+ // The background change animation.
+ scoped_ptr<ui::MultiAnimation> background_animation_;
- // The timer to delay start of animation after mode changes from |MODE_NTP| to
- // |MODE_SEARCH|.
- base::OneShotTimer<ToolbarSearchAnimator> background_change_timer_;
+ // Time (in ms) of background animation delay and duration.
+ int background_change_delay_ms_;
+ int background_change_duration_ms_;
// Observers.
ObserverList<ToolbarSearchAnimatorObserver> observers_;
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | chrome/browser/ui/search/toolbar_search_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698