Skip to content

Commit

Permalink
Don't expand minimum window size for folders
Browse files Browse the repository at this point in the history
Turn them into horizontal automatically instead
  • Loading branch information
ilya-fedin authored and john-preston committed Nov 17, 2024
1 parent 702aa94 commit 6c64c22
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/dialogs/dialogs_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,8 @@ Widget::Widget(
}

if (session().settings().dialogsFiltersEnabled()
&& Core::App().settings().chatFiltersHorizontal()) {
&& (Core::App().settings().chatFiltersHorizontal()
|| !controller->enoughSpaceForFilters())) {
toggleFiltersMenu(true);
}
}
Expand Down
13 changes: 11 additions & 2 deletions Telegram/SourceFiles/settings/settings_folders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,16 @@ void SetupTopContent(

}

void SetupView(not_null<Ui::VerticalLayout*> content) {
void SetupView(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> content) {
const auto wrap = content->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
content,
object_ptr<Ui::VerticalLayout>(content)));
wrap->toggleOn(controller->enoughSpaceForFiltersValue());
content = wrap->entity();

Ui::AddDivider(content);
Ui::AddSkip(content);
Ui::AddSubsectionTitle(content, tr::lng_filters_view_subtitle());
Expand Down Expand Up @@ -900,7 +909,7 @@ void Folders::setupContent(not_null<Window::SessionController*> controller) {

_save = SetupFoldersContent(controller, content);

SetupView(content);
SetupView(controller, content);

Ui::ResizeFitChild(this, content);
}
Expand Down
5 changes: 0 additions & 5 deletions Telegram/SourceFiles/window/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,6 @@ void MainWindow::updatePalette() {

int MainWindow::computeMinWidth() const {
auto result = st::windowMinWidth;
if (const auto session = _controller->sessionController()) {
if (const auto add = session->filtersWidth()) {
result += add;
}
}
if (_rightColumn) {
result += _rightColumn->width();
}
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/window/window_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ void Controller::setupSideBar() {
}, _sessionController->lifetime());

if (_sessionController->session().settings().dialogsFiltersEnabled()
&& _sessionController->enoughSpaceForFilters()
&& !Core::App().settings().chatFiltersHorizontal()) {
_sessionController->toggleFiltersMenu(true);
} else {
Expand Down
14 changes: 13 additions & 1 deletion Telegram/SourceFiles/window/window_session_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,14 +1315,16 @@ SessionController::SessionController(
}, lifetime());

rpl::merge(
enoughSpaceForFiltersValue() | rpl::skip(1) | rpl::to_empty,
Core::App().settings().chatFiltersHorizontalChanges() | rpl::to_empty,
session->data().chatsFilters().changed()
) | rpl::start_with_next([=] {
checkOpenedFilter();
crl::on_main(this, [this] {
if (SessionNavigation::session().data().chatsFilters().has()) {
const auto isHorizontal
= Core::App().settings().chatFiltersHorizontal();
= Core::App().settings().chatFiltersHorizontal()
|| !enoughSpaceForFilters();
content()->toggleFiltersMenu(isHorizontal);
toggleFiltersMenu(!isHorizontal);
} else {
Expand Down Expand Up @@ -2588,6 +2590,16 @@ int SessionController::filtersWidth() const {
return _filters ? st::windowFiltersWidth : 0;
}

bool SessionController::enoughSpaceForFilters() const {
return widget()->width() >= widget()->minimumWidth() + st::windowFiltersWidth;
}

rpl::producer<bool> SessionController::enoughSpaceForFiltersValue() const {
return widget()->widthValue() | rpl::map([=] {
return enoughSpaceForFilters();
}) | rpl::distinct_until_changed();
}

rpl::producer<FilterId> SessionController::activeChatsFilter() const {
return _activeChatsFilter.value();
}
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/window/window_session_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ class SessionController : public SessionNavigation {
}

[[nodiscard]] int filtersWidth() const;
[[nodiscard]] bool enoughSpaceForFilters() const;
[[nodiscard]] rpl::producer<bool> enoughSpaceForFiltersValue() const;
[[nodiscard]] rpl::producer<FilterId> activeChatsFilter() const;
[[nodiscard]] FilterId activeChatsFilterCurrent() const;
void setActiveChatsFilter(
Expand Down

0 comments on commit 6c64c22

Please sign in to comment.