2016-04-09 18:45:55 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-09 18:45:55 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-09 18:45:55 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-04-14 11:00:23 +00:00
|
|
|
#include "ui/text/text.h"
|
2019-06-17 14:37:29 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2022-08-09 15:53:40 +00:00
|
|
|
#include "ui/unread_badge.h"
|
2018-01-04 19:54:35 +00:00
|
|
|
#include "dialogs/dialogs_key.h"
|
2021-10-01 12:42:44 +00:00
|
|
|
#include "dialogs/ui/dialogs_message_view.h"
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
class History;
|
|
|
|
class HistoryItem;
|
|
|
|
|
2020-05-28 14:32:10 +00:00
|
|
|
namespace Data {
|
|
|
|
class CloudImageView;
|
|
|
|
} // namespace Data
|
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
namespace Ui {
|
|
|
|
class RippleAnimation;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2021-10-01 10:57:24 +00:00
|
|
|
namespace Dialogs::Ui {
|
|
|
|
using namespace ::Ui;
|
2016-04-09 18:45:55 +00:00
|
|
|
class RowPainter;
|
2022-05-16 11:38:35 +00:00
|
|
|
class VideoUserpic;
|
2022-09-29 10:33:17 +00:00
|
|
|
struct PaintContext;
|
2021-10-01 10:57:24 +00:00
|
|
|
} // namespace Dialogs::Ui
|
|
|
|
|
|
|
|
namespace Dialogs {
|
2016-04-09 18:45:55 +00:00
|
|
|
|
2020-03-09 11:17:56 +00:00
|
|
|
enum class SortMode;
|
|
|
|
|
2019-06-17 14:37:29 +00:00
|
|
|
class BasicRow {
|
2016-12-05 11:01:08 +00:00
|
|
|
public:
|
2019-06-17 14:37:29 +00:00
|
|
|
BasicRow();
|
2022-05-16 11:38:35 +00:00
|
|
|
virtual ~BasicRow();
|
2019-06-17 14:37:29 +00:00
|
|
|
|
2022-05-16 11:38:35 +00:00
|
|
|
virtual void paintUserpic(
|
2019-06-17 14:37:29 +00:00
|
|
|
Painter &p,
|
|
|
|
not_null<PeerData*> peer,
|
2022-05-16 11:38:35 +00:00
|
|
|
Ui::VideoUserpic *videoUserpic,
|
2020-12-02 10:52:19 +00:00
|
|
|
History *historyForCornerBadge,
|
2022-09-29 10:33:17 +00:00
|
|
|
const Ui::PaintContext &context) const;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback);
|
2016-12-05 11:01:08 +00:00
|
|
|
void stopLastRipple();
|
|
|
|
|
2019-06-17 14:37:29 +00:00
|
|
|
void paintRipple(
|
2022-09-16 20:23:27 +00:00
|
|
|
QPainter &p,
|
2019-06-17 14:37:29 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
const QColor *colorOverride = nullptr) const;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
2020-05-28 14:32:10 +00:00
|
|
|
std::shared_ptr<Data::CloudImageView> &userpicView() const {
|
|
|
|
return _userpic;
|
|
|
|
}
|
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
private:
|
2020-05-28 14:32:10 +00:00
|
|
|
mutable std::shared_ptr<Data::CloudImageView> _userpic;
|
2017-02-21 13:45:56 +00:00
|
|
|
mutable std::unique_ptr<Ui::RippleAnimation> _ripple;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-04-09 18:45:55 +00:00
|
|
|
class List;
|
2019-06-17 14:37:29 +00:00
|
|
|
class Row : public BasicRow {
|
2016-04-09 18:45:55 +00:00
|
|
|
public:
|
2018-01-04 17:15:04 +00:00
|
|
|
explicit Row(std::nullptr_t) {
|
|
|
|
}
|
2019-06-17 14:37:29 +00:00
|
|
|
Row(Key key, int pos);
|
2016-04-09 18:45:55 +00:00
|
|
|
|
2022-05-16 11:38:35 +00:00
|
|
|
void updateCornerBadgeShown(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
Fn<void()> updateCallback = nullptr) const;
|
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
Ui::VideoUserpic *videoUserpic,
|
|
|
|
History *historyForCornerBadge,
|
2022-09-29 10:33:17 +00:00
|
|
|
const Ui::PaintContext &context) const final override;
|
2022-05-16 11:38:35 +00:00
|
|
|
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] Key key() const {
|
2018-01-04 17:15:04 +00:00
|
|
|
return _id;
|
|
|
|
}
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] History *history() const {
|
2018-01-04 17:15:04 +00:00
|
|
|
return _id.history();
|
|
|
|
}
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] Data::Folder *folder() const {
|
2019-04-15 11:54:03 +00:00
|
|
|
return _id.folder();
|
2018-01-04 17:15:04 +00:00
|
|
|
}
|
2022-09-23 19:21:31 +00:00
|
|
|
[[nodiscard]] Data::ForumTopic *topic() const {
|
|
|
|
return _id.topic();
|
|
|
|
}
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] not_null<Entry*> entry() const {
|
2018-01-05 15:57:18 +00:00
|
|
|
return _id.entry();
|
|
|
|
}
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] int pos() const {
|
2016-04-09 18:45:55 +00:00
|
|
|
return _pos;
|
|
|
|
}
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] uint64 sortKey(FilterId filterId) const;
|
2018-01-04 17:15:04 +00:00
|
|
|
|
2019-04-23 12:29:23 +00:00
|
|
|
void validateListEntryCache() const;
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] const Ui::Text::String &listEntryCache() const {
|
2019-04-23 12:29:23 +00:00
|
|
|
return _listEntryCache;
|
|
|
|
}
|
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
// for any attached data, for example View in contacts list
|
|
|
|
void *attached = nullptr;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class List;
|
|
|
|
|
2022-05-16 11:38:35 +00:00
|
|
|
struct CornerBadgeUserpic {
|
|
|
|
InMemoryKey key;
|
|
|
|
float64 shown = 0.;
|
|
|
|
int frameIndex = -1;
|
|
|
|
bool active = false;
|
|
|
|
QImage frame;
|
|
|
|
Ui::Animations::Simple animation;
|
|
|
|
};
|
|
|
|
|
|
|
|
void setCornerBadgeShown(
|
|
|
|
bool shown,
|
|
|
|
Fn<void()> updateCallback) const;
|
|
|
|
void ensureCornerBadgeUserpic() const;
|
|
|
|
static void PaintCornerBadgeFrame(
|
|
|
|
not_null<CornerBadgeUserpic*> data,
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
Ui::VideoUserpic *videoUserpic,
|
2022-05-16 12:32:24 +00:00
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
2022-09-29 10:33:17 +00:00
|
|
|
const Ui::PaintContext &context);
|
2022-05-16 11:38:35 +00:00
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
Key _id;
|
|
|
|
int _pos = 0;
|
2019-04-23 12:29:23 +00:00
|
|
|
mutable uint32 _listEntryCacheVersion = 0;
|
2019-06-12 13:26:04 +00:00
|
|
|
mutable Ui::Text::String _listEntryCache;
|
2022-05-16 11:38:35 +00:00
|
|
|
mutable std::unique_ptr<CornerBadgeUserpic> _cornerBadgeUserpic;
|
|
|
|
mutable bool _cornerBadgeShown = false;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-06-17 14:37:29 +00:00
|
|
|
class FakeRow : public BasicRow {
|
2016-04-09 18:45:55 +00:00
|
|
|
public:
|
2022-08-09 15:53:40 +00:00
|
|
|
FakeRow(
|
|
|
|
Key searchInChat,
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
Fn<void()> repaint);
|
2016-04-09 18:45:55 +00:00
|
|
|
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] Key searchInChat() const {
|
2018-02-14 19:38:01 +00:00
|
|
|
return _searchInChat;
|
2017-09-05 17:21:56 +00:00
|
|
|
}
|
2021-10-01 10:57:24 +00:00
|
|
|
[[nodiscard]] not_null<HistoryItem*> item() const {
|
2016-04-09 18:45:55 +00:00
|
|
|
return _item;
|
|
|
|
}
|
2021-10-01 12:42:44 +00:00
|
|
|
[[nodiscard]] Ui::MessageView &itemView() const {
|
|
|
|
return _itemView;
|
2020-05-12 16:28:44 +00:00
|
|
|
}
|
2022-08-09 15:53:40 +00:00
|
|
|
[[nodiscard]] Fn<void()> repaint() const {
|
|
|
|
return _repaint;
|
|
|
|
}
|
|
|
|
[[nodiscard]] Ui::PeerBadge &badge() const {
|
|
|
|
return _badge;
|
|
|
|
}
|
2022-08-09 11:12:19 +00:00
|
|
|
[[nodiscard]] const Ui::Text::String &name() const;
|
2020-05-12 16:28:44 +00:00
|
|
|
|
2016-04-09 18:45:55 +00:00
|
|
|
private:
|
2021-10-01 10:57:24 +00:00
|
|
|
friend class Ui::RowPainter;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
2022-08-09 15:53:40 +00:00
|
|
|
const Key _searchInChat;
|
|
|
|
const not_null<HistoryItem*> _item;
|
|
|
|
const Fn<void()> _repaint;
|
2021-10-01 12:42:44 +00:00
|
|
|
mutable Ui::MessageView _itemView;
|
2022-08-09 15:53:40 +00:00
|
|
|
mutable Ui::PeerBadge _badge;
|
2022-08-09 11:12:19 +00:00
|
|
|
mutable Ui::Text::String _name;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Dialogs
|