diff --git a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp index 51ebf3b9e0..c6fa04eb01 100644 --- a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp +++ b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.cpp @@ -151,6 +151,10 @@ void SubsectionTabs::setupHorizontal(not_null parent) { { 0, 0, 0, st::lineWidth })), st::windowBg); }, _horizontal->lifetime()); + + _layoutRequests.fire({}); + + startFillingSlider(scroll, slider, false); } void SubsectionTabs::setupVertical(not_null parent) { @@ -204,6 +208,10 @@ void SubsectionTabs::setupVertical(not_null parent) { _vertical->paintRequest() | rpl::start_with_next([=](QRect clip) { QPainter(_vertical).fillRect(clip, st::windowBg); }, _vertical->lifetime()); + + _layoutRequests.fire({}); + + startFillingSlider(scroll, slider, true); } void SubsectionTabs::setupSlider( @@ -261,7 +269,12 @@ void SubsectionTabs::setupSlider( } } }, slider->lifetime()); +} +void SubsectionTabs::startScrollChecking( + not_null scroll, + not_null slider, + bool vertical) { rpl::merge( scroll->scrolls(), _scrollCheckRequests.events(), @@ -298,6 +311,13 @@ void SubsectionTabs::setupSlider( refreshAroundMiddle(scroll, slider); } }, scroll->lifetime()); +} + +void SubsectionTabs::startFillingSlider( + not_null scroll, + not_null slider, + bool vertical) { + // We need to fill the content after the initial size is set. using ImagePointer = std::shared_ptr; struct Cache { @@ -457,6 +477,8 @@ void SubsectionTabs::setupSlider( _scrollCheckRequests.fire({}); }, scroll->lifetime()); + + startScrollChecking(scroll, slider, vertical); } void SubsectionTabs::showThreadContextMenu(not_null thread) { @@ -503,17 +525,16 @@ rpl::producer<> SubsectionTabs::dataChanged() const { void SubsectionTabs::toggleModes() { Expects((_horizontal || _vertical) && _shadow); + const auto peerId = _history->peer->id; + const auto nowVertical = (_horizontal != nullptr); + session().settings().setVerticalSubsectionTabs(peerId, nowVertical); + session().saveSettingsDelayed(); + if (_horizontal) { setupVertical(_horizontal->parentWidget()); } else { setupHorizontal(_vertical->parentWidget()); } - const auto peerId = _history->peer->id; - const auto vertical = (_vertical != nullptr); - session().settings().setVerticalSubsectionTabs(peerId, vertical); - session().saveSettingsDelayed(); - - _layoutRequests.fire({}); } bool SubsectionTabs::dying() const { diff --git a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.h b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.h index d0d78f140c..711a0ce132 100644 --- a/Telegram/SourceFiles/history/view/history_view_subsection_tabs.h +++ b/Telegram/SourceFiles/history/view/history_view_subsection_tabs.h @@ -96,6 +96,14 @@ private: not_null scroll, not_null slider, bool vertical); + void startScrollChecking( + not_null scroll, + not_null slider, + bool vertical); + void startFillingSlider( + not_null scroll, + not_null slider, + bool vertical); void showThreadContextMenu(not_null thread); const not_null _controller;