2020-11-20 19:25:35 +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
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/wrap/slide_wrap.h"
|
2020-12-11 13:16:37 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2020-11-20 19:25:35 +00:00
|
|
|
#include "base/object_ptr.h"
|
2020-12-11 14:53:02 +00:00
|
|
|
#include "base/timer.h"
|
2020-11-20 19:25:35 +00:00
|
|
|
|
|
|
|
class Painter;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
class PlainShadow;
|
2020-11-29 13:12:46 +00:00
|
|
|
class RoundButton;
|
2020-11-20 19:25:35 +00:00
|
|
|
|
|
|
|
struct GroupCallBarContent {
|
2020-12-11 11:04:34 +00:00
|
|
|
struct User {
|
|
|
|
QImage userpic;
|
|
|
|
std::pair<uint64, uint64> userpicKey = {};
|
|
|
|
int32 id = 0;
|
|
|
|
bool speaking = false;
|
|
|
|
};
|
2020-11-20 19:25:35 +00:00
|
|
|
int count = 0;
|
|
|
|
bool shown = false;
|
2020-12-11 11:04:34 +00:00
|
|
|
std::vector<User> users;
|
2020-11-20 19:25:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class GroupCallBar final {
|
|
|
|
public:
|
|
|
|
GroupCallBar(
|
|
|
|
not_null<QWidget*> parent,
|
2020-12-14 16:58:22 +00:00
|
|
|
rpl::producer<GroupCallBarContent> content,
|
|
|
|
rpl::producer<bool> &&hideBlobs);
|
2020-11-20 19:25:35 +00:00
|
|
|
~GroupCallBar();
|
|
|
|
|
|
|
|
void show();
|
|
|
|
void hide();
|
|
|
|
void raise();
|
|
|
|
void finishAnimating();
|
|
|
|
|
|
|
|
void setShadowGeometryPostprocess(Fn<QRect(QRect)> postprocess);
|
|
|
|
|
|
|
|
void move(int x, int y);
|
|
|
|
void resizeToWidth(int width);
|
|
|
|
[[nodiscard]] int height() const;
|
|
|
|
[[nodiscard]] rpl::producer<int> heightValue() const;
|
|
|
|
[[nodiscard]] rpl::producer<> barClicks() const;
|
|
|
|
[[nodiscard]] rpl::producer<> joinClicks() const;
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::lifetime &lifetime() {
|
|
|
|
return _wrap.lifetime();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-12-11 13:16:37 +00:00
|
|
|
using User = GroupCallBarContent::User;
|
2020-12-11 14:53:02 +00:00
|
|
|
struct BlobsAnimation;
|
|
|
|
struct Userpic;
|
|
|
|
|
2020-11-20 19:25:35 +00:00
|
|
|
void updateShadowGeometry(QRect wrapGeometry);
|
|
|
|
void updateControlsGeometry(QRect wrapGeometry);
|
2020-12-11 13:16:37 +00:00
|
|
|
void updateUserpicsFromContent();
|
2020-11-20 19:25:35 +00:00
|
|
|
void setupInner();
|
|
|
|
void paint(Painter &p);
|
2020-12-11 13:16:37 +00:00
|
|
|
void paintUserpics(Painter &p);
|
|
|
|
|
|
|
|
void toggleUserpic(Userpic &userpic, bool shown);
|
|
|
|
void updateUserpics();
|
|
|
|
void updateUserpicsPositions();
|
|
|
|
void validateUserpicCache(Userpic &userpic);
|
|
|
|
[[nodiscard]] bool needUserpicCacheRefresh(Userpic &userpic);
|
2020-12-11 14:53:02 +00:00
|
|
|
void ensureBlobsAnimation(Userpic &userpic);
|
|
|
|
void sendRandomLevels();
|
2020-11-20 19:25:35 +00:00
|
|
|
|
2020-11-29 13:12:46 +00:00
|
|
|
SlideWrap<> _wrap;
|
|
|
|
not_null<RpWidget*> _inner;
|
|
|
|
std::unique_ptr<RoundButton> _join;
|
|
|
|
std::unique_ptr<PlainShadow> _shadow;
|
2020-11-20 19:25:35 +00:00
|
|
|
rpl::event_stream<> _barClicks;
|
|
|
|
Fn<QRect(QRect)> _shadowGeometryPostprocess;
|
2020-12-11 13:16:37 +00:00
|
|
|
std::vector<Userpic> _userpics;
|
2020-12-11 14:53:02 +00:00
|
|
|
base::Timer _randomSpeakingTimer;
|
|
|
|
Ui::Animations::Basic _speakingAnimation;
|
2020-12-11 13:16:37 +00:00
|
|
|
int _maxUserpicsWidth = 0;
|
2020-11-20 19:25:35 +00:00
|
|
|
bool _shouldBeShown = false;
|
|
|
|
bool _forceHidden = false;
|
|
|
|
|
2020-12-14 16:58:22 +00:00
|
|
|
bool _skipLevelUpdate = false;
|
|
|
|
crl::time _speakingAnimationHideLastTime = 0;
|
|
|
|
|
2020-11-20 19:25:35 +00:00
|
|
|
GroupCallBarContent _content;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Ui
|