Fixed members grouping toggle display for off-screen members.

This commit is contained in:
23rd
2026-07-22 17:14:57 +03:00
committed by John Preston
parent 3ae795be9c
commit 39e36af3e5
5 changed files with 21 additions and 6 deletions
@@ -585,6 +585,7 @@ base::weak_qptr<Ui::RpWidget> InnerWidget::createPinnedToTop(
content->setupStandaloneGroupControl(
members->groupByRoleValue(),
members->groupByRoleAvailableValue(),
members->rowsVisibleValue(),
crl::guard(members, [=](bool grouped) {
members->setGroupByRole(grouped);
}));
@@ -105,6 +105,10 @@ rpl::producer<bool> Members::groupByRoleAvailableValue() const {
return _listController->groupByRoleAvailableValue();
}
rpl::producer<bool> Members::rowsVisibleValue() const {
return _rowsVisible.value();
}
std::unique_ptr<MembersState> Members::saveState() {
auto result = std::make_unique<MembersState>();
result->list = _listController->saveState();
@@ -445,6 +449,9 @@ void Members::visibleTopBottomUpdated(
int visibleTop,
int visibleBottom) {
setChildVisibleTopBottom(_list, visibleTop, visibleBottom);
const auto top = _list->y();
_rowsVisible = (visibleBottom > top)
&& (visibleTop < top + _list->height());
}
void Members::peerListSetTitle(rpl::producer<QString> title) {
@@ -55,6 +55,7 @@ public:
void setGroupByRole(bool grouped);
[[nodiscard]] rpl::producer<bool> groupByRoleValue() const;
[[nodiscard]] rpl::producer<bool> groupByRoleAvailableValue() const;
[[nodiscard]] rpl::producer<bool> rowsVisibleValue() const;
std::unique_ptr<MembersState> saveState();
void restoreState(std::unique_ptr<MembersState> state);
@@ -140,6 +141,7 @@ private:
//base::Timer _searchTimer;
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
rpl::variable<bool> _rowsVisible = false;
};
@@ -158,7 +158,6 @@ constexpr auto kMinContrast = 5.5;
constexpr auto kStoryOutlineFadeEnd = 0.4;
constexpr auto kStoryOutlineFadeRange = 1. - kStoryOutlineFadeEnd;
constexpr auto kSwapMoveAmplitude = 0.3;
constexpr auto kStandaloneGroupProgress = 0.5;
using AnimatedPatternPoint = TopBar::AnimatedPatternPoint;
@@ -2086,11 +2085,13 @@ void TopBar::applyTabBindings(TabTopBarBindings &&bindings) {
void TopBar::setupStandaloneGroupControl(
rpl::producer<bool> state,
rpl::producer<bool> available,
rpl::producer<bool> reached,
Fn<void(bool)> toggle) {
_standaloneGroup = true;
_tabSetGroup = std::move(toggle);
_tabGroupActive = false;
_tabGroupAvailable = false;
_standaloneGroupReached = false;
std::move(
state
) | rpl::on_next([=](bool grouped) {
@@ -2104,8 +2105,10 @@ void TopBar::setupStandaloneGroupControl(
_tabGroupAvailable = value;
updateTabSwapVisibility();
}, lifetime());
_progress.changes(
) | rpl::on_next([=] {
std::move(
reached
) | rpl::on_next([=](bool value) {
_standaloneGroupReached = value;
updateTabSwapVisibility();
}, lifetime());
updateTabGroupActive();
@@ -2509,10 +2512,10 @@ void TopBar::updateTabSwapVisibility() {
}
}
if (_tabGroupToggle) {
const auto collapsed = _standaloneGroup
? (_progress.current() < kStandaloneGroupProgress)
const auto reached = _standaloneGroup
? _standaloneGroupReached
: swap;
const auto shown = collapsed
const auto shown = reached
&& !_tabSearchShown
&& (_tabSetGroup != nullptr)
&& _tabGroupAvailable;
@@ -129,6 +129,7 @@ public:
void setupStandaloneGroupControl(
rpl::producer<bool> state,
rpl::producer<bool> available,
rpl::producer<bool> reached,
Fn<void(bool)> toggle);
void checkBeforeCloseByEscape(Fn<void()> close);
@@ -293,6 +294,7 @@ private:
bool _tabGroupActive = false;
bool _tabGroupAvailable = false;
bool _standaloneGroup = false;
bool _standaloneGroupReached = false;
object_ptr<Ui::FlatLabel> _status;
std::unique_ptr<StatusLabel> _statusLabel;
rpl::variable<int> _statusShift = 0;