1 // Copyright (c) 2015 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.
5 #ifndef UI_GFX_PAINT_THROBBER_H_
6 #define UI_GFX_PAINT_THROBBER_H_
8 #include "base/basictypes.h"
9 #include "base/time/time.h"
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/gfx_export.h"
18 // This struct describes the "waiting" mode of a throb animation. It's useful
19 // for building a "spinning" state animation on top of a previous "waiting"
20 // mode animation. See PaintThrobberSpinningAfterWaiting.
21 struct GFX_EXPORT ThrobberWaitingState
{
22 // The amount of time that was spent in the waiting state.
23 base::TimeDelta elapsed_time
;
24 // The color of the arc in the waiting state.
26 // An opaque value used to cache calculations made by
27 // PaintThrobberSpinningAfterWaiting.
28 base::TimeDelta arc_time_offset
;
31 // Paints a single frame of the throbber in the "spinning", aka Material, state.
32 GFX_EXPORT
void PaintThrobberSpinning(Canvas
* canvas
,
33 const Rect
& bounds
, SkColor color
, const base::TimeDelta
& elapsed_time
);
35 // Paints a throbber in the "waiting" state. Used when waiting on a network
36 // response, for example.
37 GFX_EXPORT
void PaintThrobberWaiting(Canvas
* canvas
,
38 const Rect
& bounds
, SkColor color
, const base::TimeDelta
& elapsed_time
);
40 // Paint a throbber in the "spinning" state, smoothly transitioning from a
41 // previous "waiting" state described by |waiting_state|, which is an in-out
43 GFX_EXPORT
void PaintThrobberSpinningAfterWaiting(
47 const base::TimeDelta
& elapsed_time
,
48 ThrobberWaitingState
* waiting_state
);
50 // Paint a throbber in the "spinning" state, smoothly transitioning from a
51 // previous "waiting" state described by |final_waiting_frame|.
52 GFX_EXPORT
void PaintThrobberSpinningForFrameAfterWaiting(
57 SkColor waiting_color
,
58 uint32_t final_waiting_frame
);
62 #endif // UI_GFX_PAINT_THROBBER_H_