mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Fix poll answer check in custom chat themes.
This commit is contained in:
parent
1f25777929
commit
af100c2d13
5 changed files with 60 additions and 12 deletions
|
@ -1207,31 +1207,67 @@ void Poll::paintFilling(
|
|||
|
||||
top += st::historyPollAnswerPadding.top();
|
||||
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.setPen(Qt::NoPen);
|
||||
const auto thickness = st::historyPollFillingHeight;
|
||||
const auto max = awidth - st::historyPollFillingRight;
|
||||
const auto size = anim::interpolate(st::historyPollFillingMin, max, filling);
|
||||
const auto radius = st::historyPollFillingRadius;
|
||||
const auto ftop = bottom - st::historyPollFillingBottom - thickness;
|
||||
|
||||
if (chosen && !correct) {
|
||||
p.setBrush(st->boxTextFgError());
|
||||
} else if (chosen && correct && _poll->quiz() && !context.outbg) {
|
||||
p.setBrush(st->boxTextFgGood());
|
||||
} else {
|
||||
p.setBrush(stm->msgWaveformActive);
|
||||
}
|
||||
enum class Style {
|
||||
Incorrect,
|
||||
Correct,
|
||||
Default,
|
||||
};
|
||||
const auto style = [&] {
|
||||
if (chosen && !correct) {
|
||||
return Style::Incorrect;
|
||||
} else if (chosen && correct && _poll->quiz() && !context.outbg) {
|
||||
return Style::Correct;
|
||||
} else {
|
||||
return Style::Default;
|
||||
}
|
||||
}();
|
||||
auto barleft = aleft;
|
||||
auto barwidth = size;
|
||||
const auto &color = (style == Style::Incorrect)
|
||||
? st->boxTextFgError()
|
||||
: (style == Style::Correct)
|
||||
? st->boxTextFgGood()
|
||||
: stm->msgFileBg;
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(color);
|
||||
PainterHighQualityEnabler hq(p);
|
||||
if (chosen || correct) {
|
||||
const auto &icon = (chosen && !correct)
|
||||
const auto &icon = (style == Style::Incorrect)
|
||||
? st->historyPollChoiceWrong()
|
||||
: st->historyPollChoiceRight();
|
||||
: (style == Style::Correct)
|
||||
? st->historyPollChoiceRight()
|
||||
: stm->historyPollChoiceRight;
|
||||
const auto cleft = aleft - st::historyPollPercentSkip - icon.width();
|
||||
const auto ctop = ftop - (icon.height() - thickness) / 2;
|
||||
p.drawEllipse(cleft, ctop, icon.width(), icon.height());
|
||||
icon.paint(p, cleft, ctop, width);
|
||||
|
||||
const auto paintContent = [&](Painter &p) {
|
||||
icon.paint(p, cleft, ctop, width);
|
||||
};
|
||||
if (style == Style::Default && usesBubblePattern(context)) {
|
||||
const auto add = st::lineWidth * 2;
|
||||
const auto target = QRect(
|
||||
cleft,
|
||||
ctop,
|
||||
icon.width(),
|
||||
icon.height()
|
||||
).marginsAdded({ add, add, add, add });
|
||||
Ui::PaintPatternBubblePart(
|
||||
p,
|
||||
context.viewport,
|
||||
context.bubblesPattern->pixmap,
|
||||
target,
|
||||
paintContent,
|
||||
_fillingIconCache);
|
||||
} else {
|
||||
paintContent(p);
|
||||
}
|
||||
//barleft += icon.width() - radius;
|
||||
//barwidth -= icon.width() - radius;
|
||||
}
|
||||
|
|
|
@ -214,6 +214,7 @@ private:
|
|||
Ui::Animations::Simple _wrongAnswerAnimation;
|
||||
mutable QPoint _lastLinkPoint;
|
||||
mutable QImage _userpicCircleCache;
|
||||
mutable QImage _fillingIconCache;
|
||||
|
||||
mutable std::unique_ptr<CloseInformation> _close;
|
||||
|
||||
|
|
|
@ -741,6 +741,10 @@ historyPollBottomButtonSkip: 15px;
|
|||
historyPollBottomButtonTop: 4px;
|
||||
historyPollChoiceRight: icon {{ "poll_choice_right", activeButtonFg }};
|
||||
historyPollChoiceWrong: icon {{ "poll_choice_wrong", activeButtonFg }};
|
||||
historyPollOutChoiceRight: icon {{ "poll_choice_right", historyFileOutIconFg }};
|
||||
historyPollOutChoiceRightSelected: icon {{ "poll_choice_right", historyFileOutIconFgSelected }};
|
||||
historyPollInChoiceRight: icon {{ "poll_choice_right", historyFileInIconFg }};
|
||||
historyPollInChoiceRightSelected: icon {{ "poll_choice_right", historyFileInIconFgSelected }};
|
||||
historyPollOutChosen: icon {{ "poll_select_check", historyFileOutIconFg }};
|
||||
historyPollOutChosenSelected: icon {{ "poll_select_check", historyFileOutIconFgSelected }};
|
||||
historyPollInChosen: icon {{ "poll_select_check", historyFileInIconFg }};
|
||||
|
|
|
@ -391,6 +391,12 @@ ChatStyle::ChatStyle() {
|
|||
st::historyPollInChosenSelected,
|
||||
st::historyPollOutChosen,
|
||||
st::historyPollOutChosenSelected);
|
||||
make(
|
||||
&MessageStyle::historyPollChoiceRight,
|
||||
st::historyPollInChoiceRight,
|
||||
st::historyPollInChoiceRightSelected,
|
||||
st::historyPollOutChoiceRight,
|
||||
st::historyPollOutChoiceRightSelected);
|
||||
make(
|
||||
&MessageImageStyle::msgDateImgBg,
|
||||
st::msgDateImgBg,
|
||||
|
|
|
@ -69,6 +69,7 @@ struct MessageStyle {
|
|||
style::icon historyQuizTimer = { Qt::Uninitialized };
|
||||
style::icon historyQuizExplain = { Qt::Uninitialized };
|
||||
style::icon historyPollChosen = { Qt::Uninitialized };
|
||||
style::icon historyPollChoiceRight = { Qt::Uninitialized };
|
||||
};
|
||||
|
||||
struct MessageImageStyle {
|
||||
|
|
Loading…
Add table
Reference in a new issue