diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 2d76e70d51..33064de7a4 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -1716,6 +1716,7 @@ void Widget::setupStories() { _stories->collapsedGeometryChanged( ) | rpl::on_next([=] { updateLockUnlockPosition(); + updateStoriesTitleShown(); }, lifetime()); _stories->clicks( @@ -2320,6 +2321,10 @@ void Widget::refreshTopBars() { ) | rpl::on_next([=](QString query) { applySearchUpdate(); }, _subsectionTopBar->lifetime()); + _subsectionTopBar->searchModeChanges( + ) | rpl::on_next([=](bool) { + updateStoriesVisibility(); + }, _subsectionTopBar->lifetime()); _subsectionTopBar->jumpToDateRequest( ) | rpl::on_next([=] { showCalendar(); @@ -2675,7 +2680,10 @@ void Widget::updateStoriesVisibility() { || _searchSuggestionsLocked || !_searchState.query.isEmpty() || _searchState.inChat - || suggestionsAnimation; + || suggestionsAnimation + || (_openedFolder + && _subsectionTopBar + && _subsectionTopBar->searchMode()); const auto hidden = hiddenInstant || hiddenAnimated; const auto changed = (_stories->toggledHidden() != hidden); _stories->setToggledHidden(hiddenInstant, hiddenAnimated); @@ -2699,6 +2707,19 @@ void Widget::updateStoriesVisibility() { } updateLockUnlockPosition(); } + updateStoriesTitleShown(); +} + +void Widget::updateStoriesTitleShown() { + if (!_subsectionTopBar || !_openedFolder) { + return; + } + const auto shown = (!_stories + || _stories->empty() + || _stories->toggledHidden()) + ? 1. + : _stories->collapsedGeometryCurrent().expanded; + _subsectionTopBar->setTitleShownRatio(shown); } void Widget::showFast() { @@ -4312,9 +4333,15 @@ void Widget::updateControlsGeometry() { + st::dialogsStories.photo; const auto added = (st::dialogsFilter.heightMin - storiesHeight) / 2; if (_stories) { + const auto inFolderTitle = _openedFolder && _subsectionTopBar; + const auto storiesLeft = inFolderTitle + ? (_subsectionTopBar->titleLeft() + - st::dialogsStories.left + - st::dialogsStories.photoLeft) + : (filterLeft + filterWidth); _stories->setLayoutConstraints( - { filterLeft + filterWidth, filterTop + added }, - style::al_right, + { storiesLeft, filterTop + added }, + inFolderTitle ? style::al_left : style::al_right, { 0, expandedStoriesTop, barw, st::dialogsStoriesFull.height }); } if (_forumTopShadow) { diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index dd8f2481c7..a4330a2cb3 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -242,6 +242,7 @@ private: anim::type animated = anim::type::instant); void updateLoadMoreChatsVisibility(); void updateStoriesVisibility(); + void updateStoriesTitleShown(); void updateJumpToDateVisibility(bool fast = false); void updateSearchFromVisibility(bool fast = false); void updateControlsGeometry(); diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 8eaf9678c8..6dd94a81c9 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -598,17 +598,22 @@ void TopBarWidget::paintTopBar(Painter &p) { : peer->isVerifyCodes() ? tr::lng_verification_codes(tr::now) : peer->name(); - const auto textWidth = st::historySavedFont->width(text); - if (namewidth < textWidth) { - text = st::historySavedFont->elided(text, namewidth); + const auto opacity = folder ? _titleShownRatio : 1.; + if (opacity > 0.) { + const auto textWidth = st::historySavedFont->width(text); + if (namewidth < textWidth) { + text = st::historySavedFont->elided(text, namewidth); + } + p.setOpacity(opacity); + p.setPen(st::dialogsNameFg); + p.setFont(st::historySavedFont); + p.drawTextLeft( + nameleft, + (height() - st::historySavedFont->height) / 2, + width(), + text); + p.setOpacity(1.); } - p.setPen(st::dialogsNameFg); - p.setFont(st::historySavedFont); - p.drawTextLeft( - nameleft, - (height() - st::historySavedFont->height) / 2, - width(), - text); } else if (_activeChat.section == Section::Replies) { p.setPen(st::dialogsNameFg); p.setFont(st::semiboldFont); @@ -989,6 +994,17 @@ void TopBarWidget::setCustomTitle(const QString &title) { } } +void TopBarWidget::setTitleShownRatio(float64 shown) { + if (_titleShownRatio != shown) { + _titleShownRatio = shown; + update(); + } +} + +int TopBarWidget::titleLeft() const { + return _leftTaken; +} + bool TopBarWidget::rootChatsListBar() const { if (_activeChat.section != Section::ChatsList) { return false; @@ -1495,6 +1511,7 @@ bool TopBarWidget::toggleSearch(bool shown, anim::type animated) { } else { Assert(_searchField != nullptr); } + _searchModeChanges.fire_copy(shown); _searchQuery = shown ? _searchField->getLastText() : QString(); if (animated == anim::type::normal) { _searchShown.start( @@ -1618,6 +1635,10 @@ bool TopBarWidget::searchMode() const { return _searchMode; } +rpl::producer TopBarWidget::searchModeChanges() const { + return _searchModeChanges.events(); +} + bool TopBarWidget::searchHasFocus() const { return _searchMode && _searchField->hasFocus(); } diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h index a12970f55d..fddb2dbf29 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h @@ -78,6 +78,8 @@ public: ActiveChat activeChat, SendActionPainter *sendAction); void setCustomTitle(const QString &title); + void setTitleShownRatio(float64 shown); + [[nodiscard]] int titleLeft() const; void showChooseMessagesForReport(Data::ReportInput reportInput); void clearChooseMessagesForReport(); @@ -87,6 +89,7 @@ public: void searchEnableChooseFromUser(bool enable, bool visible); bool searchSetFocus(); [[nodiscard]] bool searchMode() const; + [[nodiscard]] rpl::producer searchModeChanges() const; [[nodiscard]] bool searchHasFocus() const; [[nodiscard]] rpl::producer<> searchCancelled() const; [[nodiscard]] rpl::producer<> searchSubmitted() const; @@ -232,6 +235,7 @@ private: rpl::event_stream<> _searchSubmitted; rpl::event_stream<> _jumpToDateRequests; rpl::event_stream<> _chooseFromUserRequests; + rpl::event_stream _searchModeChanges; object_ptr _back; object_ptr _cancelChoose; @@ -255,6 +259,7 @@ private: bool _titlePeerTextOnline = false; int _leftTaken = 0; int _rightTaken = 0; + float64 _titleShownRatio = 1.; bool _animatingMode = false; std::unique_ptr _connecting;