From 60fb5fdaf0e5925e944c032f19d83620e1bcc609 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 23 Oct 2023 21:29:18 +0400 Subject: [PATCH] Update color index caches on palette change. --- Telegram/SourceFiles/data/data_changes.h | 55 ++++++++++--------- Telegram/SourceFiles/data/data_peer.cpp | 14 +++++ Telegram/SourceFiles/data/data_peer.h | 4 ++ Telegram/SourceFiles/data/data_session.cpp | 23 ++++++++ Telegram/SourceFiles/data/data_session.h | 5 ++ Telegram/SourceFiles/data/data_types.h | 3 + .../history/history_inner_widget.cpp | 4 ++ Telegram/SourceFiles/history/history_item.cpp | 18 +++++- Telegram/SourceFiles/history/history_item.h | 11 ++-- .../history/history_item_components.cpp | 22 ++++---- .../history/history_item_components.h | 1 - .../history/view/history_view_element.cpp | 3 +- .../history/view/history_view_element.h | 1 - .../history/view/history_view_list_widget.cpp | 5 ++ .../history/view/media/history_view_game.cpp | 8 +-- .../history/view/media/history_view_game.h | 3 +- .../view/media/history_view_giveaway.cpp | 8 +-- .../view/media/history_view_giveaway.h | 1 - .../view/media/history_view_web_page.cpp | 8 +-- .../view/media/history_view_web_page.h | 3 +- Telegram/SourceFiles/mtproto/scheme/api.tl | 8 +-- Telegram/SourceFiles/ui/chat/chat_style.cpp | 12 +++- 22 files changed, 148 insertions(+), 72 deletions(-) diff --git a/Telegram/SourceFiles/data/data_changes.h b/Telegram/SourceFiles/data/data_changes.h index a7f52b98b..9de11be5b 100644 --- a/Telegram/SourceFiles/data/data_changes.h +++ b/Telegram/SourceFiles/data/data_changes.h @@ -72,41 +72,42 @@ struct PeerUpdate { Usernames = (1ULL << 12), TranslationDisabled = (1ULL << 13), Color = (1ULL << 14), + BackgroundEmoji = (1ULL << 15), // For users - CanShareContact = (1ULL << 15), - IsContact = (1ULL << 16), - PhoneNumber = (1ULL << 17), - OnlineStatus = (1ULL << 18), - BotCommands = (1ULL << 19), - BotCanBeInvited = (1ULL << 20), - BotStartToken = (1ULL << 21), - CommonChats = (1ULL << 22), - HasCalls = (1ULL << 23), - SupportInfo = (1ULL << 24), - IsBot = (1ULL << 25), - EmojiStatus = (1ULL << 26), - StoriesState = (1ULL << 27), + CanShareContact = (1ULL << 16), + IsContact = (1ULL << 17), + PhoneNumber = (1ULL << 18), + OnlineStatus = (1ULL << 19), + BotCommands = (1ULL << 20), + BotCanBeInvited = (1ULL << 21), + BotStartToken = (1ULL << 22), + CommonChats = (1ULL << 23), + HasCalls = (1ULL << 24), + SupportInfo = (1ULL << 25), + IsBot = (1ULL << 26), + EmojiStatus = (1ULL << 27), + StoriesState = (1ULL << 28), // For chats and channels - InviteLinks = (1ULL << 28), - Members = (1ULL << 29), - Admins = (1ULL << 30), - BannedUsers = (1ULL << 31), - Rights = (1ULL << 32), - PendingRequests = (1ULL << 33), - Reactions = (1ULL << 34), + InviteLinks = (1ULL << 29), + Members = (1ULL << 30), + Admins = (1ULL << 31), + BannedUsers = (1ULL << 32), + Rights = (1ULL << 33), + PendingRequests = (1ULL << 34), + Reactions = (1ULL << 35), // For channels - ChannelAmIn = (1ULL << 35), - StickersSet = (1ULL << 36), - ChannelLinkedChat = (1ULL << 37), - ChannelLocation = (1ULL << 38), - Slowmode = (1ULL << 39), - GroupCall = (1ULL << 40), + ChannelAmIn = (1ULL << 36), + StickersSet = (1ULL << 37), + ChannelLinkedChat = (1ULL << 38), + ChannelLocation = (1ULL << 39), + Slowmode = (1ULL << 40), + GroupCall = (1ULL << 41), // For iteration - LastUsedBit = (1ULL << 40), + LastUsedBit = (1ULL << 41), }; using Flags = base::flags; friend inline constexpr auto is_flag_type(Flag) { return true; } diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index e58c941ed..d89b23984 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -627,6 +627,13 @@ bool PeerData::changeColorIndex( : clearColorIndex(); } +bool PeerData::changeBackgroundEmoji( + const tl::conditional &cloudBackgroundEmoji) { + return changeBackgroundEmoji(cloudBackgroundEmoji + ? cloudBackgroundEmoji->v + : DocumentId()); +} + void PeerData::fillNames() { _nameWords.clear(); _nameFirstLetters.clear(); @@ -862,6 +869,13 @@ bool PeerData::clearColorIndex() { return true; } +bool PeerData::changeBackgroundEmoji(uint64 id) { + if (_backgroundEmojiId == id) { + return false; + } + _backgroundEmojiId = id; + return true; +} bool PeerData::isSelf() const { if (const auto user = asUser()) { return (user->flags() & UserDataFlag::Self); diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index 643dae041..c0d84e718 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -169,6 +169,7 @@ public: } bool changeColorIndex(uint8 index); bool clearColorIndex(); + bool changeBackgroundEmoji(uint64 id); [[nodiscard]] bool isUser() const { return peerIsUser(id); @@ -360,6 +361,8 @@ public: void setSettings(const MTPPeerSettings &data); bool changeColorIndex(const tl::conditional &cloudColorIndex); + bool changeBackgroundEmoji( + const tl::conditional &cloudBackgroundEmoji); enum class BlockStatus : char { Unknown, @@ -452,6 +455,7 @@ private: base::flat_set _nameWords; // for filtering base::flat_set _nameFirstLetters; + uint64 _backgroundEmojiId = 0; crl::time _lastFullUpdate = 0; QString _name; diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 52999367f..3f8b7796f 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -705,8 +705,18 @@ not_null Session::processUser(const MTPUser &data) { if (canShareThisContact != result->canShareThisContactFast()) { flags |= UpdateFlag::CanShareContact; } + + auto decorationsUpdated = false; if (result->changeColorIndex(data.vcolor())) { flags |= UpdateFlag::Color; + decorationsUpdated = true; + } + if (result->changeBackgroundEmoji(data.vbackground_emoji_id())) { + flags |= UpdateFlag::BackgroundEmoji; + decorationsUpdated = true; + } + if (decorationsUpdated && result->isMinimalLoaded()) { + _peerDecorationsUpdated.fire_copy(result); } }); @@ -982,8 +992,17 @@ not_null Session::processChat(const MTPChat &data) { if (wasCallNotEmpty != Data::ChannelHasActiveCall(channel)) { flags |= UpdateFlag::GroupCall; } + auto decorationsUpdated = false; if (result->changeColorIndex(data.vcolor())) { flags |= UpdateFlag::Color; + decorationsUpdated = true; + } + if (result->changeBackgroundEmoji(data.vbackground_emoji_id())) { + flags |= UpdateFlag::BackgroundEmoji; + decorationsUpdated = true; + } + if (decorationsUpdated && result->isMinimalLoaded()) { + _peerDecorationsUpdated.fire_copy(result); } }, [&](const MTPDchannelForbidden &data) { const auto channel = result->asChannel(); @@ -4515,6 +4534,10 @@ auto Session::webViewResultSent() const -> rpl::producer { return _webViewResultSent.events(); } +rpl::producer> Session::peerDecorationsUpdated() const { + return _peerDecorationsUpdated.events(); +} + void Session::clearLocalStorage() { _cache->close(); _cache->clear(); diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index 0b810b642..9ecb5c45c 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -726,6 +726,9 @@ public: void webViewResultSent(WebViewResultSent &&sent); [[nodiscard]] rpl::producer webViewResultSent() const; + [[nodiscard]] auto peerDecorationsUpdated() const + -> rpl::producer>; + void clearLocalStorage(); private: @@ -1011,6 +1014,8 @@ private: rpl::event_stream _webViewResultSent; + rpl::event_stream> _peerDecorationsUpdated; + Groups _groups; const std::unique_ptr _chatsFilters; std::unique_ptr _scheduledMessages; diff --git a/Telegram/SourceFiles/data/data_types.h b/Telegram/SourceFiles/data/data_types.h index 611a91263..8029c5eeb 100644 --- a/Telegram/SourceFiles/data/data_types.h +++ b/Telegram/SourceFiles/data/data_types.h @@ -306,6 +306,9 @@ enum class MessageFlag : uint64 { StoryItem = (1ULL << 38), InHighlightProcess = (1ULL << 39), + + // If not set then we need to refresh _displayFrom value. + DisplayFromChecked = (1ULL << 40), }; inline constexpr bool is_flag_type(MessageFlag) { return true; } using MessageFlags = base::flags; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 04f7c5518..6f103704c 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -544,6 +544,10 @@ HistoryInner::HistoryInner( PremiumPreview::InfiniteReactions); }, lifetime()); + session().data().peerDecorationsUpdated( + ) | rpl::start_with_next([=] { + update(); + }, lifetime()); session().data().itemRemoved( ) | rpl::start_with_next( [this](auto item) { itemRemoved(item); }, diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index fdbf21d52..7aa8b2494 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1126,7 +1126,7 @@ HistoryItem *HistoryItem::lookupDiscussionPostOriginal() const { forwarded->savedFromMsgId); } -PeerData *HistoryItem::displayFrom() const { +PeerData *HistoryItem::computeDisplayFrom() const { if (const auto sender = discussionPostOriginalSender()) { return sender; } else if (const auto sponsored = Get()) { @@ -1134,14 +1134,24 @@ PeerData *HistoryItem::displayFrom() const { return nullptr; } } else if (const auto forwarded = Get()) { - if (_history->peer->isSelf() || _history->peer->isRepliesChat() || forwarded->imported) { + if (_history->peer->isSelf() + || _history->peer->isRepliesChat() + || forwarded->imported) { return forwarded->originalSender; } } return author().get(); } -uint8 HistoryItem::computeColorIndex() const { +PeerData *HistoryItem::displayFrom() const { + if (!(_flags & MessageFlag::DisplayFromChecked)) { + _flags |= MessageFlag::DisplayFromChecked; + _displayFrom = computeDisplayFrom(); + } + return _displayFrom; +} + +uint8 HistoryItem::colorIndex() const { if (const auto from = displayFrom()) { return from->colorIndex(); } else if (const auto info = hiddenSenderInfo()) { @@ -1615,6 +1625,7 @@ void HistoryItem::applyEdition(const MTPDmessageService &message) { createServiceFromMtp(message); applyServiceDateEdition(message); finishEditionToEmpty(); + _flags &= ~MessageFlag::DisplayFromChecked; } else if (isService()) { if (const auto reply = Get()) { reply->clearData(this); @@ -1624,6 +1635,7 @@ void HistoryItem::applyEdition(const MTPDmessageService &message) { createServiceFromMtp(message); applyServiceDateEdition(message); finishEdition(-1); + _flags &= ~MessageFlag::DisplayFromChecked; } } diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 55b5f14b7..a5206bdcc 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -501,7 +501,7 @@ public: [[nodiscard]] bool isDiscussionPost() const; [[nodiscard]] HistoryItem *lookupDiscussionPostOriginal() const; [[nodiscard]] PeerData *displayFrom() const; - [[nodiscard]] uint8 computeColorIndex() const; + [[nodiscard]] uint8 colorIndex() const; [[nodiscard]] std::unique_ptr createView( not_null delegate, @@ -584,8 +584,8 @@ private: bool used); void setSelfDestruct(HistorySelfDestructType type, MTPint mtpTTLvalue); - TextWithEntities fromLinkText() const; - ClickHandlerPtr fromLink() const; + [[nodiscard]] TextWithEntities fromLinkText() const; + [[nodiscard]] ClickHandlerPtr fromLink() const; void setGroupId(MessageGroupId groupId); @@ -624,9 +624,12 @@ private: [[nodiscard]] PreparedServiceText prepareCallScheduledText( TimeId scheduleDate); + [[nodiscard]] PeerData *computeDisplayFrom() const; + const not_null _history; const not_null _from; - MessageFlags _flags = 0; + mutable PeerData *_displayFrom = nullptr; + mutable MessageFlags _flags = 0; TextWithEntities _text; diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index a5efe9ba8..c8b3acece 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -402,11 +402,7 @@ bool HistoryMessageReply::updateData( } } - if (resolvedMessage) { - _colorIndexPlusOne = resolvedMessage->computeColorIndex() + 1; - } else if (resolvedStory) { - _colorIndexPlusOne = resolvedStory->peer()->colorIndex() + 1; - } else { + if (!resolvedMessage && !resolvedStory) { _unavailable = 1; } @@ -422,7 +418,6 @@ bool HistoryMessageReply::updateData( if (_fields.messageId || _fields.storyId) { _unavailable = 1; } - _colorIndexPlusOne = 0; spoiler = nullptr; } if (force) { @@ -681,14 +676,19 @@ void HistoryMessageReply::paint( const auto rect = QRect(x, y, w, _height); const auto hasQuote = !_fields.quote.empty(); const auto selected = context.selected(); - const auto colorIndexPlusOne = context.outbg ? 0 : _colorIndexPlusOne; + const auto colorIndexPlusOne = resolvedMessage + ? (resolvedMessage->colorIndex() + 1) + : resolvedStory + ? (resolvedStory->peer()->colorIndex() + 1) + : 0; + const auto useColorIndex = colorIndexPlusOne && !context.outbg; const auto twoColored = colorIndexPlusOne && Ui::ColorIndexTwoColored(colorIndexPlusOne - 1); const auto cache = !inBubble ? (hasQuote ? st->serviceQuoteCache(twoColored) : st->serviceReplyCache(twoColored)).get() - : colorIndexPlusOne + : useColorIndex ? (hasQuote ? st->coloredQuoteCache(selected, colorIndexPlusOne - 1) : st->coloredReplyCache(selected, colorIndexPlusOne - 1)).get() @@ -768,7 +768,7 @@ void HistoryMessageReply::paint( w -= textLeft + st::historyReplyPadding.right(); p.setPen(!inBubble ? st->msgImgReplyBarColor()->c - : colorIndexPlusOne + : useColorIndex ? FromNameFg(context, colorIndexPlusOne - 1) : stm->msgServiceFg->c); _name.drawLeftElided(p, x + textLeft, y + st::historyReplyPadding.top(), w, w + 2 * x + 2 * textLeft); @@ -786,7 +786,7 @@ void HistoryMessageReply::paint( y + st::historyReplyPadding.top() + st::msgServiceNameFont->height); auto replyToTextPalette = &(!inBubble ? st->imgReplyTextPalette() - : colorIndexPlusOne + : useColorIndex ? st->coloredTextPalette(selected, colorIndexPlusOne - 1) : stm->replyTextPalette); if (_fields.storyId) { @@ -802,7 +802,7 @@ void HistoryMessageReply::paint( } auto owned = std::optional(); auto copy = std::optional(); - if (inBubble && _colorIndexPlusOne) { + if (inBubble && colorIndexPlusOne) { copy.emplace(*replyToTextPalette); owned.emplace(cache->icon); copy->linkFg = owned->color(); diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index 507fa46da..79b78d6d7 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -346,7 +346,6 @@ private: mutable int _minHeight = 0; mutable int _height = 0; mutable int _nameVersion = 0; - uint8 _colorIndexPlusOne : 6 = 0; uint8 _unavailable : 1 = 0; }; diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index e490fc0ff..1f3acc543 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -467,7 +467,6 @@ Element::Element( | (IsItemScheduledUntilOnline(data) ? Flag::ScheduledUntilOnline : Flag())) -, _colorIndex(data->computeColorIndex()) , _context(delegate->elementContext()) { history()->owner().registerItemView(this); refreshMedia(replacing); @@ -492,7 +491,7 @@ not_null Element::history() const { } uint8 Element::colorIndex() const { - return _colorIndex; + return data()->colorIndex(); } QDateTime Element::dateTime() const { diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index d570093c1..3cc0903ff 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -594,7 +594,6 @@ private: int _indexInBlock = -1; mutable Flags _flags = Flag(0); - uint8 _colorIndex = 0; Context _context = Context(); }; diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index f2ed79c39..e3e979285 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -353,6 +353,11 @@ ListWidget::ListWidget( update(); }, lifetime()); + session().data().peerDecorationsUpdated( + ) | rpl::start_with_next([=] { + update(); + }, lifetime()); + session().data().itemRemoved( ) | rpl::start_with_next([=](not_null item) { itemRemoved(item); diff --git a/Telegram/SourceFiles/history/view/media/history_view_game.cpp b/Telegram/SourceFiles/history/view/media/history_view_game.cpp index 70e92a6e9..9f09e28db 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_game.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_game.cpp @@ -34,7 +34,6 @@ Game::Game( : Media(parent) , _st(st::historyPagePreview) , _data(data) -, _colorIndex(parent->data()->computeColorIndex()) , _title(st::msgMinWidth - _st.padding.left() - _st.padding.right()) , _description(st::msgMinWidth - _st.padding.left() - _st.padding.right()) { if (!consumed.text.isEmpty()) { @@ -219,11 +218,12 @@ void Game::draw(Painter &p, const PaintContext &context) const { auto tshift = inner.top(); auto paintw = inner.width(); + const auto colorIndex = parent()->colorIndex(); const auto selected = context.selected(); - const auto twoColored = Ui::ColorIndexTwoColored(_colorIndex); + const auto twoColored = Ui::ColorIndexTwoColored(colorIndex); const auto cache = context.outbg ? (twoColored ? stm->replyCacheTwo : stm->replyCache).get() - : st->coloredReplyCache(selected, _colorIndex).get(); + : st->coloredReplyCache(selected, colorIndex).get(); Ui::Text::ValidateQuotePaintCache(*cache, _st); Ui::Text::FillQuotePaint(p, outer, *cache, _st); @@ -232,7 +232,7 @@ void Game::draw(Painter &p, const PaintContext &context) const { p.setPen(cache->icon); p.setTextPalette(context.outbg ? stm->semiboldPalette - : st->coloredTextPalette(selected, _colorIndex)); + : st->coloredTextPalette(selected, colorIndex)); auto endskip = 0; if (_title.hasSkipBlock()) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_game.h b/Telegram/SourceFiles/history/view/media/history_view_game.h index d942064fd..9cec01fdc 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_game.h +++ b/Telegram/SourceFiles/history/view/media/history_view_game.h @@ -105,8 +105,7 @@ private: int _gameTagWidth = 0; int _descriptionLines = 0; - uint32 _titleLines : 24 = 0; - uint32 _colorIndex : 8 = 0; + int _titleLines = 0; Ui::Text::String _title; Ui::Text::String _description; diff --git a/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp b/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp index 07a96f934..9079ac6e0 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp @@ -61,8 +61,7 @@ Giveaway::Giveaway( , _participants(st::msgMinWidth) , _countries(st::msgMinWidth) , _winnersTitle(st::msgMinWidth) -, _winners(st::msgMinWidth) -, _colorIndex(parent->data()->computeColorIndex()) { +, _winners(st::msgMinWidth) { fillFromData(giveaway); } @@ -347,10 +346,11 @@ void Giveaway::paintChannels( const auto ratio = style::DevicePixelRatio(); const auto stm = context.messageStyle(); const auto selected = context.selected(); - const auto twoColored = Ui::ColorIndexTwoColored(_colorIndex); + const auto colorIndex = parent()->colorIndex(); + const auto twoColored = Ui::ColorIndexTwoColored(colorIndex); const auto cache = context.outbg ? (twoColored ? stm->replyCacheTwo : stm->replyCache).get() - : context.st->coloredReplyCache(selected, _colorIndex).get(); + : context.st->coloredReplyCache(selected, colorIndex).get(); if (_channelCorners[0].isNull() || _channelBg != cache->bg) { _channelBg = cache->bg; _channelCorners = Images::CornersMask(size / 2); diff --git a/Telegram/SourceFiles/history/view/media/history_view_giveaway.h b/Telegram/SourceFiles/history/view/media/history_view_giveaway.h index 437c94c5c..6529ad497 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_giveaway.h +++ b/Telegram/SourceFiles/history/view/media/history_view_giveaway.h @@ -115,7 +115,6 @@ private: int _countriesWidth = 0; int _winnersTitleTop = 0; int _winnersTop = 0; - uint8 _colorIndex : 7 = 0; mutable uint8 _subscribedToThumbnails : 1 = 0; }; diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 2bce7b939..1bc521a16 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -126,7 +126,6 @@ WebPage::WebPage( : Media(parent) , _st(st::historyPagePreview) , _data(data) -, _colorIndex(parent->data()->computeColorIndex()) , _siteName(st::msgMinWidth - _st.padding.left() - _st.padding.right()) , _title(st::msgMinWidth - _st.padding.left() - _st.padding.right()) , _description(st::msgMinWidth - _st.padding.left() - _st.padding.right()) @@ -546,10 +545,11 @@ void WebPage::draw(Painter &p, const PaintContext &context) const { auto attachAdditionalInfoText = _attach ? _attach->additionalInfoString() : QString(); const auto selected = context.selected(); - const auto twoColored = Ui::ColorIndexTwoColored(_colorIndex); + const auto colorIndex = parent()->colorIndex(); + const auto twoColored = Ui::ColorIndexTwoColored(colorIndex); const auto cache = context.outbg ? (twoColored ? stm->replyCacheTwo : stm->replyCache).get() - : st->coloredReplyCache(selected, _colorIndex).get(); + : st->coloredReplyCache(selected, colorIndex).get(); Ui::Text::ValidateQuotePaintCache(*cache, _st); Ui::Text::FillQuotePaint(p, outer, *cache, _st); @@ -605,7 +605,7 @@ void WebPage::draw(Painter &p, const PaintContext &context) const { p.setPen(cache->icon); p.setTextPalette(context.outbg ? stm->semiboldPalette - : st->coloredTextPalette(selected, _colorIndex)); + : st->coloredTextPalette(selected, colorIndex)); auto endskip = 0; if (_siteName.hasSkipBlock()) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.h b/Telegram/SourceFiles/history/view/media/history_view_web_page.h index 18e7f032a..0946714ff 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.h +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.h @@ -132,8 +132,7 @@ private: int _dataVersion = -1; int _siteNameLines = 0; int _descriptionLines = 0; - uint32 _titleLines : 24 = 0; - uint32 _colorIndex : 7 = 0; + uint32 _titleLines : 31 = 0; uint32 _asArticle : 1 = 0; Ui::Text::String _siteName; diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 599b38e5c..2ae1e0463 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -172,7 +172,7 @@ messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction; messageActionRequestedPeer#fe77345d button_id:int peer:Peer = MessageAction; messageActionSetChatWallPaper#bc44a927 wallpaper:WallPaper = MessageAction; messageActionSetSameChatWallPaper#c0787d6d wallpaper:WallPaper = MessageAction; -messageActionGiftCode#d2cfdb0e flags:# via_giveaway:flags.0?true boost_peer:flags.1?Peer months:int slug:string = MessageAction; +messageActionGiftCode#d2cfdb0e flags:# via_giveaway:flags.0?true unclaimed:flags.2?true boost_peer:flags.1?Peer months:int slug:string = MessageAction; messageActionGiveawayLaunch#332ba9ed = MessageAction; dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; @@ -292,7 +292,7 @@ updateChatParticipantAdd#3dda5451 chat_id:long user_id:long inviter_id:long date updateChatParticipantDelete#e32f3d77 chat_id:long user_id:long version:int = Update; updateDcOptions#8e5e9873 dc_options:Vector = Update; updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings = Update; -updateServiceNotification#ebe46819 flags:# popup:flags.0?true inbox_date:flags.1?int type:string message:string media:MessageMedia entities:Vector = Update; +updateServiceNotification#ebe46819 flags:# popup:flags.0?true invert_media:flags.2?true inbox_date:flags.1?int type:string message:string media:MessageMedia entities:Vector = Update; updatePrivacy#ee3b272a key:PrivacyKey rules:Vector = Update; updateUserPhone#5492a13 user_id:long phone:string = Update; updateReadHistoryInbox#9c974fdf flags:# folder_id:flags.0?int peer:Peer max_id:int still_unread_count:int pts:int pts_count:int = Update; @@ -686,7 +686,7 @@ messages.savedGifsNotModified#e8025ca2 = messages.SavedGifs; messages.savedGifs#84a02a0d hash:long gifs:Vector = messages.SavedGifs; inputBotInlineMessageMediaAuto#3380c786 flags:# invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; -inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; +inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; inputBotInlineMessageMediaGeo#96929a85 flags:# geo_point:InputGeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; inputBotInlineMessageMediaVenue#417bbf11 flags:# geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; inputBotInlineMessageMediaContact#a6edbffd flags:# phone_number:string first_name:string last_name:string vcard:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; @@ -700,7 +700,7 @@ inputBotInlineResultDocument#fff8fdc4 flags:# id:string type:string title:flags. inputBotInlineResultGame#4fa417f2 id:string short_name:string send_message:InputBotInlineMessage = InputBotInlineResult; botInlineMessageMediaAuto#764cf810 flags:# invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; -botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; +botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true invert_media:flags.3?true message:string entities:flags.1?Vector reply_markup:flags.2?ReplyMarkup = BotInlineMessage; botInlineMessageMediaGeo#51846fd flags:# geo:GeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = BotInlineMessage; botInlineMessageMediaVenue#8a86659c flags:# geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage; botInlineMessageMediaContact#18d1cdc2 flags:# phone_number:string first_name:string last_name:string vcard:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage; diff --git a/Telegram/SourceFiles/ui/chat/chat_style.cpp b/Telegram/SourceFiles/ui/chat/chat_style.cpp index 5f817b44c..17524b4ee 100644 --- a/Telegram/SourceFiles/ui/chat/chat_style.cpp +++ b/Telegram/SourceFiles/ui/chat/chat_style.cpp @@ -180,7 +180,7 @@ ColorIndexValues SimpleColorIndexValues(QColor color, bool twoColored) { outline1.setAlphaF(0.9); auto outline2 = outline1; if (twoColored) { - outline2.setAlphaF(0.3); + outline2.setAlphaF(0.5); } return { .name = color, @@ -624,7 +624,9 @@ void ChatStyle::assignPalette(not_null palette) { style.msgBgCornersSmall = {}; style.msgBgCornersLarge = {}; style.quoteCache = nullptr; + style.quoteCacheTwo = nullptr; style.replyCache = nullptr; + style.replyCacheTwo = nullptr; style.preCache = nullptr; } for (auto &style : _imageStyles) { @@ -653,6 +655,12 @@ void ChatStyle::assignPalette(not_null palette) { for (auto &palette : _coloredTextPalettes) { palette.linkFg.reset(); } + for (auto &cache : _coloredReplyCaches) { + cache = nullptr; + } + for (auto &cache : _coloredQuoteCaches) { + cache = nullptr; + } updateDarkValue(); _paletteChanged.fire({}); @@ -782,7 +790,7 @@ const style::TextPalette &ChatStyle::coloredTextPalette( const auto shift = (selected ? kColorIndexCount : 0); auto &result = _coloredTextPalettes[shift + colorIndex]; if (!result.linkFg) { - result.linkFg.emplace(FromNameFg(this, selected, colorIndex)); + result.linkFg.emplace(coloredValues(selected, colorIndex).name); make( result.data, (selected