From 07e3671ca8e61e2d9a972c19c520d16077b89aa0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 12 May 2020 11:06:44 +0400 Subject: [PATCH] Allow monospace blocks to extend bubble width. This partially fixes #2060 instead of additional settings from #7822. --- Telegram/SourceFiles/boxes/create_poll_box.cpp | 2 +- .../SourceFiles/history/view/history_view_message.cpp | 11 +++++++++-- .../SourceFiles/history/view/history_view_message.h | 6 ++++-- .../media/streaming/media_streaming_video_track.cpp | 4 ++-- .../SourceFiles/window/themes/window_theme_editor.h | 2 +- Telegram/lib_ui | 2 +- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index 698ebc2d6..3ec7844b7 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -83,7 +83,7 @@ private: void show(anim::type animated); void destroy(FnMut done); - [[nodisacrd]] bool hasShadow() const; + [[nodiscard]] bool hasShadow() const; void createShadow(); void destroyShadow(); diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 9a09b5961..6f83064b1 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1464,6 +1464,12 @@ int Message::plainMaxWidth() const { + st::msgPadding.right(); } +int Message::monospaceMaxWidth() const { + return st::msgPadding.left() + + (hasVisibleText() ? message()->_text.countMaxMonospaceWidth() : 0) + + st::msgPadding.right(); +} + void Message::initLogEntryOriginal() { if (const auto log = message()->Get()) { AddComponents(LogEntryOriginal::Bit()); @@ -1787,7 +1793,7 @@ QRect Message::countGeometry() const { // contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth); } accumulate_min(contentWidth, maxWidth()); - accumulate_min(contentWidth, st::msgMaxWidth); + accumulate_min(contentWidth, _bubbleWidthLimit); if (mediaWidth < contentWidth) { const auto textualWidth = plainMaxWidth(); if (mediaWidth < textualWidth @@ -1829,7 +1835,8 @@ int Message::resizeContentGetHeight(int newWidth) { contentWidth -= st::msgPhotoSkip; } accumulate_min(contentWidth, maxWidth()); - accumulate_min(contentWidth, st::msgMaxWidth); + _bubbleWidthLimit = std::max(st::msgMaxWidth, monospaceMaxWidth()); + accumulate_min(contentWidth, _bubbleWidthLimit); if (mediaDisplayed) { media->resizeGetHeight(contentWidth); if (media->width() < contentWidth) { diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index d215e70a0..61effe84c 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -157,8 +157,9 @@ private: const HistoryMessageEdited *displayedEditBadge() const; HistoryMessageEdited *displayedEditBadge(); void initTime(); - int timeLeft() const; - int plainMaxWidth() const; + [[nodiscard]] int timeLeft() const; + [[nodiscard]] int plainMaxWidth() const; + [[nodiscard]] int monospaceMaxWidth() const; WebPage *logEntryOriginal() const; @@ -167,6 +168,7 @@ private: mutable ClickHandlerPtr _rightActionLink; mutable ClickHandlerPtr _fastReplyLink; + int _bubbleWidthLimit = 0; }; diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp index 61e66870d..5c39f2f65 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp @@ -37,8 +37,8 @@ public: void process(std::vector &&packets); - [[nodisacrd]] rpl::producer<> checkNextFrame() const; - [[nodisacrd]] rpl::producer<> waitingForData() const; + [[nodiscard]] rpl::producer<> checkNextFrame() const; + [[nodiscard]] rpl::producer<> waitingForData() const; void pause(crl::time time); void resume(crl::time time); diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.h b/Telegram/SourceFiles/window/themes/window_theme_editor.h index 9a3c36352..b8e459888 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.h +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.h @@ -43,7 +43,7 @@ struct ParsedTheme { const QByteArray &value); [[nodiscard]] QByteArray WriteCloudToText(const Data::CloudTheme &cloud); [[nodiscard]] Data::CloudTheme ReadCloudFromText(const QByteArray &text); -[[nodisacrd]] QByteArray StripCloudTextFields(const QByteArray &text); +[[nodiscard]] QByteArray StripCloudTextFields(const QByteArray &text); class Editor : public TWidget { public: diff --git a/Telegram/lib_ui b/Telegram/lib_ui index d05d9b214..b1d00d0b2 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit d05d9b214da0e9708ff0c5f540c6fb09f6187e7d +Subproject commit b1d00d0b28cfce60d88b1a0a088539980adcfdb5