mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Improve lottie icon layout in group calls.
This commit is contained in:
parent
ab2e7f4c03
commit
4430bd0328
2 changed files with 43 additions and 21 deletions
|
@ -82,6 +82,28 @@ constexpr auto kRadialFinishArcShift = 1200;
|
|||
: type;
|
||||
};
|
||||
|
||||
[[nodiscard]] QSize AdjustedLottieSize(
|
||||
not_null<const style::CallMuteButton*> st) {
|
||||
const auto &button = st->active.button;
|
||||
const auto left = (button.width - st->lottieSize.width()) / 2;
|
||||
const auto size = button.width - 2 * left;
|
||||
return QSize(size, size);
|
||||
}
|
||||
|
||||
[[nodiscard]] int AdjustedBgSize(
|
||||
not_null<const style::CallMuteButton*> st) {
|
||||
const auto &button = st->active.button;
|
||||
const auto left = (button.width - st->active.bgSize) / 2;
|
||||
return button.width - 2 * left;
|
||||
}
|
||||
|
||||
[[nodiscard]] int AdjustedBgSkip(
|
||||
not_null<const style::CallMuteButton*> st) {
|
||||
const auto &button = st->active.button;
|
||||
const auto bgSize = AdjustedBgSize(st);
|
||||
return (button.width - bgSize) / 2;
|
||||
}
|
||||
|
||||
auto MuteBlobs() {
|
||||
return std::vector<Paint::Blobs::BlobData>{
|
||||
{
|
||||
|
@ -515,9 +537,12 @@ CallMuteButton::CallMuteButton(
|
|||
CallMuteButtonState initial)
|
||||
: _state(initial)
|
||||
, _st(&st)
|
||||
, _lottieSize(AdjustedLottieSize(_st))
|
||||
, _bgSize(AdjustedBgSize(_st))
|
||||
, _bgSkip(AdjustedBgSkip(_st))
|
||||
, _blobs(base::make_unique_q<BlobsWidget>(
|
||||
parent,
|
||||
_st->active.bgSize,
|
||||
_bgSize,
|
||||
rpl::combine(
|
||||
PowerSaving::OnValue(PowerSaving::kCalls),
|
||||
std::move(hideBlobs),
|
||||
|
@ -593,13 +618,13 @@ void CallMuteButton::refreshIcons() {
|
|||
_icons[0].emplace(Lottie::IconDescriptor{
|
||||
.path = u":/icons/calls/voice.lottie"_q,
|
||||
.color = &st::groupCallIconFg,
|
||||
.sizeOverride = _st->lottieSize,
|
||||
.sizeOverride = _lottieSize,
|
||||
.frame = (_iconState.index ? 0 : _iconState.frameTo),
|
||||
});
|
||||
_icons[1].emplace(Lottie::IconDescriptor{
|
||||
.path = u":/icons/calls/hands.lottie"_q,
|
||||
.color = &st::groupCallIconFg,
|
||||
.sizeOverride = _st->lottieSize,
|
||||
.sizeOverride = _lottieSize,
|
||||
.frame = (_iconState.index ? _iconState.frameTo : 0),
|
||||
});
|
||||
|
||||
|
@ -813,7 +838,7 @@ void CallMuteButton::init() {
|
|||
// Icon rect.
|
||||
_content->sizeValue(
|
||||
) | rpl::start_with_next([=](QSize size) {
|
||||
const auto icon = _st->lottieSize;
|
||||
const auto icon = _lottieSize;
|
||||
_muteIconRect = QRect(
|
||||
(size.width() - icon.width()) / 2,
|
||||
_st->lottieTop,
|
||||
|
@ -858,8 +883,8 @@ void CallMuteButton::init() {
|
|||
InfiniteRadialAnimation::Draw(
|
||||
p,
|
||||
r,
|
||||
_st->active.bgPosition,
|
||||
QSize(_st->active.bgSize, _st->active.bgSize),
|
||||
QPoint(_bgSkip, _bgSkip),
|
||||
QSize(_bgSize, _bgSize),
|
||||
_content->width(),
|
||||
QPen(_radialInfo.st.color),
|
||||
_radialInfo.st.thickness);
|
||||
|
@ -870,8 +895,8 @@ void CallMuteButton::init() {
|
|||
InfiniteRadialAnimation::Draw(
|
||||
p,
|
||||
std::move(state),
|
||||
_st->active.bgPosition,
|
||||
QSize(_st->active.bgSize, _st->active.bgSize),
|
||||
QPoint(_bgSkip, _bgSkip),
|
||||
QSize(_bgSize, _bgSize),
|
||||
_content->width(),
|
||||
QPen(_radialInfo.st.color),
|
||||
_radialInfo.st.thickness);
|
||||
|
@ -1027,6 +1052,9 @@ void CallMuteButton::setStyle(const style::CallMuteButton &st) {
|
|||
return;
|
||||
}
|
||||
_st = &st;
|
||||
_lottieSize = AdjustedLottieSize(_st);
|
||||
_bgSize = AdjustedBgSize(_st);
|
||||
_bgSkip = AdjustedBgSkip(_st);
|
||||
const auto &button = _st->active.button;
|
||||
_content->resize(button.width, button.height);
|
||||
_blobs->setDiameter(_st->active.bgSize);
|
||||
|
@ -1057,21 +1085,13 @@ rpl::producer<Qt::MouseButton> CallMuteButton::clicks() {
|
|||
}
|
||||
|
||||
QSize CallMuteButton::innerSize() const {
|
||||
return innerGeometry().size();
|
||||
}
|
||||
|
||||
QRect CallMuteButton::innerGeometry() const {
|
||||
const auto &skip = _st->active.outerRadius;
|
||||
return QRect(
|
||||
_content->x(),
|
||||
_content->y(),
|
||||
_content->width() - 2 * skip,
|
||||
_content->width() - 2 * skip);
|
||||
return QSize(
|
||||
_content->width() - 2 * _bgSkip,
|
||||
_content->width() - 2 * _bgSkip);
|
||||
}
|
||||
|
||||
void CallMuteButton::moveInner(QPoint position) {
|
||||
const auto &skip = _st->active.outerRadius;
|
||||
_content->move(position - QPoint(skip, skip));
|
||||
_content->move(position - QPoint(_bgSkip, _bgSkip));
|
||||
|
||||
{
|
||||
const auto offset = QPoint(
|
||||
|
|
|
@ -73,7 +73,6 @@ public:
|
|||
[[nodiscard]] rpl::producer<Qt::MouseButton> clicks();
|
||||
|
||||
[[nodiscard]] QSize innerSize() const;
|
||||
[[nodiscard]] QRect innerGeometry() const;
|
||||
void moveInner(QPoint position);
|
||||
|
||||
void shake();
|
||||
|
@ -165,6 +164,9 @@ private:
|
|||
HandleMouseState _handleMouseState = HandleMouseState::Enabled;
|
||||
|
||||
not_null<const style::CallMuteButton*> _st;
|
||||
QSize _lottieSize;
|
||||
int _bgSize = 0;
|
||||
int _bgSkip = 0;
|
||||
|
||||
const base::unique_qptr<BlobsWidget> _blobs;
|
||||
const base::unique_qptr<AbstractButton> _content;
|
||||
|
|
Loading…
Add table
Reference in a new issue