diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 6df70cd0d..592d4dbd1 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -799,7 +799,21 @@ void MainWindow::updateControlsGeometry() { auto body = bodyWidget()->rect(); if (_passcodeLock) _passcodeLock->setGeometry(body); - if (_main) _main->setGeometry(body); + auto mainLeft = 0; + auto mainWidth = body.width(); + if (const auto session = sessionController()) { + if (const auto skip = session->filtersWidth()) { + mainLeft += skip; + mainWidth -= skip; + } + } + if (_main) { + _main->setGeometry({ + body.x() + mainLeft, + body.y(), + mainWidth, + body.height() }); + } if (_intro) _intro->setGeometry(body); if (_layer) _layer->setGeometry(body); if (_mediaPreview) _mediaPreview->setGeometry(body); diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index d78970a0e..88ffe6e48 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -522,12 +522,6 @@ void MainWindow::updateControlsGeometry() { bodyWidth -= _rightColumn->width(); _rightColumn->setGeometry(bodyWidth, bodyTop, width() - bodyWidth, height() - bodyTop); } - if (const auto session = _controller->sessionController()) { - if (const auto skip = session->filtersWidth()) { - bodyLeft += skip; - bodyWidth -= skip; - } - } _body->setGeometry(bodyLeft, bodyTop, bodyWidth, height() - bodyTop); } diff --git a/Telegram/SourceFiles/window/window_filters_menu.cpp b/Telegram/SourceFiles/window/window_filters_menu.cpp index 8128cb31d..9a8105048 100644 --- a/Telegram/SourceFiles/window/window_filters_menu.cpp +++ b/Telegram/SourceFiles/window/window_filters_menu.cpp @@ -17,19 +17,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Window { -FiltersMenu::FiltersMenu(not_null session) +FiltersMenu::FiltersMenu( + not_null parent, + not_null session) : _session(session) -, _widget(session->widget(), st::defaultSideBarMenu) { +, _parent(parent) +, _widget(_parent, st::defaultSideBarMenu) { setup(); } void FiltersMenu::setup() { - const auto body = _session->widget()->bodyWidget(); - rpl::combine( - body->topValue(), - body->heightValue() - ) | rpl::start_with_next([=](int top, int height) { - _widget.setGeometry({ 0, top, st::windowFiltersWidth, height }); + _parent->heightValue( + ) | rpl::start_with_next([=](int height) { + _widget.setGeometry({ 0, 0, st::windowFiltersWidth, height }); }, _widget.lifetime()); const auto filters = &_session->session().data().chatsFilters(); diff --git a/Telegram/SourceFiles/window/window_filters_menu.h b/Telegram/SourceFiles/window/window_filters_menu.h index b4c70ba52..0555da74f 100644 --- a/Telegram/SourceFiles/window/window_filters_menu.h +++ b/Telegram/SourceFiles/window/window_filters_menu.h @@ -15,13 +15,16 @@ class SessionController; class FiltersMenu final { public: - explicit FiltersMenu(not_null session); + FiltersMenu( + not_null parent, + not_null session); private: void setup(); void refresh(); const not_null _session; + const not_null _parent; Ui::SideBarMenu _widget; }; diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 04dd32108..ad4df58b6 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -194,7 +194,9 @@ void SessionController::toggleFiltersMenu(bool enabled) { if (!enabled == !_filters) { return; } else if (enabled) { - _filters = std::make_unique(this); + _filters = std::make_unique( + widget()->bodyWidget(), + this); } else { _filters = nullptr; } @@ -346,10 +348,10 @@ bool SessionController::forceWideDialogs() const { return !App::main()->isMainSectionShown(); } -SessionController::ColumnLayout SessionController::computeColumnLayout() const { +auto SessionController::computeColumnLayout() const -> ColumnLayout { auto layout = Adaptive::WindowLayout::OneColumn; - auto bodyWidth = widget()->bodyWidget()->width(); + auto bodyWidth = widget()->bodyWidget()->width() - filtersWidth(); auto dialogsWidth = 0, chatWidth = 0, thirdWidth = 0; auto useOneColumnLayout = [&] { diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 5daa506e0..8568b7b23 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -215,7 +215,7 @@ public: int thirdWidth; Adaptive::WindowLayout windowLayout; }; - ColumnLayout computeColumnLayout() const; + [[nodiscard]] ColumnLayout computeColumnLayout() const; int dialogsSmallColumnWidth() const; bool forceWideDialogs() const; void updateColumnLayout();