mirror of https://github.com/procxx/kepka.git
Fix radial animations in emoji download.
This commit is contained in:
parent
75de655642
commit
3c5f8d08ad
|
@ -127,6 +127,7 @@ private:
|
||||||
void setupHandler();
|
void setupHandler();
|
||||||
void load();
|
void load();
|
||||||
void radialAnimationCallback(crl::time now);
|
void radialAnimationCallback(crl::time now);
|
||||||
|
void updateLoadingToFinished();
|
||||||
|
|
||||||
int _id = 0;
|
int _id = 0;
|
||||||
bool _switching = false;
|
bool _switching = false;
|
||||||
|
@ -152,6 +153,12 @@ int GetDownloadSize(int id) {
|
||||||
return ranges::find(sets, id, &Set::id)->size;
|
return ranges::find(sets, id, &Set::id)->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] float64 CountProgress(not_null<const Loading*> loading) {
|
||||||
|
return (loading->size > 0)
|
||||||
|
? (loading->already / float64(loading->size))
|
||||||
|
: 0.;
|
||||||
|
}
|
||||||
|
|
||||||
MTP::DedicatedLoader::Location GetDownloadLocation(int id) {
|
MTP::DedicatedLoader::Location GetDownloadLocation(int id) {
|
||||||
constexpr auto kUsername = "tdhbcfiles";
|
constexpr auto kUsername = "tdhbcfiles";
|
||||||
const auto sets = Sets();
|
const auto sets = Sets();
|
||||||
|
@ -379,6 +386,9 @@ void Row::paintPreview(Painter &p) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Row::paintRadio(Painter &p) {
|
void Row::paintRadio(Painter &p) {
|
||||||
|
if (_loading && !_loading->animating()) {
|
||||||
|
_loading = nullptr;
|
||||||
|
}
|
||||||
const auto loading = _loading
|
const auto loading = _loading
|
||||||
? _loading->computeState()
|
? _loading->computeState()
|
||||||
: Ui::RadialState{ 0., 0, FullArcLength };
|
: Ui::RadialState{ 0., 0, FullArcLength };
|
||||||
|
@ -580,14 +590,20 @@ void Row::setupPreview(const Set &set) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Row::updateLoadingToFinished() {
|
||||||
|
_loading->update(
|
||||||
|
_state.current().is<Failed>() ? 0. : 1.,
|
||||||
|
true,
|
||||||
|
crl::now());
|
||||||
|
}
|
||||||
|
|
||||||
void Row::radialAnimationCallback(crl::time now) {
|
void Row::radialAnimationCallback(crl::time now) {
|
||||||
const auto updated = [&] {
|
const auto updated = [&] {
|
||||||
const auto state = _state.current();
|
const auto state = _state.current();
|
||||||
if (const auto loading = base::get_if<Loading>(&state)) {
|
if (const auto loading = base::get_if<Loading>(&state)) {
|
||||||
const auto progress = (loading->size > 0)
|
return _loading->update(CountProgress(loading), false, now);
|
||||||
? (loading->already / float64(loading->size))
|
} else {
|
||||||
: 0.;
|
updateLoadingToFinished();
|
||||||
return _loading->update(progress, false, now);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}();
|
}();
|
||||||
|
@ -636,15 +652,9 @@ void Row::setupAnimation() {
|
||||||
if (loading && !_loading) {
|
if (loading && !_loading) {
|
||||||
_loading = std::make_unique<Ui::RadialAnimation>(
|
_loading = std::make_unique<Ui::RadialAnimation>(
|
||||||
[=](crl::time now) { radialAnimationCallback(now); });
|
[=](crl::time now) { radialAnimationCallback(now); });
|
||||||
const auto progress = (loading->size > 0)
|
_loading->start(CountProgress(loading));
|
||||||
? (loading->already / float64(loading->size))
|
|
||||||
: 0.;
|
|
||||||
_loading->start(progress);
|
|
||||||
} else if (!loading && _loading) {
|
} else if (!loading && _loading) {
|
||||||
_loading->update(
|
updateLoadingToFinished();
|
||||||
_state.current().is<Failed>() ? 0. : 1.,
|
|
||||||
true,
|
|
||||||
crl::now());
|
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue