From 011d0ba692d86e66e749f213358009ccded18c6f Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 30 Nov 2020 10:59:21 +0300 Subject: [PATCH] Fixed blobs paint for non-default scales. --- ui/widgets/call_mute_button.cpp | 43 ++++++++++++++++++++------------- ui/widgets/widgets.style | 7 ++++++ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/ui/widgets/call_mute_button.cpp b/ui/widgets/call_mute_button.cpp index a39c979..73be479 100644 --- a/ui/widgets/call_mute_button.cpp +++ b/ui/widgets/call_mute_button.cpp @@ -28,13 +28,10 @@ constexpr auto kScaleSmall = 0.704 - 0.1; constexpr auto kScaleBigMin = 0.878; constexpr auto kScaleSmallMin = 0.926; -constexpr auto kScaleBigMax = kScaleBigMin + kScaleBig; -constexpr auto kScaleSmallMax = kScaleSmallMin + kScaleSmall; +constexpr auto kScaleBigMax = (float)(kScaleBigMin + kScaleBig); +constexpr auto kScaleSmallMax = (float)(kScaleSmallMin + kScaleSmall); -constexpr auto kMainRadiusFactor = 50. / 57.; - -constexpr auto kMainMinRadius = 57. * kMainRadiusFactor; -constexpr auto kMainMaxRadius = 63. * kMainRadiusFactor; +constexpr auto kMainRadiusFactor = (float)(50. / 57.); constexpr auto kGlowPaddingFactor = 1.2; constexpr auto kGlowMinScale = 0.6; @@ -42,29 +39,39 @@ constexpr auto kGlowAlpha = 150; constexpr auto kSwitchStateDuration = 120; -constexpr auto MuteBlobs() -> std::array { +auto MuteBlobs() -> std::array { return {{ { .segmentsCount = 6, .minScale = 1., - .minRadius = kMainMinRadius, - .maxRadius = kMainMaxRadius, + .minRadius = st::callMuteMainBlobMinRadius + * kMainRadiusFactor, + .maxRadius = st::callMuteMainBlobMaxRadius + * kMainRadiusFactor, .speedScale = .4, .alpha = 1., }, { .segmentsCount = 9, .minScale = kScaleSmallMin / kScaleSmallMax, - .minRadius = 62 * kScaleSmallMax * kMainRadiusFactor, - .maxRadius = 72 * kScaleSmallMax * kMainRadiusFactor, + .minRadius = st::callMuteMinorBlobMinRadius + * kScaleSmallMax + * kMainRadiusFactor, + .maxRadius = st::callMuteMinorBlobMaxRadius + * kScaleSmallMax + * kMainRadiusFactor, .speedScale = 1., .alpha = (76. / 255.), }, { .segmentsCount = 12, .minScale = kScaleBigMin / kScaleBigMax, - .minRadius = 65 * kScaleBigMax * kMainRadiusFactor, - .maxRadius = 75 * kScaleBigMax * kMainRadiusFactor, + .minRadius = st::callMuteMajorBlobMinRadius + * kScaleBigMax + * kMainRadiusFactor, + .maxRadius = st::callMuteMajorBlobMaxRadius + * kScaleBigMax + * kMainRadiusFactor, .speedScale = 1., .alpha = (76. / 255.), }, @@ -171,7 +178,9 @@ void BlobsWidget::init() { p.translate(_center, _center); p.setPen(Qt::NoPen); p.setBrush(_blobBrush); - p.drawEllipse(QPointF(), kMainMinRadius, kMainMinRadius); + const auto radius = st::callMuteMainBlobMinRadius + * kMainRadiusFactor; + p.drawEllipse(QPointF(), radius, radius); return; } @@ -351,9 +360,9 @@ void CallMuteButton::init() { { auto radius = _state.value( ) | rpl::map([](const CallMuteButtonState &state) -> float { - return IsConnecting(state.type) - ? kMainMinRadius - : kMainMaxRadius; + return (IsConnecting(state.type) + ? st::callMuteMainBlobMinRadius + : st::callMuteMainBlobMaxRadius) * kMainRadiusFactor; }) | rpl::distinct_until_changed(); _blobs->setMainRadius(std::move(radius)); } diff --git a/ui/widgets/widgets.style b/ui/widgets/widgets.style index 662ea2b..6fb9b39 100644 --- a/ui/widgets/widgets.style +++ b/ui/widgets/widgets.style @@ -1405,6 +1405,13 @@ defaultToast: Toast { durationSlide: 160; } +callMuteMainBlobMinRadius: 57px; +callMuteMainBlobMaxRadius: 63px; +callMuteMinorBlobMinRadius: 62px; +callMuteMinorBlobMaxRadius: 72px; +callMuteMajorBlobMinRadius: 65px; +callMuteMajorBlobMaxRadius: 75px; + callMuteButtonActiveIcon: icon {{ "calls/voice_unmuted_large", groupCallIconFg }}; callMuteButtonActiveInner: IconButton { width: 136px;