mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-02 23:45:44 +00:00
Implement animated spoilers.
This commit is contained in:
@@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/unread_badge.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "lang/lang_keys.h"
|
||||
@@ -53,7 +54,7 @@ const auto kPsaBadgePrefix = "cloud_lng_badge_psa_";
|
||||
|| history->peer->asUser()->onlineTill > 0);
|
||||
}
|
||||
|
||||
void PaintRowTopRight(Painter &p, const QString &text, QRect &rectForName, bool active, bool selected) {
|
||||
void PaintRowTopRight(QPainter &p, const QString &text, QRect &rectForName, bool active, bool selected) {
|
||||
const auto width = st::dialogsDateFont->width(text);
|
||||
rectForName.setWidth(rectForName.width() - width - st::dialogsDateSkip);
|
||||
p.setFont(st::dialogsDateFont);
|
||||
@@ -61,7 +62,7 @@ void PaintRowTopRight(Painter &p, const QString &text, QRect &rectForName, bool
|
||||
p.drawText(rectForName.left() + rectForName.width() + st::dialogsDateSkip, rectForName.top() + st::msgNameFont->height - st::msgDateFont->descent, text);
|
||||
}
|
||||
|
||||
void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, bool selected) {
|
||||
void PaintRowDate(QPainter &p, QDateTime date, QRect &rectForName, bool active, bool selected) {
|
||||
const auto now = QDateTime::currentDateTime();
|
||||
const auto &lastTime = date;
|
||||
const auto nowDate = now.date();
|
||||
@@ -83,7 +84,7 @@ void PaintRowDate(Painter &p, QDateTime date, QRect &rectForName, bool active, b
|
||||
}
|
||||
|
||||
void PaintNarrowCounter(
|
||||
Painter &p,
|
||||
QPainter &p,
|
||||
bool displayUnreadCounter,
|
||||
bool displayUnreadMark,
|
||||
bool displayMentionBadge,
|
||||
@@ -160,7 +161,7 @@ void PaintNarrowCounter(
|
||||
}
|
||||
|
||||
int PaintWideCounter(
|
||||
Painter &p,
|
||||
QPainter &p,
|
||||
int texttop,
|
||||
int availableWidth,
|
||||
int fullWidth,
|
||||
@@ -263,32 +264,29 @@ void PaintListEntryText(
|
||||
return;
|
||||
}
|
||||
row->validateListEntryCache();
|
||||
const auto &palette = row->folder()
|
||||
? (active
|
||||
? st::dialogsTextPaletteArchiveActive
|
||||
: selected
|
||||
? st::dialogsTextPaletteArchiveOver
|
||||
: st::dialogsTextPaletteArchive)
|
||||
: (active
|
||||
? st::dialogsTextPaletteActive
|
||||
: selected
|
||||
? st::dialogsTextPaletteOver
|
||||
: st::dialogsTextPalette);
|
||||
const auto &color = active
|
||||
p.setFont(st::dialogsTextFont);
|
||||
p.setPen(active
|
||||
? st::dialogsTextFgActive
|
||||
: selected
|
||||
? st::dialogsTextFgOver
|
||||
: st::dialogsTextFg;
|
||||
p.setTextPalette(palette);
|
||||
p.setFont(st::dialogsTextFont);
|
||||
p.setPen(color);
|
||||
row->listEntryCache().drawElided(
|
||||
p,
|
||||
rect.left(),
|
||||
rect.top(),
|
||||
rect.width(),
|
||||
rect.height() / st::dialogsTextFont->height);
|
||||
p.restoreTextPalette();
|
||||
: st::dialogsTextFg);
|
||||
row->listEntryCache().draw(p, {
|
||||
.position = rect.topLeft(),
|
||||
.availableWidth = rect.width(),
|
||||
.palette = &(row->folder()
|
||||
? (active
|
||||
? st::dialogsTextPaletteArchiveActive
|
||||
: selected
|
||||
? st::dialogsTextPaletteArchiveOver
|
||||
: st::dialogsTextPaletteArchive)
|
||||
: (active
|
||||
? st::dialogsTextPaletteActive
|
||||
: selected
|
||||
? st::dialogsTextPaletteOver
|
||||
: st::dialogsTextPalette)),
|
||||
.spoiler = Text::DefaultSpoilerCache(),
|
||||
.elisionLines = rect.height() / st::dialogsTextFont->height,
|
||||
});
|
||||
}
|
||||
|
||||
enum class Flag {
|
||||
@@ -434,7 +432,12 @@ void paintRow(
|
||||
DialogTextOptions());
|
||||
}
|
||||
p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg));
|
||||
history->cloudDraftTextCache.drawElided(p, nameleft, texttop, availableWidth, 1);
|
||||
history->cloudDraftTextCache.draw(p, {
|
||||
.position = { nameleft, texttop },
|
||||
.availableWidth = availableWidth,
|
||||
.spoiler = Text::DefaultSpoilerCache(),
|
||||
.elisionLines = 1,
|
||||
});
|
||||
} else if (draft
|
||||
|| (supportMode
|
||||
&& entry->session().supportHelper().isOccupiedBySomeone(history))) {
|
||||
@@ -485,13 +488,23 @@ void paintRow(
|
||||
context);
|
||||
}
|
||||
p.setPen(active ? st::dialogsTextFgActive : (selected ? st::dialogsTextFgOver : st::dialogsTextFg));
|
||||
if (supportMode) {
|
||||
p.setTextPalette(active ? st::dialogsTextPaletteTakenActive : (selected ? st::dialogsTextPaletteTakenOver : st::dialogsTextPaletteTaken));
|
||||
} else {
|
||||
p.setTextPalette(active ? st::dialogsTextPaletteDraftActive : (selected ? st::dialogsTextPaletteDraftOver : st::dialogsTextPaletteDraft));
|
||||
}
|
||||
history->cloudDraftTextCache.drawElided(p, nameleft, texttop, availableWidth, 1);
|
||||
p.restoreTextPalette();
|
||||
history->cloudDraftTextCache.draw(p, {
|
||||
.position = { nameleft, texttop },
|
||||
.availableWidth = availableWidth,
|
||||
.palette = &(supportMode
|
||||
? (active
|
||||
? st::dialogsTextPaletteTakenActive
|
||||
: selected
|
||||
? st::dialogsTextPaletteTakenOver
|
||||
: st::dialogsTextPaletteTaken)
|
||||
: (active
|
||||
? st::dialogsTextPaletteDraftActive
|
||||
: selected
|
||||
? st::dialogsTextPaletteDraftOver
|
||||
: st::dialogsTextPaletteDraft)),
|
||||
.spoiler = Text::DefaultSpoilerCache(),
|
||||
.elisionLines = 1,
|
||||
});
|
||||
}
|
||||
} else if (!item) {
|
||||
auto availableWidth = namewidth;
|
||||
@@ -692,7 +705,7 @@ QImage colorizeCircleHalf(UnreadBadgeSizeData *data, int size, int half, int xof
|
||||
return result;
|
||||
}
|
||||
|
||||
void PaintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st) {
|
||||
void PaintUnreadBadge(QPainter &p, const QRect &rect, const UnreadBadgeStyle &st) {
|
||||
Assert(rect.height() == st.size);
|
||||
|
||||
int index = (st.muted ? 0x03 : 0x00) + (st.active ? 0x02 : (st.selected ? 0x01 : 0x00));
|
||||
@@ -784,7 +797,7 @@ QSize CountUnreadBadgeSize(
|
||||
}
|
||||
|
||||
QRect PaintUnreadBadge(
|
||||
Painter &p,
|
||||
QPainter &p,
|
||||
const QString &unreadCount,
|
||||
int x,
|
||||
int y,
|
||||
|
Reference in New Issue
Block a user