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

Unified Diff: cc/top_controls_animation.h

Issue 11552009: Add support for calculating the position of the top controls in the cc layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove some unnecessary bits after addressing comments. Created 8 years 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: cc/top_controls_animation.h
diff --git a/cc/top_controls_animation.h b/cc/top_controls_animation.h
new file mode 100644
index 0000000000000000000000000000000000000000..dc9c122de01139e6d06897628b6ee7abe9dbaafe
--- /dev/null
+++ b/cc/top_controls_animation.h
@@ -0,0 +1,56 @@
+// Copyright 2012 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 CC_TOP_CONTROLS_ANIMATION_H_
+#define CC_TOP_CONTROLS_ANIMATION_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/time.h"
+#include "ui/gfx/size.h"
+#include "ui/gfx/vector2d_f.h"
+
+namespace cc {
+
+class TimingFunction;
+
+// A small helper class that does the math for animations pertaining to the
+// position of the top controls.
+//
+// All sizes and vectors in this class's public methods are in the root scroll
+// layer's coordinate space.
+class TopControlsAnimation {
+ public:
+ // Construct with the state at the beginning of the animation.
+ static scoped_ptr<TopControlsAnimation> Create(float start_y_offset,
+ float top_controls_height,
+ base::TimeTicks start_time,
+ base::TimeDelta max_duration);
+
+ ~TopControlsAnimation();
+
+ void SetDirection(bool showing);
+
+ // Call these functions while the animation is in progress to output the
+ // current state.
+ float ScrollOffsetAtTime(base::TimeTicks time) const;
+ bool IsAnimationCompleteAtTime(base::TimeTicks time) const;
+
+ protected:
+ TopControlsAnimation(float start_y_offset,
+ float top_controls_height,
+ base::TimeTicks start_time,
+ base::TimeDelta max_duration);
+
+ private:
+ scoped_ptr<TimingFunction> timing_function_;
+ const float top_controls_height_;
+ const float start_y_offset_;
+ const base::TimeTicks start_time_;
+ const base::TimeDelta max_duration_;
+ int direction_;
+};
+
+} // namespace cc
+
+#endif // CC_TOP_CONTROLS_ANIMATION_H_

Powered by Google App Engine
This is Rietveld 408576698