2016-09-28 10:15:03 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-09-28 10:15:03 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-09-28 10:15:03 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2018-05-03 15:05:18 +00:00
|
|
|
namespace style {
|
|
|
|
struct InfiniteRadialAnimation;
|
|
|
|
} // namespace style
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
namespace Ui {
|
|
|
|
|
2019-01-02 12:11:13 +00:00
|
|
|
struct RadialState {
|
|
|
|
float64 shown = 0.;
|
|
|
|
int arcFrom = 0;
|
|
|
|
int arcLength = FullArcLength;
|
|
|
|
};
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
class RadialAnimation {
|
|
|
|
public:
|
|
|
|
RadialAnimation(AnimationCallbacks &&callbacks);
|
|
|
|
|
|
|
|
float64 opacity() const {
|
|
|
|
return _opacity;
|
|
|
|
}
|
|
|
|
bool animating() const {
|
|
|
|
return _animation.animating();
|
|
|
|
}
|
|
|
|
|
|
|
|
void start(float64 prg);
|
2019-02-19 06:57:53 +00:00
|
|
|
bool update(float64 prg, bool finished, crl::time ms);
|
2016-09-28 10:15:03 +00:00
|
|
|
void stop();
|
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
void step(crl::time ms);
|
2016-09-28 10:15:03 +00:00
|
|
|
void step() {
|
2019-02-19 06:57:53 +00:00
|
|
|
step(crl::now());
|
2016-09-28 10:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-01-02 12:11:13 +00:00
|
|
|
void draw(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &inner,
|
|
|
|
int32 thickness,
|
|
|
|
style::color color);
|
|
|
|
|
|
|
|
RadialState computeState();
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
private:
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _firstStart = 0;
|
|
|
|
crl::time _lastStart = 0;
|
|
|
|
crl::time _lastTime = 0;
|
2016-09-28 10:15:03 +00:00
|
|
|
float64 _opacity = 0.;
|
2016-12-05 11:01:08 +00:00
|
|
|
anim::value a_arcEnd;
|
|
|
|
anim::value a_arcStart;
|
2016-12-07 13:32:25 +00:00
|
|
|
BasicAnimation _animation;
|
2018-10-31 09:32:47 +00:00
|
|
|
bool _finished = false;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-05-03 15:05:18 +00:00
|
|
|
class InfiniteRadialAnimation {
|
|
|
|
public:
|
2018-05-04 16:57:50 +00:00
|
|
|
InfiniteRadialAnimation(
|
|
|
|
AnimationCallbacks &&callbacks,
|
|
|
|
const style::InfiniteRadialAnimation &st);
|
2018-05-03 15:05:18 +00:00
|
|
|
|
|
|
|
bool animating() const {
|
|
|
|
return _animation.animating();
|
|
|
|
}
|
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
void start(crl::time skip = 0);
|
2019-03-01 11:16:55 +00:00
|
|
|
void stop(anim::type animated = anim::type::normal);
|
2018-05-03 15:05:18 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
void step(crl::time ms);
|
2018-05-03 15:05:18 +00:00
|
|
|
void step() {
|
2019-02-19 06:57:53 +00:00
|
|
|
step(crl::now());
|
2018-05-03 15:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2018-05-03 15:05:18 +00:00
|
|
|
|
|
|
|
private:
|
2018-05-04 16:57:50 +00:00
|
|
|
const style::InfiniteRadialAnimation &_st;
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _workStarted = 0;
|
|
|
|
crl::time _workFinished = 0;
|
2018-05-03 15:05:18 +00:00
|
|
|
BasicAnimation _animation;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
} // namespace Ui
|