forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththrob_animation.h
70 lines (52 loc) · 2.24 KB
/
throb_animation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 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 UI_GFX_ANIMATION_THROB_ANIMATION_H_
#define UI_GFX_ANIMATION_THROB_ANIMATION_H_
#include "base/macros.h"
#include "ui/gfx/animation/slide_animation.h"
namespace gfx {
// A subclass of SlideAnimation that can continually slide. All of the Animation
// methods behave like that of SlideAnimation: transition to the next state.
// The StartThrobbing method causes the ThrobAnimation to cycle between hidden
// and shown for a set number of cycles.
//
// A ThrobAnimation has two durations: the duration used when behavior like
// a SlideAnimation, and the duration used when throbbing.
class ANIMATION_EXPORT ThrobAnimation : public SlideAnimation {
public:
explicit ThrobAnimation(AnimationDelegate* target);
~ThrobAnimation() override {}
// Starts throbbing. cycles_til_stop gives the number of cycles to do before
// stopping. A negative value means "throb indefinitely".
void StartThrobbing(int cycles_til_stop);
// Sets the duration of the slide animation when throbbing.
void SetThrobDuration(int duration) { throb_duration_ = duration; }
// Overridden to reset to the slide duration.
void Reset() override;
void Reset(double value) override;
void Show() override;
void Hide() override;
// Overridden to maintain the slide duration.
void SetSlideDuration(int duration) override;
// The number of cycles remaining until the animation stops.
void set_cycles_remaining(int value) { cycles_remaining_ = value; }
int cycles_remaining() const { return cycles_remaining_; }
protected:
// Overriden to continually throb (assuming we're throbbing).
void Step(base::TimeTicks time_now) override;
private:
// Resets state such that we behave like SlideAnimation.
void ResetForSlide();
// Duration of the slide animation.
int slide_duration_;
// Duration of the slide animation when throbbing.
int throb_duration_;
// If throbbing, this is the number of cycles left.
int cycles_remaining_;
// Are we throbbing?
bool throbbing_;
DISALLOW_COPY_AND_ASSIGN(ThrobAnimation);
};
} // namespace gfx
#endif // UI_GFX_ANIMATION_THROB_ANIMATION_H_