mirror of https://github.com/procxx/kepka.git
Animate check in album sending.
This commit is contained in:
parent
8eb0f3b60a
commit
e6c4c48261
|
@ -125,6 +125,28 @@ std::vector<std::unique_ptr<Data::Media>> PrepareCollageMedia(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaintInterpolatedIcon(
|
||||||
|
Painter &p,
|
||||||
|
const style::icon &a,
|
||||||
|
const style::icon &b,
|
||||||
|
float64 b_ratio,
|
||||||
|
QRect rect) {
|
||||||
|
PainterHighQualityEnabler hq(p);
|
||||||
|
p.save();
|
||||||
|
p.translate(rect.center());
|
||||||
|
p.setOpacity(b_ratio);
|
||||||
|
p.scale(b_ratio, b_ratio);
|
||||||
|
b.paintInCenter(p, rect.translated(-rect.center()));
|
||||||
|
p.restore();
|
||||||
|
|
||||||
|
p.save();
|
||||||
|
p.translate(rect.center());
|
||||||
|
p.setOpacity(1. - b_ratio);
|
||||||
|
p.scale(1. - b_ratio, 1. - b_ratio);
|
||||||
|
a.paintInCenter(p, rect.translated(-rect.center()));
|
||||||
|
p.restore();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
QString FillAmountAndCurrency(uint64 amount, const QString ¤cy) {
|
QString FillAmountAndCurrency(uint64 amount, const QString ¤cy) {
|
||||||
|
@ -488,7 +510,8 @@ void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, Tim
|
||||||
p.setOpacity(radialOpacity);
|
p.setOpacity(radialOpacity);
|
||||||
auto icon = ([radial, this, selected]() -> const style::icon* {
|
auto icon = ([radial, this, selected]() -> const style::icon* {
|
||||||
if (radial || _data->loading()) {
|
if (radial || _data->loading()) {
|
||||||
if (!_data->full->location().isNull()) {
|
if (_data->uploading()
|
||||||
|
|| !_data->full->location().isNull()) {
|
||||||
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
|
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -625,9 +648,12 @@ void HistoryPhoto::drawGrouped(
|
||||||
|| (!loaded && !_data->loading())
|
|| (!loaded && !_data->loading())
|
||||||
|| _data->waitingForAlbum();
|
|| _data->waitingForAlbum();
|
||||||
if (displayState) {
|
if (displayState) {
|
||||||
const auto radialOpacity = (radial && loaded && !_data->uploading())
|
const auto radialOpacity = radial
|
||||||
? _animation->radial.opacity()
|
? _animation->radial.opacity()
|
||||||
: 1.;
|
: 1.;
|
||||||
|
const auto backOpacity = (loaded && !_data->uploading())
|
||||||
|
? radialOpacity
|
||||||
|
: 1.;
|
||||||
const auto radialSize = st::historyGroupRadialSize;
|
const auto radialSize = st::historyGroupRadialSize;
|
||||||
const auto inner = QRect(
|
const auto inner = QRect(
|
||||||
geometry.x() + (geometry.width() - radialSize) / 2,
|
geometry.x() + (geometry.width() - radialSize) / 2,
|
||||||
|
@ -645,27 +671,37 @@ void HistoryPhoto::drawGrouped(
|
||||||
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg);
|
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setOpacity(radialOpacity * p.opacity());
|
p.setOpacity(backOpacity * p.opacity());
|
||||||
|
|
||||||
{
|
{
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
p.drawEllipse(inner);
|
p.drawEllipse(inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setOpacity(radialOpacity);
|
const auto icon = [&]() -> const style::icon* {
|
||||||
auto icon = [&]() -> const style::icon* {
|
|
||||||
if (_data->waitingForAlbum()) {
|
if (_data->waitingForAlbum()) {
|
||||||
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting);
|
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting);
|
||||||
} else if (radial || _data->loading()) {
|
} else if (radial || _data->loading()) {
|
||||||
if (!_data->full->location().isNull()) {
|
if (_data->uploading() || !_data->full->location().isNull()) {
|
||||||
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
|
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
|
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
|
||||||
}();
|
}();
|
||||||
|
const auto previous = [&]() -> const style::icon* {
|
||||||
|
if (_data->waitingForAlbum()) {
|
||||||
|
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}();
|
||||||
|
p.setOpacity(backOpacity);
|
||||||
if (icon) {
|
if (icon) {
|
||||||
icon->paintInCenter(p, inner);
|
if (previous && radialOpacity > 0. && radialOpacity < 1.) {
|
||||||
|
PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner);
|
||||||
|
} else {
|
||||||
|
icon->paintInCenter(p, inner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p.setOpacity(1);
|
p.setOpacity(1);
|
||||||
if (radial) {
|
if (radial) {
|
||||||
|
@ -1082,9 +1118,12 @@ void HistoryVideo::drawGrouped(
|
||||||
App::complexOverlayRect(p, geometry, roundRadius, corners);
|
App::complexOverlayRect(p, geometry, roundRadius, corners);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto radialOpacity = (radial && loaded && !_data->uploading())
|
const auto radialOpacity = radial
|
||||||
? _animation->radial.opacity()
|
? _animation->radial.opacity()
|
||||||
: 1.;
|
: 1.;
|
||||||
|
const auto backOpacity = (loaded && !_data->uploading())
|
||||||
|
? radialOpacity
|
||||||
|
: 1.;
|
||||||
const auto radialSize = st::historyGroupRadialSize;
|
const auto radialSize = st::historyGroupRadialSize;
|
||||||
const auto inner = QRect(
|
const auto inner = QRect(
|
||||||
geometry.x() + (geometry.width() - radialSize) / 2,
|
geometry.x() + (geometry.width() - radialSize) / 2,
|
||||||
|
@ -1102,14 +1141,13 @@ void HistoryVideo::drawGrouped(
|
||||||
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg);
|
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setOpacity(radialOpacity * p.opacity());
|
p.setOpacity(backOpacity * p.opacity());
|
||||||
|
|
||||||
{
|
{
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
p.drawEllipse(inner);
|
p.drawEllipse(inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setOpacity(radialOpacity);
|
|
||||||
auto icon = [&]() -> const style::icon * {
|
auto icon = [&]() -> const style::icon * {
|
||||||
if (_data->waitingForAlbum()) {
|
if (_data->waitingForAlbum()) {
|
||||||
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting);
|
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting);
|
||||||
|
@ -1123,8 +1161,20 @@ void HistoryVideo::drawGrouped(
|
||||||
}
|
}
|
||||||
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
|
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
|
||||||
}();
|
}();
|
||||||
|
const auto previous = [&]() -> const style::icon* {
|
||||||
|
if (_data->waitingForAlbum()) {
|
||||||
|
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}();
|
||||||
|
p.setOpacity(backOpacity);
|
||||||
if (icon) {
|
if (icon) {
|
||||||
icon->paintInCenter(p, inner);
|
if (previous && radialOpacity > 0. && radialOpacity < 1.) {
|
||||||
|
LOG(("INTERPOLATING: %1").arg(radialOpacity));
|
||||||
|
PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner);
|
||||||
|
} else {
|
||||||
|
icon->paintInCenter(p, inner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p.setOpacity(1);
|
p.setOpacity(1);
|
||||||
if (radial) {
|
if (radial) {
|
||||||
|
|
|
@ -26,15 +26,22 @@ void RadialAnimation::start(float64 prg) {
|
||||||
bool RadialAnimation::update(float64 prg, bool finished, TimeMs ms) {
|
bool RadialAnimation::update(float64 prg, bool finished, TimeMs ms) {
|
||||||
const auto iprg = qRound(qMax(prg, 0.0001) * AlmostFullArcLength);
|
const auto iprg = qRound(qMax(prg, 0.0001) * AlmostFullArcLength);
|
||||||
const auto result = (iprg != qRound(a_arcEnd.to()));
|
const auto result = (iprg != qRound(a_arcEnd.to()));
|
||||||
if (result) {
|
if (_finished != finished) {
|
||||||
|
a_arcEnd.start(iprg);
|
||||||
|
_finished = finished;
|
||||||
|
_lastStart = _lastTime;
|
||||||
|
} else if (result) {
|
||||||
a_arcEnd.start(iprg);
|
a_arcEnd.start(iprg);
|
||||||
_lastStart = _lastTime;
|
_lastStart = _lastTime;
|
||||||
}
|
}
|
||||||
_lastTime = ms;
|
_lastTime = ms;
|
||||||
|
|
||||||
auto dt = float64(ms - _lastStart);
|
const auto dt = float64(ms - _lastStart);
|
||||||
auto fulldt = float64(ms - _firstStart);
|
const auto fulldt = float64(ms - _firstStart);
|
||||||
_opacity = qMin(fulldt / st::radialDuration, 1.);
|
const auto opacitydt = _finished
|
||||||
|
? (_lastStart - _firstStart)
|
||||||
|
: fulldt;
|
||||||
|
_opacity = qMin(opacitydt / st::radialDuration, 1.);
|
||||||
if (anim::Disabled()) {
|
if (anim::Disabled()) {
|
||||||
a_arcEnd.update(1., anim::linear);
|
a_arcEnd.update(1., anim::linear);
|
||||||
if (finished) {
|
if (finished) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ private:
|
||||||
anim::value a_arcEnd;
|
anim::value a_arcEnd;
|
||||||
anim::value a_arcStart;
|
anim::value a_arcStart;
|
||||||
BasicAnimation _animation;
|
BasicAnimation _animation;
|
||||||
|
bool _finished = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue