2016-12-01 19:20:33 +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-12-01 19:20:33 +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-12-01 19:20:33 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2020-07-06 09:58:18 +00:00
|
|
|
namespace Api {
|
|
|
|
enum class SendProgressType;
|
|
|
|
} // namespace Api
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
class SendActionAnimation {
|
|
|
|
public:
|
2020-07-06 09:58:18 +00:00
|
|
|
using Type = Api::SendProgressType;
|
2016-12-01 19:20:33 +00:00
|
|
|
|
|
|
|
void start(Type type);
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
int width() const {
|
|
|
|
return _impl ? _impl->width() : 0;
|
|
|
|
}
|
2019-02-19 06:57:53 +00:00
|
|
|
void paint(Painter &p, style::color color, int x, int y, int outerWidth, crl::time ms) {
|
2016-12-01 19:20:33 +00:00
|
|
|
if (_impl) {
|
|
|
|
_impl->paint(p, color, x, y, outerWidth, ms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit operator bool() const {
|
|
|
|
return _impl != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Impl {
|
|
|
|
public:
|
2020-07-06 09:58:18 +00:00
|
|
|
using Type = Api::SendProgressType;
|
2016-12-01 19:20:33 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
Impl(int period) : _period(period), _started(crl::now()) {
|
2016-12-01 19:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct MetaData {
|
|
|
|
int index;
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<Impl> (*creator)();
|
2016-12-01 19:20:33 +00:00
|
|
|
};
|
|
|
|
virtual const MetaData *metaData() const = 0;
|
|
|
|
bool supports(Type type) const;
|
|
|
|
|
|
|
|
virtual int width() const = 0;
|
2018-09-20 16:39:59 +00:00
|
|
|
void paint(
|
|
|
|
Painter &p,
|
|
|
|
style::color color,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time ms);
|
2016-12-01 19:20:33 +00:00
|
|
|
|
2016-12-04 19:40:41 +00:00
|
|
|
virtual ~Impl() = default;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
private:
|
2016-12-23 13:21:01 +00:00
|
|
|
virtual void paintFrame(Painter &p, style::color color, int x, int y, int outerWidth, int frameMs) = 0;
|
2016-12-01 19:20:33 +00:00
|
|
|
|
|
|
|
int _period = 1;
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _started = 0;
|
2016-12-01 19:20:33 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-12-04 19:40:41 +00:00
|
|
|
~SendActionAnimation();
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
private:
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<Impl> createByType(Type type);
|
2016-12-01 19:20:33 +00:00
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<Impl> _impl;
|
2016-12-01 19:20:33 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Ui
|