2017-09-13 17:01:23 +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.
|
2017-09-13 17:01:23 +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
|
2017-09-13 17:01:23 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/rp_widget.h"
|
2019-03-07 11:35:28 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "styles/style_widgets.h"
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
namespace Ui {
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
class FadeAnimation {
|
2017-09-13 17:01:23 +00:00
|
|
|
public:
|
2017-11-27 11:43:57 +00:00
|
|
|
FadeAnimation(TWidget *widget, float64 scale = 1.);
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
bool paint(Painter &p);
|
|
|
|
void refreshCache();
|
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
using FinishedCallback = Fn<void()>;
|
2017-09-30 18:26:45 +00:00
|
|
|
void setFinishedCallback(FinishedCallback &&callback);
|
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
using UpdatedCallback = Fn<void(float64)>;
|
2017-09-30 18:26:45 +00:00
|
|
|
void setUpdatedCallback(UpdatedCallback &&callback);
|
|
|
|
|
|
|
|
void show();
|
|
|
|
void hide();
|
|
|
|
|
|
|
|
void fadeIn(int duration);
|
|
|
|
void fadeOut(int duration);
|
|
|
|
|
|
|
|
void finish() {
|
|
|
|
stopAnimation();
|
2017-09-13 17:01:23 +00:00
|
|
|
}
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
bool animating() const {
|
|
|
|
return _animation.animating();
|
|
|
|
}
|
|
|
|
bool visible() const {
|
|
|
|
return _visible;
|
2017-09-13 17:01:23 +00:00
|
|
|
}
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
private:
|
|
|
|
void startAnimation(int duration);
|
|
|
|
void stopAnimation();
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
void updateCallback();
|
|
|
|
QPixmap grabContent();
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
TWidget *_widget = nullptr;
|
2017-11-27 11:43:57 +00:00
|
|
|
float64 _scale = 1.;
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2019-03-07 11:35:28 +00:00
|
|
|
Ui::Animations::Simple _animation;
|
2017-09-30 18:26:45 +00:00
|
|
|
QSize _size;
|
|
|
|
QPixmap _cache;
|
|
|
|
bool _visible = false;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
FinishedCallback _finishedCallback;
|
|
|
|
UpdatedCallback _updatedCallback;
|
2017-09-13 17:01:23 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
} // namespace Ui
|