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

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: rebase Created 8 years, 5 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
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..7627bb16a37f75106e346bebb75acc9e88ce6bfa 100644
--- a/chrome/browser/ui/search/toolbar_search_animator.h
+++ b/chrome/browser/ui/search/toolbar_search_animator.h
@@ -9,51 +9,42 @@
#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"
+#include "ui/base/animation/slide_animation.h"
class TabContents;
-namespace ui {
-class SlideAnimation;
-}
-
namespace chrome {
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
-// ToolbarSearchAnimatorObserver. The ToolbarSearchAnimatorObserver is then
-// notified appropriately.
+// ToolbarSearchAnimator is used to track the gradient background and separator
+// states 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;
+
+ // Get the toolbar separator opacity to paint, a value between 0f and 1f
+ // inclusive:
+ // - 0f: do not paint separator
+ // - < 1f: paint separator at specified opacity
+ // - 1f: paint separator at full opacity
+ double GetSeparatorOpacity() const;
// Called from SearchDelegate::StopObservingTab() when a tab is deactivated or
// closing or detached, to jump to the end state of the animation.
@@ -73,20 +64,21 @@ class ToolbarSearchAnimator : public SearchModelObserver,
virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
private:
- // State of animation.
+ // State of background or separator animation.
enum AnimateState {
ANIMATE_STATE_NONE, // Doing nothing.
- ANIMATE_STATE_WAITING, // Waiting to run background animation.
- ANIMATE_STATE_RUNNING, // Running background animation.
+ ANIMATE_STATE_WAITING, // Waiting to run animation.
+ ANIMATE_STATE_RUNNING, // Running animation.
};
// Callback for |background_change_timer_| to actually start the background
// change animation.
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
+ // Reset state of animator: reset all animate states, stop timer or
+ // animation(s).
+ // If we're waiting to animate or animating, i.e. animate state is not
+ // ANIMATE_STAET_NONE, we'll notify observers via
// ToolbarSearchAnimatorObserver::BackgroundChangeCanceled.
// Pass in |tab_contents| if animation is canceled because of deactivating or
// detaching or closing a tab.
@@ -95,16 +87,30 @@ class ToolbarSearchAnimator : public SearchModelObserver,
// Weak. Owned by Browser. Non-NULL.
SearchModel* search_model_;
- // State of animation.
- AnimateState animate_state_;
+ // State of background animation.
+ AnimateState background_animate_state_;
+
+ // State of separator animation.
+ AnimateState separator_animate_state_;
// The background fade animation.
- scoped_ptr<ui::SlideAnimation> background_animation_;
+ ui::SlideAnimation background_animation_;
+
+ // The separator fade animation.
+ ui::SlideAnimation separator_animation_;
// The timer to delay start of animation after mode changes from |MODE_NTP| to
// |MODE_SEARCH|.
base::OneShotTimer<ToolbarSearchAnimator> background_change_timer_;
+ // Mode that we're animating from.
+ Mode::Type from_mode_;
+ // Mode that we're animating to.
+ Mode::Type to_mode_;
+ // True if |from_mode_| and |to_mode_| have been intiialized via the very
+ // first ModeChanged method.
+ bool modes_initialized_;
+
// Observers.
ObserverList<ToolbarSearchAnimatorObserver> observers_;

Powered by Google App Engine
This is Rietveld 408576698