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