From 455d1139559b6002ab2b1c8095b6082f359e4153 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 18 Mar 2020 16:14:45 +0400 Subject: [PATCH] Fix small column layout with filters side bar. --- Telegram/SourceFiles/dialogs/dialogs.style | 5 +++++ .../SourceFiles/dialogs/dialogs_widget.cpp | 21 +++++++++++++++++-- Telegram/SourceFiles/dialogs/dialogs_widget.h | 1 + .../SourceFiles/window/window_controller.cpp | 7 +++++++ .../window/window_session_controller.cpp | 6 +++++- .../window/window_session_controller.h | 3 +++ Telegram/lib_ui | 2 +- 7 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index e42995f19..5afa45572 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -120,6 +120,11 @@ dialogsSearchFrom: IconButton(dialogsCalendar) { icon: icon {{ "dialogs_search_from", dialogsMenuIconFg }}; iconOver: icon {{ "dialogs_search_from", dialogsMenuIconFgOver }}; } +dialogsSearchForNarrowFilters: IconButton(dialogsMenuToggle) { + icon: icon {{ "top_bar_search", menuIconFg }}; + iconOver: icon {{ "top_bar_search", menuIconFgOver }}; + iconPosition: point(4px, 4px); +} dialogsSearchFromPadding: margins(10px, 10px, 10px, 10px); dialogsFilter: FlatInput(defaultFlatInput) { diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 406075ee2..d7b1e899c 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -161,6 +161,7 @@ Widget::Widget( : Window::AbstractSectionWidget(parent, controller) , _searchControls(this) , _mainMenuToggle(_searchControls, st::dialogsMenuToggle) +, _searchForNarrowFilters(_searchControls, st::dialogsSearchForNarrowFilters) , _filter(_searchControls, st::dialogsFilter, tr::lng_dlg_filter()) , _chooseFromUser( _searchControls, @@ -259,8 +260,18 @@ Widget::Widget( Core::App().lockByPasscode(); _lockUnlock->setIconOverride(nullptr); }); - _mainMenuToggle->setVisible(!controller->filtersWidth()); - _mainMenuToggle->setClickedCallback([this] { showMainMenu(); }); + rpl::single( + rpl::empty_value() + ) | rpl::then( + controller->filtersMenuChanged() + ) | rpl::start_with_next([=] { + const auto filtersHidden = !controller->filtersWidth(); + _mainMenuToggle->setVisible(filtersHidden); + _searchForNarrowFilters->setVisible(!filtersHidden); + updateControlsGeometry(); + }, lifetime()); + _mainMenuToggle->setClickedCallback([=] { showMainMenu(); }); + _searchForNarrowFilters->setClickedCallback([=] { Ui::showChatsList(); }); _chooseByDragTimer.setSingleShot(true); connect(&_chooseByDragTimer, SIGNAL(timeout()), this, SLOT(onChooseByDrag())); @@ -1515,6 +1526,12 @@ void Widget::updateControlsGeometry() { _filter->setGeometryToLeft(filterLeft, filterTop, filterWidth, _filter->height()); auto mainMenuLeft = anim::interpolate(st::dialogsFilterPadding.x(), (smallLayoutWidth - _mainMenuToggle->width()) / 2, smallLayoutRatio); _mainMenuToggle->moveToLeft(mainMenuLeft, st::dialogsFilterPadding.y()); + const auto searchLeft = anim::interpolate( + -_searchForNarrowFilters->width(), + (smallLayoutWidth - _searchForNarrowFilters->width()) / 2, + smallLayoutRatio); + _searchForNarrowFilters->moveToLeft(searchLeft, st::dialogsFilterPadding.y()); + auto right = filterLeft + filterWidth; _lockUnlock->moveToLeft(right + st::dialogsFilterPadding.x(), st::dialogsFilterPadding.y()); _cancelSearch->moveToLeft(right - _cancelSearch->width(), _filter->y()); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index 700a5ab96..fc81317e8 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -178,6 +178,7 @@ private: object_ptr _searchControls; object_ptr _folderTopBar = { nullptr } ; object_ptr _mainMenuToggle; + object_ptr _searchForNarrowFilters; object_ptr _filter; object_ptr> _chooseFromUser; object_ptr> _jumpToDate; diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index ea4726060..9fa618cf5 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "main/main_account.h" +#include "main/main_session.h" #include "ui/layers/box_content.h" #include "ui/layers/layer_widget.h" #include "ui/toast/toast.h" @@ -32,6 +33,12 @@ Controller::Controller(not_null account) _sessionController = session ? std::make_unique(session, this) : nullptr; + if (_sessionController) { + _sessionController->filtersMenuChanged( + ) | rpl::start_with_next([=] { + sideBarChanged(); + }, session->lifetime()); + } if (_sessionController && Global::DialogsFiltersEnabled()) { _sessionController->toggleFiltersMenu(true); } else { diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 135bb95de..bf67f667d 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -210,7 +210,7 @@ void SessionController::toggleFiltersMenu(bool enabled) { } else { _filters = nullptr; } - _window->sideBarChanged(); + _filtersMenuChanged.fire({}); } void SessionController::refreshFiltersMenu() { @@ -222,6 +222,10 @@ void SessionController::refreshFiltersMenu() { } } +rpl::producer<> SessionController::filtersMenuChanged() const { + return _filtersMenuChanged.events(); +} + bool SessionController::uniqueChatsInSearchResults() const { return session().supportMode() && !session().settings().supportAllSearchResults() diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 0a8adafa0..38275c58a 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -300,6 +300,7 @@ public: void toggleFiltersMenu(bool enabled); void refreshFiltersMenu(); + [[nodiscard]] rpl::producer<> filtersMenuChanged() const; rpl::lifetime &lifetime() { return _lifetime; @@ -354,6 +355,8 @@ private: PeerData *_showEditPeer = nullptr; rpl::variable _openedFolder; + rpl::event_stream<> _filtersMenuChanged; + rpl::lifetime _lifetime; }; diff --git a/Telegram/lib_ui b/Telegram/lib_ui index e4e8faaa7..ed97ff0d4 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit e4e8faaa73d1f6f9b690d7322d069183799ac6c2 +Subproject commit ed97ff0d4fd71dea6ad509b1178bb167f01bc178