2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Finish animations disabling.

Replace some infinite animations with static layouts.
This commit is contained in:
John Preston
2018-09-20 19:39:59 +03:00
parent f68466b072
commit 1ffbec0215
29 changed files with 410 additions and 155 deletions

View File

@@ -182,28 +182,50 @@ void EmojiButton::paintEvent(QPaintEvent *e) {
p.fillRect(e->rect(), st::historyComposeAreaBg);
paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y(), ms, _rippleOverride ? &(*_rippleOverride)->c : nullptr);
const auto over = isOver();
const auto loadingState = _loading
? _loading->computeState()
: Ui::InfiniteRadialAnimation::State{ 0., 0, FullArcLength };
p.setOpacity(1. - loadingState.shown);
if (loadingState.shown < 1.) {
p.setOpacity(1. - loadingState.shown);
auto over = isOver();
auto icon = _iconOverride ? _iconOverride : &(over ? _st.iconOver : _st.icon);
icon->paint(p, _st.iconPosition, width());
auto icon = _iconOverride ? _iconOverride : &(over ? _st.iconOver : _st.icon);
icon->paint(p, _st.iconPosition, width());
p.setOpacity(1.);
auto pen = _colorOverride ? (*_colorOverride)->p : (over ? st::historyEmojiCircleFgOver : st::historyEmojiCircleFg)->p;
pen.setWidth(st::historyEmojiCircleLine);
pen.setCapStyle(Qt::RoundCap);
p.setPen(pen);
p.setBrush(Qt::NoBrush);
p.setOpacity(1.);
}
PainterHighQualityEnabler hq(p);
QRect inner(QPoint((width() - st::historyEmojiCircle.width()) / 2, st::historyEmojiCircleTop), st::historyEmojiCircle);
if (loadingState.arcLength < FullArcLength) {
p.drawArc(inner, loadingState.arcFrom, loadingState.arcLength);
const auto color = (_colorOverride
? *_colorOverride
: (over
? st::historyEmojiCircleFgOver
: st::historyEmojiCircleFg));
if (_loading && anim::Disabled()) {
anim::DrawStaticLoading(
p,
inner,
st::historyEmojiCircleLine,
color);
} else {
p.drawEllipse(inner);
auto pen = color->p;
pen.setWidth(st::historyEmojiCircleLine);
pen.setCapStyle(Qt::RoundCap);
p.setPen(pen);
p.setBrush(Qt::NoBrush);
PainterHighQualityEnabler hq(p);
if (loadingState.arcLength < FullArcLength) {
p.drawArc(inner, loadingState.arcFrom, loadingState.arcLength);
} else {
p.drawEllipse(inner);
}
}
}
void EmojiButton::step_loading(TimeMs ms, bool timer) {
if (timer && !anim::Disabled()) {
update();
}
}
@@ -215,8 +237,10 @@ void EmojiButton::setLoading(bool loading) {
}
if (loading) {
_loading->start();
update();
} else if (_loading) {
_loading->stop();
update();
}
}