2021-05-07 13:01:54 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "calls/group/calls_group_members_row.h"
|
|
|
|
|
|
|
|
#include "calls/group/calls_group_call.h"
|
|
|
|
#include "calls/group/calls_group_common.h"
|
|
|
|
#include "data/data_peer.h"
|
|
|
|
#include "data/data_group_call.h"
|
|
|
|
#include "ui/paint/arcs.h"
|
|
|
|
#include "ui/paint/blobs.h"
|
|
|
|
#include "ui/text/text_options.h"
|
|
|
|
#include "ui/effects/ripple_animation.h"
|
2022-09-16 20:23:27 +00:00
|
|
|
#include "ui/painter.h"
|
2021-05-07 13:01:54 +00:00
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "webrtc/webrtc_video_track.h"
|
|
|
|
#include "styles/style_calls.h"
|
|
|
|
|
|
|
|
namespace Calls::Group {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr auto kLevelDuration = 100. + 500. * 0.23;
|
|
|
|
constexpr auto kBlobScale = 0.605;
|
|
|
|
constexpr auto kMinorBlobFactor = 0.9f;
|
|
|
|
constexpr auto kUserpicMinScale = 0.8;
|
|
|
|
constexpr auto kMaxLevel = 1.;
|
|
|
|
constexpr auto kWideScale = 5;
|
|
|
|
|
|
|
|
constexpr auto kArcsStrokeRatio = 0.8;
|
|
|
|
|
|
|
|
const auto kSpeakerThreshold = std::vector<float>{
|
|
|
|
Group::kDefaultVolume * 0.1f / Group::kMaxVolume,
|
|
|
|
Group::kDefaultVolume * 0.9f / Group::kMaxVolume };
|
|
|
|
|
|
|
|
auto RowBlobs() -> std::array<Ui::Paint::Blobs::BlobData, 2> {
|
|
|
|
return { {
|
|
|
|
{
|
|
|
|
.segmentsCount = 6,
|
|
|
|
.minScale = kBlobScale * kMinorBlobFactor,
|
|
|
|
.minRadius = st::groupCallRowBlobMinRadius * kMinorBlobFactor,
|
|
|
|
.maxRadius = st::groupCallRowBlobMaxRadius * kMinorBlobFactor,
|
|
|
|
.speedScale = 1.,
|
|
|
|
.alpha = .5,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.segmentsCount = 8,
|
|
|
|
.minScale = kBlobScale,
|
|
|
|
.minRadius = (float)st::groupCallRowBlobMinRadius,
|
|
|
|
.maxRadius = (float)st::groupCallRowBlobMaxRadius,
|
|
|
|
.speedScale = 1.,
|
|
|
|
.alpha = .2,
|
|
|
|
},
|
|
|
|
} };
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] QString StatusPercentString(float volume) {
|
2021-09-27 08:13:57 +00:00
|
|
|
return QString::number(int(base::SafeRound(volume * 200))) + '%';
|
2021-05-07 13:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] int StatusPercentWidth(const QString &percent) {
|
|
|
|
return st::normalFont->width(percent);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
struct MembersRow::BlobsAnimation {
|
|
|
|
BlobsAnimation(
|
|
|
|
std::vector<Ui::Paint::Blobs::BlobData> blobDatas,
|
|
|
|
float levelDuration,
|
|
|
|
float maxLevel);
|
|
|
|
|
|
|
|
Ui::Paint::Blobs blobs;
|
|
|
|
crl::time lastTime = 0;
|
|
|
|
crl::time lastSoundingUpdateTime = 0;
|
|
|
|
float64 enter = 0.;
|
|
|
|
|
|
|
|
QImage userpicCache;
|
|
|
|
InMemoryKey userpicKey;
|
|
|
|
|
|
|
|
rpl::lifetime lifetime;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MembersRow::StatusIcon {
|
|
|
|
StatusIcon(bool shown, float volume);
|
|
|
|
|
|
|
|
const style::icon &speaker;
|
|
|
|
Ui::Paint::ArcsAnimation arcs;
|
|
|
|
Ui::Animations::Simple arcsAnimation;
|
|
|
|
Ui::Animations::Simple shownAnimation;
|
|
|
|
QString percent;
|
|
|
|
int percentWidth = 0;
|
|
|
|
int arcsWidth = 0;
|
|
|
|
int wasArcsWidth = 0;
|
|
|
|
bool shown = true;
|
|
|
|
|
|
|
|
rpl::lifetime lifetime;
|
|
|
|
};
|
|
|
|
|
|
|
|
MembersRow::BlobsAnimation::BlobsAnimation(
|
|
|
|
std::vector<Ui::Paint::Blobs::BlobData> blobDatas,
|
|
|
|
float levelDuration,
|
|
|
|
float maxLevel)
|
|
|
|
: blobs(std::move(blobDatas), levelDuration, maxLevel) {
|
|
|
|
style::PaletteChanged(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
userpicCache = QImage();
|
|
|
|
}, lifetime);
|
|
|
|
}
|
|
|
|
|
|
|
|
MembersRow::StatusIcon::StatusIcon(bool shown, float volume)
|
|
|
|
: speaker(st::groupCallStatusSpeakerIcon)
|
|
|
|
, arcs(
|
|
|
|
st::groupCallStatusSpeakerArcsAnimation,
|
|
|
|
kSpeakerThreshold,
|
|
|
|
volume,
|
|
|
|
Ui::Paint::ArcsAnimation::Direction::Right)
|
|
|
|
, percent(StatusPercentString(volume))
|
|
|
|
, percentWidth(StatusPercentWidth(percent))
|
|
|
|
, shown(shown) {
|
|
|
|
}
|
|
|
|
|
|
|
|
MembersRow::MembersRow(
|
|
|
|
not_null<MembersRowDelegate*> delegate,
|
|
|
|
not_null<PeerData*> participantPeer)
|
|
|
|
: PeerListRow(participantPeer)
|
2021-11-10 07:53:01 +00:00
|
|
|
, _delegate(delegate) {
|
2021-05-07 13:01:54 +00:00
|
|
|
refreshStatus();
|
|
|
|
_aboutText = participantPeer->about();
|
|
|
|
}
|
|
|
|
|
|
|
|
MembersRow::~MembersRow() = default;
|
|
|
|
|
|
|
|
void MembersRow::setSkipLevelUpdate(bool value) {
|
|
|
|
_skipLevelUpdate = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::updateState(
|
|
|
|
const Data::GroupCallParticipant *participant) {
|
|
|
|
setVolume(participant
|
|
|
|
? participant->volume
|
|
|
|
: Group::kDefaultVolume);
|
|
|
|
if (!participant) {
|
|
|
|
setState(State::Invited);
|
|
|
|
setSounding(false);
|
|
|
|
setSpeaking(false);
|
2021-05-31 11:46:15 +00:00
|
|
|
_mutedByMe = false;
|
2021-05-07 13:01:54 +00:00
|
|
|
_raisedHandRating = 0;
|
|
|
|
} else if (!participant->muted
|
2021-07-09 09:32:20 +00:00
|
|
|
|| (participant->sounding && participant->ssrc != 0)
|
|
|
|
|| (participant->additionalSounding
|
|
|
|
&& GetAdditionalAudioSsrc(participant->videoParams) != 0)) {
|
2021-05-31 11:46:15 +00:00
|
|
|
setState(State::Active);
|
2021-07-09 09:32:20 +00:00
|
|
|
setSounding((participant->sounding && participant->ssrc != 0)
|
|
|
|
|| (participant->additionalSounding
|
|
|
|
&& GetAdditionalAudioSsrc(participant->videoParams) != 0));
|
|
|
|
setSpeaking((participant->speaking && participant->ssrc != 0)
|
|
|
|
|| (participant->additionalSpeaking
|
|
|
|
&& GetAdditionalAudioSsrc(participant->videoParams) != 0));
|
2021-05-31 11:46:15 +00:00
|
|
|
_mutedByMe = participant->mutedByMe;
|
2021-05-07 13:01:54 +00:00
|
|
|
_raisedHandRating = 0;
|
|
|
|
} else if (participant->canSelfUnmute) {
|
2021-05-31 11:46:15 +00:00
|
|
|
setState(State::Inactive);
|
2021-05-07 13:01:54 +00:00
|
|
|
setSounding(false);
|
|
|
|
setSpeaking(false);
|
2021-05-31 11:46:15 +00:00
|
|
|
_mutedByMe = participant->mutedByMe;
|
2021-05-07 13:01:54 +00:00
|
|
|
_raisedHandRating = 0;
|
|
|
|
} else {
|
|
|
|
setSounding(false);
|
|
|
|
setSpeaking(false);
|
2021-05-31 11:46:15 +00:00
|
|
|
_mutedByMe = participant->mutedByMe;
|
|
|
|
_raisedHandRating = participant->raisedHandRating;
|
|
|
|
setState(_raisedHandRating ? State::RaisedHand : State::Muted);
|
2021-05-07 13:01:54 +00:00
|
|
|
}
|
|
|
|
refreshStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::setSpeaking(bool speaking) {
|
|
|
|
if (_speaking == speaking) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_speaking = speaking;
|
|
|
|
_speakingAnimation.start(
|
|
|
|
[=] { _delegate->rowUpdateRow(this); },
|
|
|
|
_speaking ? 0. : 1.,
|
|
|
|
_speaking ? 1. : 0.,
|
|
|
|
st::widgetFadeDuration);
|
|
|
|
|
|
|
|
if (!_speaking
|
2021-05-31 11:46:15 +00:00
|
|
|
|| _mutedByMe
|
2021-05-07 13:01:54 +00:00
|
|
|
|| (_state == State::Muted)
|
|
|
|
|| (_state == State::RaisedHand)) {
|
|
|
|
if (_statusIcon) {
|
|
|
|
_statusIcon = nullptr;
|
|
|
|
_delegate->rowUpdateRow(this);
|
|
|
|
}
|
|
|
|
} else if (!_statusIcon) {
|
|
|
|
_statusIcon = std::make_unique<StatusIcon>(
|
|
|
|
(_volume != Group::kDefaultVolume),
|
|
|
|
(float)_volume / Group::kMaxVolume);
|
|
|
|
_statusIcon->arcs.setStrokeRatio(kArcsStrokeRatio);
|
|
|
|
_statusIcon->arcsWidth = _statusIcon->arcs.finishedWidth();
|
|
|
|
_statusIcon->arcs.startUpdateRequests(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
if (!_statusIcon->arcsAnimation.animating()) {
|
|
|
|
_statusIcon->wasArcsWidth = _statusIcon->arcsWidth;
|
|
|
|
}
|
|
|
|
auto callback = [=](float64 value) {
|
|
|
|
_statusIcon->arcs.update(crl::now());
|
|
|
|
_statusIcon->arcsWidth = anim::interpolate(
|
|
|
|
_statusIcon->wasArcsWidth,
|
|
|
|
_statusIcon->arcs.finishedWidth(),
|
|
|
|
value);
|
|
|
|
_delegate->rowUpdateRow(this);
|
|
|
|
};
|
|
|
|
_statusIcon->arcsAnimation.start(
|
|
|
|
std::move(callback),
|
|
|
|
0.,
|
|
|
|
1.,
|
|
|
|
st::groupCallSpeakerArcsAnimation.duration);
|
|
|
|
}, _statusIcon->lifetime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::setSounding(bool sounding) {
|
|
|
|
if (_sounding == sounding) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_sounding = sounding;
|
|
|
|
if (!_sounding) {
|
|
|
|
_blobsAnimation = nullptr;
|
|
|
|
} else if (!_blobsAnimation) {
|
|
|
|
_blobsAnimation = std::make_unique<BlobsAnimation>(
|
|
|
|
RowBlobs() | ranges::to_vector,
|
|
|
|
kLevelDuration,
|
|
|
|
kMaxLevel);
|
|
|
|
_blobsAnimation->lastTime = crl::now();
|
|
|
|
updateLevel(GroupCall::kSpeakLevelThreshold);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::clearRaisedHandStatus() {
|
|
|
|
if (!_raisedHandStatus) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_raisedHandStatus = false;
|
|
|
|
refreshStatus();
|
|
|
|
_delegate->rowUpdateRow(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::setState(State state) {
|
|
|
|
if (_state == state) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto wasActive = (_state == State::Active);
|
|
|
|
const auto wasMuted = (_state == State::Muted)
|
|
|
|
|| (_state == State::RaisedHand);
|
|
|
|
const auto wasRaisedHand = (_state == State::RaisedHand);
|
|
|
|
_state = state;
|
|
|
|
const auto nowActive = (_state == State::Active);
|
|
|
|
const auto nowMuted = (_state == State::Muted)
|
|
|
|
|| (_state == State::RaisedHand);
|
|
|
|
const auto nowRaisedHand = (_state == State::RaisedHand);
|
|
|
|
if (!wasRaisedHand && nowRaisedHand) {
|
|
|
|
_raisedHandStatus = true;
|
|
|
|
_delegate->rowScheduleRaisedHandStatusRemove(this);
|
|
|
|
}
|
|
|
|
if (nowActive != wasActive) {
|
|
|
|
_activeAnimation.start(
|
|
|
|
[=] { _delegate->rowUpdateRow(this); },
|
|
|
|
nowActive ? 0. : 1.,
|
|
|
|
nowActive ? 1. : 0.,
|
|
|
|
st::widgetFadeDuration);
|
|
|
|
}
|
|
|
|
if (nowMuted != wasMuted) {
|
|
|
|
_mutedAnimation.start(
|
|
|
|
[=] { _delegate->rowUpdateRow(this); },
|
|
|
|
nowMuted ? 0. : 1.,
|
|
|
|
nowMuted ? 1. : 0.,
|
|
|
|
st::widgetFadeDuration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::setVolume(int volume) {
|
|
|
|
_volume = volume;
|
|
|
|
if (_statusIcon) {
|
|
|
|
const auto floatVolume = (float)volume / Group::kMaxVolume;
|
|
|
|
_statusIcon->arcs.setValue(floatVolume);
|
|
|
|
_statusIcon->percent = StatusPercentString(floatVolume);
|
|
|
|
_statusIcon->percentWidth = StatusPercentWidth(_statusIcon->percent);
|
|
|
|
|
|
|
|
const auto shown = (volume != Group::kDefaultVolume);
|
|
|
|
if (_statusIcon->shown != shown) {
|
|
|
|
_statusIcon->shown = shown;
|
|
|
|
_statusIcon->shownAnimation.start(
|
|
|
|
[=] { _delegate->rowUpdateRow(this); },
|
|
|
|
shown ? 0. : 1.,
|
|
|
|
shown ? 1. : 0.,
|
|
|
|
st::groupCallSpeakerArcsAnimation.duration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::updateLevel(float level) {
|
|
|
|
Expects(_blobsAnimation != nullptr);
|
|
|
|
|
|
|
|
const auto spoke = (level >= GroupCall::kSpeakLevelThreshold)
|
|
|
|
? crl::now()
|
|
|
|
: crl::time();
|
|
|
|
if (spoke && _speaking) {
|
|
|
|
_speakingLastTime = spoke;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_skipLevelUpdate) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spoke) {
|
|
|
|
_blobsAnimation->lastSoundingUpdateTime = spoke;
|
|
|
|
}
|
|
|
|
_blobsAnimation->blobs.setLevel(level);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::updateBlobAnimation(crl::time now) {
|
|
|
|
Expects(_blobsAnimation != nullptr);
|
|
|
|
|
|
|
|
const auto soundingFinishesAt = _blobsAnimation->lastSoundingUpdateTime
|
|
|
|
+ Data::GroupCall::kSoundStatusKeptFor;
|
|
|
|
const auto soundingStartsFinishing = soundingFinishesAt
|
|
|
|
- kBlobsEnterDuration;
|
|
|
|
const auto soundingFinishes = (soundingStartsFinishing < now);
|
|
|
|
if (soundingFinishes) {
|
|
|
|
_blobsAnimation->enter = std::clamp(
|
|
|
|
(soundingFinishesAt - now) / float64(kBlobsEnterDuration),
|
|
|
|
0.,
|
|
|
|
1.);
|
|
|
|
} else if (_blobsAnimation->enter < 1.) {
|
|
|
|
_blobsAnimation->enter = std::clamp(
|
|
|
|
(_blobsAnimation->enter
|
|
|
|
+ ((now - _blobsAnimation->lastTime)
|
|
|
|
/ float64(kBlobsEnterDuration))),
|
|
|
|
0.,
|
|
|
|
1.);
|
|
|
|
}
|
|
|
|
_blobsAnimation->blobs.updateLevel(now - _blobsAnimation->lastTime);
|
|
|
|
_blobsAnimation->lastTime = now;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::ensureUserpicCache(
|
2022-12-05 12:18:10 +00:00
|
|
|
Ui::PeerUserpicView &view,
|
2021-05-07 13:01:54 +00:00
|
|
|
int size) {
|
|
|
|
Expects(_blobsAnimation != nullptr);
|
|
|
|
|
|
|
|
const auto user = peer();
|
|
|
|
const auto key = user->userpicUniqueKey(view);
|
|
|
|
const auto full = QSize(size, size) * kWideScale * cIntRetinaFactor();
|
|
|
|
auto &cache = _blobsAnimation->userpicCache;
|
|
|
|
if (cache.isNull()) {
|
|
|
|
cache = QImage(full, QImage::Format_ARGB32_Premultiplied);
|
|
|
|
cache.setDevicePixelRatio(cRetinaFactor());
|
|
|
|
} else if (_blobsAnimation->userpicKey == key
|
|
|
|
&& cache.size() == full) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_blobsAnimation->userpicKey = key;
|
|
|
|
cache.fill(Qt::transparent);
|
|
|
|
{
|
|
|
|
Painter p(&cache);
|
|
|
|
const auto skip = (kWideScale - 1) / 2 * size;
|
|
|
|
user->paintUserpicLeft(p, view, skip, skip, kWideScale * size, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::paintBlobs(
|
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int sizew,
|
|
|
|
int sizeh,
|
|
|
|
PanelMode mode) {
|
|
|
|
if (!_blobsAnimation) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto size = sizew;
|
|
|
|
const auto shift = QPointF(x + size / 2., y + size / 2.);
|
|
|
|
auto hq = PainterHighQualityEnabler(p);
|
|
|
|
p.translate(shift);
|
2021-05-31 11:46:15 +00:00
|
|
|
const auto brush = _mutedByMe
|
2021-05-07 13:01:54 +00:00
|
|
|
? st::groupCallMemberMutedIcon->b
|
|
|
|
: anim::brush(
|
|
|
|
st::groupCallMemberInactiveStatus,
|
|
|
|
st::groupCallMemberActiveStatus,
|
|
|
|
_speakingAnimation.value(_speaking ? 1. : 0.));
|
|
|
|
_blobsAnimation->blobs.paint(p, brush);
|
|
|
|
p.translate(-shift);
|
|
|
|
p.setOpacity(1.);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::paintScaledUserpic(
|
|
|
|
Painter &p,
|
2022-12-05 12:18:10 +00:00
|
|
|
Ui::PeerUserpicView &userpic,
|
2021-05-07 13:01:54 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
int sizew,
|
|
|
|
int sizeh,
|
|
|
|
PanelMode mode) {
|
|
|
|
auto size = sizew;
|
|
|
|
if (!_blobsAnimation) {
|
|
|
|
peer()->paintUserpicLeft(p, userpic, x, y, outerWidth, size);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto enter = _blobsAnimation->enter;
|
|
|
|
const auto &minScale = kUserpicMinScale;
|
|
|
|
const auto scaleUserpic = minScale
|
|
|
|
+ (1. - minScale) * _blobsAnimation->blobs.currentLevel();
|
|
|
|
const auto scale = scaleUserpic * enter + 1. * (1. - enter);
|
|
|
|
if (scale == 1.) {
|
|
|
|
peer()->paintUserpicLeft(p, userpic, x, y, outerWidth, size);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ensureUserpicCache(userpic, size);
|
|
|
|
|
|
|
|
PainterHighQualityEnabler hq(p);
|
|
|
|
|
|
|
|
auto target = QRect(
|
|
|
|
x + (1 - kWideScale) / 2 * size,
|
|
|
|
y + (1 - kWideScale) / 2 * size,
|
|
|
|
kWideScale * size,
|
|
|
|
kWideScale * size);
|
|
|
|
auto shrink = anim::interpolate(
|
|
|
|
(1 - kWideScale) / 2 * size,
|
|
|
|
0,
|
|
|
|
scale);
|
|
|
|
auto margins = QMargins(shrink, shrink, shrink, shrink);
|
|
|
|
p.drawImage(
|
|
|
|
target.marginsAdded(margins),
|
|
|
|
_blobsAnimation->userpicCache);
|
|
|
|
}
|
|
|
|
|
2021-05-07 15:37:28 +00:00
|
|
|
void MembersRow::paintMuteIcon(
|
2022-09-16 20:23:27 +00:00
|
|
|
QPainter &p,
|
2021-05-07 15:37:28 +00:00
|
|
|
QRect iconRect,
|
|
|
|
MembersRowStyle style) {
|
|
|
|
_delegate->rowPaintIcon(p, iconRect, computeIconState(style));
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:01:54 +00:00
|
|
|
auto MembersRow::generatePaintUserpicCallback() -> PaintRoundImageCallback {
|
|
|
|
return [=](Painter &p, int x, int y, int outerWidth, int size) {
|
|
|
|
const auto outer = outerWidth;
|
|
|
|
paintComplexUserpic(p, x, y, outer, size, size, PanelMode::Default);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::paintComplexUserpic(
|
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
int sizew,
|
|
|
|
int sizeh,
|
|
|
|
PanelMode mode,
|
|
|
|
bool selected) {
|
|
|
|
paintBlobs(p, x, y, sizew, sizeh, mode);
|
|
|
|
paintScaledUserpic(
|
|
|
|
p,
|
|
|
|
ensureUserpicView(),
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
outerWidth,
|
|
|
|
sizew,
|
|
|
|
sizeh,
|
|
|
|
mode);
|
|
|
|
}
|
|
|
|
|
2021-05-14 12:08:48 +00:00
|
|
|
int MembersRow::statusIconWidth(bool skipIcon) const {
|
2021-05-07 13:01:54 +00:00
|
|
|
if (!_statusIcon || !_speaking) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
const auto shown = _statusIcon->shownAnimation.value(
|
|
|
|
_statusIcon->shown ? 1. : 0.);
|
2021-05-14 12:08:48 +00:00
|
|
|
const auto iconWidth = skipIcon
|
|
|
|
? 0
|
|
|
|
: (_statusIcon->speaker.width() + _statusIcon->arcsWidth);
|
|
|
|
const auto full = iconWidth
|
2021-05-07 13:01:54 +00:00
|
|
|
+ _statusIcon->percentWidth
|
|
|
|
+ st::normalFont->spacew;
|
2021-09-27 08:13:57 +00:00
|
|
|
return int(base::SafeRound(shown * full));
|
2021-05-07 13:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int MembersRow::statusIconHeight() const {
|
|
|
|
return (_statusIcon && _speaking) ? _statusIcon->speaker.height() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::paintStatusIcon(
|
|
|
|
Painter &p,
|
2021-05-11 16:29:54 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
2021-05-07 13:01:54 +00:00
|
|
|
const style::PeerListItem &st,
|
|
|
|
const style::font &font,
|
2021-05-14 12:08:48 +00:00
|
|
|
bool selected,
|
|
|
|
bool skipIcon) {
|
2021-05-07 13:01:54 +00:00
|
|
|
if (!_statusIcon) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto shown = _statusIcon->shownAnimation.value(
|
|
|
|
_statusIcon->shown ? 1. : 0.);
|
|
|
|
if (shown == 0.) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
p.setFont(font);
|
|
|
|
const auto color = (_speaking
|
|
|
|
? st.statusFgActive
|
|
|
|
: (selected ? st.statusFgOver : st.statusFg))->c;
|
|
|
|
p.setPen(color);
|
|
|
|
|
|
|
|
const auto speakerRect = QRect(
|
2021-05-11 16:29:54 +00:00
|
|
|
QPoint(x, y + (font->height - statusIconHeight()) / 2),
|
2021-05-07 13:01:54 +00:00
|
|
|
_statusIcon->speaker.size());
|
|
|
|
const auto arcPosition = speakerRect.topLeft()
|
|
|
|
+ QPoint(
|
|
|
|
speakerRect.width() - st::groupCallStatusSpeakerArcsSkip,
|
|
|
|
speakerRect.height() / 2);
|
2021-05-14 12:08:48 +00:00
|
|
|
const auto iconWidth = skipIcon
|
|
|
|
? 0
|
|
|
|
: (speakerRect.width() + _statusIcon->arcsWidth);
|
|
|
|
const auto fullWidth = iconWidth
|
2021-05-07 13:01:54 +00:00
|
|
|
+ _statusIcon->percentWidth
|
|
|
|
+ st::normalFont->spacew;
|
|
|
|
|
|
|
|
p.save();
|
|
|
|
if (shown < 1.) {
|
|
|
|
const auto centerx = speakerRect.x() + fullWidth / 2;
|
|
|
|
const auto centery = speakerRect.y() + speakerRect.height() / 2;
|
|
|
|
p.translate(centerx, centery);
|
|
|
|
p.scale(shown, shown);
|
|
|
|
p.translate(-centerx, -centery);
|
|
|
|
}
|
2021-05-14 12:08:48 +00:00
|
|
|
if (!skipIcon) {
|
|
|
|
_statusIcon->speaker.paint(
|
|
|
|
p,
|
|
|
|
speakerRect.topLeft(),
|
|
|
|
speakerRect.width(),
|
|
|
|
color);
|
|
|
|
p.translate(arcPosition);
|
|
|
|
_statusIcon->arcs.paint(p, color);
|
|
|
|
p.translate(-arcPosition);
|
|
|
|
}
|
2021-05-07 13:01:54 +00:00
|
|
|
p.setFont(st::normalFont);
|
|
|
|
p.setPen(st.statusFgActive);
|
|
|
|
p.drawTextLeft(
|
2021-05-14 12:08:48 +00:00
|
|
|
x + iconWidth,
|
2021-05-11 16:29:54 +00:00
|
|
|
y,
|
2021-05-07 13:01:54 +00:00
|
|
|
fullWidth,
|
|
|
|
_statusIcon->percent);
|
|
|
|
p.restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::setAbout(const QString &about) {
|
|
|
|
if (_aboutText == about) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_aboutText = about;
|
|
|
|
_delegate->rowUpdateRow(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::paintStatusText(
|
|
|
|
Painter &p,
|
|
|
|
const style::PeerListItem &st,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int availableWidth,
|
|
|
|
int outerWidth,
|
|
|
|
bool selected) {
|
2021-05-07 15:37:28 +00:00
|
|
|
paintComplexStatusText(
|
|
|
|
p,
|
|
|
|
st,
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
availableWidth,
|
|
|
|
outerWidth,
|
|
|
|
selected,
|
2021-05-30 14:46:51 +00:00
|
|
|
MembersRowStyle::Default);
|
2021-05-07 15:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::paintComplexStatusText(
|
|
|
|
Painter &p,
|
|
|
|
const style::PeerListItem &st,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int availableWidth,
|
|
|
|
int outerWidth,
|
|
|
|
bool selected,
|
|
|
|
MembersRowStyle style) {
|
2021-05-30 14:46:51 +00:00
|
|
|
const auto skip = (style == MembersRowStyle::Default)
|
2021-05-14 12:08:48 +00:00
|
|
|
? _delegate->rowPaintStatusIcon(
|
|
|
|
p,
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
outerWidth,
|
|
|
|
this,
|
|
|
|
computeIconState(MembersRowStyle::Narrow))
|
|
|
|
: 0;
|
|
|
|
const auto narrowMode = (skip > 0);
|
|
|
|
x += skip;
|
|
|
|
availableWidth -= skip;
|
2021-05-07 13:01:54 +00:00
|
|
|
const auto &font = st::normalFont;
|
2021-05-30 14:46:51 +00:00
|
|
|
const auto about = (style == MembersRowStyle::Video)
|
2021-05-11 08:57:41 +00:00
|
|
|
? QString()
|
2021-05-14 12:08:48 +00:00
|
|
|
: ((_state == State::RaisedHand && !_raisedHandStatus)
|
2021-06-01 10:16:40 +00:00
|
|
|
|| (_state != State::RaisedHand && !_speaking))
|
2021-05-07 13:01:54 +00:00
|
|
|
? _aboutText
|
|
|
|
: QString();
|
|
|
|
if (about.isEmpty()
|
|
|
|
&& _state != State::Invited
|
2021-05-31 11:46:15 +00:00
|
|
|
&& !_mutedByMe) {
|
2021-05-14 12:08:48 +00:00
|
|
|
paintStatusIcon(p, x, y, st, font, selected, narrowMode);
|
2021-05-07 13:01:54 +00:00
|
|
|
|
2021-05-14 12:08:48 +00:00
|
|
|
const auto translatedWidth = statusIconWidth(narrowMode);
|
2021-05-07 13:01:54 +00:00
|
|
|
p.translate(translatedWidth, 0);
|
|
|
|
const auto guard = gsl::finally([&] {
|
|
|
|
p.translate(-translatedWidth, 0);
|
|
|
|
});
|
|
|
|
|
2021-05-14 17:32:43 +00:00
|
|
|
const auto &style = (!narrowMode
|
|
|
|
|| (_state == State::RaisedHand && _raisedHandStatus))
|
|
|
|
? st
|
|
|
|
: st::groupCallNarrowMembersListItem;
|
2021-05-07 13:01:54 +00:00
|
|
|
PeerListRow::paintStatusText(
|
|
|
|
p,
|
2021-05-14 17:32:43 +00:00
|
|
|
style,
|
2021-05-07 13:01:54 +00:00
|
|
|
x,
|
|
|
|
y,
|
|
|
|
availableWidth - translatedWidth,
|
|
|
|
outerWidth,
|
|
|
|
selected);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
p.setFont(font);
|
2021-05-30 14:46:51 +00:00
|
|
|
if (style == MembersRowStyle::Video) {
|
2021-05-07 15:37:28 +00:00
|
|
|
p.setPen(st::groupCallVideoSubTextFg);
|
2021-05-31 11:46:15 +00:00
|
|
|
} else if (_mutedByMe) {
|
2021-05-07 13:01:54 +00:00
|
|
|
p.setPen(st::groupCallMemberMutedIcon);
|
|
|
|
} else {
|
|
|
|
p.setPen(st::groupCallMemberNotJoinedStatus);
|
|
|
|
}
|
|
|
|
p.drawTextLeft(
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
outerWidth,
|
2021-05-31 11:46:15 +00:00
|
|
|
(_mutedByMe
|
2021-05-07 13:01:54 +00:00
|
|
|
? tr::lng_group_call_muted_by_me_status(tr::now)
|
2021-05-11 08:57:41 +00:00
|
|
|
: !about.isEmpty()
|
2021-05-07 13:01:54 +00:00
|
|
|
? font->m.elidedText(about, Qt::ElideRight, availableWidth)
|
|
|
|
: _delegate->rowIsMe(peer())
|
|
|
|
? tr::lng_status_connecting(tr::now)
|
|
|
|
: tr::lng_group_call_invited_status(tr::now)));
|
|
|
|
}
|
|
|
|
|
2021-10-13 12:37:38 +00:00
|
|
|
QSize MembersRow::rightActionSize() const {
|
2021-05-14 17:32:43 +00:00
|
|
|
return _delegate->rowIsNarrow() ? QSize() : QSize(
|
2021-05-07 13:01:54 +00:00
|
|
|
st::groupCallActiveButton.width,
|
|
|
|
st::groupCallActiveButton.height);
|
|
|
|
}
|
|
|
|
|
2021-10-13 12:37:38 +00:00
|
|
|
bool MembersRow::rightActionDisabled() const {
|
2021-05-07 13:01:54 +00:00
|
|
|
return _delegate->rowIsMe(peer())
|
|
|
|
|| (_state == State::Invited)
|
|
|
|
|| !_delegate->rowCanMuteMembers();
|
|
|
|
}
|
|
|
|
|
2021-10-13 12:37:38 +00:00
|
|
|
QMargins MembersRow::rightActionMargins() const {
|
2021-05-07 13:01:54 +00:00
|
|
|
return QMargins(
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
st::groupCallMemberButtonSkip,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
2021-10-13 12:37:38 +00:00
|
|
|
void MembersRow::rightActionPaint(
|
2021-05-07 13:01:54 +00:00
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
bool selected,
|
|
|
|
bool actionSelected) {
|
2021-10-13 12:37:38 +00:00
|
|
|
auto size = rightActionSize();
|
2021-05-07 13:01:54 +00:00
|
|
|
const auto iconRect = style::rtlrect(
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
size.width(),
|
|
|
|
size.height(),
|
|
|
|
outerWidth);
|
|
|
|
if (_state == State::Invited) {
|
|
|
|
_actionRipple = nullptr;
|
|
|
|
}
|
|
|
|
if (_actionRipple) {
|
|
|
|
_actionRipple->paint(
|
|
|
|
p,
|
|
|
|
x + st::groupCallActiveButton.rippleAreaPosition.x(),
|
|
|
|
y + st::groupCallActiveButton.rippleAreaPosition.y(),
|
|
|
|
outerWidth);
|
|
|
|
if (_actionRipple->empty()) {
|
|
|
|
_actionRipple.reset();
|
|
|
|
}
|
|
|
|
}
|
2021-05-07 15:37:28 +00:00
|
|
|
paintMuteIcon(p, iconRect);
|
2021-05-07 13:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MembersRowDelegate::IconState MembersRow::computeIconState(
|
2021-05-07 15:37:28 +00:00
|
|
|
MembersRowStyle style) const {
|
2021-05-07 13:01:54 +00:00
|
|
|
const auto speaking = _speakingAnimation.value(_speaking ? 1. : 0.);
|
|
|
|
const auto active = _activeAnimation.value(
|
|
|
|
(_state == State::Active) ? 1. : 0.);
|
|
|
|
const auto muted = _mutedAnimation.value(
|
|
|
|
(_state == State::Muted || _state == State::RaisedHand) ? 1. : 0.);
|
|
|
|
return {
|
|
|
|
.speaking = speaking,
|
|
|
|
.active = active,
|
|
|
|
.muted = muted,
|
2021-05-31 11:46:15 +00:00
|
|
|
.mutedByMe = _mutedByMe,
|
2021-05-07 13:01:54 +00:00
|
|
|
.raisedHand = (_state == State::RaisedHand),
|
2021-05-14 12:08:48 +00:00
|
|
|
.invited = (_state == State::Invited),
|
2021-05-07 15:37:28 +00:00
|
|
|
.style = style,
|
2021-05-07 13:01:54 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-27 19:20:16 +00:00
|
|
|
void MembersRow::showContextMenu() {
|
|
|
|
return _delegate->rowShowContextMenu(this);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:01:54 +00:00
|
|
|
void MembersRow::refreshStatus() {
|
|
|
|
setCustomStatus(
|
|
|
|
(_speaking
|
|
|
|
? tr::lng_group_call_active(tr::now)
|
|
|
|
: _raisedHandStatus
|
|
|
|
? tr::lng_group_call_raised_hand_status(tr::now)
|
|
|
|
: tr::lng_group_call_inactive(tr::now)),
|
|
|
|
_speaking);
|
|
|
|
}
|
|
|
|
|
2021-10-13 12:37:38 +00:00
|
|
|
void MembersRow::rightActionAddRipple(
|
|
|
|
QPoint point,
|
|
|
|
Fn<void()> updateCallback) {
|
2021-05-07 13:01:54 +00:00
|
|
|
if (!_actionRipple) {
|
2022-10-03 11:11:05 +00:00
|
|
|
auto mask = Ui::RippleAnimation::EllipseMask(QSize(
|
2021-05-07 13:01:54 +00:00
|
|
|
st::groupCallActiveButton.rippleAreaSize,
|
|
|
|
st::groupCallActiveButton.rippleAreaSize));
|
|
|
|
_actionRipple = std::make_unique<Ui::RippleAnimation>(
|
|
|
|
st::groupCallActiveButton.ripple,
|
|
|
|
std::move(mask),
|
|
|
|
std::move(updateCallback));
|
|
|
|
}
|
|
|
|
_actionRipple->add(point - st::groupCallActiveButton.rippleAreaPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MembersRow::refreshName(const style::PeerListItem &st) {
|
|
|
|
PeerListRow::refreshName(st);
|
2021-05-14 12:08:48 +00:00
|
|
|
//_narrowName = Ui::Text::String();
|
2021-05-07 13:01:54 +00:00
|
|
|
}
|
|
|
|
|
2021-10-13 12:37:38 +00:00
|
|
|
void MembersRow::rightActionStopLastRipple() {
|
2021-05-07 13:01:54 +00:00
|
|
|
if (_actionRipple) {
|
|
|
|
_actionRipple->lastStop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Calls::Group
|