Paint expanded topics indicator.

This commit is contained in:
John Preston 2022-11-30 13:57:00 +04:00
parent 823bbb1b77
commit 188c6ba64a
3 changed files with 25 additions and 0 deletions

View file

@ -546,6 +546,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
auto fullWidth = width(); auto fullWidth = width();
auto dialogsClip = r; auto dialogsClip = r;
const auto ms = crl::now(); const auto ms = crl::now();
const auto shownForum = _controller->shownForum().current();
const auto paintRow = [&]( const auto paintRow = [&](
not_null<Row*> row, not_null<Row*> row,
bool selected, bool selected,
@ -557,6 +558,10 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
if (forum && !_topicJumpCache) { if (forum && !_topicJumpCache) {
_topicJumpCache = std::make_unique<Ui::TopicJumpCache>(); _topicJumpCache = std::make_unique<Ui::TopicJumpCache>();
} }
const auto expanded = !active
&& forum
&& !_openedForum
&& (key.history()->peer->forum() == shownForum);
Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), { Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), {
.st = (forum ? &st::forumDialogRow : _st.get()), .st = (forum ? &st::forumDialogRow : _st.get()),
.topicJumpCache = _topicJumpCache.get(), .topicJumpCache = _topicJumpCache.get(),
@ -569,6 +574,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
.selected = (_menuRow.key .selected = (_menuRow.key
? (row->key() == _menuRow.key) ? (row->key() == _menuRow.key)
: selected), : selected),
.topicsExpanded = expanded,
.topicJumpSelected = (selected .topicJumpSelected = (selected
&& _selectedTopicJump && _selectedTopicJump
&& (!_pressed || _pressedTopicJump)), && (!_pressed || _pressedTopicJump)),

View file

@ -186,6 +186,21 @@ int PaintBadges(
return (initial - right); return (initial - right);
} }
void PaintExpandedTopicsBar(QPainter &p) {
auto hq = PainterHighQualityEnabler(p);
const auto radius = st::roundRadiusLarge;
const auto width = st::forumDialogRow.padding.left() / 2;
p.setPen(Qt::NoPen);
p.setBrush(st::dialogsBgActive);
p.drawRoundedRect(
-3 * radius,
st::forumDialogRow.padding.top(),
3 * radius + width,
st::forumDialogRow.photoSize,
radius,
radius);
}
void PaintNarrowCounter( void PaintNarrowCounter(
QPainter &p, QPainter &p,
const PaintContext &context, const PaintContext &context,
@ -338,6 +353,9 @@ void PaintRow(
if (!draft && item && !item->isEmpty()) { if (!draft && item && !item->isEmpty()) {
PaintNarrowCounter(p, context, badgesState); PaintNarrowCounter(p, context, badgesState);
} }
if (context.topicsExpanded) {
PaintExpandedTopicsBar(p);
}
return; return;
} }

View file

@ -62,6 +62,7 @@ struct PaintContext {
int width = 0; int width = 0;
bool active = false; bool active = false;
bool selected = false; bool selected = false;
bool topicsExpanded = false;
bool topicJumpSelected = false; bool topicJumpSelected = false;
bool paused = false; bool paused = false;
bool search = false; bool search = false;