mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added resize handler of volume menu item in group calls.
This commit is contained in:
parent
1cbb217210
commit
1d3e76e1fe
2 changed files with 19 additions and 13 deletions
|
@ -36,16 +36,22 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
st::mediaPlayerPanelPlayback))
|
st::mediaPlayerPanelPlayback))
|
||||||
, _dummyAction(new QAction(parent))
|
, _dummyAction(new QAction(parent))
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _font(st.itemStyle.font)
|
|
||||||
, _stCross(st::groupCallMuteCrossLine)
|
, _stCross(st::groupCallMuteCrossLine)
|
||||||
, _crossLineMute(std::make_unique<Ui::CrossLineAnimation>(_stCross, true)) {
|
, _crossLineMute(std::make_unique<Ui::CrossLineAnimation>(_stCross, true)) {
|
||||||
|
|
||||||
initResizeHook(parent->sizeValue());
|
initResizeHook(parent->sizeValue());
|
||||||
enableMouseSelecting();
|
enableMouseSelecting();
|
||||||
|
|
||||||
const auto itemRect = rect() - st.itemPadding;
|
sizeValue(
|
||||||
const auto speakerRect = QRect(itemRect.topLeft(), _stCross.icon.size());
|
) | rpl::start_with_next([=](const QSize &size) {
|
||||||
const auto volumeRect = speakerRect.translated(_stCross.icon.width(), 0);
|
const auto geometry = QRect(QPoint(), size);
|
||||||
|
_itemRect = geometry - _st.itemPadding;
|
||||||
|
_speakerRect = QRect(_itemRect.topLeft(), _stCross.icon.size());
|
||||||
|
_volumeRect = _speakerRect.translated(_stCross.icon.width(), 0);
|
||||||
|
|
||||||
|
_slider->setGeometry(_itemRect
|
||||||
|
- style::margins(0, contentHeight() / 2, 0, 0));
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
paintRequest(
|
paintRequest(
|
||||||
) | rpl::start_with_next([=](const QRect &clip) {
|
) | rpl::start_with_next([=](const QRect &clip) {
|
||||||
|
@ -59,13 +65,13 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
: selected
|
: selected
|
||||||
? st.itemFgOver
|
? st.itemFgOver
|
||||||
: (enabled ? st.itemFg : st.itemFgDisabled));
|
: (enabled ? st.itemFg : st.itemFgDisabled));
|
||||||
p.setFont(_font);
|
p.setFont(_st.itemStyle.font);
|
||||||
const auto volume = std::round(_slider->value() * kMaxVolumePercent);
|
const auto volume = std::round(_slider->value() * kMaxVolumePercent);
|
||||||
p.drawText(volumeRect, u"%1%"_q.arg(volume), style::al_center);
|
p.drawText(_volumeRect, u"%1%"_q.arg(volume), style::al_center);
|
||||||
|
|
||||||
_crossLineMute->paint(
|
_crossLineMute->paint(
|
||||||
p,
|
p,
|
||||||
speakerRect.topLeft(),
|
_speakerRect.topLeft(),
|
||||||
_crossLineAnimation.value(_localMuted ? 1. : 0.));
|
_crossLineAnimation.value(_localMuted ? 1. : 0.));
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
@ -78,7 +84,7 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
_toggleMuteLocallyRequests.fire_copy(newMuted);
|
_toggleMuteLocallyRequests.fire_copy(newMuted);
|
||||||
|
|
||||||
_crossLineAnimation.start(
|
_crossLineAnimation.start(
|
||||||
[=] { update(speakerRect); },
|
[=] { update(_speakerRect); },
|
||||||
_localMuted ? 0. : 1.,
|
_localMuted ? 0. : 1.,
|
||||||
_localMuted ? 1. : 0.,
|
_localMuted ? 1. : 0.,
|
||||||
st::callPanelDuration);
|
st::callPanelDuration);
|
||||||
|
@ -86,7 +92,7 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
_changeVolumeLocallyRequests.fire(value * _maxVolume);
|
_changeVolumeLocallyRequests.fire(value * _maxVolume);
|
||||||
}
|
}
|
||||||
update(volumeRect);
|
update(_volumeRect);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto returnVolume = [=] {
|
const auto returnVolume = [=] {
|
||||||
|
@ -141,9 +147,6 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
}
|
}
|
||||||
_waitingForUpdateVolume = false;
|
_waitingForUpdateVolume = false;
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_slider->setGeometry(itemRect
|
|
||||||
- style::margins(0, contentHeight() / 2, 0, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuVolumeItem::setCloudVolume(int volume) {
|
void MenuVolumeItem::setCloudVolume(int volume) {
|
||||||
|
|
|
@ -54,10 +54,13 @@ private:
|
||||||
bool _cloudMuted = false;
|
bool _cloudMuted = false;
|
||||||
bool _localMuted = false;
|
bool _localMuted = false;
|
||||||
|
|
||||||
|
QRect _itemRect;
|
||||||
|
QRect _speakerRect;
|
||||||
|
QRect _volumeRect;
|
||||||
|
|
||||||
const base::unique_qptr<Ui::MediaSlider> _slider;
|
const base::unique_qptr<Ui::MediaSlider> _slider;
|
||||||
const not_null<QAction*> _dummyAction;
|
const not_null<QAction*> _dummyAction;
|
||||||
const style::Menu &_st;
|
const style::Menu &_st;
|
||||||
const style::font &_font;
|
|
||||||
const style::CrossLineAnimation &_stCross;
|
const style::CrossLineAnimation &_stCross;
|
||||||
|
|
||||||
const std::unique_ptr<Ui::CrossLineAnimation> _crossLineMute;
|
const std::unique_ptr<Ui::CrossLineAnimation> _crossLineMute;
|
||||||
|
|
Loading…
Add table
Reference in a new issue