Show radial progress in PeerShortInfoBox video.
This commit is contained in:
parent
9f21da8bde
commit
d73d5724d8
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/peers/peer_short_info_box.h"
|
#include "boxes/peers/peer_short_info_box.h"
|
||||||
|
|
||||||
|
#include "ui/effects/radial_animation.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
@ -36,6 +37,17 @@ struct PeerShortInfoBox::CustomLabelStyle {
|
||||||
float64 opacity = 1.;
|
float64 opacity = 1.;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PeerShortInfoBox::Radial {
|
||||||
|
explicit Radial(Fn<void()> &&callback);
|
||||||
|
|
||||||
|
Ui::RadialAnimation radial;
|
||||||
|
base::Timer removeTimer;
|
||||||
|
};
|
||||||
|
|
||||||
|
PeerShortInfoBox::Radial::Radial(Fn<void()> &&callback)
|
||||||
|
: radial(callback) {
|
||||||
|
}
|
||||||
|
|
||||||
PeerShortInfoBox::CustomLabelStyle::CustomLabelStyle(
|
PeerShortInfoBox::CustomLabelStyle::CustomLabelStyle(
|
||||||
const style::FlatLabel &original)
|
const style::FlatLabel &original)
|
||||||
: textFg([=, c = original.textFg]{
|
: textFg([=, c = original.textFg]{
|
||||||
|
@ -259,6 +271,7 @@ void PeerShortInfoBox::paintCover(QPainter &p) {
|
||||||
paintCoverImage(p, frame.isNull() ? _userpicImage : frame);
|
paintCoverImage(p, frame.isNull() ? _userpicImage : frame);
|
||||||
paintBars(p);
|
paintBars(p);
|
||||||
paintShadow(p);
|
paintShadow(p);
|
||||||
|
paintRadial(p);
|
||||||
if (_videoInstance && _videoInstance->ready() && !paused) {
|
if (_videoInstance && _videoInstance->ready() && !paused) {
|
||||||
_videoInstance->markFrameShown();
|
_videoInstance->markFrameShown();
|
||||||
}
|
}
|
||||||
|
@ -437,6 +450,31 @@ void PeerShortInfoBox::paintShadow(QPainter &p) {
|
||||||
p.setOpacity(1.);
|
p.setOpacity(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PeerShortInfoBox::paintRadial(QPainter &p) {
|
||||||
|
const auto radial = radialRect();
|
||||||
|
if (_videoInstance && _videoInstance->waitingShown()) {
|
||||||
|
const auto line = st::shortInfoRadialAnimation.thickness;
|
||||||
|
const auto arc = radial.marginsRemoved(
|
||||||
|
{ line, line, line, line });
|
||||||
|
p.setOpacity(_videoInstance->waitingOpacity());
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.setBrush(st::radialBg);
|
||||||
|
{
|
||||||
|
PainterHighQualityEnabler hq(p);
|
||||||
|
p.drawEllipse(radial);
|
||||||
|
}
|
||||||
|
p.setOpacity(1.);
|
||||||
|
Ui::InfiniteRadialAnimation::Draw(
|
||||||
|
p,
|
||||||
|
_videoInstance->waitingState(),
|
||||||
|
arc.topLeft(),
|
||||||
|
arc.size(),
|
||||||
|
st::shortInfoWidth,
|
||||||
|
st::radialFg,
|
||||||
|
line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QImage PeerShortInfoBox::currentVideoFrame() const {
|
QImage PeerShortInfoBox::currentVideoFrame() const {
|
||||||
const auto coverSize = st::shortInfoWidth;
|
const auto coverSize = st::shortInfoWidth;
|
||||||
const auto size = QSize(coverSize, coverSize);
|
const auto size = QSize(coverSize, coverSize);
|
||||||
|
@ -631,11 +669,16 @@ void PeerShortInfoBox::refreshBarImages() {
|
||||||
|
|
||||||
QRect PeerShortInfoBox::radialRect() const {
|
QRect PeerShortInfoBox::radialRect() const {
|
||||||
const auto cover = _cover->rect();
|
const auto cover = _cover->rect();
|
||||||
return cover;
|
const auto size = st::boxLoadingSize;
|
||||||
|
return QRect(
|
||||||
|
cover.x() + (cover.width() - size) / 2,
|
||||||
|
cover.y() + (cover.height() - size) / 2,
|
||||||
|
size,
|
||||||
|
size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerShortInfoBox::videoWaiting() {
|
void PeerShortInfoBox::videoWaiting() {
|
||||||
if (!anim::Disabled()) {
|
if (!anim::Disabled()) {
|
||||||
update(radialRect());
|
_cover->update(radialRect());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CustomLabelStyle;
|
struct CustomLabelStyle;
|
||||||
|
struct Radial;
|
||||||
|
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
void prepareRows();
|
void prepareRows();
|
||||||
|
@ -74,6 +75,7 @@ private:
|
||||||
void paintCoverImage(QPainter &p, const QImage &image);
|
void paintCoverImage(QPainter &p, const QImage &image);
|
||||||
void paintBars(QPainter &p);
|
void paintBars(QPainter &p);
|
||||||
void paintShadow(QPainter &p);
|
void paintShadow(QPainter &p);
|
||||||
|
void paintRadial(QPainter &p);
|
||||||
|
|
||||||
void refreshRoundedTopImage(const QColor &color);
|
void refreshRoundedTopImage(const QColor &color);
|
||||||
int fillRoundedTopHeight();
|
int fillRoundedTopHeight();
|
||||||
|
@ -132,6 +134,8 @@ private:
|
||||||
Fn<bool()> _videoPaused;
|
Fn<bool()> _videoPaused;
|
||||||
QImage _shadowBottom;
|
QImage _shadowBottom;
|
||||||
|
|
||||||
|
std::unique_ptr<Radial> _radial;
|
||||||
|
|
||||||
rpl::event_stream<> _openRequests;
|
rpl::event_stream<> _openRequests;
|
||||||
rpl::event_stream<int> _moveRequests;
|
rpl::event_stream<int> _moveRequests;
|
||||||
|
|
||||||
|
|
|
@ -984,3 +984,8 @@ shortInfoScroll: ScrollArea(defaultScrollArea) {
|
||||||
duration: 150;
|
duration: 150;
|
||||||
hiding: 1000;
|
hiding: 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shortInfoRadialAnimation: InfiniteRadialAnimation(defaultInfiniteRadialAnimation) {
|
||||||
|
color: radialFg;
|
||||||
|
thickness: 2px;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue