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
|
|
|
|
|
2019-04-01 17:44:54 +00:00
|
|
|
#include "ui/effects/animations.h"
|
|
|
|
|
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:
|
2019-04-01 17:44:54 +00:00
|
|
|
template <typename Callback>
|
|
|
|
RadialAnimation(Callback &&callback);
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
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-01-02 12:11:13 +00:00
|
|
|
void draw(
|
|
|
|
Painter &p,
|
|
|
|
const QRect &inner,
|
|
|
|
int32 thickness,
|
2019-03-11 09:51:15 +00:00
|
|
|
style::color color) const;
|
2019-01-02 12:11:13 +00:00
|
|
|
|
2019-03-11 09:51:15 +00:00
|
|
|
RadialState computeState() const;
|
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.;
|
2019-04-01 17:44:54 +00:00
|
|
|
anim::value _arcEnd;
|
|
|
|
anim::value _arcStart;
|
|
|
|
Ui::Animations::Basic _animation;
|
2018-10-31 09:32:47 +00:00
|
|
|
bool _finished = false;
|
2016-09-28 10:15:03 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-04-01 17:44:54 +00:00
|
|
|
template <typename Callback>
|
|
|
|
inline RadialAnimation::RadialAnimation(Callback &&callback)
|
|
|
|
: _arcStart(0, FullArcLength)
|
|
|
|
, _animation(std::forward<Callback>(callback)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-03 15:05:18 +00:00
|
|
|
class InfiniteRadialAnimation {
|
|
|
|
public:
|
2019-04-01 17:44:54 +00:00
|
|
|
template <typename Callback>
|
2018-05-04 16:57:50 +00:00
|
|
|
InfiniteRadialAnimation(
|
2019-04-01 17:44:54 +00:00
|
|
|
Callback &&callback,
|
2018-05-04 16:57:50 +00:00
|
|
|
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
|
|
|
|
|
|
|
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;
|
2019-04-01 17:44:54 +00:00
|
|
|
Ui::Animations::Basic _animation;
|
2018-05-03 15:05:18 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-04-01 17:44:54 +00:00
|
|
|
template <typename Callback>
|
|
|
|
inline InfiniteRadialAnimation::InfiniteRadialAnimation(
|
|
|
|
Callback &&callback,
|
|
|
|
const style::InfiniteRadialAnimation &st)
|
|
|
|
: _st(st)
|
|
|
|
, _animation(std::forward<Callback>(callback)) {
|
|
|
|
}
|
|
|
|
|
2016-09-28 10:15:03 +00:00
|
|
|
} // namespace Ui
|