Improve shading of collapsed chats list.

This commit is contained in:
John Preston 2022-12-05 10:07:54 +04:00
parent fbf3168317
commit 2407ac50bc
4 changed files with 44 additions and 35 deletions

View File

@ -565,6 +565,18 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
auto dialogsClip = r;
const auto ms = crl::now();
const auto childListShown = _childListShown.current();
auto context = Ui::PaintContext{
.st = _st,
.topicJumpCache = _topicJumpCache.get(),
.folder = _openedFolder,
.forum = _openedForum,
.filter = _filterId,
.childListShown = childListShown.shown,
.now = ms,
.width = fullWidth,
.paused = videoPaused,
.narrow = (fullWidth < st::columnMinimalWidthLeft / 2),
};
const auto paintRow = [&](
not_null<Row*> row,
bool selected,
@ -575,31 +587,21 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
if (forum && !_topicJumpCache) {
_topicJumpCache = std::make_unique<Ui::TopicJumpCache>();
}
const auto expanding = forum
&& (key.history()->peer->id == childListShown.peerId);
const auto expanded = (!active
&& forum
&& (key.history()->peer->id == childListShown.peerId))
context.st = (forum ? &st::forumDialogRow : _st.get());
context.topicsExpanded = (expanding && !active)
? childListShown.shown
: 0.;
Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), {
.st = (forum ? &st::forumDialogRow : _st.get()),
.topicJumpCache = _topicJumpCache.get(),
.folder = _openedFolder,
.forum = _openedForum,
.filter = _filterId,
.topicsExpanded = expanded,
.now = ms,
.width = fullWidth,
.active = active,
.selected = (_menuRow.key
? (row->key() == _menuRow.key)
: selected),
.topicJumpSelected = (selected
&& _selectedTopicJump
&& (!_pressed || _pressedTopicJump)),
.paused = videoPaused,
.narrow = (fullWidth < st::columnMinimalWidthLeft / 2),
});
context.active = active;
context.selected = _menuRow.key
? (row->key() == _menuRow.key)
: selected;
context.topicJumpSelected = selected
&& _selectedTopicJump
&& (!_pressed || _pressedTopicJump);
Ui::RowPainter::Paint(p, row, validateVideoUserpic(row), context);
};
if (_state == WidgetState::Default) {
paintCollapsedRows(p, r);

View File

@ -2013,21 +2013,17 @@ void Widget::openChildList(
const auto opacity = shadow->lifetime().make_state<float64>(0.);
shadow->setAttribute(Qt::WA_TransparentForMouseEvents);
shadow->paintRequest(
) | rpl::start_with_next([=] {
) | rpl::start_with_next([=](QRect clip) {
auto p = QPainter(shadow);
p.setOpacity(*opacity);
st::slideShadow.fill(p, QRect(
shadow->width() - st::slideShadow.width(),
0,
st::slideShadow.width(),
shadow->height()));
p.fillRect(clip, st::shadowFg);
}, shadow->lifetime());
_childListShown.value() | rpl::start_with_next([=](float64 value) {
*opacity = value;
update();
_inner->update();
if (!value && _childListShadow.get() != shadow) {
delete shadow;
} else {
shadow->update();
}
}, shadow->lifetime());
@ -2056,6 +2052,7 @@ void Widget::closeChildList(anim::type animated) {
if (animated == anim::type::normal) {
oldContentCache = Ui::GrabWidget(_childList.get());
_hideChildListCanvas = std::make_unique<Ui::RpWidget>(this);
_hideChildListCanvas->setAttribute(Qt::WA_TransparentForMouseEvents);
_hideChildListCanvas->setGeometry(geometry);
animation = _hideChildListCanvas->lifetime().make_state<
Window::SlideAnimation
@ -2457,10 +2454,12 @@ void Widget::updateControlsGeometry() {
if (_childList) {
const auto childw = std::max(_narrowWidth, width() - scrollw);
const auto childh = scrollTop + scrollHeight;
const auto childx = width() - childw;
_childList->setGeometryWithTopMoved(
{ width() - childw, 0, childw, childh },
{ childx, 0, childw, childh },
_topDelta);
_childListShadow->setGeometry(0, 0, (width() - childw), childh);
const auto line = st::lineWidth;
_childListShadow->setGeometry(childx - line, 0, line, childh);
}
}
@ -2511,9 +2510,13 @@ void Widget::paintEvent(QPaintEvent *e) {
_showAnimation->paintContents(p);
return;
}
const auto bg = anim::brush(
st::dialogsBg,
st::dialogsBgOver,
_childListShown.current());
auto above = QRect(0, 0, width(), _scroll->y());
if (above.intersects(r)) {
p.fillRect(above.intersected(r), st::dialogsBg);
p.fillRect(above.intersected(r), bg);
}
auto belowTop = _scroll->y() + qMin(_scroll->height(), _inner->height());
@ -2524,7 +2527,7 @@ void Widget::paintEvent(QPaintEvent *e) {
auto below = QRect(0, belowTop, width(), height() - belowTop);
if (below.intersects(r)) {
p.fillRect(below.intersected(r), st::dialogsBg);
p.fillRect(below.intersected(r), bg);
}
}

View File

@ -305,7 +305,10 @@ void PaintRow(
? st::dialogsBgActive
: context.selected
? st::dialogsBgOver
: st::dialogsBg;
: anim::brush(
st::dialogsBg,
st::dialogsBgOver,
context.childListShown);
p.fillRect(geometry, bg);
if (!(flags & Flag::TopicJumpRipple)) {
auto ripple = context.active

View File

@ -59,6 +59,7 @@ struct PaintContext {
Data::Forum *forum = nullptr;
FilterId filter = 0;
float64 topicsExpanded = 0.;
float64 childListShown = 0.;
crl::time now = 0;
int width = 0;
bool active = false;