From 025dd03a6a899e44b20f20ed2f9b8ec6a851d99f Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 25 Jun 2026 23:49:53 +0400 Subject: [PATCH] Fade chat list under Add a Chat to Community button --- Telegram/SourceFiles/dialogs/dialogs_widget.cpp | 5 +++++ .../ui/dialogs_top_bar_suggestion_content.cpp | 16 ++++++++++++++++ .../ui/dialogs_top_bar_suggestion_content.h | 6 ++++++ .../info/community/info_community_widget.cpp | 15 ++++++++++++++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index fc2750c1af..7ff255279e 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -1332,6 +1332,11 @@ void Widget::updateCommunityAddChatButton() { button->setFullWidth(width); button->moveToLeft(0, 0, width); }, row->lifetime()); + entity->paintOn([=](QPainter &p) { + const auto fadeHeight = st::communityAddChatButtonMargin.top() + + st::communityAddChatButton.height / 2; + PaintBottomFade(p, entity->width(), fadeHeight, st::dialogsBg); + }); _communityAddChat.reset(wrap.release()); const auto raw = _communityAddChat.get(); diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_top_bar_suggestion_content.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_top_bar_suggestion_content.cpp index 9fc0b5597f..0f9d41bb26 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_top_bar_suggestion_content.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_top_bar_suggestion_content.cpp @@ -81,6 +81,22 @@ namespace { } // namespace +void PaintBottomFade( + QPainter &p, + int outerWidth, + int fadeHeight, + style::color bg) { + if (fadeHeight <= 0) { + return; + } + auto transparent = bg->c; + transparent.setAlpha(0); + auto grad = QLinearGradient(0, 0, 0, fadeHeight); + grad.setColorAt(0, transparent); + grad.setColorAt(1, bg->c); + p.fillRect(QRect(0, 0, outerWidth, fadeHeight), grad); +} + int PillRadius() { const auto padding = st::msgReplyPadding.top(); return (padding diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_top_bar_suggestion_content.h b/Telegram/SourceFiles/dialogs/ui/dialogs_top_bar_suggestion_content.h index 2b6c8dfa54..5185fef2af 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_top_bar_suggestion_content.h +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_top_bar_suggestion_content.h @@ -36,6 +36,12 @@ int PaintSuggestionBubbleBackground( const Ui::BoxShadow &shadow, int cornerRadius = 0); +void PaintBottomFade( + QPainter &p, + int outerWidth, + int fadeHeight, + style::color bg); + class UnconfirmedAuthWrap : public Ui::SlideWrap { public: UnconfirmedAuthWrap( diff --git a/Telegram/SourceFiles/info/community/info_community_widget.cpp b/Telegram/SourceFiles/info/community/info_community_widget.cpp index dd95c797f9..cb4ac8b9fc 100644 --- a/Telegram/SourceFiles/info/community/info_community_widget.cpp +++ b/Telegram/SourceFiles/info/community/info_community_widget.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_changes.h" #include "data/data_channel.h" #include "data/data_community.h" +#include "dialogs/ui/dialogs_top_bar_suggestion_content.h" #include "info/profile/info_profile_top_bar.h" #include "info/profile/info_profile_values.h" #include "info/info_controller.h" @@ -212,6 +213,14 @@ std::unique_ptr Widget::setupAddChatButton() { auto result = std::make_unique(this); const auto wrap = result.get(); + const auto fade = Ui::CreateChild(this); + fade->setAttribute(Qt::WA_TransparentForMouseEvents); + const auto fadeHeight = st::communityAddChatButtonMargin.top() + + st::communityAddChatButton.height / 2; + fade->paintOn([=](QPainter &p) { + Dialogs::PaintBottomFade(p, fade->width(), fadeHeight, st::boxBg); + }); + const auto row = wrap->add( object_ptr(wrap), st::communityAddChatButtonMargin); @@ -227,6 +236,7 @@ std::unique_ptr Widget::setupAddChatButton() { widthValue() | rpl::on_next([=](int width) { wrap->resizeToWidth(width); + fade->resize(width, fadeHeight); }, wrap->lifetime()); rpl::combine( @@ -234,7 +244,10 @@ std::unique_ptr Widget::setupAddChatButton() { heightValue() ) | rpl::on_next([=](int height, int fullHeight) { setScrollBottomSkip(height); - wrap->move(0, fullHeight - height); + const auto seam = fullHeight - height; + wrap->move(0, seam); + fade->setGeometry(0, seam - fadeHeight, wrap->width(), fadeHeight); + fade->raise(); }, wrap->lifetime()); return result;