Support different row styles in chats list.

This commit is contained in:
John Preston 2022-09-29 14:33:17 +04:00
parent 1401b19994
commit 405d8c327d
20 changed files with 369 additions and 324 deletions

View file

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_histories.h" #include "data/data_histories.h"
#include "data/data_changes.h" #include "data/data_changes.h"
#include "dialogs/dialogs_key.h" #include "dialogs/dialogs_key.h"
#include "dialogs/ui/dialogs_layout.h"
#include "history/history.h" #include "history/history.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "ui/painter.h" #include "ui/painter.h"
@ -225,9 +226,15 @@ void Folder::loadUserpic() {
void Folder::paintUserpic( void Folder::paintUserpic(
Painter &p, Painter &p,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
int x, const Dialogs::Ui::PaintContext &context) const {
int y, paintUserpic(
int size) const { p,
context.st->padding.left(),
context.st->padding.top(),
context.st->photoSize);
}
void Folder::paintUserpic(Painter &p, int x, int y, int size) const {
paintUserpic(p, x, y, size, nullptr, nullptr); paintUserpic(p, x, y, size, nullptr, nullptr);
} }
@ -254,7 +261,7 @@ void Folder::paintUserpic(
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.drawEllipse(x, y, size, size); p.drawEllipse(x, y, size, size);
} }
if (size == st::dialogsPhotoSize) { if (size == st::defaultDialogRow.photoSize) {
const auto rect = QRect{ x, y, size, size }; const auto rect = QRect{ x, y, size, size };
if (overrideFg) { if (overrideFg) {
st::dialogsArchiveUserpic.paintInCenter( st::dialogsArchiveUserpic.paintInCenter(
@ -266,10 +273,10 @@ void Folder::paintUserpic(
} }
} else { } else {
p.save(); p.save();
const auto ratio = size / float64(st::dialogsPhotoSize); const auto ratio = size / float64(st::defaultDialogRow.photoSize);
p.translate(x + size / 2., y + size / 2.); p.translate(x + size / 2., y + size / 2.);
p.scale(ratio, ratio); p.scale(ratio, ratio);
const auto skip = st::dialogsPhotoSize; const auto skip = st::defaultDialogRow.photoSize;
const auto rect = QRect{ -skip, -skip, 2 * skip, 2 * skip }; const auto rect = QRect{ -skip, -skip, 2 * skip, 2 * skip };
if (overrideFg) { if (overrideFg) {
st::dialogsArchiveUserpic.paintInCenter( st::dialogsArchiveUserpic.paintInCenter(

View file

@ -60,10 +60,8 @@ public:
void paintUserpic( void paintUserpic(
Painter &p, Painter &p,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
int x, const Dialogs::Ui::PaintContext &context) const override;
int y, void paintUserpic(Painter &p, int x, int y, int size) const;
int size) const override;
void paintUserpic( void paintUserpic(
Painter &p, Painter &p,
int x, int x,

View file

@ -12,11 +12,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h" #include "data/data_session.h"
#include "data/stickers/data_custom_emoji.h" #include "data/stickers/data_custom_emoji.h"
#include "dialogs/dialogs_main_list.h" #include "dialogs/dialogs_main_list.h"
#include "dialogs/ui/dialogs_layout.h"
#include "core/application.h" #include "core/application.h"
#include "core/core_settings.h" #include "core/core_settings.h"
#include "history/history.h" #include "history/history.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "styles/style_dialogs.h"
namespace Data { namespace Data {
@ -207,20 +209,14 @@ void ForumTopic::loadUserpic() {
void ForumTopic::paintUserpic( void ForumTopic::paintUserpic(
Painter &p, Painter &p,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
int x, const Dialogs::Ui::PaintContext &context) const {
int y,
int size) const {
if (_icon) { if (_icon) {
const auto emoji = Data::FrameSizeFromTag( const auto &st = context.st;
Data::CustomEmojiManager::SizeTag::Isolated
) / style::DevicePixelRatio();
_icon->paint(p, { _icon->paint(p, {
.preview = st::windowBgOver->c, .preview = st::windowBgOver->c,
.now = crl::now(), .now = context.now,
.position = QPoint( .position = QPoint(st->padding.left(), st->padding.top()),
x + (size - emoji) / 2, .paused = context.paused,
y + (size - emoji) / 2),
.paused = false,
}); });
} }
} }
@ -297,7 +293,7 @@ void ForumTopic::applyIconId(DocumentId iconId) {
? _history->owner().customEmojiManager().create( ? _history->owner().customEmojiManager().create(
_iconId, _iconId,
[=] { updateChatListEntry(); }, [=] { updateChatListEntry(); },
Data::CustomEmojiManager::SizeTag::Isolated) Data::CustomEmojiManager::SizeTag::Normal)
: nullptr; : nullptr;
} }
updateChatListEntry(); updateChatListEntry();

View file

@ -76,9 +76,7 @@ public:
void paintUserpic( void paintUserpic(
Painter &p, Painter &p,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
int x, const Dialogs::Ui::PaintContext &context) const override;
int y,
int size) const override;
[[nodiscard]] int unreadCount() const; [[nodiscard]] int unreadCount() const;
[[nodiscard]] bool unreadCountKnown() const; [[nodiscard]] bool unreadCountKnown() const;

View file

@ -9,6 +9,16 @@ using "ui/basic.style";
using "ui/widgets/widgets.style"; using "ui/widgets/widgets.style";
DialogRow {
height: pixels;
padding: margins;
photoSize: pixels;
nameLeft: pixels;
nameTop: pixels;
textLeft: pixels;
textTop: pixels;
}
dialogsUnreadFont: font(12px bold); dialogsUnreadFont: font(12px bold);
dialogsUnreadHeight: 19px; dialogsUnreadHeight: 19px;
dialogsUnreadPadding: 5px; dialogsUnreadPadding: 5px;
@ -25,14 +35,20 @@ dialogsTextStyle: TextStyle(defaultTextStyle) {
} }
dialogsDateFont: font(13px); dialogsDateFont: font(13px);
dialogsDateSkip: 5px; dialogsDateSkip: 5px;
dialogsNameTop: 2px;
dialogsRowHeight: 62px; dialogsRowHeight: 62px;
dialogsFilterPadding: point(7px, 7px); dialogsFilterPadding: point(7px, 7px);
dialogsFilterSkip: 4px; dialogsFilterSkip: 4px;
dialogsPhotoSize: 46px;
dialogsPhotoPadding: 12px; defaultDialogRow: DialogRow {
dialogsPadding: point(10px, 8px); height: dialogsRowHeight;
padding: margins(10px, 8px, 10px, 8px);
photoSize: 46px;
nameLeft: 68px;
nameTop: 10px;
textLeft: 68px;
textTop: 35px;
}
dialogsOnlineBadgeStroke: 2px; dialogsOnlineBadgeStroke: 2px;
dialogsOnlineBadgeSize: 10px; dialogsOnlineBadgeSize: 10px;
@ -47,8 +63,6 @@ dialogsSpeakingDenominator: 8.;
dialogsImportantBarHeight: 37px; dialogsImportantBarHeight: 37px;
dialogsSkip: 8px;
dialogsWidthDuration: 120; dialogsWidthDuration: 120;
dialogsTextWidthMin: 150px; dialogsTextWidthMin: 150px;
@ -371,3 +385,13 @@ downloadLoadedSize: 30px;
downloadIconDocument: icon {{ "dialogs/dialogs_downloads", windowFgActive }}; downloadIconDocument: icon {{ "dialogs/dialogs_downloads", windowFgActive }};
downloadIconSize: 16px; downloadIconSize: 16px;
downloadIconSizeDone: 20px; downloadIconSizeDone: 20px;
forumTopicRow: DialogRow(defaultDialogRow) {
height: 54px;
padding: margins(8px, 7px, 8px, 7px);
photoSize: 20px;
nameLeft: 39px;
nameTop: 7px;
textLeft: 68px;
textTop: 29px;
}

View file

@ -23,6 +23,14 @@ class ForumTopic;
class CloudImageView; class CloudImageView;
} // namespace Data } // namespace Data
namespace Ui {
} // namespace Ui
namespace Dialogs::Ui {
using namespace ::Ui;
struct PaintContext;
} // namespace Dialogs::Ui
namespace Dialogs { namespace Dialogs {
class Row; class Row;
@ -174,18 +182,7 @@ public:
virtual void paintUserpic( virtual void paintUserpic(
Painter &p, Painter &p,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
int x, const Ui::PaintContext &context) const = 0;
int y,
int size) const = 0;
void paintUserpicLeft(
Painter &p,
std::shared_ptr<Data::CloudImageView> &view,
int x,
int y,
int w,
int size) const {
paintUserpic(p, view, rtl() ? (w - x - size) : x, y, size);
}
[[nodiscard]] TimeId chatListTimeId() const { [[nodiscard]] TimeId chatListTimeId() const {
return _timeId; return _timeId;

View file

@ -121,7 +121,7 @@ struct InnerWidget::HashtagResult {
}; };
struct InnerWidget::PeerSearchResult { struct InnerWidget::PeerSearchResult {
PeerSearchResult(not_null<PeerData*> peer) : peer(peer) { explicit PeerSearchResult(not_null<PeerData*> peer) : peer(peer) {
} }
not_null<PeerData*> peer; not_null<PeerData*> peer;
mutable Ui::Text::String name; mutable Ui::Text::String name;
@ -134,6 +134,7 @@ InnerWidget::InnerWidget(
not_null<Window::SessionController*> controller) not_null<Window::SessionController*> controller)
: RpWidget(parent) : RpWidget(parent)
, _controller(controller) , _controller(controller)
, _st(&st::defaultDialogRow)
, _pinnedShiftAnimation([=](crl::time now) { , _pinnedShiftAnimation([=](crl::time now) {
return pinnedShiftAnimationCallback(now); return pinnedShiftAnimationCallback(now);
}) })
@ -177,6 +178,7 @@ InnerWidget::InnerWidget(
) | rpl::start_with_next([=]( ) | rpl::start_with_next([=](
const Data::SendActionManager::AnimationUpdate &update) { const Data::SendActionManager::AnimationUpdate &update) {
const auto updateRect = Ui::RowPainter::SendActionAnimationRect( const auto updateRect = Ui::RowPainter::SendActionAnimationRect(
_st,
update.left, update.left,
update.width, update.width,
update.height, update.height,
@ -348,7 +350,7 @@ void InnerWidget::refreshWithCollapsedRows(bool toTop) {
int InnerWidget::dialogsOffset() const { int InnerWidget::dialogsOffset() const {
return _collapsedRows.size() * st::dialogsImportantBarHeight return _collapsedRows.size() * st::dialogsImportantBarHeight
- _skipTopDialogs * st::dialogsRowHeight; - _skipTopDialogs * _st->height;
} }
int InnerWidget::fixedOnTopCount() const { int InnerWidget::fixedOnTopCount() const {
@ -364,7 +366,7 @@ int InnerWidget::fixedOnTopCount() const {
} }
int InnerWidget::pinnedOffset() const { int InnerWidget::pinnedOffset() const {
return dialogsOffset() + fixedOnTopCount() * st::dialogsRowHeight; return dialogsOffset() + fixedOnTopCount() * _st->height;
} }
int InnerWidget::filteredOffset() const { int InnerWidget::filteredOffset() const {
@ -372,11 +374,17 @@ int InnerWidget::filteredOffset() const {
} }
int InnerWidget::peerSearchOffset() const { int InnerWidget::peerSearchOffset() const {
return filteredOffset() + (_filterResults.size() * st::dialogsRowHeight) + st::searchedBarHeight; return filteredOffset()
+ (_filterResults.size() * _st->height)
+ st::searchedBarHeight;
} }
int InnerWidget::searchedOffset() const { int InnerWidget::searchedOffset() const {
auto result = peerSearchOffset() + (_peerSearchResults.empty() ? 0 : ((_peerSearchResults.size() * st::dialogsRowHeight) + st::searchedBarHeight)); auto result = peerSearchOffset();
if (!_peerSearchResults.empty()) {
result += (_peerSearchResults.size() * st::dialogsRowHeight)
+ st::searchedBarHeight;
}
if (_searchInChat) { if (_searchInChat) {
result += searchInChatSkip(); result += searchInChatSkip();
} }
@ -412,6 +420,7 @@ void InnerWidget::changeOpenedForum(ChannelData *forum) {
stopReorderPinned(); stopReorderPinned();
clearSelection(); clearSelection();
_openedForum = forum ? forum->forum() : nullptr; _openedForum = forum ? forum->forum() : nullptr;
_st = forum ? &st::forumTopicRow : &st::defaultDialogRow;
_openedForumLifetime.destroy(); _openedForumLifetime.destroy();
if (forum) { if (forum) {
@ -449,7 +458,8 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
const auto rows = shownDialogs(); const auto rows = shownDialogs();
const auto &list = rows->all(); const auto &list = rows->all();
const auto otherStart = std::max(int(rows->size()) - _skipTopDialogs, 0) * st::dialogsRowHeight; const auto shownCount = int(rows->size()) - _skipTopDialogs;
const auto otherStart = std::max(shownCount, 0) * _st->height;
const auto active = activeEntry.key; const auto active = activeEntry.key;
const auto selected = _menuRow.key const auto selected = _menuRow.key
? _menuRow.key ? _menuRow.key
@ -464,7 +474,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
const auto skip = dialogsOffset(); const auto skip = dialogsOffset();
auto reorderingPinned = (_aboveIndex >= 0 && !_pinnedRows.empty()); auto reorderingPinned = (_aboveIndex >= 0 && !_pinnedRows.empty());
if (reorderingPinned) { if (reorderingPinned) {
dialogsClip = dialogsClip.marginsAdded(QMargins(0, st::dialogsRowHeight, 0, st::dialogsRowHeight)); dialogsClip = dialogsClip.marginsAdded(QMargins(0, _st->height, 0, _st->height));
} }
const auto promoted = fixedOnTopCount(); const auto promoted = fixedOnTopCount();
@ -482,6 +492,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
const auto isActive = (key == active); const auto isActive = (key == active);
const auto isSelected = (key == selected); const auto isSelected = (key == selected);
Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), { Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), {
.st = _st,
.folder = _openedFolder, .folder = _openedFolder,
.forum = _openedForum, .forum = _openedForum,
.filter = _filterId, .filter = _filterId,
@ -497,7 +508,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
} }
}; };
auto i = list.cfind(dialogsClip.top() - skip, st::dialogsRowHeight); auto i = list.cfind(dialogsClip.top() - skip, _st->height);
while (i != list.cend() && (*i)->pos() < _skipTopDialogs) { while (i != list.cend() && (*i)->pos() < _skipTopDialogs) {
++i; ++i;
} }
@ -506,13 +517,13 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
// If we're reordering pinned chats we need to fill this area background first. // If we're reordering pinned chats we need to fill this area background first.
if (reorderingPinned) { if (reorderingPinned) {
p.fillRect(0, (promoted - _skipTopDialogs) * st::dialogsRowHeight, fullWidth, st::dialogsRowHeight * _pinnedRows.size(), st::dialogsBg); p.fillRect(0, (promoted - _skipTopDialogs) * _st->height, fullWidth, st::dialogsRowHeight * _pinnedRows.size(), st::dialogsBg);
} }
p.translate(0, (lastPaintedPos - _skipTopDialogs) * st::dialogsRowHeight); p.translate(0, (lastPaintedPos - _skipTopDialogs) * _st->height);
for (auto e = list.cend(); i != e; ++i) { for (auto e = list.cend(); i != e; ++i) {
auto row = (*i); auto row = (*i);
if ((lastPaintedPos - _skipTopDialogs) * st::dialogsRowHeight >= dialogsClip.top() - skip + dialogsClip.height()) { if ((lastPaintedPos - _skipTopDialogs) * _st->height >= dialogsClip.top() - skip + dialogsClip.height()) {
break; break;
} }
@ -522,7 +533,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
paintDialog(row); paintDialog(row);
} }
p.translate(0, st::dialogsRowHeight); p.translate(0, _st->height);
++lastPaintedPos; ++lastPaintedPos;
} }
@ -531,9 +542,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
auto i = list.cfind(promoted + _aboveIndex, 1); auto i = list.cfind(promoted + _aboveIndex, 1);
auto pos = (i == list.cend()) ? -1 : (*i)->pos(); auto pos = (i == list.cend()) ? -1 : (*i)->pos();
if (pos == promoted + _aboveIndex) { if (pos == promoted + _aboveIndex) {
p.translate(0, (pos - lastPaintedPos) * st::dialogsRowHeight); p.translate(0, (pos - lastPaintedPos) * _st->height);
paintDialog(*i); paintDialog(*i);
p.translate(0, (lastPaintedPos - pos) * st::dialogsRowHeight); p.translate(0, (lastPaintedPos - pos) * _st->height);
} }
} }
} }
@ -547,7 +558,10 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
auto to = ceilclamp(r.y() + r.height(), st::mentionHeight, 0, _hashtagResults.size()); auto to = ceilclamp(r.y() + r.height(), st::mentionHeight, 0, _hashtagResults.size());
p.translate(0, from * st::mentionHeight); p.translate(0, from * st::mentionHeight);
if (from < _hashtagResults.size()) { if (from < _hashtagResults.size()) {
auto htagwidth = fullWidth - st::dialogsPadding.x() * 2; const auto htagleft = st::defaultDialogRow.padding.left();
auto htagwidth = fullWidth
- htagleft
- st::defaultDialogRow.padding.right();
p.setFont(st::mentionFont); p.setFont(st::mentionFont);
for (; from < to; ++from) { for (; from < to; ++from) {
@ -576,11 +590,11 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
p.setFont(st::mentionFont); p.setFont(st::mentionFont);
if (!first.isEmpty()) { if (!first.isEmpty()) {
p.setPen(selected ? st::mentionFgOverActive : st::mentionFgActive); p.setPen(selected ? st::mentionFgOverActive : st::mentionFgActive);
p.drawText(st::dialogsPadding.x(), st::mentionTop + st::mentionFont->ascent, first); p.drawText(htagleft, st::mentionTop + st::mentionFont->ascent, first);
} }
if (!second.isEmpty()) { if (!second.isEmpty()) {
p.setPen(selected ? st::mentionFgOver : st::mentionFg); p.setPen(selected ? st::mentionFgOver : st::mentionFg);
p.drawText(st::dialogsPadding.x() + firstwidth, st::mentionTop + st::mentionFont->ascent, second); p.drawText(htagleft + firstwidth, st::mentionTop + st::mentionFont->ascent, second);
} }
p.translate(0, st::mentionHeight); p.translate(0, st::mentionHeight);
} }
@ -588,9 +602,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
} }
if (!_filterResults.empty()) { if (!_filterResults.empty()) {
auto skip = filteredOffset(); auto skip = filteredOffset();
auto from = floorclamp(r.y() - skip, st::dialogsRowHeight, 0, _filterResults.size()); auto from = floorclamp(r.y() - skip, _st->height, 0, _filterResults.size());
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _filterResults.size()); auto to = ceilclamp(r.y() + r.height() - skip, _st->height, 0, _filterResults.size());
p.translate(0, from * st::dialogsRowHeight); p.translate(0, from * _st->height);
if (from < _filterResults.size()) { if (from < _filterResults.size()) {
for (; from < to; ++from) { for (; from < to; ++from) {
const auto row = _filterResults[from]; const auto row = _filterResults[from];
@ -603,6 +617,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
? _filteredPressed ? _filteredPressed
: _filteredSelected)); : _filteredSelected));
Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), { Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), {
.st = _st,
.folder = _openedFolder, .folder = _openedFolder,
.forum = _openedForum, .forum = _openedForum,
.filter = _filterId, .filter = _filterId,
@ -613,7 +628,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
.paused = videoPaused, .paused = videoPaused,
.narrow = (fullWidth < st::columnMinimalWidthLeft), .narrow = (fullWidth < st::columnMinimalWidthLeft),
}); });
p.translate(0, st::dialogsRowHeight); p.translate(0, _st->height);
} }
} }
} }
@ -642,6 +657,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
? _peerSearchPressed ? _peerSearchPressed
: _peerSearchSelected)); : _peerSearchSelected));
paintPeerSearchResult(p, result.get(), { paintPeerSearchResult(p, result.get(), {
.st = &st::defaultDialogRow,
.now = ms, .now = ms,
.width = fullWidth, .width = fullWidth,
.active = active, .active = active,
@ -704,6 +720,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
? _searchedPressed ? _searchedPressed
: _searchedSelected)); : _searchedSelected));
Ui::RowPainter::Paint(p, result.get(), { Ui::RowPainter::Paint(p, result.get(), {
.st = &st::defaultDialogRow,
.folder = _openedFolder, .folder = _openedFolder,
.forum = _openedForum, .forum = _openedForum,
.filter = _filterId, .filter = _filterId,
@ -778,14 +795,11 @@ void InnerWidget::paintCollapsedRow(
const auto text = row->folder->chatListName(); const auto text = row->folder->chatListName();
const auto unread = row->folder->chatListUnreadCount(); const auto unread = row->folder->chatListUnreadCount();
Ui::PaintCollapsedRow( Ui::PaintCollapsedRow(p, row->row, row->folder, text, unread, {
p, .st = _st,
row->row, .width = width(),
row->folder, .selected = selected,
text, });
unread,
width(),
selected);
} }
bool InnerWidget::isSearchResultActive( bool InnerWidget::isSearchResultActive(
@ -818,11 +832,17 @@ void InnerWidget::paintPeerSearchResult(
auto peer = result->peer; auto peer = result->peer;
auto userpicPeer = (peer->migrateTo() ? peer->migrateTo() : peer); auto userpicPeer = (peer->migrateTo() ? peer->migrateTo() : peer);
userpicPeer->paintUserpicLeft(p, result->row.userpicView(), st::dialogsPadding.x(), st::dialogsPadding.y(), width(), st::dialogsPhotoSize); userpicPeer->paintUserpicLeft(
p,
result->row.userpicView(),
context.st->padding.left(),
context.st->padding.top(),
width(),
context.st->photoSize);
auto nameleft = st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPhotoPadding; auto nameleft = context.st->nameLeft;
auto namewidth = context.width - nameleft - st::dialogsPadding.x(); auto namewidth = context.width - nameleft - context.st->padding.right();
QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height); QRect rectForName(nameleft, context.st->nameTop, namewidth, st::msgNameFont->height);
if (result->name.isEmpty()) { if (result->name.isEmpty()) {
result->name.setText( result->name.setText(
@ -874,7 +894,7 @@ void InnerWidget::paintPeerSearchResult(
}); });
rectForName.setWidth(rectForName.width() - badgeWidth); rectForName.setWidth(rectForName.width() - badgeWidth);
QRect tr(nameleft, st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip, namewidth, st::dialogsTextFont->height); QRect tr(context.st->textLeft, context.st->textTop, namewidth, st::dialogsTextFont->height);
p.setFont(st::dialogsTextFont); p.setFont(st::dialogsTextFont);
QString username = peer->userName(); QString username = peer->userName();
if (!context.active && username.startsWith(_peerSearchQuery, Qt::CaseInsensitive)) { if (!context.active && username.startsWith(_peerSearchQuery, Qt::CaseInsensitive)) {
@ -942,17 +962,18 @@ void InnerWidget::paintSearchInFilter(
const style::icon *icon, const style::icon *icon,
const Ui::Text::String &text) const { const Ui::Text::String &text) const {
const auto savedPen = p.pen(); const auto savedPen = p.pen();
const auto userpicLeft = st::dialogsPadding.x(); const auto userpicLeft = st::defaultDialogRow.padding.left();
const auto userpicTop = top const auto userpicTop = top
+ (st::dialogsSearchInHeight - st::dialogsSearchInPhotoSize) / 2; + (st::dialogsSearchInHeight - st::dialogsSearchInPhotoSize) / 2;
paintUserpic(p, userpicLeft, userpicTop, st::dialogsSearchInPhotoSize); paintUserpic(p, userpicLeft, userpicTop, st::dialogsSearchInPhotoSize);
const auto nameleft = st::dialogsPadding.x() const auto nameleft = st::defaultDialogRow.padding.left()
+ st::dialogsSearchInPhotoSize + st::dialogsSearchInPhotoSize
+ st::dialogsSearchInPhotoPadding; + st::dialogsSearchInPhotoPadding;
const auto namewidth = width() const auto namewidth = width()
- nameleft - nameleft
- st::dialogsPadding.x() * 2 - st::defaultDialogRow.padding.left()
- st::defaultDialogRow.padding.right()
- st::dialogsCancelSearch.width; - st::dialogsCancelSearch.width;
auto rectForName = QRect( auto rectForName = QRect(
nameleft, nameleft,
@ -1056,9 +1077,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
const auto selected = (collapsedSelected >= 0) const auto selected = (collapsedSelected >= 0)
? nullptr ? nullptr
: (mouseY >= offset) : (mouseY >= offset)
? shownDialogs()->rowAtY( ? shownDialogs()->rowAtY(mouseY - offset, _st->height)
mouseY - offset,
st::dialogsRowHeight)
: nullptr; : nullptr;
if (_selected != selected || _collapsedSelected != collapsedSelected) { if (_selected != selected || _collapsedSelected != collapsedSelected) {
updateSelectedRow(); updateSelectedRow();
@ -1089,7 +1108,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
} }
if (!_filterResults.empty()) { if (!_filterResults.empty()) {
auto skip = filteredOffset(); auto skip = filteredOffset();
auto filteredSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1; auto filteredSelected = (mouseY >= skip) ? ((mouseY - skip) / _st->height) : -1;
if (filteredSelected < 0 || filteredSelected >= _filterResults.size()) { if (filteredSelected < 0 || filteredSelected >= _filterResults.size()) {
filteredSelected = -1; filteredSelected = -1;
} }
@ -1147,11 +1166,14 @@ void InnerWidget::mousePressEvent(QMouseEvent *e) {
}); });
} else if (_pressed) { } else if (_pressed) {
auto row = _pressed; auto row = _pressed;
row->addRipple(e->pos() - QPoint(0, dialogsOffset() + _pressed->pos() * st::dialogsRowHeight), QSize(width(), st::dialogsRowHeight), [this, row] { row->addRipple(
if (!_pinnedShiftAnimation.animating()) { e->pos() - QPoint(0, dialogsOffset() + _pressed->pos() * _st->height),
row->entry()->updateChatListEntry(); QSize(width(), _st->height),
} [this, row] {
}); if (!_pinnedShiftAnimation.animating()) {
row->entry()->updateChatListEntry();
}
});
_dragStart = e->pos(); _dragStart = e->pos();
} else if (base::in_range(_hashtagPressed, 0, _hashtagResults.size()) && !_hashtagDeletePressed) { } else if (base::in_range(_hashtagPressed, 0, _hashtagResults.size()) && !_hashtagDeletePressed) {
auto row = &_hashtagResults[_hashtagPressed]->row; auto row = &_hashtagResults[_hashtagPressed]->row;
@ -1162,8 +1184,8 @@ void InnerWidget::mousePressEvent(QMouseEvent *e) {
const auto row = _filterResults[_filteredPressed]; const auto row = _filterResults[_filteredPressed];
const auto filterId = _filterId; const auto filterId = _filterId;
row->addRipple( row->addRipple(
e->pos() - QPoint(0, filteredOffset() + _filteredPressed * st::dialogsRowHeight), e->pos() - QPoint(0, filteredOffset() + _filteredPressed * _st->height),
QSize(width(), st::dialogsRowHeight), QSize(width(), _st->height),
[=] { repaintDialogRow(filterId, row); }); [=] { repaintDialogRow(filterId, row); });
} else if (base::in_range(_peerSearchPressed, 0, _peerSearchResults.size())) { } else if (base::in_range(_peerSearchPressed, 0, _peerSearchResults.size())) {
auto &result = _peerSearchResults[_peerSearchPressed]; auto &result = _peerSearchResults[_peerSearchPressed];
@ -1303,36 +1325,35 @@ bool InnerWidget::updateReorderPinned(QPoint localPosition) {
auto yaddWas = _pinnedRows[_draggingIndex].yadd.current(); auto yaddWas = _pinnedRows[_draggingIndex].yadd.current();
auto shift = 0; auto shift = 0;
auto now = crl::now(); auto now = crl::now();
auto rowHeight = st::dialogsRowHeight;
if (_dragStart.y() > localPosition.y() && _draggingIndex > 0) { if (_dragStart.y() > localPosition.y() && _draggingIndex > 0) {
shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex); shift = -floorclamp(_dragStart.y() - localPosition.y() + (_st->height / 2), _st->height, 0, _draggingIndex);
for (auto from = _draggingIndex, to = _draggingIndex + shift; from > to; --from) { for (auto from = _draggingIndex, to = _draggingIndex + shift; from > to; --from) {
list->movePinned(_dragging, -1); list->movePinned(_dragging, -1);
std::swap(_pinnedRows[from], _pinnedRows[from - 1]); std::swap(_pinnedRows[from], _pinnedRows[from - 1]);
_pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() - rowHeight, 0); _pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() - _st->height, 0);
_pinnedRows[from].animStartTime = now; _pinnedRows[from].animStartTime = now;
} }
} else if (_dragStart.y() < localPosition.y() && _draggingIndex + 1 < pinnedCount) { } else if (_dragStart.y() < localPosition.y() && _draggingIndex + 1 < pinnedCount) {
shift = floorclamp(localPosition.y() - _dragStart.y() + (rowHeight / 2), rowHeight, 0, pinnedCount - _draggingIndex - 1); shift = floorclamp(localPosition.y() - _dragStart.y() + (_st->height / 2), _st->height, 0, pinnedCount - _draggingIndex - 1);
for (auto from = _draggingIndex, to = _draggingIndex + shift; from < to; ++from) { for (auto from = _draggingIndex, to = _draggingIndex + shift; from < to; ++from) {
list->movePinned(_dragging, 1); list->movePinned(_dragging, 1);
std::swap(_pinnedRows[from], _pinnedRows[from + 1]); std::swap(_pinnedRows[from], _pinnedRows[from + 1]);
_pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() + rowHeight, 0); _pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() + _st->height, 0);
_pinnedRows[from].animStartTime = now; _pinnedRows[from].animStartTime = now;
} }
} }
if (shift) { if (shift) {
_draggingIndex += shift; _draggingIndex += shift;
_aboveIndex = _draggingIndex; _aboveIndex = _draggingIndex;
_dragStart.setY(_dragStart.y() + shift * rowHeight); _dragStart.setY(_dragStart.y() + shift * _st->height);
if (!_pinnedShiftAnimation.animating()) { if (!_pinnedShiftAnimation.animating()) {
_pinnedShiftAnimation.start(); _pinnedShiftAnimation.start();
} }
} }
_aboveTopShift = qCeil(_pinnedRows[_aboveIndex].yadd.current()); _aboveTopShift = qCeil(_pinnedRows[_aboveIndex].yadd.current());
_pinnedRows[_draggingIndex].yadd = anim::value(yaddWas - shift * rowHeight, localPosition.y() - _dragStart.y()); _pinnedRows[_draggingIndex].yadd = anim::value(yaddWas - shift * _st->height, localPosition.y() - _dragStart.y());
if (!_pinnedRows[_draggingIndex].animStartTime) { if (!_pinnedRows[_draggingIndex].animStartTime) {
_pinnedRows[_draggingIndex].yadd.finish(); _pinnedRows[_draggingIndex].yadd.finish();
} }
@ -1383,11 +1404,11 @@ bool InnerWidget::pinnedShiftAnimationCallback(crl::time now) {
} }
if (updateMin >= 0) { if (updateMin >= 0) {
auto top = pinnedOffset(); auto top = pinnedOffset();
auto updateFrom = top + st::dialogsRowHeight * (updateMin - 1); auto updateFrom = top + _st->height * (updateMin - 1);
auto updateHeight = st::dialogsRowHeight * (updateMax - updateMin + 3); auto updateHeight = _st->height * (updateMax - updateMin + 3);
if (base::in_range(_aboveIndex, 0, _pinnedRows.size())) { if (base::in_range(_aboveIndex, 0, _pinnedRows.size())) {
// Always include currently dragged chat in its current and old positions. // Always include currently dragged chat in its current and old positions.
auto aboveRowBottom = top + (_aboveIndex + 1) * st::dialogsRowHeight; auto aboveRowBottom = top + (_aboveIndex + 1) * _st->height;
auto aboveTopShift = qCeil(_pinnedRows[_aboveIndex].yadd.current()); auto aboveTopShift = qCeil(_pinnedRows[_aboveIndex].yadd.current());
accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + _aboveTopShift); accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + _aboveTopShift);
accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + aboveTopShift); accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + aboveTopShift);
@ -1549,9 +1570,9 @@ void InnerWidget::handleChatListEntryRefreshes() {
) | rpl::filter([=](const Event &event) { ) | rpl::filter([=](const Event &event) {
return (event.filterId == _filterId); return (event.filterId == _filterId);
}) | rpl::start_with_next([=](const Event &event) { }) | rpl::start_with_next([=](const Event &event) {
const auto rowHeight = st::dialogsRowHeight; const auto offset = dialogsOffset();
const auto from = dialogsOffset() + event.moved.from * rowHeight; const auto from = offset + event.moved.from * _st->height;
const auto to = dialogsOffset() + event.moved.to * rowHeight; const auto to = offset + event.moved.to * _st->height;
const auto &key = event.key; const auto &key = event.key;
const auto entry = key.entry(); const auto entry = key.entry();
@ -1590,7 +1611,7 @@ void InnerWidget::handleChatListEntryRefreshes() {
0, 0,
std::min(from, to), std::min(from, to),
width(), width(),
std::abs(from - to) + rowHeight); std::abs(from - to) + _st->height);
} }
}, lifetime()); }, lifetime());
} }
@ -1610,7 +1631,7 @@ int InnerWidget::defaultRowTop(not_null<Row*> row) const {
if (base::in_range(position, 0, _pinnedRows.size())) { if (base::in_range(position, 0, _pinnedRows.size())) {
top += qRound(_pinnedRows[position].yadd.current()); top += qRound(_pinnedRows[position].yadd.current());
} }
return top + position * st::dialogsRowHeight; return top + position * _st->height;
} }
void InnerWidget::repaintDialogRow( void InnerWidget::repaintDialogRow(
@ -1621,7 +1642,7 @@ void InnerWidget::repaintDialogRow(
if (const auto folder = row->folder()) { if (const auto folder = row->folder()) {
repaintCollapsedFolderRow(folder); repaintCollapsedFolderRow(folder);
} }
update(0, defaultRowTop(row), width(), st::dialogsRowHeight); update(0, defaultRowTop(row), width(), _st->height);
} }
} else if (_state == WidgetState::Filtered) { } else if (_state == WidgetState::Filtered) {
if (!filterId) { if (!filterId) {
@ -1629,9 +1650,9 @@ void InnerWidget::repaintDialogRow(
if (_filterResults[i]->key() == row->key()) { if (_filterResults[i]->key() == row->key()) {
update( update(
0, 0,
filteredOffset() + i * st::dialogsRowHeight, filteredOffset() + i * _st->height,
width(), width(),
st::dialogsRowHeight); _st->height);
break; break;
} }
} }
@ -1677,7 +1698,7 @@ void InnerWidget::updateDialogRow(
QRect updateRect, QRect updateRect,
UpdateRowSections sections) { UpdateRowSections sections) {
if (updateRect.isEmpty()) { if (updateRect.isEmpty()) {
updateRect = QRect(0, 0, width(), st::dialogsRowHeight); updateRect = QRect(0, 0, width(), _st->height);
} }
if (IsServerMsgId(-row.fullId.msg)) { if (IsServerMsgId(-row.fullId.msg)) {
if (const auto peer = row.key.peer()) { if (const auto peer = row.key.peer()) {
@ -1691,12 +1712,12 @@ void InnerWidget::updateDialogRow(
} }
} }
const auto updateRow = [&](int rowTop) { const auto updateRow = [&](int rowTop, int rowHeight = 0) {
rtlupdate( rtlupdate(
updateRect.x(), updateRect.x(),
rowTop + updateRect.y(), rowTop + updateRect.y(),
updateRect.width(), updateRect.width(),
updateRect.height()); rowHeight ? rowHeight : updateRect.height());
}; };
if (_state == WidgetState::Default) { if (_state == WidgetState::Default) {
if (sections & UpdateRowSection::Default) { if (sections & UpdateRowSection::Default) {
@ -1709,7 +1730,7 @@ void InnerWidget::updateDialogRow(
if (base::in_range(position, 0, _pinnedRows.size())) { if (base::in_range(position, 0, _pinnedRows.size())) {
top += qRound(_pinnedRows[position].yadd.current()); top += qRound(_pinnedRows[position].yadd.current());
} }
updateRow(top + position * st::dialogsRowHeight); updateRow(top + position * _st->height);
} }
} }
} else if (_state == WidgetState::Filtered) { } else if (_state == WidgetState::Filtered) {
@ -1719,7 +1740,7 @@ void InnerWidget::updateDialogRow(
auto index = 0; auto index = 0;
for (const auto result : _filterResults) { for (const auto result : _filterResults) {
if (result->key() == row.key) { if (result->key() == row.key) {
updateRow(add + index * st::dialogsRowHeight); updateRow(add + index * _st->height);
break; break;
} }
++index; ++index;
@ -1732,7 +1753,9 @@ void InnerWidget::updateDialogRow(
auto index = 0; auto index = 0;
for (const auto &result : _peerSearchResults) { for (const auto &result : _peerSearchResults) {
if (result->peer == peer) { if (result->peer == peer) {
updateRow(add + index * st::dialogsRowHeight); updateRow(
add + index * st::dialogsRowHeight,
st::dialogsRowHeight);
break; break;
} }
++index; ++index;
@ -1745,7 +1768,9 @@ void InnerWidget::updateDialogRow(
auto index = 0; auto index = 0;
for (const auto &result : _searchResults) { for (const auto &result : _searchResults) {
if (isSearchResultActive(result.get(), row)) { if (isSearchResultActive(result.get(), row)) {
updateRow(add + index * st::dialogsRowHeight); updateRow(
add + index * st::dialogsRowHeight,
st::dialogsRowHeight);
break; break;
} }
++index; ++index;
@ -1770,9 +1795,9 @@ void InnerWidget::updateSelectedRow(Key key) {
if (base::in_range(position, 0, _pinnedRows.size())) { if (base::in_range(position, 0, _pinnedRows.size())) {
top += qRound(_pinnedRows[position].yadd.current()); top += qRound(_pinnedRows[position].yadd.current());
} }
update(0, top + position * st::dialogsRowHeight, width(), st::dialogsRowHeight); update(0, top + position * _st->height, width(), _st->height);
} else if (_selected) { } else if (_selected) {
update(0, dialogsOffset() + _selected->pos() * st::dialogsRowHeight, width(), st::dialogsRowHeight); update(0, dialogsOffset() + _selected->pos() * _st->height, width(), _st->height);
} else if (_collapsedSelected >= 0) { } else if (_collapsedSelected >= 0) {
update(0, _collapsedSelected * st::dialogsImportantBarHeight, width(), st::dialogsImportantBarHeight); update(0, _collapsedSelected * st::dialogsImportantBarHeight, width(), st::dialogsImportantBarHeight);
} }
@ -1780,14 +1805,14 @@ void InnerWidget::updateSelectedRow(Key key) {
if (key) { if (key) {
for (auto i = 0, l = int(_filterResults.size()); i != l; ++i) { for (auto i = 0, l = int(_filterResults.size()); i != l; ++i) {
if (_filterResults[i]->key() == key) { if (_filterResults[i]->key() == key) {
update(0, filteredOffset() + i * st::dialogsRowHeight, width(), st::dialogsRowHeight); update(0, filteredOffset() + i * _st->height, width(), _st->height);
break; break;
} }
} }
} else if (_hashtagSelected >= 0) { } else if (_hashtagSelected >= 0) {
update(0, _hashtagSelected * st::mentionHeight, width(), st::mentionHeight); update(0, _hashtagSelected * st::mentionHeight, width(), st::mentionHeight);
} else if (_filteredSelected >= 0) { } else if (_filteredSelected >= 0) {
update(0, filteredOffset() + _filteredSelected * st::dialogsRowHeight, width(), st::dialogsRowHeight); update(0, filteredOffset() + _filteredSelected * _st->height, width(), _st->height);
} else if (_peerSearchSelected >= 0) { } else if (_peerSearchSelected >= 0) {
update(0, peerSearchOffset() + _peerSearchSelected * st::dialogsRowHeight, width(), st::dialogsRowHeight); update(0, peerSearchOffset() + _peerSearchSelected * st::dialogsRowHeight, width(), st::dialogsRowHeight);
} else if (_searchedSelected >= 0) { } else if (_searchedSelected >= 0) {
@ -2344,7 +2369,7 @@ void InnerWidget::refresh(bool toTop) {
if (list->empty()) { if (list->empty()) {
h = st::dialogsEmptyHeight; h = st::dialogsEmptyHeight;
} else { } else {
h = dialogsOffset() + list->size() * st::dialogsRowHeight; h = dialogsOffset() + list->size() * _st->height;
} }
} else if (_state == WidgetState::Filtered) { } else if (_state == WidgetState::Filtered) {
if (_waitingForSearch) { if (_waitingForSearch) {
@ -2537,8 +2562,8 @@ void InnerWidget::repaintSearchResult(int index) {
rtlupdate( rtlupdate(
0, 0,
searchedOffset() + index * st::dialogsRowHeight, searchedOffset() + index * st::dialogsRowHeight,
width(),
width(), st::dialogsRowHeight); st::dialogsRowHeight);
} }
void InnerWidget::clearFilter() { void InnerWidget::clearFilter() {
@ -2598,8 +2623,8 @@ void InnerWidget::selectSkip(int32 direction) {
if (_collapsedSelected >= 0 || _selected) { if (_collapsedSelected >= 0 || _selected) {
const auto fromY = (_collapsedSelected >= 0) const auto fromY = (_collapsedSelected >= 0)
? (_collapsedSelected * st::dialogsImportantBarHeight) ? (_collapsedSelected * st::dialogsImportantBarHeight)
: (dialogsOffset() + _selected->pos() * st::dialogsRowHeight); : (dialogsOffset() + _selected->pos() * _st->height);
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight }); _mustScrollTo.fire({ fromY, fromY + _st->height });
} }
} else if (_state == WidgetState::Filtered) { } else if (_state == WidgetState::Filtered) {
if (_hashtagResults.empty() && _filterResults.empty() && _peerSearchResults.empty() && _searchResults.empty()) { if (_hashtagResults.empty() && _filterResults.empty() && _peerSearchResults.empty() && _searchResults.empty()) {
@ -2654,9 +2679,9 @@ void InnerWidget::selectSkip(int32 direction) {
}); });
} else if (base::in_range(_filteredSelected, 0, _filterResults.size())) { } else if (base::in_range(_filteredSelected, 0, _filterResults.size())) {
_mustScrollTo.fire({ _mustScrollTo.fire({
filteredOffset() + _filteredSelected * st::dialogsRowHeight, filteredOffset() + _filteredSelected * _st->height,
filteredOffset() filteredOffset()
+ (_filteredSelected + 1) * st::dialogsRowHeight, + (_filteredSelected + 1) * _st->height,
}); });
} else if (base::in_range(_peerSearchSelected, 0, _peerSearchResults.size())) { } else if (base::in_range(_peerSearchSelected, 0, _peerSearchResults.size())) {
_mustScrollTo.fire({ _mustScrollTo.fire({
@ -2680,36 +2705,38 @@ void InnerWidget::selectSkip(int32 direction) {
} }
void InnerWidget::scrollToEntry(const RowDescriptor &entry) { void InnerWidget::scrollToEntry(const RowDescriptor &entry) {
int32 fromY = -1; auto fromY = -1;
auto rowHeight = _st->height;
if (_state == WidgetState::Default) { if (_state == WidgetState::Default) {
if (auto row = shownDialogs()->getRow(entry.key)) { if (auto row = shownDialogs()->getRow(entry.key)) {
fromY = dialogsOffset() + row->pos() * st::dialogsRowHeight; fromY = dialogsOffset() + row->pos() * _st->height;
} }
} else if (_state == WidgetState::Filtered) { } else if (_state == WidgetState::Filtered) {
for (int32 i = 0, c = _searchResults.size(); i < c; ++i) { for (int32 i = 0, c = _searchResults.size(); i < c; ++i) {
if (isSearchResultActive(_searchResults[i].get(), entry)) { if (isSearchResultActive(_searchResults[i].get(), entry)) {
fromY = searchedOffset() + i * st::dialogsRowHeight; fromY = searchedOffset() + i * st::dialogsRowHeight;
rowHeight = st::dialogsRowHeight;
break; break;
} }
} }
if (fromY < 0) { if (fromY < 0) {
for (auto i = 0, c = int(_filterResults.size()); i != c; ++i) { for (auto i = 0, c = int(_filterResults.size()); i != c; ++i) {
if (_filterResults[i]->key() == entry.key) { if (_filterResults[i]->key() == entry.key) {
fromY = filteredOffset() + (i * st::dialogsRowHeight); fromY = filteredOffset() + (i * _st->height);
break; break;
} }
} }
} }
} }
if (fromY >= 0) { if (fromY >= 0) {
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight }); _mustScrollTo.fire({ fromY, fromY + rowHeight });
} }
} }
void InnerWidget::selectSkipPage(int32 pixels, int32 direction) { void InnerWidget::selectSkipPage(int32 pixels, int32 direction) {
clearMouseSelection(); clearMouseSelection();
const auto list = shownDialogs(); const auto list = shownDialogs();
int toSkip = pixels / int(st::dialogsRowHeight); int toSkip = pixels / _st->height;
if (_state == WidgetState::Default) { if (_state == WidgetState::Default) {
if (!_selected) { if (!_selected) {
if (direction > 0 && list->size() > _skipTopDialogs) { if (direction > 0 && list->size() > _skipTopDialogs) {
@ -2735,8 +2762,8 @@ void InnerWidget::selectSkipPage(int32 pixels, int32 direction) {
if (_collapsedSelected >= 0 || _selected) { if (_collapsedSelected >= 0 || _selected) {
const auto fromY = (_collapsedSelected >= 0) const auto fromY = (_collapsedSelected >= 0)
? (_collapsedSelected * st::dialogsImportantBarHeight) ? (_collapsedSelected * st::dialogsImportantBarHeight)
: (dialogsOffset() + _selected->pos() * st::dialogsRowHeight); : (dialogsOffset() + _selected->pos() * _st->height);
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight }); _mustScrollTo.fire({ fromY, fromY + _st->height });
} }
} else { } else {
return selectSkip(direction * toSkip); return selectSkip(direction * toSkip);
@ -2751,10 +2778,10 @@ void InnerWidget::loadPeerPhotos() {
auto yFrom = _visibleTop; auto yFrom = _visibleTop;
auto yTo = _visibleTop + (_visibleBottom - _visibleTop) * (PreloadHeightsCount + 1); auto yTo = _visibleTop + (_visibleBottom - _visibleTop) * (PreloadHeightsCount + 1);
if (_state == WidgetState::Default) { if (_state == WidgetState::Default) {
auto otherStart = list->size() * st::dialogsRowHeight; auto otherStart = list->size() * _st->height;
if (yFrom < otherStart) { if (yFrom < otherStart) {
for (auto i = list->cfind(yFrom, st::dialogsRowHeight), end = list->cend(); i != end; ++i) { for (auto i = list->cfind(yFrom, _st->height), end = list->cend(); i != end; ++i) {
if (((*i)->pos() * st::dialogsRowHeight) >= yTo) { if (((*i)->pos() * _st->height) >= yTo) {
break; break;
} }
(*i)->entry()->loadUserpic(); (*i)->entry()->loadUserpic();
@ -2765,10 +2792,10 @@ void InnerWidget::loadPeerPhotos() {
} }
yTo -= otherStart; yTo -= otherStart;
} else if (_state == WidgetState::Filtered) { } else if (_state == WidgetState::Filtered) {
int32 from = (yFrom - filteredOffset()) / st::dialogsRowHeight; int32 from = (yFrom - filteredOffset()) / _st->height;
if (from < 0) from = 0; if (from < 0) from = 0;
if (from < _filterResults.size()) { if (from < _filterResults.size()) {
int32 to = (yTo / int32(st::dialogsRowHeight)) + 1; int32 to = (yTo / _st->height) + 1;
if (to > _filterResults.size()) to = _filterResults.size(); if (to > _filterResults.size()) to = _filterResults.size();
for (; from < to; ++from) { for (; from < to; ++from) {
@ -2776,20 +2803,20 @@ void InnerWidget::loadPeerPhotos() {
} }
} }
from = (yFrom > filteredOffset() + st::searchedBarHeight ? ((yFrom - filteredOffset() - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size(); from = (yFrom > filteredOffset() + st::searchedBarHeight ? ((yFrom - filteredOffset() - st::searchedBarHeight) / st::dialogsRowHeight) : 0) - _filterResults.size();
if (from < 0) from = 0; if (from < 0) from = 0;
if (from < _peerSearchResults.size()) { if (from < _peerSearchResults.size()) {
int32 to = (yTo > filteredOffset() + st::searchedBarHeight ? ((yTo - filteredOffset() - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() + 1; int32 to = (yTo > filteredOffset() + st::searchedBarHeight ? ((yTo - filteredOffset() - st::searchedBarHeight) / st::dialogsRowHeight) : 0) - _filterResults.size() + 1;
if (to > _peerSearchResults.size()) to = _peerSearchResults.size(); if (to > _peerSearchResults.size()) to = _peerSearchResults.size();
for (; from < to; ++from) { for (; from < to; ++from) {
_peerSearchResults[from]->peer->loadUserpic(); _peerSearchResults[from]->peer->loadUserpic();
} }
} }
from = (yFrom > filteredOffset() + ((_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? ((yFrom - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size(); from = (yFrom > filteredOffset() + ((_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? ((yFrom - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / st::dialogsRowHeight) : 0) - _filterResults.size() - _peerSearchResults.size();
if (from < 0) from = 0; if (from < 0) from = 0;
if (from < _searchResults.size()) { if (from < _searchResults.size()) {
int32 to = (yTo > filteredOffset() + (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight ? ((yTo - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size() + 1; int32 to = (yTo > filteredOffset() + (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight ? ((yTo - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / st::dialogsRowHeight) : 0) - _filterResults.size() - _peerSearchResults.size() + 1;
if (to > _searchResults.size()) to = _searchResults.size(); if (to > _searchResults.size()) to = _searchResults.size();
for (; from < to; ++from) { for (; from < to; ++from) {
@ -3156,14 +3183,15 @@ void InnerWidget::updateDialogRowCornerStatus(not_null<History*> history) {
? st::dialogsOnlineBadgeSkip ? st::dialogsOnlineBadgeSkip
: st::dialogsCallBadgeSkip; : st::dialogsCallBadgeSkip;
const auto updateRect = QRect( const auto updateRect = QRect(
st::dialogsPhotoSize - skip.x() - size, _st->photoSize - skip.x() - size,
st::dialogsPhotoSize - skip.y() - size, _st->photoSize - skip.y() - size,
size, size,
size size
).marginsAdded( ).marginsAdded(
{ stroke, stroke, stroke, stroke } { stroke, stroke, stroke, stroke }
).translated( ).translated(
st::dialogsPadding st::defaultDialogRow.padding.left(),
st::defaultDialogRow.padding.top()
); );
updateDialogRow( updateDialogRow(
RowDescriptor( RowDescriptor(
@ -3217,11 +3245,11 @@ void InnerWidget::updateRowCornerStatusShown(
[](not_null<Row*> row) { return row->history(); }); [](not_null<Row*> row) { return row->history(); });
const auto index = (i - begin(_filterResults)); const auto index = (i - begin(_filterResults));
const auto row = (i == end(_filterResults)) ? nullptr : i->get(); const auto row = (i == end(_filterResults)) ? nullptr : i->get();
return { row, filteredOffset() + index * st::dialogsRowHeight }; return { row, filteredOffset() + index * _st->height };
}; };
if (const auto &[row, top] = findRow(history); row != nullptr) { if (const auto &[row, top] = findRow(history); row != nullptr) {
const auto visible = (top < _visibleBottom) const auto visible = (top < _visibleBottom)
&& (top + st::dialogsRowHeight > _visibleTop); && (top + _st->height > _visibleTop);
row->updateCornerBadgeShown( row->updateCornerBadgeShown(
history->peer, history->peer,
visible ? Fn<void()>(crl::guard(this, repaint)) : nullptr); visible ? Fn<void()>(crl::guard(this, repaint)) : nullptr);

View file

@ -15,6 +15,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/flags.h" #include "base/flags.h"
#include "base/object_ptr.h" #include "base/object_ptr.h"
namespace style {
struct DialogRow;
} // namespace style
namespace MTP { namespace MTP {
class Error; class Error;
} // namespace MTP } // namespace MTP
@ -76,7 +80,6 @@ enum class WidgetState {
}; };
class InnerWidget final : public Ui::RpWidget { class InnerWidget final : public Ui::RpWidget {
public: public:
InnerWidget( InnerWidget(
QWidget *parent, QWidget *parent,
@ -112,18 +115,21 @@ public:
void scrollToEntry(const RowDescriptor &entry); void scrollToEntry(const RowDescriptor &entry);
Data::Folder *shownFolder() const; [[nodiscard]] Data::Folder *shownFolder() const;
Data::Forum *shownForum() const; [[nodiscard]] Data::Forum *shownForum() const;
int32 lastSearchDate() const; [[nodiscard]] int32 lastSearchDate() const;
PeerData *lastSearchPeer() const; [[nodiscard]] PeerData *lastSearchPeer() const;
MsgId lastSearchId() const; [[nodiscard]] MsgId lastSearchId() const;
MsgId lastSearchMigratedId() const; [[nodiscard]] MsgId lastSearchMigratedId() const;
WidgetState state() const; [[nodiscard]] WidgetState state() const;
bool waitingForSearch() const { [[nodiscard]] const style::DialogRow *st() const {
return _st;
}
[[nodiscard]] bool waitingForSearch() const {
return _waitingForSearch; return _waitingForSearch;
} }
bool hasFilteredResults() const; [[nodiscard]] bool hasFilteredResults() const;
void searchInChat(Key key, PeerData *from); void searchInChat(Key key, PeerData *from);
@ -354,6 +360,7 @@ private:
rpl::lifetime _openedForumLifetime; rpl::lifetime _openedForumLifetime;
std::vector<std::unique_ptr<CollapsedRow>> _collapsedRows; std::vector<std::unique_ptr<CollapsedRow>> _collapsedRows;
not_null<const style::DialogRow*> _st;
int _collapsedSelected = -1; int _collapsedSelected = -1;
int _collapsedPressed = -1; int _collapsedPressed = -1;
int _skipTopDialogs = 0; int _skipTopDialogs = 0;

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/painter.h" #include "ui/painter.h"
#include "dialogs/dialogs_entry.h" #include "dialogs/dialogs_entry.h"
#include "dialogs/ui/dialogs_video_userpic.h" #include "dialogs/ui/dialogs_video_userpic.h"
#include "dialogs/ui/dialogs_layout.h"
#include "data/data_folder.h" #include "data/data_folder.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
#include "history/history.h" #include "history/history.h"
@ -126,20 +127,17 @@ void BasicRow::paintUserpic(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::VideoUserpic *videoUserpic, Ui::VideoUserpic *videoUserpic,
History *historyForCornerBadge, History *historyForCornerBadge,
crl::time now, const Ui::PaintContext &context) const {
bool active,
int fullWidth,
bool paused) const {
PaintUserpic( PaintUserpic(
p, p,
peer, peer,
videoUserpic, videoUserpic,
_userpic, _userpic,
st::dialogsPadding.x(), context.st->padding.left(),
st::dialogsPadding.y(), context.st->padding.top(),
fullWidth, context.width,
st::dialogsPhotoSize, context.st->photoSize,
paused); context.paused);
} }
Row::Row(Key key, int pos) : _id(key), _pos(pos) { Row::Row(Key key, int pos) : _id(key), _pos(pos) {
@ -221,7 +219,7 @@ void Row::PaintCornerBadgeFrame(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::VideoUserpic *videoUserpic, Ui::VideoUserpic *videoUserpic,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
bool paused) { const Ui::PaintContext &context) {
data->frame.fill(Qt::transparent); data->frame.fill(Qt::transparent);
Painter q(&data->frame); Painter q(&data->frame);
@ -233,8 +231,8 @@ void Row::PaintCornerBadgeFrame(
0, 0,
0, 0,
data->frame.width() / data->frame.devicePixelRatio(), data->frame.width() / data->frame.devicePixelRatio(),
st::dialogsPhotoSize, context.st->photoSize,
paused); context.paused);
PainterHighQualityEnabler hq(q); PainterHighQualityEnabler hq(q);
q.setCompositionMode(QPainter::CompositionMode_Source); q.setCompositionMode(QPainter::CompositionMode_Source);
@ -255,8 +253,8 @@ void Row::PaintCornerBadgeFrame(
? st::dialogsOnlineBadgeFgActive ? st::dialogsOnlineBadgeFgActive
: st::dialogsOnlineBadgeFg); : st::dialogsOnlineBadgeFg);
q.drawEllipse(QRectF( q.drawEllipse(QRectF(
st::dialogsPhotoSize - skip.x() - size, context.st->photoSize - skip.x() - size,
st::dialogsPhotoSize - skip.y() - size, context.st->photoSize - skip.y() - size,
size, size,
size size
).marginsRemoved({ shrink, shrink, shrink, shrink })); ).marginsRemoved({ shrink, shrink, shrink, shrink }));
@ -267,10 +265,7 @@ void Row::paintUserpic(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::VideoUserpic *videoUserpic, Ui::VideoUserpic *videoUserpic,
History *historyForCornerBadge, History *historyForCornerBadge,
crl::time now, const Ui::PaintContext &context) const {
bool active,
int fullWidth,
bool paused) const {
updateCornerBadgeShown(peer); updateCornerBadgeShown(peer);
const auto shown = _cornerBadgeUserpic const auto shown = _cornerBadgeUserpic
@ -282,61 +277,63 @@ void Row::paintUserpic(
peer, peer,
videoUserpic, videoUserpic,
historyForCornerBadge, historyForCornerBadge,
now, context);
active,
fullWidth,
paused);
if (!historyForCornerBadge || !_cornerBadgeShown) { if (!historyForCornerBadge || !_cornerBadgeShown) {
_cornerBadgeUserpic = nullptr; _cornerBadgeUserpic = nullptr;
} }
return; return;
} }
ensureCornerBadgeUserpic(); ensureCornerBadgeUserpic();
if (_cornerBadgeUserpic->frame.isNull()) { const auto ratio = style::DevicePixelRatio();
const auto frameSide = context.st->photoSize * style::DevicePixelRatio();
const auto frameSize = QSize(frameSide, frameSide);
if (_cornerBadgeUserpic->frame.size() != frameSize) {
_cornerBadgeUserpic->frame = QImage( _cornerBadgeUserpic->frame = QImage(
st::dialogsPhotoSize * cRetinaFactor(), frameSize,
st::dialogsPhotoSize * cRetinaFactor(),
QImage::Format_ARGB32_Premultiplied); QImage::Format_ARGB32_Premultiplied);
_cornerBadgeUserpic->frame.setDevicePixelRatio(cRetinaFactor()); _cornerBadgeUserpic->frame.setDevicePixelRatio(ratio);
} }
const auto key = peer->userpicUniqueKey(userpicView()); const auto key = peer->userpicUniqueKey(userpicView());
const auto frameIndex = videoUserpic ? videoUserpic->frameIndex() : -1; const auto frameIndex = videoUserpic ? videoUserpic->frameIndex() : -1;
if (_cornerBadgeUserpic->shown != shown if (_cornerBadgeUserpic->shown != shown
|| _cornerBadgeUserpic->key != key || _cornerBadgeUserpic->key != key
|| _cornerBadgeUserpic->active != active || _cornerBadgeUserpic->active != context.active
|| _cornerBadgeUserpic->frameIndex != frameIndex || _cornerBadgeUserpic->frameIndex != frameIndex
|| videoUserpic) { || videoUserpic) {
_cornerBadgeUserpic->shown = shown; _cornerBadgeUserpic->shown = shown;
_cornerBadgeUserpic->key = key; _cornerBadgeUserpic->key = key;
_cornerBadgeUserpic->active = active; _cornerBadgeUserpic->active = context.active;
_cornerBadgeUserpic->frameIndex = frameIndex; _cornerBadgeUserpic->frameIndex = frameIndex;
PaintCornerBadgeFrame( PaintCornerBadgeFrame(
_cornerBadgeUserpic.get(), _cornerBadgeUserpic.get(),
peer, peer,
videoUserpic, videoUserpic,
userpicView(), userpicView(),
paused); context);
} }
p.drawImage(st::dialogsPadding, _cornerBadgeUserpic->frame); p.drawImage(
context.st->padding.left(),
context.st->padding.top(),
_cornerBadgeUserpic->frame);
if (historyForCornerBadge->peer->isUser()) { if (historyForCornerBadge->peer->isUser()) {
return; return;
} }
const auto actionPainter = historyForCornerBadge->sendActionPainter(); const auto actionPainter = historyForCornerBadge->sendActionPainter();
const auto bg = active const auto bg = context.active
? st::dialogsBgActive ? st::dialogsBgActive
: st::dialogsBg; : st::dialogsBg;
const auto size = st::dialogsCallBadgeSize; const auto size = st::dialogsCallBadgeSize;
const auto skip = st::dialogsCallBadgeSkip; const auto skip = st::dialogsCallBadgeSkip;
p.setOpacity(shown); p.setOpacity(shown);
p.translate(st::dialogsPadding); p.translate(context.st->padding.left(), context.st->padding.top());
actionPainter->paintSpeaking( actionPainter->paintSpeaking(
p, p,
st::dialogsPhotoSize - skip.x() - size, context.st->photoSize - skip.x() - size,
st::dialogsPhotoSize - skip.y() - size, context.st->photoSize - skip.y() - size,
fullWidth, context.width,
bg, bg,
now); context.now);
p.translate(-st::dialogsPadding); p.translate(-context.st->padding.left(), -context.st->padding.top());
p.setOpacity(1.); p.setOpacity(1.);
} }

View file

@ -28,6 +28,7 @@ namespace Dialogs::Ui {
using namespace ::Ui; using namespace ::Ui;
class RowPainter; class RowPainter;
class VideoUserpic; class VideoUserpic;
struct PaintContext;
} // namespace Dialogs::Ui } // namespace Dialogs::Ui
namespace Dialogs { namespace Dialogs {
@ -44,10 +45,7 @@ public:
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::VideoUserpic *videoUserpic, Ui::VideoUserpic *videoUserpic,
History *historyForCornerBadge, History *historyForCornerBadge,
crl::time now, const Ui::PaintContext &context) const;
bool active,
int fullWidth,
bool paused) const;
void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback); void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback);
void stopLastRipple(); void stopLastRipple();
@ -84,10 +82,7 @@ public:
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::VideoUserpic *videoUserpic, Ui::VideoUserpic *videoUserpic,
History *historyForCornerBadge, History *historyForCornerBadge,
crl::time now, const Ui::PaintContext &context) const final override;
bool active,
int fullWidth,
bool paused) const final override;
[[nodiscard]] Key key() const { [[nodiscard]] Key key() const {
return _id; return _id;
@ -138,7 +133,7 @@ private:
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::VideoUserpic *videoUserpic, Ui::VideoUserpic *videoUserpic,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
bool paused); const Ui::PaintContext &context);
Key _id; Key _id;
int _pos = 0; int _pos = 0;

View file

@ -232,9 +232,9 @@ Widget::Widget(
) | rpl::start_with_next([=](const Ui::ScrollToRequest &data) { ) | rpl::start_with_next([=](const Ui::ScrollToRequest &data) {
const auto movedFrom = data.ymin; const auto movedFrom = data.ymin;
const auto movedTo = data.ymax; const auto movedTo = data.ymax;
const auto st = int32(_scroll->scrollTop()); const auto st = _scroll->scrollTop();
if (st > movedTo && st < movedFrom) { if (st > movedTo && st < movedFrom) {
_scroll->scrollToY(st + st::dialogsRowHeight); _scroll->scrollToY(st + _inner->st()->height);
} }
}, lifetime()); }, lifetime());
_inner->searchMessages( _inner->searchMessages(
@ -1723,7 +1723,7 @@ void Widget::updateControlsGeometry() {
_forwardCancel->moveToLeft(0, filterAreaTop); _forwardCancel->moveToLeft(0, filterAreaTop);
filterAreaTop += st::dialogsForwardHeight; filterAreaTop += st::dialogsForwardHeight;
} }
auto smallLayoutWidth = (st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x()); auto smallLayoutWidth = (st::defaultDialogRow.padding.left() + st::defaultDialogRow.photoSize + st::defaultDialogRow.padding.left());
auto smallLayoutRatio = (width() < st::columnMinimalWidthLeft) ? (st::columnMinimalWidthLeft - width()) / float64(st::columnMinimalWidthLeft - smallLayoutWidth) : 0.; auto smallLayoutRatio = (width() < st::columnMinimalWidthLeft) ? (st::columnMinimalWidthLeft - width()) / float64(st::columnMinimalWidthLeft - smallLayoutWidth) : 0.;
auto filterLeft = (controller()->filtersWidth() ? st::dialogsFilterSkip : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x(); auto filterLeft = (controller()->filtersWidth() ? st::dialogsFilterSkip : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x();
auto filterRight = (session().domain().local().hasLocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x(); auto filterRight = (session().domain().local().hasLocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x();

View file

@ -118,10 +118,10 @@ void PaintNarrowCounter(
|| displayReactionBadge) || displayReactionBadge)
? 1 ? 1
: 3; : 3;
const auto unreadRight = st::dialogsPadding.x() const auto unreadRight = context.st->padding.left()
+ st::dialogsPhotoSize; + context.st->photoSize;
const auto unreadTop = st::dialogsPadding.y() const auto unreadTop = context.st->padding.top()
+ st::dialogsPhotoSize + context.st->photoSize
- st::dialogsUnreadHeight; - st::dialogsUnreadHeight;
UnreadBadgeStyle st; UnreadBadgeStyle st;
@ -139,11 +139,11 @@ void PaintNarrowCounter(
} }
if (displayMentionBadge || displayReactionBadge) { if (displayMentionBadge || displayReactionBadge) {
const auto counter = QString(); const auto counter = QString();
const auto unreadRight = st::dialogsPadding.x() const auto unreadRight = context.st->padding.left()
+ st::dialogsPhotoSize + context.st->photoSize
- skipBeforeMention; - skipBeforeMention;
const auto unreadTop = st::dialogsPadding.y() const auto unreadTop = context.st->padding.top()
+ st::dialogsPhotoSize + context.st->photoSize
- st::dialogsUnreadHeight; - st::dialogsUnreadHeight;
UnreadBadgeStyle st; UnreadBadgeStyle st;
@ -193,8 +193,7 @@ int PaintWideCounter(
const auto counter = (unreadCount > 0) const auto counter = (unreadCount > 0)
? QString::number(unreadCount) ? QString::number(unreadCount)
: QString(); : QString();
const auto unreadRight = context.width const auto unreadRight = context.width - context.st->padding.right();
- st::dialogsPadding.x();
const auto unreadTop = texttop const auto unreadTop = texttop
+ st::dialogsTextFont->ascent + st::dialogsTextFont->ascent
- st::dialogsUnreadFont->ascent - st::dialogsUnreadFont->ascent
@ -219,7 +218,7 @@ int PaintWideCounter(
: st::dialogsPinnedIcon; : st::dialogsPinnedIcon;
icon.paint( icon.paint(
p, p,
context.width - st::dialogsPadding.x() - icon.width(), context.width - context.st->padding.right() - icon.width(),
texttop, texttop,
context.width); context.width);
availableWidth -= icon.width() + st::dialogsUnreadPadding; availableWidth -= icon.width() + st::dialogsUnreadPadding;
@ -227,7 +226,7 @@ int PaintWideCounter(
if (displayMentionBadge || displayReactionBadge) { if (displayMentionBadge || displayReactionBadge) {
const auto counter = QString(); const auto counter = QString();
const auto unreadRight = context.width const auto unreadRight = context.width
- st::dialogsPadding.x() - context.st->padding.right()
- (initial - availableWidth); - (initial - availableWidth);
const auto unreadTop = texttop const auto unreadTop = texttop
+ st::dialogsTextFont->ascent + st::dialogsTextFont->ascent
@ -334,7 +333,7 @@ void PaintRow(
draft = nullptr; draft = nullptr;
} }
auto fullRect = QRect(0, 0, context.width, st::dialogsRowHeight); auto fullRect = QRect(0, 0, context.width, context.st->height);
auto bg = context.active auto bg = context.active
? st::dialogsBgActive ? st::dialogsBgActive
: context.selected : context.selected
@ -351,47 +350,36 @@ void PaintRow(
if (flags & Flag::SavedMessages) { if (flags & Flag::SavedMessages) {
EmptyUserpic::PaintSavedMessages( EmptyUserpic::PaintSavedMessages(
p, p,
st::dialogsPadding.x(), context.st->padding.left(),
st::dialogsPadding.y(), context.st->padding.top(),
context.width, context.width,
st::dialogsPhotoSize); context.st->photoSize);
} else if (flags & Flag::RepliesMessages) { } else if (flags & Flag::RepliesMessages) {
EmptyUserpic::PaintRepliesMessages( EmptyUserpic::PaintRepliesMessages(
p, p,
st::dialogsPadding.x(), context.st->padding.left(),
st::dialogsPadding.y(), context.st->padding.top(),
context.width, context.width,
st::dialogsPhotoSize); context.st->photoSize);
} else if (from) { } else if (from) {
row->paintUserpic( row->paintUserpic(
p, p,
from, from,
videoUserpic, videoUserpic,
(flags & Flag::AllowUserOnline) ? history : nullptr, (flags & Flag::AllowUserOnline) ? history : nullptr,
context.now, context);
context.active,
context.width,
context.paused);
} else if (hiddenSenderInfo) { } else if (hiddenSenderInfo) {
hiddenSenderInfo->emptyUserpic.paint( hiddenSenderInfo->emptyUserpic.paint(
p, p,
st::dialogsPadding.x(), context.st->padding.left(),
st::dialogsPadding.y(), context.st->padding.top(),
context.width, context.width,
st::dialogsPhotoSize); context.st->photoSize);
} else { } else {
entry->paintUserpicLeft( entry->paintUserpic(p, row->userpicView(), context);
p,
row->userpicView(),
st::dialogsPadding.x(),
st::dialogsPadding.y(),
context.width,
st::dialogsPhotoSize);
} }
auto nameleft = st::dialogsPadding.x() auto nameleft = context.st->nameLeft;
+ st::dialogsPhotoSize
+ st::dialogsPhotoPadding;
if (context.width <= nameleft) { if (context.width <= nameleft) {
if (!draft && item && !item->isEmpty()) { if (!draft && item && !item->isEmpty()) {
paintCounterCallback(); paintCounterCallback();
@ -399,10 +387,10 @@ void PaintRow(
return; return;
} }
auto namewidth = context.width - nameleft - st::dialogsPadding.x(); auto namewidth = context.width - nameleft - context.st->padding.right();
auto rectForName = QRect( auto rectForName = QRect(
nameleft, nameleft,
st::dialogsPadding.y() + st::dialogsNameTop, context.st->nameTop,
namewidth, namewidth,
st::msgNameFont->height); st::msgNameFont->height);
@ -425,9 +413,7 @@ void PaintRow(
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
} }
} }
auto texttop = st::dialogsPadding.y() auto texttop = context.st->textTop;
+ st::msgNameFont->height
+ st::dialogsSkip;
if (promoted && !history->topPromotionMessage().isEmpty()) { if (promoted && !history->topPromotionMessage().isEmpty()) {
auto availableWidth = namewidth; auto availableWidth = namewidth;
p.setFont(st::dialogsTextFont); p.setFont(st::dialogsTextFont);
@ -467,7 +453,7 @@ void PaintRow(
: st::dialogsPinnedIcon; : st::dialogsPinnedIcon;
icon.paint( icon.paint(
p, p,
context.width - st::dialogsPadding.x() - icon.width(), context.width - context.st->padding.right() - icon.width(),
texttop, texttop,
context.width); context.width);
availableWidth -= icon.width() + st::dialogsUnreadPadding; availableWidth -= icon.width() + st::dialogsUnreadPadding;
@ -553,7 +539,7 @@ void PaintRow(
: context.selected : context.selected
? st::dialogsPinnedIconOver ? st::dialogsPinnedIconOver
: st::dialogsPinnedIcon; : st::dialogsPinnedIcon;
icon.paint(p, context.width - st::dialogsPadding.x() - icon.width(), texttop, context.width); icon.paint(p, context.width - context.st->padding.right() - icon.width(), texttop, context.width);
availableWidth -= icon.width() + st::dialogsUnreadPadding; availableWidth -= icon.width() + st::dialogsUnreadPadding;
} }
@ -587,7 +573,7 @@ void PaintRow(
: context.selected : context.selected
? st::dialogsPinnedIconOver ? st::dialogsPinnedIconOver
: st::dialogsPinnedIcon; : st::dialogsPinnedIcon;
icon.paint(p, context.width - st::dialogsPadding.x() - icon.width(), texttop, context.width); icon.paint(p, context.width - context.st->padding.right() - icon.width(), texttop, context.width);
} }
auto sendStateIcon = [&]() -> const style::icon* { auto sendStateIcon = [&]() -> const style::icon* {
if (draft) { if (draft) {
@ -967,9 +953,7 @@ void RowPainter::Paint(
| (peer && peer->isSelf() ? Flag::SavedMessages : Flag(0)) | (peer && peer->isSelf() ? Flag::SavedMessages : Flag(0))
| (peer && peer->isRepliesChat() ? Flag::RepliesMessages : Flag(0)); | (peer && peer->isRepliesChat() ? Flag::RepliesMessages : Flag(0));
const auto paintItemCallback = [&](int nameleft, int namewidth) { const auto paintItemCallback = [&](int nameleft, int namewidth) {
const auto texttop = st::dialogsPadding.y() const auto texttop = context.st->textTop;
+ st::msgNameFont->height
+ st::dialogsSkip;
const auto availableWidth = PaintWideCounter( const auto availableWidth = PaintWideCounter(
p, p,
context, context,
@ -1111,9 +1095,7 @@ void RowPainter::Paint(
const auto displayPinnedIcon = false; const auto displayPinnedIcon = false;
const auto paintItemCallback = [&](int nameleft, int namewidth) { const auto paintItemCallback = [&](int nameleft, int namewidth) {
const auto texttop = st::dialogsPadding.y() const auto texttop = context.st->textTop;
+ st::msgNameFont->height
+ st::dialogsSkip;
const auto availableWidth = PaintWideCounter( const auto availableWidth = PaintWideCounter(
p, p,
context, context,
@ -1178,18 +1160,15 @@ void RowPainter::Paint(
} }
QRect RowPainter::SendActionAnimationRect( QRect RowPainter::SendActionAnimationRect(
not_null<const style::DialogRow*> st,
int animationLeft, int animationLeft,
int animationWidth, int animationWidth,
int animationHeight, int animationHeight,
int fullWidth, int fullWidth,
bool textUpdated) { bool textUpdated) {
const auto nameleft = st::dialogsPadding.x() const auto nameleft = st->nameLeft;
+ st::dialogsPhotoSize const auto namewidth = fullWidth - nameleft - st->padding.right();
+ st::dialogsPhotoPadding; const auto texttop = st->textTop;
const auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
const auto texttop = st::dialogsPadding.y()
+ st::msgNameFont->height
+ st::dialogsSkip;
return QRect( return QRect(
nameleft + (textUpdated ? 0 : animationLeft), nameleft + (textUpdated ? 0 : animationLeft),
texttop, texttop,
@ -1203,40 +1182,34 @@ void PaintCollapsedRow(
Data::Folder *folder, Data::Folder *folder,
const QString &text, const QString &text,
int unread, int unread,
int fullWidth, const PaintContext &context) {
bool selected) { p.fillRect(
p.fillRect(0, 0, fullWidth, st::dialogsImportantBarHeight, selected ? st::dialogsBgOver : st::dialogsBg); QRect{ 0, 0, context.width, st::dialogsImportantBarHeight },
context.selected ? st::dialogsBgOver : st::dialogsBg);
row.paintRipple(p, 0, 0, fullWidth); row.paintRipple(p, 0, 0, context.width);
const auto smallWidth = st::dialogsPadding.x()
+ st::dialogsPhotoSize
+ st::dialogsPhotoPadding;
const auto narrow = (fullWidth <= smallWidth);
const auto unreadTop = (st::dialogsImportantBarHeight - st::dialogsUnreadHeight) / 2; const auto unreadTop = (st::dialogsImportantBarHeight - st::dialogsUnreadHeight) / 2;
if (!narrow || !folder) { if (!context.narrow || !folder) {
p.setFont(st::semiboldFont); p.setFont(st::semiboldFont);
p.setPen(st::dialogsNameFg); p.setPen(st::dialogsNameFg);
const auto textBaseline = unreadTop const auto textBaseline = unreadTop
+ (st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2 + (st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2
+ st::dialogsUnreadFont->ascent; + st::dialogsUnreadFont->ascent;
const auto left = narrow const auto left = context.narrow
? ((fullWidth - st::semiboldFont->width(text)) / 2) ? ((context.width - st::semiboldFont->width(text)) / 2)
: st::dialogsPadding.x(); : context.st->padding.left();
p.drawText(left, textBaseline, text); p.drawText(left, textBaseline, text);
} else { } else {
folder->paintUserpicLeft( folder->paintUserpic(
p, p,
row.userpicView(), (context.width - st::dialogsUnreadHeight) / 2,
(fullWidth - st::dialogsUnreadHeight) / 2,
unreadTop, unreadTop,
fullWidth,
st::dialogsUnreadHeight); st::dialogsUnreadHeight);
} }
if (!narrow && unread) { if (!context.narrow && unread) {
const auto unreadRight = fullWidth - st::dialogsPadding.x(); const auto unreadRight = context.width - context.st->padding.right();
UnreadBadgeStyle st; UnreadBadgeStyle st;
st.muted = true; st.muted = true;
PaintUnreadBadge( PaintUnreadBadge(

View file

@ -7,6 +7,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#pragma once #pragma once
namespace style {
struct DialogRow;
} // namespace style
namespace st {
extern const style::DialogRow &defaultDialogRow;
} // namespace st
namespace Ui { namespace Ui {
} // namespace Ui } // namespace Ui
@ -28,6 +36,7 @@ using namespace ::Ui;
class VideoUserpic; class VideoUserpic;
struct PaintContext { struct PaintContext {
not_null<const style::DialogRow*> st;
Data::Folder *folder = nullptr; Data::Folder *folder = nullptr;
Data::Forum *forum = nullptr; Data::Forum *forum = nullptr;
FilterId filter = 0; FilterId filter = 0;
@ -43,7 +52,7 @@ struct PaintContext {
const style::icon *ChatTypeIcon( const style::icon *ChatTypeIcon(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const PaintContext &context = {}); const PaintContext &context = { .st = &st::defaultDialogRow });
class RowPainter { class RowPainter {
public: public:
@ -57,6 +66,7 @@ public:
not_null<const FakeRow*> row, not_null<const FakeRow*> row,
const PaintContext &context); const PaintContext &context);
static QRect SendActionAnimationRect( static QRect SendActionAnimationRect(
not_null<const style::DialogRow*> st,
int animationLeft, int animationLeft,
int animationWidth, int animationWidth,
int animationHeight, int animationHeight,
@ -70,8 +80,7 @@ void PaintCollapsedRow(
Data::Folder *folder, Data::Folder *folder,
const QString &text, const QString &text,
int unread, int unread,
int fullWidth, const PaintContext &context);
bool selected);
enum class UnreadBadgeSize { enum class UnreadBadgeSize {
Dialogs, Dialogs,

View file

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_inner_widget.h" #include "history/history_inner_widget.h"
#include "history/history_unread_things.h" #include "history/history_unread_things.h"
#include "dialogs/dialogs_indexed_list.h" #include "dialogs/dialogs_indexed_list.h"
#include "dialogs/ui/dialogs_layout.h"
#include "data/notify/data_notify_settings.h" #include "data/notify/data_notify_settings.h"
#include "data/stickers/data_stickers.h" #include "data/stickers/data_stickers.h"
#include "data/data_drafts.h" #include "data/data_drafts.h"
@ -1074,6 +1075,25 @@ void History::applyServiceChanges(
peer->setThemeEmoji(qs(data.vemoticon())); peer->setThemeEmoji(qs(data.vemoticon()));
}, [&](const MTPDmessageActionChatJoinedByRequest &data) { }, [&](const MTPDmessageActionChatJoinedByRequest &data) {
processJoinedPeer(item->from()); processJoinedPeer(item->from());
}, [&](const MTPDmessageActionTopicCreate &data) {
if (const auto forum = peer->forum()) {
forum->applyTopicAdded(
item->id,
qs(data.vtitle()),
data.vicon_emoji_id().value_or(DocumentId()));
}
}, [&](const MTPDmessageActionTopicEditTitle &data) {
if (const auto forum = peer->forum()) {
if (const auto topic = forum->topicFor(item)) {
topic->applyTitle(qs(data.vtitle()));
}
}
}, [&](const MTPDmessageActionTopicEditIcon &data) {
if (const auto forum = peer->forum()) {
if (const auto topic = forum->topicFor(item)) {
topic->applyIconId(data.vemoji_document_id().v);
}
}
}, [](const auto &) { }, [](const auto &) {
}); });
} }
@ -2081,10 +2101,13 @@ void History::loadUserpic() {
void History::paintUserpic( void History::paintUserpic(
Painter &p, Painter &p,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
int x, const Dialogs::Ui::PaintContext &context) const {
int y, peer->paintUserpic(
int size) const { p,
peer->paintUserpic(p, view, x, y, size); view,
context.st->padding.left(),
context.st->padding.top(),
context.st->photoSize);
} }
void History::startBuildingFrontBlock(int expectedItemsCount) { void History::startBuildingFrontBlock(int expectedItemsCount) {

View file

@ -415,9 +415,7 @@ public:
void paintUserpic( void paintUserpic(
Painter &p, Painter &p,
std::shared_ptr<Data::CloudImageView> &view, std::shared_ptr<Data::CloudImageView> &view,
int x, const Dialogs::Ui::PaintContext &context) const override;
int y,
int size) const override;
void refreshChatListNameSortKey(); void refreshChatListNameSortKey();

View file

@ -802,23 +802,6 @@ void HistoryService::applyAction(const MTPMessageAction &action) {
this, this,
_from, _from,
data.vmonths().v); data.vmonths().v);
}, [&](const MTPDmessageActionTopicCreate &data) {
if (const auto forum = history()->peer->forum()) {
const auto iconId = DocumentId(0); // #TODO forum icon
forum->applyTopicAdded(id, qs(data.vtitle()), iconId);
}
}, [&](const MTPDmessageActionTopicEditTitle &data) {
if (const auto forum = history()->peer->forum()) {
if (const auto topic = forum->topicFor(this)) {
topic->applyTitle(qs(data.vtitle()));
}
}
}, [&](const MTPDmessageActionTopicEditIcon &data) {
if (const auto forum = history()->peer->forum()) {
if (const auto topic = forum->topicFor(this)) {
topic->applyIconId(data.vemoji_document_id().v);
}
}
}, [](const auto &) { }, [](const auto &) {
}); });
} }

View file

@ -100,6 +100,7 @@ void Row::elementsPaint(
int selectedElement) { int selectedElement) {
_outerWidth = outerWidth; _outerWidth = outerWidth;
Dialogs::Ui::RowPainter::Paint(p, _fakeRow.get(), { Dialogs::Ui::RowPainter::Paint(p, _fakeRow.get(), {
.st = &st::defaultDialogRow,
.now = crl::now(), .now = crl::now(),
.width = outerWidth, .width = outerWidth,
.selected = selected, .selected = selected,

View file

@ -140,7 +140,7 @@ void PaintRepliesMessagesInner(
x, x,
y, y,
size, size,
st::dialogsPhotoSize, st::defaultDialogRow.photoSize,
st::dialogsRepliesUserpic, st::dialogsRepliesUserpic,
fg); fg);
} }

View file

@ -214,7 +214,7 @@ void Generator::prepare() {
_inner = extended() ? _rect.marginsRemoved(st::themePreviewMargin) : _rect; _inner = extended() ? _rect.marginsRemoved(st::themePreviewMargin) : _rect;
_body = extended() ? _inner.marginsRemoved(QMargins(0, Platform::PreviewTitleHeight(), 0, 0)) : _inner; _body = extended() ? _inner.marginsRemoved(QMargins(0, Platform::PreviewTitleHeight(), 0, 0)) : _inner;
_dialogs = QRect(_body.x(), _body.y(), st::themePreviewDialogsWidth, _body.height()); _dialogs = QRect(_body.x(), _body.y(), st::themePreviewDialogsWidth, _body.height());
_dialogsList = _dialogs.marginsRemoved(QMargins(0, st::dialogsFilterPadding.y() + st::dialogsMenuToggle.height + st::dialogsFilterPadding.y(), 0, st::dialogsPadding.y())); _dialogsList = _dialogs.marginsRemoved(QMargins(0, st::dialogsFilterPadding.y() + st::dialogsMenuToggle.height + st::dialogsFilterPadding.y(), 0, st::defaultDialogRow.padding.bottom()));
_topBar = QRect(_dialogs.x() + _dialogs.width(), _dialogs.y(), _body.width() - _dialogs.width(), st::topBarHeight); _topBar = QRect(_dialogs.x() + _dialogs.width(), _dialogs.y(), _body.width() - _dialogs.width(), st::topBarHeight);
_composeArea = QRect(_topBar.x(), _body.y() + _body.height() - st::historySendSize.height(), _topBar.width(), st::historySendSize.height()); _composeArea = QRect(_topBar.x(), _body.y() + _body.height() - st::historySendSize.height(), _topBar.width(), st::historySendSize.height());
_history = QRect(_topBar.x(), _topBar.y() + _topBar.height(), _topBar.width(), _body.height() - _topBar.height() - _composeArea.height()); _history = QRect(_topBar.x(), _topBar.y() + _topBar.height(), _topBar.width(), _body.height() - _topBar.height() - _composeArea.height());
@ -666,11 +666,17 @@ void Generator::paintRow(const Row &row) {
if (row.active || row.selected) { if (row.active || row.selected) {
_p->fillRect(fullRect, row.active ? st::dialogsBgActive[_palette] : st::dialogsBgOver[_palette]); _p->fillRect(fullRect, row.active ? st::dialogsBgActive[_palette] : st::dialogsBgOver[_palette]);
} }
paintUserpic(x + st::dialogsPadding.x(), y + st::dialogsPadding.y(), row.type, row.peerIndex, row.letters); const auto &st = st::defaultDialogRow;
paintUserpic(
x + st.padding.left(),
y + st.padding.top(),
row.type,
row.peerIndex,
row.letters);
auto nameleft = x + st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPhotoPadding; auto nameleft = x + st.nameLeft;
auto namewidth = x + fullWidth - nameleft - st::dialogsPadding.x(); auto namewidth = x + fullWidth - nameleft - st.padding.right();
auto rectForName = QRect(nameleft, y + st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height); auto rectForName = QRect(nameleft, y + st.nameTop, namewidth, st::msgNameFont->height);
auto chatTypeIcon = ([&row]() -> const style::icon * { auto chatTypeIcon = ([&row]() -> const style::icon * {
if (row.type == Row::Type::Group) { if (row.type == Row::Type::Group) {
@ -685,7 +691,7 @@ void Generator::paintRow(const Row &row) {
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
} }
auto texttop = y + st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip; auto texttop = st.textTop;
auto dateWidth = st::dialogsDateFont->width(row.date); auto dateWidth = st::dialogsDateFont->width(row.date);
rectForName.setWidth(rectForName.width() - dateWidth - st::dialogsDateSkip); rectForName.setWidth(rectForName.width() - dateWidth - st::dialogsDateSkip);
@ -696,7 +702,7 @@ void Generator::paintRow(const Row &row) {
auto availableWidth = namewidth; auto availableWidth = namewidth;
if (row.unreadCounter) { if (row.unreadCounter) {
auto counter = QString::number(row.unreadCounter); auto counter = QString::number(row.unreadCounter);
auto unreadRight = x + fullWidth - st::dialogsPadding.x(); auto unreadRight = x + fullWidth - st.padding.right();
auto unreadTop = texttop + st::dialogsTextFont->ascent - st::dialogsUnreadFont->ascent - (st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2; auto unreadTop = texttop + st::dialogsTextFont->ascent - st::dialogsUnreadFont->ascent - (st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2;
auto unreadWidth = st::dialogsUnreadFont->width(counter); auto unreadWidth = st::dialogsUnreadFont->width(counter);
@ -728,7 +734,7 @@ void Generator::paintRow(const Row &row) {
_p->drawText(unreadRectLeft + (unreadRectWidth - unreadWidth) / 2, unreadRectTop + textTop + st::dialogsUnreadFont->ascent, counter); _p->drawText(unreadRectLeft + (unreadRectWidth - unreadWidth) / 2, unreadRectTop + textTop + st::dialogsUnreadFont->ascent, counter);
} else if (row.pinned) { } else if (row.pinned) {
auto icon = (row.active ? st::dialogsPinnedIconActive[_palette] : (row.selected ? st::dialogsPinnedIconOver[_palette] : st::dialogsPinnedIcon[_palette])); auto icon = (row.active ? st::dialogsPinnedIconActive[_palette] : (row.selected ? st::dialogsPinnedIconOver[_palette] : st::dialogsPinnedIcon[_palette]));
icon.paint(*_p, x + fullWidth - st::dialogsPadding.x() - icon.width(), texttop, fullWidth); icon.paint(*_p, x + fullWidth - st.padding.right() - icon.width(), texttop, fullWidth);
availableWidth -= icon.width() + st::dialogsUnreadPadding; availableWidth -= icon.width() + st::dialogsUnreadPadding;
} }
auto textRect = QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height); auto textRect = QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height);
@ -955,22 +961,25 @@ void Generator::paintUserpic(int x, int y, Row::Type type, int index, QString le
}; };
auto color = colors[index % base::array_size(colors)]; auto color = colors[index % base::array_size(colors)];
auto image = QImage(st::dialogsPhotoSize * cIntRetinaFactor(), st::dialogsPhotoSize * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied); const auto size = st::defaultDialogRow.photoSize;
auto image = QImage(
QSize(size, size) * cIntRetinaFactor(),
QImage::Format_ARGB32_Premultiplied);
image.setDevicePixelRatio(cRetinaFactor()); image.setDevicePixelRatio(cRetinaFactor());
image.fill(color[_palette]->c); image.fill(color[_palette]->c);
{ {
Painter p(&image); Painter p(&image);
auto fontsize = (st::dialogsPhotoSize * 13) / 33; auto fontsize = (size * 13) / 33;
auto font = st::historyPeerUserpicFont->f; auto font = st::historyPeerUserpicFont->f;
font.setPixelSize(fontsize); font.setPixelSize(fontsize);
p.setFont(font); p.setFont(font);
p.setBrush(Qt::NoBrush); p.setBrush(Qt::NoBrush);
p.setPen(st::historyPeerUserpicFg[_palette]); p.setPen(st::historyPeerUserpicFg[_palette]);
p.drawText(QRect(0, 0, st::dialogsPhotoSize, st::dialogsPhotoSize), letters, QTextOption(style::al_center)); p.drawText(QRect(0, 0, size, size), letters, QTextOption(style::al_center));
} }
image = Images::Circle(std::move(image)); image = Images::Circle(std::move(image));
_p->drawImage(rtl() ? (_rect.width() - x - st::dialogsPhotoSize) : x, y, image); _p->drawImage(rtl() ? (_rect.width() - x - size) : x, y, image);
} }
void Generator::paintHistoryShadows() { void Generator::paintHistoryShadows() {

View file

@ -1092,7 +1092,9 @@ void SessionController::floatPlayerAreaUpdated() {
} }
int SessionController::dialogsSmallColumnWidth() const { int SessionController::dialogsSmallColumnWidth() const {
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x(); return st::defaultDialogRow.padding.left()
+ st::defaultDialogRow.photoSize
+ st::defaultDialogRow.padding.left();
} }
int SessionController::minimalThreeColumnWidth() const { int SessionController::minimalThreeColumnWidth() const {