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

Side by Side Diff: content/browser/android/edge_effect_base.h

Issue 1419123002: android: move overscroll effects to ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix exports for component build Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « content/browser/android/edge_effect.cc ('k') | content/browser/android/edge_effect_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_ANDROID_EDGE_EFFECT_BASE_H_
6 #define CONTENT_BROWSER_ANDROID_EDGE_EFFECT_BASE_H_
7
8 #include "base/basictypes.h"
9 #include "base/time/time.h"
10 #include "ui/gfx/geometry/size_f.h"
11 #include "ui/gfx/transform.h"
12
13 namespace cc {
14 class Layer;
15 }
16
17 namespace content {
18
19 // A base class for overscroll-related Android effects.
20 class EdgeEffectBase {
21 public:
22 enum State {
23 STATE_IDLE = 0,
24 STATE_PULL,
25 STATE_ABSORB,
26 STATE_RECEDE,
27 STATE_PULL_DECAY
28 };
29
30 enum Edge { EDGE_TOP, EDGE_LEFT, EDGE_BOTTOM, EDGE_RIGHT, EDGE_COUNT };
31
32 virtual ~EdgeEffectBase() {}
33
34 virtual void Pull(base::TimeTicks current_time,
35 float delta_distance,
36 float displacement) = 0;
37 virtual void Absorb(base::TimeTicks current_time, float velocity) = 0;
38 virtual bool Update(base::TimeTicks current_time) = 0;
39 virtual void Release(base::TimeTicks current_time) = 0;
40
41 virtual void Finish() = 0;
42 virtual bool IsFinished() const = 0;
43 virtual float GetAlpha() const = 0;
44
45 virtual void ApplyToLayers(Edge edge,
46 const gfx::SizeF& viewport_size,
47 float offset) = 0;
48 virtual void SetParent(cc::Layer* parent) = 0;
49
50 protected:
51 // Computes the transform for an edge effect given the |edge|, |viewport_size|
52 // and edge |offset|. This assumes the the effect transform anchor is at the
53 // centered edge of the effect.
54 static gfx::Transform ComputeTransform(Edge edge,
55 const gfx::SizeF& viewport_size,
56 float offset);
57
58 // Computes the maximum effect size relative to the screen |edge|. For
59 // top/bottom edges, thsi is simply |viewport_size|, while for left/right
60 // edges this is |viewport_size| with coordinates swapped.
61 static gfx::SizeF ComputeOrientedSize(Edge edge,
62 const gfx::SizeF& viewport_size);
63 };
64
65 } // namespace content
66
67 #endif // CONTENT_BROWSER_ANDROID_EDGE_EFFECT_BASE_H_
OLDNEW
« no previous file with comments | « content/browser/android/edge_effect.cc ('k') | content/browser/android/edge_effect_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698