Added colors overriding for call settings button from mute button.
This commit is contained in:
parent
07359392c2
commit
5897e357bf
2 changed files with 49 additions and 1 deletions
|
|
@ -37,6 +37,9 @@ constexpr auto kGlowPaddingFactor = 1.2;
|
||||||
constexpr auto kGlowMinScale = 0.6;
|
constexpr auto kGlowMinScale = 0.6;
|
||||||
constexpr auto kGlowAlpha = 150;
|
constexpr auto kGlowAlpha = 150;
|
||||||
|
|
||||||
|
constexpr auto kOverrideColorBgAlpha = 76;
|
||||||
|
constexpr auto kOverrideColorRippleAlpha = 50;
|
||||||
|
|
||||||
constexpr auto kSwitchStateDuration = 120;
|
constexpr auto kSwitchStateDuration = 120;
|
||||||
|
|
||||||
auto MuteBlobs() -> std::array<Paint::Blobs::BlobData, 3> {
|
auto MuteBlobs() -> std::array<Paint::Blobs::BlobData, 3> {
|
||||||
|
|
@ -111,6 +114,10 @@ bool IsConnecting(CallMuteButtonType type) {
|
||||||
return (type == CallMuteButtonType::Connecting);
|
return (type == CallMuteButtonType::Connecting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsInactive(CallMuteButtonType type) {
|
||||||
|
return IsConnecting(type) || (type == CallMuteButtonType::ForceMuted);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class BlobsWidget final : public RpWidget {
|
class BlobsWidget final : public RpWidget {
|
||||||
|
|
@ -280,7 +287,7 @@ void CallMuteButton::init() {
|
||||||
lifetime().make_state<CallMuteButtonType>(_state.current().type);
|
lifetime().make_state<CallMuteButtonType>(_state.current().type);
|
||||||
|
|
||||||
const auto glowColor = [=](CallMuteButtonType type) {
|
const auto glowColor = [=](CallMuteButtonType type) {
|
||||||
if (IsConnecting(type) || (type == CallMuteButtonType::ForceMuted)) {
|
if (IsInactive(type)) {
|
||||||
return st::groupCallBg->c;
|
return st::groupCallBg->c;
|
||||||
}
|
}
|
||||||
auto c = _colors.at(type)[0];
|
auto c = _colors.at(type)[0];
|
||||||
|
|
@ -336,6 +343,8 @@ void CallMuteButton::init() {
|
||||||
if (radialShowProgress != _radialShowProgress.current()) {
|
if (radialShowProgress != _radialShowProgress.current()) {
|
||||||
_radialShowProgress = radialShowProgress;
|
_radialShowProgress = radialShowProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
overridesColors(previous, type, value);
|
||||||
};
|
};
|
||||||
|
|
||||||
_switchAnimation.stop();
|
_switchAnimation.stop();
|
||||||
|
|
@ -451,6 +460,37 @@ void CallMuteButton::lower() {
|
||||||
_blobs->lower();
|
_blobs->lower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CallMuteButton::overridesColors(
|
||||||
|
CallMuteButtonType fromType,
|
||||||
|
CallMuteButtonType toType,
|
||||||
|
float64 progress) {
|
||||||
|
const auto toInactive = IsInactive(toType);
|
||||||
|
const auto fromInactive = IsInactive(fromType);
|
||||||
|
if (toInactive && (progress == 1)) {
|
||||||
|
_colorOverrides.fire({ std::nullopt, std::nullopt });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto from = _colors.at(fromType)[0];
|
||||||
|
auto to = _colors.at(toType)[0];
|
||||||
|
auto fromRipple = from;
|
||||||
|
auto toRipple = to;
|
||||||
|
if (!toInactive) {
|
||||||
|
toRipple.setAlpha(kOverrideColorRippleAlpha);
|
||||||
|
to.setAlpha(kOverrideColorBgAlpha);
|
||||||
|
}
|
||||||
|
if (!fromInactive) {
|
||||||
|
fromRipple.setAlpha(kOverrideColorRippleAlpha);
|
||||||
|
from.setAlpha(kOverrideColorBgAlpha);
|
||||||
|
}
|
||||||
|
const auto resultBg = anim::color(from, to, progress);
|
||||||
|
const auto resultRipple = anim::color(fromRipple, toRipple, progress);
|
||||||
|
_colorOverrides.fire({ resultBg, resultRipple });
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<CallButtonColors> CallMuteButton::colorOverrides() const {
|
||||||
|
return _colorOverrides.events();
|
||||||
|
}
|
||||||
|
|
||||||
rpl::lifetime &CallMuteButton::lifetime() {
|
rpl::lifetime &CallMuteButton::lifetime() {
|
||||||
return _blobs->lifetime();
|
return _blobs->lifetime();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,17 @@ public:
|
||||||
void raise();
|
void raise();
|
||||||
void lower();
|
void lower();
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<CallButtonColors> colorOverrides() const;
|
||||||
|
|
||||||
[[nodiscard]] rpl::lifetime &lifetime();
|
[[nodiscard]] rpl::lifetime &lifetime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void contentPaint();
|
void contentPaint();
|
||||||
|
void overridesColors(
|
||||||
|
CallMuteButtonType fromType,
|
||||||
|
CallMuteButtonType toType,
|
||||||
|
float64 progress);
|
||||||
|
|
||||||
rpl::variable<CallMuteButtonState> _state;
|
rpl::variable<CallMuteButtonState> _state;
|
||||||
float _level = 0.;
|
float _level = 0.;
|
||||||
|
|
@ -76,6 +82,8 @@ private:
|
||||||
CrossLineAnimation _crossLineMuteAnimation;
|
CrossLineAnimation _crossLineMuteAnimation;
|
||||||
Animations::Simple _switchAnimation;
|
Animations::Simple _switchAnimation;
|
||||||
|
|
||||||
|
rpl::event_stream<CallButtonColors> _colorOverrides;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue