/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/view/history_view_reactions.h" #include "history/history_message.h" #include "history/history.h" #include "history/view/history_view_message.h" #include "history/view/history_view_cursor_state.h" #include "history/view/history_view_react_animation.h" #include "history/view/history_view_group_call_bar.h" #include "core/click_handler_types.h" #include "data/data_message_reactions.h" #include "data/data_peer.h" #include "lang/lang_tag.h" #include "ui/chat/chat_style.h" #include "styles/style_chat.h" namespace HistoryView::Reactions { namespace { constexpr auto kInNonChosenOpacity = 0.12; constexpr auto kOutNonChosenOpacity = 0.18; constexpr auto kMaxRecentUserpics = 3; constexpr auto kMaxNicePerRow = 5; [[nodiscard]] QColor AdaptChosenServiceFg(QColor serviceBg) { serviceBg.setAlpha(std::max(serviceBg.alpha(), 192)); return serviceBg; } } // namespace InlineList::InlineList( not_null<::Data::Reactions*> owner, Fn handlerFactory, Data &&data) : _owner(owner) , _handlerFactory(std::move(handlerFactory)) , _data(std::move(data)) { layout(); } InlineList::~InlineList() = default; void InlineList::update(Data &&data, int availableWidth) { _data = std::move(data); layout(); if (width() > 0) { resizeGetHeight(std::min(maxWidth(), availableWidth)); } } void InlineList::updateSkipBlock(int width, int height) { _skipBlock = { width, height }; } void InlineList::removeSkipBlock() { _skipBlock = {}; } void InlineList::layout() { layoutButtons(); initDimensions(); } void InlineList::layoutButtons() { if (_data.reactions.empty()) { _buttons.clear(); return; } auto sorted = ranges::view::all( _data.reactions ) | ranges::view::transform([](const auto &pair) { return std::make_pair(pair.first, pair.second); }) | ranges::to_vector; const auto &list = _owner->list(::Data::Reactions::Type::All); ranges::sort(sorted, [&](const auto &p1, const auto &p2) { if (p1.second > p2.second) { return true; } else if (p1.second < p2.second) { return false; } return ranges::find(list, p1.first, &::Data::Reaction::emoji) < ranges::find(list, p2.first, &::Data::Reaction::emoji); }); auto buttons = std::vector