mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added animation of volume percents in menu of group calls.
This commit is contained in:
parent
3001ad4b89
commit
6d5bf53dd1
2 changed files with 24 additions and 19 deletions
|
@ -78,11 +78,16 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
_speakerRect = QRect(_itemRect.topLeft(), _stCross.icon.size());
|
_speakerRect = QRect(_itemRect.topLeft(), _stCross.icon.size());
|
||||||
_arcPosition = _speakerRect.center()
|
_arcPosition = _speakerRect.center()
|
||||||
+ QPoint(0, st::groupCallMenuSpeakerArcsSkip);
|
+ QPoint(0, st::groupCallMenuSpeakerArcsSkip);
|
||||||
|
_volumeRect = QRect(
|
||||||
|
_arcPosition.x()
|
||||||
|
+ st::groupCallMenuVolumeSkip
|
||||||
|
+ _arcs->finishedWidth(),
|
||||||
|
_speakerRect.y(),
|
||||||
|
_st.itemStyle.font->width(VolumeString(kMaxVolumePercent)),
|
||||||
|
_speakerRect.height());
|
||||||
|
|
||||||
_slider->setGeometry(_itemRect
|
_slider->setGeometry(_itemRect
|
||||||
- style::margins(0, contentHeight() / 2, 0, 0));
|
- style::margins(0, contentHeight() / 2, 0, 0));
|
||||||
|
|
||||||
computeVolumeRect();
|
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
setCloudVolume(startVolume);
|
setCloudVolume(startVolume);
|
||||||
|
@ -135,7 +140,6 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
_changeVolumeLocallyRequests.fire(value * _maxVolume);
|
_changeVolumeLocallyRequests.fire(value * _maxVolume);
|
||||||
}
|
}
|
||||||
computeVolumeRect();
|
|
||||||
update(_volumeRect);
|
update(_volumeRect);
|
||||||
_arcs->setValue(value);
|
_arcs->setValue(value);
|
||||||
});
|
});
|
||||||
|
@ -204,15 +208,31 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuVolumeItem::initArcsAnimation() {
|
void MenuVolumeItem::initArcsAnimation() {
|
||||||
|
const auto volumeLeftWas = lifetime().make_state<int>(0);
|
||||||
|
const auto lastTime = lifetime().make_state<int>(0);
|
||||||
_arcsAnimation.init([=](crl::time now) {
|
_arcsAnimation.init([=](crl::time now) {
|
||||||
_arcs->update(now);
|
_arcs->update(now);
|
||||||
update(_speakerRect);
|
update(_speakerRect);
|
||||||
computeVolumeRect();
|
|
||||||
|
const auto wasRect = _volumeRect;
|
||||||
|
_volumeRect.moveLeft(anim::interpolate(
|
||||||
|
*volumeLeftWas,
|
||||||
|
_arcPosition.x()
|
||||||
|
+ st::groupCallMenuVolumeSkip
|
||||||
|
+ _arcs->finishedWidth(),
|
||||||
|
std::clamp(
|
||||||
|
(now - (*lastTime))
|
||||||
|
/ float64(st::groupCallSpeakerArcsAnimation.duration),
|
||||||
|
0.,
|
||||||
|
1.)));
|
||||||
|
update(_speakerRect.united(wasRect.united(_volumeRect)));
|
||||||
});
|
});
|
||||||
|
|
||||||
_arcs->startUpdateRequests(
|
_arcs->startUpdateRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
if (!_arcsAnimation.animating()) {
|
if (!_arcsAnimation.animating()) {
|
||||||
|
*volumeLeftWas = _volumeRect.left();
|
||||||
|
*lastTime = crl::now();
|
||||||
_arcsAnimation.start();
|
_arcsAnimation.start();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
@ -223,19 +243,6 @@ void MenuVolumeItem::initArcsAnimation() {
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuVolumeItem::computeVolumeRect() {
|
|
||||||
const auto was = _volumeRect;
|
|
||||||
_volumeRect = QRect(
|
|
||||||
_arcPosition.x() + st::groupCallMenuVolumeSkip + _arcs->width(),
|
|
||||||
_speakerRect.y(),
|
|
||||||
_st.itemStyle.font->width(VolumeString(kMaxVolumePercent)),
|
|
||||||
_speakerRect.height());
|
|
||||||
if (was != _volumeRect) {
|
|
||||||
// Clear the previous text rendering.
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor MenuVolumeItem::unmuteColor() const {
|
QColor MenuVolumeItem::unmuteColor() const {
|
||||||
return (isSelected()
|
return (isSelected()
|
||||||
? _st.itemFgOver
|
? _st.itemFgOver
|
||||||
|
|
|
@ -53,8 +53,6 @@ private:
|
||||||
void setCloudVolume(int volume);
|
void setCloudVolume(int volume);
|
||||||
void setSliderVolume(int volume);
|
void setSliderVolume(int volume);
|
||||||
|
|
||||||
void computeVolumeRect();
|
|
||||||
|
|
||||||
QColor unmuteColor() const;
|
QColor unmuteColor() const;
|
||||||
QColor muteColor() const;
|
QColor muteColor() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue