mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added arcs animation to volume menu item in group calls.
This commit is contained in:
parent
833ffe1784
commit
50f87cce84
3 changed files with 70 additions and 4 deletions
|
@ -786,6 +786,21 @@ groupCallMuteCrossLine: CrossLineAnimation {
|
||||||
stroke: 2px;
|
stroke: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
groupCallMenuSpeakerArcsSkip: 1px;
|
||||||
|
groupCallMenuVolumeSkip: 5px;
|
||||||
|
|
||||||
|
groupCallSpeakerArcsAnimation: ArcsAnimation {
|
||||||
|
fg: groupCallIconFg;
|
||||||
|
stroke: 2px;
|
||||||
|
space: 4px;
|
||||||
|
duration: 200;
|
||||||
|
deltaAngle: 60;
|
||||||
|
deltaHeight: 6px;
|
||||||
|
deltaWidth: 7px;
|
||||||
|
startHeight: 3px;
|
||||||
|
startWidth: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
callTopBarMuteCrossLine: CrossLineAnimation {
|
callTopBarMuteCrossLine: CrossLineAnimation {
|
||||||
fg: callBarFg;
|
fg: callBarFg;
|
||||||
icon: icon {{ "calls/call_record_active", callBarFg }};
|
icon: icon {{ "calls/call_record_active", callBarFg }};
|
||||||
|
|
|
@ -14,11 +14,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_calls.h"
|
#include "styles/style_calls.h"
|
||||||
#include "styles/style_media_player.h"
|
#include "styles/style_media_player.h"
|
||||||
|
|
||||||
|
#include "ui/paint/arcs.h"
|
||||||
|
|
||||||
namespace Calls {
|
namespace Calls {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kMaxVolumePercent = 200;
|
constexpr auto kMaxVolumePercent = 200;
|
||||||
|
|
||||||
|
constexpr auto kSpeakerThreshold = {
|
||||||
|
10.0f / kMaxVolumePercent,
|
||||||
|
50.0f / kMaxVolumePercent,
|
||||||
|
150.0f / kMaxVolumePercent };
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MenuVolumeItem::MenuVolumeItem(
|
MenuVolumeItem::MenuVolumeItem(
|
||||||
|
@ -38,7 +45,12 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
, _dummyAction(new QAction(parent))
|
, _dummyAction(new QAction(parent))
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _stCross(st::groupCallMuteCrossLine)
|
, _stCross(st::groupCallMuteCrossLine)
|
||||||
, _crossLineMute(std::make_unique<Ui::CrossLineAnimation>(_stCross, true)) {
|
, _crossLineMute(std::make_unique<Ui::CrossLineAnimation>(_stCross, true))
|
||||||
|
, _arcs(std::make_unique<Ui::Paint::ArcsAnimation>(
|
||||||
|
st::groupCallSpeakerArcsAnimation,
|
||||||
|
kSpeakerThreshold,
|
||||||
|
_localMuted ? 0. : (startVolume / float(maxVolume)),
|
||||||
|
Ui::Paint::ArcsAnimation::HorizontalDirection::Right)) {
|
||||||
|
|
||||||
initResizeHook(parent->sizeValue());
|
initResizeHook(parent->sizeValue());
|
||||||
enableMouseSelecting();
|
enableMouseSelecting();
|
||||||
|
@ -48,12 +60,18 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
const auto geometry = QRect(QPoint(), size);
|
const auto geometry = QRect(QPoint(), size);
|
||||||
_itemRect = geometry - _st.itemPadding;
|
_itemRect = geometry - _st.itemPadding;
|
||||||
_speakerRect = QRect(_itemRect.topLeft(), _stCross.icon.size());
|
_speakerRect = QRect(_itemRect.topLeft(), _stCross.icon.size());
|
||||||
_volumeRect = _speakerRect.translated(_stCross.icon.width(), 0);
|
_volumeRect = _speakerRect.translated(
|
||||||
|
_stCross.icon.width() + st::groupCallMenuVolumeSkip,
|
||||||
|
0);
|
||||||
|
_arcPosition = _speakerRect.center()
|
||||||
|
+ QPoint(0, st::groupCallMenuSpeakerArcsSkip);
|
||||||
|
|
||||||
_slider->setGeometry(_itemRect
|
_slider->setGeometry(_itemRect
|
||||||
- style::margins(0, contentHeight() / 2, 0, 0));
|
- style::margins(0, contentHeight() / 2, 0, 0));
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
setCloudVolume(startVolume);
|
||||||
|
|
||||||
paintRequest(
|
paintRequest(
|
||||||
) | rpl::start_with_next([=](const QRect &clip) {
|
) | rpl::start_with_next([=](const QRect &clip) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
@ -78,9 +96,12 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
_speakerRect.topLeft(),
|
_speakerRect.topLeft(),
|
||||||
muteProgress,
|
muteProgress,
|
||||||
(!muteProgress) ? std::nullopt : std::optional<QColor>(mutePen));
|
(!muteProgress) ? std::nullopt : std::optional<QColor>(mutePen));
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
setCloudVolume(startVolume);
|
{
|
||||||
|
p.translate(_arcPosition);
|
||||||
|
_arcs->paint(p);
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
_slider->setChangeProgressCallback([=](float64 value) {
|
_slider->setChangeProgressCallback([=](float64 value) {
|
||||||
const auto newMuted = (value == 0);
|
const auto newMuted = (value == 0);
|
||||||
|
@ -98,6 +119,7 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
_changeVolumeLocallyRequests.fire(value * _maxVolume);
|
_changeVolumeLocallyRequests.fire(value * _maxVolume);
|
||||||
}
|
}
|
||||||
update(_volumeRect);
|
update(_volumeRect);
|
||||||
|
_arcs->setValue(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto returnVolume = [=] {
|
const auto returnVolume = [=] {
|
||||||
|
@ -152,6 +174,27 @@ MenuVolumeItem::MenuVolumeItem(
|
||||||
}
|
}
|
||||||
_waitingForUpdateVolume = false;
|
_waitingForUpdateVolume = false;
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
initArcsAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuVolumeItem::initArcsAnimation() {
|
||||||
|
_arcsAnimation.init([=](crl::time now) {
|
||||||
|
_arcs->update(now);
|
||||||
|
update(_speakerRect);
|
||||||
|
});
|
||||||
|
|
||||||
|
_arcs->startUpdateRequests(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
if (!_arcsAnimation.animating()) {
|
||||||
|
_arcsAnimation.start();
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
|
_arcs->stopUpdateRequests(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
_arcsAnimation.stop();
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor MenuVolumeItem::unmuteColor() const {
|
QColor MenuVolumeItem::unmuteColor() const {
|
||||||
|
|
|
@ -13,6 +13,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class CrossLineAnimation;
|
class CrossLineAnimation;
|
||||||
class MediaSlider;
|
class MediaSlider;
|
||||||
|
namespace Paint {
|
||||||
|
class ArcsAnimation;
|
||||||
|
} // namespace Paint
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Calls {
|
namespace Calls {
|
||||||
|
@ -45,6 +48,8 @@ protected:
|
||||||
int contentHeight() const override;
|
int contentHeight() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initArcsAnimation();
|
||||||
|
|
||||||
void setCloudVolume(int volume);
|
void setCloudVolume(int volume);
|
||||||
void setSliderVolume(int volume);
|
void setSliderVolume(int volume);
|
||||||
|
|
||||||
|
@ -60,6 +65,7 @@ private:
|
||||||
QRect _itemRect;
|
QRect _itemRect;
|
||||||
QRect _speakerRect;
|
QRect _speakerRect;
|
||||||
QRect _volumeRect;
|
QRect _volumeRect;
|
||||||
|
QPoint _arcPosition;
|
||||||
|
|
||||||
const base::unique_qptr<Ui::MediaSlider> _slider;
|
const base::unique_qptr<Ui::MediaSlider> _slider;
|
||||||
const not_null<QAction*> _dummyAction;
|
const not_null<QAction*> _dummyAction;
|
||||||
|
@ -68,6 +74,8 @@ private:
|
||||||
|
|
||||||
const std::unique_ptr<Ui::CrossLineAnimation> _crossLineMute;
|
const std::unique_ptr<Ui::CrossLineAnimation> _crossLineMute;
|
||||||
Ui::Animations::Simple _crossLineAnimation;
|
Ui::Animations::Simple _crossLineAnimation;
|
||||||
|
const std::unique_ptr<Ui::Paint::ArcsAnimation> _arcs;
|
||||||
|
Ui::Animations::Basic _arcsAnimation;
|
||||||
|
|
||||||
rpl::event_stream<bool> _toggleMuteRequests;
|
rpl::event_stream<bool> _toggleMuteRequests;
|
||||||
rpl::event_stream<bool> _toggleMuteLocallyRequests;
|
rpl::event_stream<bool> _toggleMuteLocallyRequests;
|
||||||
|
|
Loading…
Add table
Reference in a new issue