From 9c83b8bac5e2090875b38d5efffb5203338ce967 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 2 Jun 2024 23:07:36 +0300 Subject: [PATCH] Fixed emoji display in reply markup button from bar for pinned messages. --- .../chat_helpers/chat_helpers.style | 7 +++++- .../SourceFiles/history/history_widget.cpp | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index 8439c5eeee..b3f7e73c97 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -930,7 +930,12 @@ historyPinnedBotButton: RoundButton(defaultActiveButton) { textTop: 6px; padding: margins(2px, 10px, 10px, 9px); } -historyPinnedBotButtonMaxWidth: 150px; +historyPinnedBotLabel: FlatLabel(defaultFlatLabel) { + style: semiboldTextStyle; + align: align(center); + maxHeight: 30px; +} +historyPinnedBotButtonMaxWidth: 120px; historyToDownPosition: point(12px, 10px); historyToDownAbove: icon {{ "history_down_arrow", historyToDownFg }}; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 383a76109d..a805c54796 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -7249,10 +7249,27 @@ void HistoryWidget::refreshPinnedBarButton(bool many, HistoryItem *item) { if ((rows.size() == 1) && (rows.front().size() == 1)) { const auto text = rows.front().front().text; if (!text.isEmpty()) { + const auto &st = st::historyPinnedBotButton; auto button = object_ptr( this, - rpl::single(text), - st::historyPinnedBotButton); + rpl::never(), + st); + const auto label = Ui::CreateChild( + button.data(), + text, + st::historyPinnedBotLabel); + if (label->width() > st::historyPinnedBotButtonMaxWidth) { + label->resizeToWidth(st::historyPinnedBotButtonMaxWidth); + } + button->setFullWidth(label->width() + + st.padding.left() + + st.padding.right() + + st.height); + label->moveToLeft( + st.padding.left() + st.height / 2, + (button->height() - label->height()) / 2); + label->setTextColorOverride(st.textFg->c); + label->setAttribute(Qt::WA_TransparentForMouseEvents); button->setTextTransform( Ui::RoundButton::TextTransform::NoTransform); button->setFullRadius(true); @@ -7262,9 +7279,6 @@ void HistoryWidget::refreshPinnedBarButton(bool many, HistoryItem *item) { 0, 0); }); - if (button->width() > st::historyPinnedBotButtonMaxWidth) { - button->setFullWidth(st::historyPinnedBotButtonMaxWidth); - } struct State { base::unique_qptr menu; };