mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-23 06:02:49 +02:00
parent
3683fa3814
commit
c998352ab7
3 changed files with 15 additions and 6 deletions
|
@ -432,10 +432,14 @@ void SubsectionTabs::setupSlider(
|
|||
.session = &session(),
|
||||
}),
|
||||
}, paused);
|
||||
slider->setActiveSectionFast(activeIndex);
|
||||
|
||||
const auto ignoreActiveScroll = (scrollSavingIndex >= 0);
|
||||
slider->setActiveSectionFast(activeIndex, ignoreActiveScroll);
|
||||
|
||||
_sectionsSlice = _slice;
|
||||
if (scrollSavingIndex >= 0) {
|
||||
Assert(slider->sectionsCount() == _slice.size());
|
||||
if (ignoreActiveScroll) {
|
||||
Assert(scrollSavingIndex < slider->sectionsCount());
|
||||
const auto position = scrollSavingShift
|
||||
+ slider->lookupSectionPosition(scrollSavingIndex);
|
||||
if (vertical) {
|
||||
|
@ -702,6 +706,8 @@ void SubsectionTabs::refreshSlice() {
|
|||
if (_slice != slice) {
|
||||
_slice = std::move(slice);
|
||||
_refreshed.fire({});
|
||||
Assert((!_horizontal && !_vertical)
|
||||
|| (_slice.size() == _sectionsSlice.size()));
|
||||
}
|
||||
});
|
||||
const auto push = [&](not_null<Data::Thread*> thread) {
|
||||
|
|
|
@ -394,7 +394,7 @@ void SubsectionSlider::activate(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
void SubsectionSlider::setActiveSectionFast(int active) {
|
||||
void SubsectionSlider::setActiveSectionFast(int active, bool ignoreScroll) {
|
||||
Expects(active < int(_tabs.size()));
|
||||
|
||||
if (_active == active) {
|
||||
|
@ -403,8 +403,10 @@ void SubsectionSlider::setActiveSectionFast(int active) {
|
|||
_active = active;
|
||||
_activeFrom.stop();
|
||||
_activeSize.stop();
|
||||
const auto now = getFinalActiveRange();
|
||||
_requestShown.fire({ now.from, now.from + now.size });
|
||||
if (_active >= 0 && !ignoreScroll) {
|
||||
const auto now = getFinalActiveRange();
|
||||
_requestShown.fire({ now.from, now.from + now.size });
|
||||
}
|
||||
_bar->update();
|
||||
}
|
||||
|
||||
|
@ -425,6 +427,7 @@ rpl::producer<int> SubsectionSlider::sectionContextMenu() const {
|
|||
}
|
||||
|
||||
int SubsectionSlider::lookupSectionPosition(int index) const {
|
||||
Expects(!_tabs.empty());
|
||||
Expects(index >= 0 && index < _tabs.size());
|
||||
|
||||
return _vertical ? _tabs[index]->y() : _tabs[index]->x();
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
void setSections(
|
||||
SubsectionTabs sections,
|
||||
Fn<bool()> paused);
|
||||
void setActiveSectionFast(int active);
|
||||
void setActiveSectionFast(int active, bool ignoreScroll = false);
|
||||
|
||||
[[nodiscard]] int sectionsCount() const;
|
||||
[[nodiscard]] rpl::producer<int> sectionActivated() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue