mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added color animation to volume menu item in group calls.
This commit is contained in:
parent
1d3e76e1fe
commit
833ffe1784
2 changed files with 31 additions and 8 deletions
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "calls/calls_volume_item.h"
|
#include "calls/calls_volume_item.h"
|
||||||
|
|
||||||
#include "calls/calls_group_common.h"
|
#include "calls/calls_group_common.h"
|
||||||
|
#include "ui/effects/animation_value.h"
|
||||||
#include "ui/effects/cross_line.h"
|
#include "ui/effects/cross_line.h"
|
||||||
#include "ui/widgets/continuous_sliders.h"
|
#include "ui/widgets/continuous_sliders.h"
|
||||||
#include "styles/style_calls.h"
|
#include "styles/style_calls.h"
|
||||||
|
@ -57,14 +58,17 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
) | rpl::start_with_next([=](const QRect &clip) {
|
) | rpl::start_with_next([=](const QRect &clip) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
const auto enabled = isEnabled();
|
const auto muteProgress =
|
||||||
|
_crossLineAnimation.value(_localMuted ? 1. : 0.);
|
||||||
|
|
||||||
const auto selected = isSelected();
|
const auto selected = isSelected();
|
||||||
p.fillRect(clip, selected ? st.itemBgOver : st.itemBg);
|
p.fillRect(clip, selected ? st.itemBgOver : st.itemBg);
|
||||||
p.setPen(_localMuted
|
|
||||||
? (selected ? st::attentionButtonFgOver : st::attentionButtonFg)
|
const auto mutePen = anim::color(
|
||||||
: selected
|
unmuteColor(),
|
||||||
? st.itemFgOver
|
muteColor(),
|
||||||
: (enabled ? st.itemFg : st.itemFgDisabled));
|
muteProgress);
|
||||||
|
p.setPen(mutePen);
|
||||||
p.setFont(_st.itemStyle.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);
|
||||||
|
@ -72,7 +76,8 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
_crossLineMute->paint(
|
_crossLineMute->paint(
|
||||||
p,
|
p,
|
||||||
_speakerRect.topLeft(),
|
_speakerRect.topLeft(),
|
||||||
_crossLineAnimation.value(_localMuted ? 1. : 0.));
|
muteProgress,
|
||||||
|
(!muteProgress) ? std::nullopt : std::optional<QColor>(mutePen));
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
setCloudVolume(startVolume);
|
setCloudVolume(startVolume);
|
||||||
|
@ -84,7 +89,7 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
_toggleMuteLocallyRequests.fire_copy(newMuted);
|
_toggleMuteLocallyRequests.fire_copy(newMuted);
|
||||||
|
|
||||||
_crossLineAnimation.start(
|
_crossLineAnimation.start(
|
||||||
[=] { update(_speakerRect); },
|
[=] { update(_speakerRect.united(_volumeRect)); },
|
||||||
_localMuted ? 0. : 1.,
|
_localMuted ? 0. : 1.,
|
||||||
_localMuted ? 1. : 0.,
|
_localMuted ? 1. : 0.,
|
||||||
st::callPanelDuration);
|
st::callPanelDuration);
|
||||||
|
@ -149,6 +154,20 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor MenuVolumeItem::unmuteColor() const {
|
||||||
|
return (isSelected()
|
||||||
|
? _st.itemFgOver
|
||||||
|
: isEnabled()
|
||||||
|
? _st.itemFg
|
||||||
|
: _st.itemFgDisabled)->c;
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor MenuVolumeItem::muteColor() const {
|
||||||
|
return (isSelected()
|
||||||
|
? st::attentionButtonFgOver
|
||||||
|
: st::attentionButtonFg)->c;
|
||||||
|
}
|
||||||
|
|
||||||
void MenuVolumeItem::setCloudVolume(int volume) {
|
void MenuVolumeItem::setCloudVolume(int volume) {
|
||||||
if (_cloudVolume == volume) {
|
if (_cloudVolume == volume) {
|
||||||
return;
|
return;
|
||||||
|
@ -161,6 +180,7 @@ void MenuVolumeItem::setCloudVolume(int volume) {
|
||||||
|
|
||||||
void MenuVolumeItem::setSliderVolume(int volume) {
|
void MenuVolumeItem::setSliderVolume(int volume) {
|
||||||
_slider->setValue(float64(volume) / _maxVolume);
|
_slider->setValue(float64(volume) / _maxVolume);
|
||||||
|
update(_volumeRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<QAction*> MenuVolumeItem::action() const {
|
not_null<QAction*> MenuVolumeItem::action() const {
|
||||||
|
|
|
@ -48,6 +48,9 @@ private:
|
||||||
void setCloudVolume(int volume);
|
void setCloudVolume(int volume);
|
||||||
void setSliderVolume(int volume);
|
void setSliderVolume(int volume);
|
||||||
|
|
||||||
|
QColor unmuteColor() const;
|
||||||
|
QColor muteColor() const;
|
||||||
|
|
||||||
const int _maxVolume;
|
const int _maxVolume;
|
||||||
int _cloudVolume = 0;
|
int _cloudVolume = 0;
|
||||||
bool _waitingForUpdateVolume = false;
|
bool _waitingForUpdateVolume = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue