2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Allow to resize chats list. One more mode added (narrow chats list).

This commit is contained in:
John Preston
2017-01-14 21:50:16 +03:00
parent 983db3a682
commit 4424dbf64a
33 changed files with 558 additions and 140 deletions

View File

@@ -53,6 +53,7 @@ dialogsSkip: 8px;
dialogsWidthMin: 260px;
dialogsWidthMax: 540px;
dialogsWidthDuration: 120;
dialogsTextWidthMin: 150px;
dialogsScroll: ScrollArea(defaultScrollArea) {
topsh: 0px;
@@ -191,6 +192,9 @@ dialogsUpdateButton: FlatButton {
}
}
dialogsInstallUpdate: icon {{ "install_update", activeButtonFg }};
dialogsInstallUpdateOver: icon {{ "install_update", activeButtonFgOver }};
dialogsForwardHeight: 32px;
dialogsForwardTextLeft: 35px;
dialogsForwardTextTop: 6px;

View File

@@ -58,8 +58,8 @@ void paintRowDate(Painter &p, const QDateTime &date, QRect &rectForName, bool ac
p.drawText(rectForName.left() + rectForName.width() + st::dialogsDateSkip, rectForName.top() + st::msgNameFont->height - st::msgDateFont->descent, dt);
}
template <typename PaintItemCallback>
void paintRow(Painter &p, const RippleRow *row, History *history, HistoryItem *item, Data::Draft *draft, QDateTime date, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms, PaintItemCallback paintItemCallback) {
template <typename PaintItemCallback, typename PaintCounterCallback>
void paintRow(Painter &p, const RippleRow *row, History *history, HistoryItem *item, Data::Draft *draft, QDateTime date, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms, PaintItemCallback paintItemCallback, PaintCounterCallback paintCounterCallback) {
QRect fullRect(0, 0, fullWidth, st::dialogsRowHeight);
p.fillRect(fullRect, active ? st::dialogsBgActive : (selected ? st::dialogsBgOver : st::dialogsBg));
row->paintRipple(p, 0, 0, fullWidth, ms, &(active ? st::dialogsRippleBgActive : st::dialogsRippleBg)->c);
@@ -69,6 +69,13 @@ void paintRow(Painter &p, const RippleRow *row, History *history, HistoryItem *i
userpicPeer->paintUserpicLeft(p, st::dialogsPadding.x(), st::dialogsPadding.y(), fullWidth, st::dialogsPhotoSize);
auto nameleft = st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPhotoPadding;
if (fullWidth <= nameleft) {
if (!draft && item && !item->isEmpty()) {
paintCounterCallback();
}
return;
}
auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height);
@@ -105,8 +112,7 @@ void paintRow(Painter &p, const RippleRow *row, History *history, HistoryItem *i
auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
p.setFont(st::dialogsTextFont);
if (!history->paintSendAction(p, nameleft, texttop, namewidth, fullWidth, color, ms)) {
p.setPen(color);
p.drawText(nameleft, texttop + st::msgNameFont->ascent, lang(lng_empty_history));
// Empty history
}
} else if (!item->isEmpty()) {
paintRowDate(p, date, rectForName, active, selected);
@@ -299,6 +305,22 @@ void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, b
if (!history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
item->drawInDialog(p, QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height), active, selected, history->textCachedFor, history->lastItemTextCache);
}
}, [&p, fullWidth, active, selected, ms, history, unreadCount] {
if (unreadCount) {
auto counter = QString::number(unreadCount);
if (counter.size() > 4) {
counter = qsl("..") + counter.mid(counter.size() - 3);
}
auto mutedCounter = history->mute();
auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize;
auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
auto unreadWidth = 0;
UnreadBadgeStyle st;
st.active = active;
st.muted = history->mute();
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
}
});
}
@@ -308,6 +330,7 @@ void RowPainter::paint(Painter &p, const FakeRow *row, int fullWidth, bool activ
paintRow(p, row, history, item, nullptr, item->date, fullWidth, active, selected, onlyBackground, ms, [&p, row, active, selected](int nameleft, int namewidth, HistoryItem *item) {
int lastWidth = namewidth, texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip;
item->drawInDialog(p, QRect(nameleft, texttop, lastWidth, st::dialogsTextFont->height), active, selected, row->_cacheFor, row->_cache);
}, [] {
});
}