tdesktop/Telegram/SourceFiles/ui/effects/radial_animation.h

101 lines
1.7 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace style {
struct InfiniteRadialAnimation;
} // namespace style
namespace Ui {
2019-01-02 12:11:13 +00:00
struct RadialState {
float64 shown = 0.;
int arcFrom = 0;
int arcLength = FullArcLength;
};
class RadialAnimation {
public:
RadialAnimation(AnimationCallbacks &&callbacks);
float64 opacity() const {
return _opacity;
}
bool animating() const {
return _animation.animating();
}
void start(float64 prg);
bool update(float64 prg, bool finished, TimeMs ms);
void stop();
2016-12-01 19:20:33 +00:00
void step(TimeMs ms);
void step() {
step(getms());
}
2019-01-02 12:11:13 +00:00
void draw(
Painter &p,
const QRect &inner,
int32 thickness,
style::color color);
RadialState computeState();
private:
2016-12-01 19:20:33 +00:00
TimeMs _firstStart = 0;
TimeMs _lastStart = 0;
TimeMs _lastTime = 0;
float64 _opacity = 0.;
anim::value a_arcEnd;
anim::value a_arcStart;
BasicAnimation _animation;
2018-10-31 09:32:47 +00:00
bool _finished = false;
};
class InfiniteRadialAnimation {
public:
2018-05-04 16:57:50 +00:00
InfiniteRadialAnimation(
AnimationCallbacks &&callbacks,
const style::InfiniteRadialAnimation &st);
bool animating() const {
return _animation.animating();
}
void start();
void stop();
void step(TimeMs ms);
void step() {
step(getms());
}
void draw(
Painter &p,
QPoint position,
2018-05-04 16:57:50 +00:00
int outerWidth);
2018-05-07 17:44:33 +00:00
void draw(
Painter &p,
QPoint position,
QSize size,
int outerWidth);
2018-05-04 16:57:50 +00:00
2019-01-02 12:11:13 +00:00
RadialState computeState();
private:
2018-05-04 16:57:50 +00:00
const style::InfiniteRadialAnimation &_st;
TimeMs _workStarted = 0;
TimeMs _workFinished = 0;
BasicAnimation _animation;
};
} // namespace Ui