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"
|
2018-01-04 19:54:35 +00:00
|
|
|
#include "dialogs/dialogs_key.h"
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
class History;
|
|
|
|
class HistoryItem;
|
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
namespace Ui {
|
|
|
|
class RippleAnimation;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2016-04-09 18:45:55 +00:00
|
|
|
namespace Dialogs {
|
|
|
|
namespace Layout {
|
|
|
|
class RowPainter;
|
|
|
|
} // namespace Layout
|
|
|
|
|
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();
|
|
|
|
~BasicRow();
|
|
|
|
|
|
|
|
void setOnline(bool online, Fn<void()> updateCallback = nullptr) const;
|
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
bool allowOnline,
|
|
|
|
bool active,
|
|
|
|
int fullWidth) 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(
|
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
const QColor *colorOverride = nullptr) const;
|
2016-12-05 11:01:08 +00:00
|
|
|
|
|
|
|
private:
|
2019-06-17 14:37:29 +00:00
|
|
|
struct OnlineUserpic {
|
|
|
|
InMemoryKey key;
|
|
|
|
float64 online = 0.;
|
|
|
|
bool active = false;
|
|
|
|
QImage frame;
|
|
|
|
Ui::Animations::Simple animation;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ensureOnlineUserpic() const;
|
|
|
|
static void PaintOnlineFrame(
|
|
|
|
not_null<OnlineUserpic*> data,
|
|
|
|
not_null<PeerData*> peer);
|
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
mutable std::unique_ptr<Ui::RippleAnimation> _ripple;
|
2019-06-17 14:37:29 +00:00
|
|
|
mutable std::unique_ptr<OnlineUserpic> _onlineUserpic;
|
|
|
|
mutable bool _online = false;
|
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
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
Key key() const {
|
|
|
|
return _id;
|
|
|
|
}
|
2016-04-09 18:45:55 +00:00
|
|
|
History *history() const {
|
2018-01-04 17:15:04 +00:00
|
|
|
return _id.history();
|
|
|
|
}
|
2019-04-15 11:54:03 +00:00
|
|
|
Data::Folder *folder() const {
|
|
|
|
return _id.folder();
|
2018-01-04 17:15:04 +00:00
|
|
|
}
|
2018-01-05 15:57:18 +00:00
|
|
|
not_null<Entry*> entry() const {
|
|
|
|
return _id.entry();
|
|
|
|
}
|
2016-04-09 18:45:55 +00:00
|
|
|
int pos() const {
|
|
|
|
return _pos;
|
|
|
|
}
|
2018-01-13 12:45:11 +00:00
|
|
|
uint64 sortKey() const;
|
2018-01-04 17:15:04 +00:00
|
|
|
|
2019-04-23 12:29:23 +00:00
|
|
|
void validateListEntryCache() const;
|
2019-06-12 13:26:04 +00:00
|
|
|
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;
|
|
|
|
|
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;
|
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:
|
2018-02-14 19:38:01 +00:00
|
|
|
FakeRow(Key searchInChat, not_null<HistoryItem*> item);
|
2016-04-09 18:45:55 +00:00
|
|
|
|
2018-02-14 19:38:01 +00:00
|
|
|
Key searchInChat() const {
|
|
|
|
return _searchInChat;
|
2017-09-05 17:21:56 +00:00
|
|
|
}
|
|
|
|
not_null<HistoryItem*> item() const {
|
2016-04-09 18:45:55 +00:00
|
|
|
return _item;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class Layout::RowPainter;
|
|
|
|
|
2018-02-14 19:38:01 +00:00
|
|
|
Key _searchInChat;
|
2017-09-05 17:21:56 +00:00
|
|
|
not_null<HistoryItem*> _item;
|
2016-04-09 18:45:55 +00:00
|
|
|
mutable const HistoryItem *_cacheFor = nullptr;
|
2019-06-12 13:26:04 +00:00
|
|
|
mutable Ui::Text::String _cache;
|
2016-04-09 18:45:55 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Dialogs
|