Show expand/collapse icon in factcheck.

This commit is contained in:
John Preston 2024-05-23 17:50:59 +04:00
parent a87a221f26
commit 74861a334d
4 changed files with 22 additions and 4 deletions

View File

@ -598,6 +598,7 @@ QSize WebPage::countCurrentSize(int newWidth) {
: FactcheckMetrics(); : FactcheckMetrics();
if (factcheck) { if (factcheck) {
factcheck->expandable = factcheckMetrics.expandable; factcheck->expandable = factcheckMetrics.expandable;
factcheck->expanded = factcheckMetrics.expanded;
_openl = factcheck->expandable _openl = factcheck->expandable
? ToggleFactcheckClickHandler(_parent) ? ToggleFactcheckClickHandler(_parent)
: nullptr; : nullptr;
@ -779,11 +780,12 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
auto paintw = inner.width(); auto paintw = inner.width();
const auto sponsored = sponsoredData(); const auto sponsored = sponsoredData();
const auto factcheck = factcheckData();
const auto selected = context.selected(); const auto selected = context.selected();
const auto view = parent(); const auto view = parent();
const auto from = view->data()->contentColorsFrom(); const auto from = view->data()->contentColorsFrom();
const auto colorIndex = factcheckData() const auto colorIndex = factcheck
? 0 // red ? 0 // red
: (sponsored && sponsored->colorIndex) : (sponsored && sponsored->colorIndex)
? sponsored->colorIndex ? sponsored->colorIndex
@ -793,8 +795,9 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
const auto cache = context.outbg const auto cache = context.outbg
? stm->replyCache[st->colorPatternIndex(colorIndex)].get() ? stm->replyCache[st->colorPatternIndex(colorIndex)].get()
: st->coloredReplyCache(selected, colorIndex).get(); : st->coloredReplyCache(selected, colorIndex).get();
const auto backgroundEmojiId = (sponsored const auto backgroundEmojiId = factcheck
&& sponsored->backgroundEmojiId) ? DocumentId()
: (sponsored && sponsored->backgroundEmojiId)
? sponsored->backgroundEmojiId ? sponsored->backgroundEmojiId
: from : from
? from->backgroundEmojiId() ? from->backgroundEmojiId()
@ -821,6 +824,15 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
if (!backgroundEmojiCache->frames[0].isNull()) { if (!backgroundEmojiCache->frames[0].isNull()) {
FillBackgroundEmoji(p, outer, false, *backgroundEmojiCache); FillBackgroundEmoji(p, outer, false, *backgroundEmojiCache);
} }
} else if (factcheck && factcheck->expandable) {
const auto &icon = factcheck->expanded
? st::factcheckIconCollapse
: st::factcheckIconExpand;
icon.paint(
p,
outer.x() + outer.width() - icon.width() - _st.padding.right(),
outer.y() + _st.padding.top(),
width());
} }
if (_ripple) { if (_ripple) {
@ -1487,6 +1499,7 @@ WebPage::FactcheckMetrics WebPage::computeFactcheckMetrics(
return { return {
.lines = allowExpanding ? possible : kFactcheckCollapsedLines, .lines = allowExpanding ? possible : kFactcheckCollapsedLines,
.expandable = expandable, .expandable = expandable,
.expanded = expanded,
}; };
} }

View File

@ -104,6 +104,7 @@ private:
struct FactcheckMetrics { struct FactcheckMetrics {
int lines = 0; int lines = 0;
bool expandable = false; bool expandable = false;
bool expanded = false;
}; };
struct HintData { struct HintData {
QSize size; QSize size;
@ -129,6 +130,7 @@ private:
struct FactcheckData { struct FactcheckData {
HintData hint; HintData hint;
bool expandable = false; bool expandable = false;
bool expanded = false;
}; };
using AdditionalData = std::variant< using AdditionalData = std::variant<
StickerSetData, StickerSetData,

View File

@ -1132,3 +1132,6 @@ effectPreviewPromoPadding: margins(4px, 6px, 4px, 6px);
effectPreviewLoading: InfiniteRadialAnimation(defaultInfiniteRadialAnimation) { effectPreviewLoading: InfiniteRadialAnimation(defaultInfiniteRadialAnimation) {
thickness: 2px; thickness: 2px;
} }
factcheckIconExpand: icon {{ "fast_to_original-rotate_cw", historyPeer1NameFg }};
factcheckIconCollapse: icon {{ "fast_to_original-rotate_ccw", historyPeer1NameFg }};

@ -1 +1 @@
Subproject commit 6462cda46ec5d48a9ae452ba1b6f7dfe1b6d882d Subproject commit 0af136124083369073b8fdaf45f0816fd2b10bad