Report animate phases from PopupMenu.
This commit is contained in:
parent
41ee2fb0f0
commit
43e9128014
3 changed files with 29 additions and 5 deletions
|
|
@ -484,7 +484,10 @@ void PopupMenu::paintEvent(QPaintEvent *e) {
|
|||
_showAnimation->paintFrame(p, 0, 0, width(), 1., 1.);
|
||||
_showAnimation.reset();
|
||||
_showStateChanges.fire({});
|
||||
PostponeCall(this, [=] { showChildren(); });
|
||||
PostponeCall(this, [=] {
|
||||
showChildren();
|
||||
_animatePhase = AnimatePhase::Shown;
|
||||
});
|
||||
} else {
|
||||
paintBg(p);
|
||||
}
|
||||
|
|
@ -750,6 +753,7 @@ void PopupMenu::hideFinished() {
|
|||
_hiding = false;
|
||||
_a_show.stop();
|
||||
_cache = QPixmap();
|
||||
_animatePhase = AnimatePhase::Hidden;
|
||||
if (!isHidden()) {
|
||||
hide();
|
||||
}
|
||||
|
|
@ -790,6 +794,9 @@ void PopupMenu::startOpacityAnimation(bool hiding) {
|
|||
_hiding = false;
|
||||
prepareCache();
|
||||
_hiding = hiding;
|
||||
_animatePhase = hiding
|
||||
? AnimatePhase::StartHide
|
||||
: AnimatePhase::StartShow;
|
||||
hideChildren();
|
||||
_a_opacity.start(
|
||||
[=] { opacityAnimationCallback(); },
|
||||
|
|
@ -832,6 +839,7 @@ void PopupMenu::startShowAnimation() {
|
|||
}
|
||||
_showAnimation->start();
|
||||
}
|
||||
_animatePhase = AnimatePhase::StartShow;
|
||||
hideChildren();
|
||||
_a_show.start([this] { showAnimationCallback(); }, 0., 1., _st.showDuration);
|
||||
fireCurrentShowState();
|
||||
|
|
@ -858,6 +866,7 @@ void PopupMenu::opacityAnimationCallback() {
|
|||
hideFinished();
|
||||
} else {
|
||||
showChildren();
|
||||
_animatePhase = AnimatePhase::Shown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,13 @@ public:
|
|||
Bottom,
|
||||
};
|
||||
|
||||
enum class AnimatePhase {
|
||||
Hidden,
|
||||
StartShow,
|
||||
Shown,
|
||||
StartHide,
|
||||
};
|
||||
|
||||
PopupMenu(QWidget *parent, const style::PopupMenu &st = st::defaultPopupMenu);
|
||||
PopupMenu(QWidget *parent, QMenu *menu, const style::PopupMenu &st = st::defaultPopupMenu);
|
||||
~PopupMenu();
|
||||
|
|
@ -40,6 +47,9 @@ public:
|
|||
[[nodiscard]] QRect inner() const {
|
||||
return _inner;
|
||||
}
|
||||
[[nodiscard]] rpl::producer<AnimatePhase> animatePhaseValue() const {
|
||||
return _animatePhase.value();
|
||||
}
|
||||
|
||||
not_null<QAction*> addAction(base::unique_qptr<Menu::ItemBase> widget);
|
||||
not_null<QAction*> addAction(
|
||||
|
|
@ -195,6 +205,7 @@ private:
|
|||
std::unique_ptr<PanelAnimation> _showAnimation;
|
||||
Animations::Simple _a_show;
|
||||
rpl::event_stream<ShowState> _showStateChanges;
|
||||
rpl::variable<AnimatePhase> _animatePhase = AnimatePhase::Hidden;
|
||||
|
||||
bool _useTransparency = true;
|
||||
bool _hiding = false;
|
||||
|
|
|
|||
|
|
@ -198,14 +198,18 @@ void ScrollBar::paintEvent(QPaintEvent *e) {
|
|||
bg.setAlpha(anim::interpolate(0, bg.alpha(), opacity));
|
||||
auto bar = anim::color(_st->barBg, _st->barBgOver, _a_barOver.value((_overbar || _moving) ? 1. : 0.));
|
||||
bar.setAlpha(anim::interpolate(0, bar.alpha(), opacity));
|
||||
if (_st->round) {
|
||||
const auto outer = QRect(deltal, deltat, width() - deltal - deltar, height() - deltat - deltab);
|
||||
const auto radius = (_st->round < 0)
|
||||
? (std::min(outer.width(), outer.height()) / 2.)
|
||||
: _st->round;
|
||||
if (radius) {
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.setBrush(bg);
|
||||
p.drawRoundedRect(QRect(deltal, deltat, width() - deltal - deltar, height() - deltat - deltab), _st->round, _st->round);
|
||||
p.drawRoundedRect(outer, radius, radius);
|
||||
p.setBrush(bar);
|
||||
p.drawRoundedRect(_bar, _st->round, _st->round);
|
||||
p.drawRoundedRect(_bar, radius, radius);
|
||||
} else {
|
||||
p.fillRect(QRect(deltal, deltat, width() - deltal - deltar, height() - deltat - deltab), bg);
|
||||
p.fillRect(outer, bg);
|
||||
p.fillRect(_bar, bar);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue