Custom colors in all media/history_view_ modules.

This commit is contained in:
John Preston 2021-09-03 17:18:03 +03:00
parent cbfe57c51d
commit b2364140e9
24 changed files with 207 additions and 142 deletions

View file

@ -594,14 +594,18 @@ QRect BackgroundPreviewBox::radialRect() const {
void BackgroundPreviewBox::paintTexts(Painter &p, crl::time ms) { void BackgroundPreviewBox::paintTexts(Painter &p, crl::time ms) {
const auto height1 = _text1->height(); const auto height1 = _text1->height();
const auto height2 = _text2->height(); const auto height2 = _text2->height();
const auto context = _controller->defaultChatTheme()->preparePaintContext( auto context = _controller->defaultChatTheme()->preparePaintContext(
_chatStyle.get(), _chatStyle.get(),
rect(), rect(),
rect()); rect());
p.translate(0, textsTop()); p.translate(0, textsTop());
paintDate(p); paintDate(p);
context.outbg = _text1->hasOutLayout();
_text1->draw(p, context); _text1->draw(p, context);
p.translate(0, height1); p.translate(0, height1);
context.outbg = _text2->hasOutLayout();
_text2->draw(p, context); _text2->draw(p, context);
p.translate(0, height2); p.translate(0, height2);
} }

View file

@ -366,7 +366,14 @@ void HistoryMessageReply::paint(
auto to = style::rtlrect(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(), st::msgReplyBarSize.height(), st::msgReplyBarSize.height(), w + 2 * x); auto to = style::rtlrect(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(), st::msgReplyBarSize.height(), st::msgReplyBarSize.height(), w + 2 * x);
auto previewWidth = image->width() / cIntRetinaFactor(); auto previewWidth = image->width() / cIntRetinaFactor();
auto previewHeight = image->height() / cIntRetinaFactor(); auto previewHeight = image->height() / cIntRetinaFactor();
auto preview = image->pixSingle(previewWidth, previewHeight, to.width(), to.height(), ImageRoundRadius::Small, RectPart::AllCorners, context.selected() ? &st->msgStickerOverlay() : nullptr); auto preview = image->pixSingle(
previewWidth,
previewHeight,
to.width(),
to.height(),
ImageRoundRadius::Small,
RectPart::AllCorners,
context.selected() ? &st->msgStickerOverlay() : nullptr);
p.drawPixmap(to.x(), to.y(), preview); p.drawPixmap(to.x(), to.y(), preview);
} }
} }

View file

@ -55,7 +55,7 @@ ClickHandlerPtr Dice::link() {
return _link; return _link;
} }
void Dice::draw(Painter &p, const QRect &r, bool selected) { void Dice::draw(Painter &p, const PaintContext &context, const QRect &r) {
if (!_start) { if (!_start) {
if (const auto document = Lookup(_parent, _dice->emoji(), 0)) { if (const auto document = Lookup(_parent, _dice->emoji(), 0)) {
_start.emplace(_parent, document); _start.emplace(_parent, document);
@ -74,9 +74,9 @@ void Dice::draw(Painter &p, const QRect &r, bool selected) {
_drawingEnd = false; _drawingEnd = false;
} }
if (_drawingEnd) { if (_drawingEnd) {
_end->draw(p, r, selected); _end->draw(p, context, r);
} else if (_start) { } else if (_start) {
_start->draw(p, r, selected); _start->draw(p, context, r);
if (_end && _end->readyToDrawLottie() && _start->atTheEnd()) { if (_end && _end->readyToDrawLottie() && _start->atTheEnd()) {
_drawingEnd = true; _drawingEnd = true;
} }

View file

@ -22,7 +22,10 @@ public:
~Dice(); ~Dice();
QSize size() override; QSize size() override;
void draw(Painter &p, const QRect &r, bool selected) override; void draw(
Painter &p,
const PaintContext &context,
const QRect &r) override;
ClickHandlerPtr link() override; ClickHandlerPtr link() override;

View file

@ -266,7 +266,7 @@ void Game::draw(Painter &p, const PaintContext &context) const {
Ui::FillRoundRect(p, style::rtlrect(gameX, gameY, gameW, gameH, pixwidth), sti->msgDateImgBg, sti->msgDateImgBgCorners); Ui::FillRoundRect(p, style::rtlrect(gameX, gameY, gameW, gameH, pixwidth), sti->msgDateImgBg, sti->msgDateImgBgCorners);
p.setFont(st::msgDateFont); p.setFont(st::msgDateFont);
p.setPen(st::msgDateImgFg); p.setPen(st->msgDateImgFg());
p.drawTextLeft(gameX + st::msgDateImgPadding.x(), gameY + st::msgDateImgPadding.y(), pixwidth, tr::lng_game_tag(tr::now).toUpper()); p.drawTextLeft(gameX + st::msgDateImgPadding.x(), gameY + st::msgDateImgPadding.y(), pixwidth, tr::lng_game_tag(tr::now).toUpper());
p.translate(-attachLeft, -attachTop); p.translate(-attachLeft, -attachTop);

View file

@ -286,7 +286,6 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
const auto st = context.st; const auto st = context.st;
const auto sti = context.imageStyle(); const auto sti = context.imageStyle();
const auto stm = context.messageStyle(); const auto stm = context.messageStyle();
const auto selected = (context.selection == FullSelection);
const auto autoPaused = _parent->delegate()->elementIsGifPaused(); const auto autoPaused = _parent->delegate()->elementIsGifPaused();
const auto cornerDownload = downloadInCorner(); const auto cornerDownload = downloadInCorner();
const auto canBePlayed = _dataMedia->canBePlayed(); const auto canBePlayed = _dataMedia->canBePlayed();
@ -407,7 +406,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
if (const auto playback = videoPlayback()) { if (const auto playback = videoPlayback()) {
const auto value = playback->value(); const auto value = playback->value();
if (value > 0.) { if (value > 0.) {
auto pen = st::historyVideoMessageProgressFg->p; auto pen = st->historyVideoMessageProgressFg()->p;
auto was = p.pen(); auto was = p.pen();
pen.setWidth(st::radialLine); pen.setWidth(st::radialLine);
pen.setCapStyle(Qt::RoundCap); pen.setCapStyle(Qt::RoundCap);
@ -456,13 +455,13 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
| RectPart::NoTopBottom | RectPart::NoTopBottom
| (roundTop ? RectPart::Top : RectPart::None) | (roundTop ? RectPart::Top : RectPart::None)
| (roundBottom ? RectPart::Bottom : RectPart::None); | (roundBottom ? RectPart::Bottom : RectPart::None);
Ui::FillRoundRect(p, rthumb.marginsAdded({ 0, roundTop ? 0 : margin, 0, roundBottom ? 0 : margin }), st::imageBg, roundRadius, parts); Ui::FillRoundRect(p, rthumb.marginsAdded({ 0, roundTop ? 0 : margin, 0, roundBottom ? 0 : margin }), st->imageBg(), roundRadius, parts);
} }
} }
} }
} }
if (selected) { if (context.selected()) {
Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners); Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners);
} }
@ -479,7 +478,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
const auto innerSize = st::msgFileLayout.thumbSize; const auto innerSize = st::msgFileLayout.thumbSize;
auto inner = QRect(rthumb.x() + (rthumb.width() - innerSize) / 2, rthumb.y() + (rthumb.height() - innerSize) / 2, innerSize, innerSize); auto inner = QRect(rthumb.x() + (rthumb.width() - innerSize) / 2, rthumb.y() + (rthumb.height() - innerSize) / 2, innerSize, innerSize);
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
if (selected) { if (context.selected()) {
p.setBrush(st->msgDateImgBgSelected()); p.setBrush(st->msgDateImgBgSelected());
} else if (isThumbAnimation()) { } else if (isThumbAnimation()) {
auto over = _animation->a_thumbOver.value(1.); auto over = _animation->a_thumbOver.value(1.);
@ -501,14 +500,14 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
if (streamingMode && !_data->uploading()) { if (streamingMode && !_data->uploading()) {
return nullptr; return nullptr;
} else if ((loaded || canBePlayed) && (!radial || cornerDownload)) { } else if ((loaded || canBePlayed) && (!radial || cornerDownload)) {
return &(selected ? st::historyFileThumbPlaySelected : st::historyFileThumbPlay); return &sti->historyFileThumbPlay;
} else if (radial || _data->loading()) { } else if (radial || _data->loading()) {
if (!item->isSending() || _data->uploading()) { if (!item->isSending() || _data->uploading()) {
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); return &sti->historyFileThumbCancel;
} }
return nullptr; return nullptr;
} }
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload); return &sti->historyFileThumbDownload;
}(); }();
if (icon) { if (icon) {
icon->paintInCenter(p, inner); icon->paintInCenter(p, inner);
@ -516,9 +515,6 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
p.setOpacity(1); p.setOpacity(1);
if (radial) { if (radial) {
QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine)));
const auto fg = selected
? st::historyFileThumbRadialFgSelected
: st::historyFileThumbRadialFg;
if (streamedForWaiting && !_data->uploading()) { if (streamedForWaiting && !_data->uploading()) {
Ui::InfiniteRadialAnimation::Draw( Ui::InfiniteRadialAnimation::Draw(
p, p,
@ -526,14 +522,14 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
rinner.topLeft(), rinner.topLeft(),
rinner.size(), rinner.size(),
width(), width(),
fg, sti->historyFileThumbRadialFg,
st::msgFileRadialLine); st::msgFileRadialLine);
} else if (!cornerDownload) { } else if (!cornerDownload) {
_animation->radial.draw( _animation->radial.draw(
p, p,
rinner, rinner,
st::msgFileRadialLine, st::msgFileRadialLine,
fg); sti->historyFileThumbRadialFg);
} }
} }
} }
@ -543,7 +539,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
p.setBrush(sti->msgDateImgBg); p.setBrush(sti->msgDateImgBg);
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.drawEllipse(muteRect); p.drawEllipse(muteRect);
(selected ? st::historyVideoMessageMuteSelected : st::historyVideoMessageMute).paintInCenter(p, muteRect); sti->historyVideoMessageMute.paintInCenter(p, muteRect);
} }
if (!isRound) { if (!isRound) {
@ -561,11 +557,11 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
} }
Ui::FillRoundRect(p, style::rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), sti->msgServiceBg, sti->msgServiceBgCorners); Ui::FillRoundRect(p, style::rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), sti->msgServiceBg, sti->msgServiceBgCorners);
p.setFont(st::normalFont); p.setFont(st::normalFont);
p.setPen(st::msgServiceFg); p.setPen(st->msgServiceFg());
p.drawTextLeft(statusX, statusY, width(), _statusText, statusW - 2 * st::msgDateImgPadding.x()); p.drawTextLeft(statusX, statusY, width(), _statusText, statusW - 2 * st::msgDateImgPadding.x());
if (mediaUnread) { if (mediaUnread) {
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(st::msgServiceFg); p.setBrush(st->msgServiceFg());
{ {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
@ -591,7 +587,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
if (rtl()) rectx = width() - rectx - rectw; if (rtl()) rectx = width() - rectx - rectw;
Ui::FillRoundRect(p, rectx, recty, rectw, recth, sti->msgServiceBg, sti->msgServiceBgCorners); Ui::FillRoundRect(p, rectx, recty, rectw, recth, sti->msgServiceBg, sti->msgServiceBgCorners);
p.setPen(st::msgServiceFg); p.setPen(st->msgServiceFg());
rectx += st::msgReplyPadding.left(); rectx += st::msgReplyPadding.left();
rectw = innerw; rectw = innerw;
if (forwarded) { if (forwarded) {
@ -611,7 +607,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
} }
} }
if (!isRound && !_caption.isEmpty()) { if (!isRound && !_caption.isEmpty()) {
p.setPen(outbg ? (selected ? st::historyTextOutFgSelected : st::historyTextOutFg) : (selected ? st::historyTextInFgSelected : st::historyTextInFg)); p.setPen(stm->historyTextFg);
_caption.draw(p, st::msgPadding.left(), painty + painth + st::mediaCaptionSkip, captionw, style::al_left, 0, -1, context.selection); _caption.draw(p, st::msgPadding.left(), painty + painth + st::mediaCaptionSkip, captionw, style::al_left, 0, -1, context.selection);
} else if (!inWebPage) { } else if (!inWebPage) {
auto fullRight = paintx + usex + usew; auto fullRight = paintx + usex + usew;
@ -695,7 +691,7 @@ void Gif::drawCornerStatus(
const auto statusTextTop = statusY + (cornerDownload ? (((statusH - 2 * st::normalFont->height) / 3) - padding.y()) : 0); const auto statusTextTop = statusY + (cornerDownload ? (((statusH - 2 * st::normalFont->height) / 3) - padding.y()) : 0);
Ui::FillRoundRect(p, around, sti->msgDateImgBg, sti->msgDateImgBgCorners); Ui::FillRoundRect(p, around, sti->msgDateImgBg, sti->msgDateImgBgCorners);
p.setFont(st::normalFont); p.setFont(st::normalFont);
p.setPen(st::msgDateImgFg); p.setPen(st->msgDateImgFg());
p.drawTextLeft(statusX + addLeft, statusTextTop, width(), text, statusW - 2 * padding.x()); p.drawTextLeft(statusX + addLeft, statusTextTop, width(), text, statusW - 2 * padding.x());
if (cornerDownload) { if (cornerDownload) {
const auto downloadTextTop = statusY + st::normalFont->height + (2 * (statusH - 2 * st::normalFont->height) / 3) - padding.y(); const auto downloadTextTop = statusY + st::normalFont->height + (2 * (statusH - 2 * st::normalFont->height) / 3) - padding.y();

View file

@ -263,7 +263,7 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
Ui::FillRoundRect(p, style::rtlrect(statusX, statusY, statusW, statusH, pixwidth), sti->msgDateImgBg, sti->msgDateImgBgCorners); Ui::FillRoundRect(p, style::rtlrect(statusX, statusY, statusW, statusH, pixwidth), sti->msgDateImgBg, sti->msgDateImgBgCorners);
p.setFont(st::msgDateFont); p.setFont(st::msgDateFont);
p.setPen(st::msgDateImgFg); p.setPen(st->msgDateImgFg());
_status.drawLeftElided(p, statusX + st::msgDateImgPadding.x(), statusY + st::msgDateImgPadding.y(), available, pixwidth); _status.drawLeftElided(p, statusX + st::msgDateImgPadding.x(), statusY + st::msgDateImgPadding.y(), available, pixwidth);
p.translate(-attachLeft, -attachTop); p.translate(-attachLeft, -attachTop);

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h" #include "history/history_item.h"
#include "history/history.h" #include "history/history.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "ui/chat/chat_style.h"
#include "data/data_file_origin.h" #include "data/data_file_origin.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
@ -65,7 +66,10 @@ QSize LargeEmoji::size() {
return _size; return _size;
} }
void LargeEmoji::draw(Painter &p, const QRect &r, bool selected) { void LargeEmoji::draw(
Painter &p,
const PaintContext &context,
const QRect &r) {
auto &&images = NonEmpty(_images); auto &&images = NonEmpty(_images);
const auto &padding = st::largeEmojiPadding; const auto &padding = st::largeEmojiPadding;
auto x = r.x() + (r.width() - _size.width()) / 2 + padding.left(); auto x = r.x() + (r.width() - _size.width()) / 2 + padding.left();
@ -76,9 +80,8 @@ void LargeEmoji::draw(Painter &p, const QRect &r, bool selected) {
const auto w = size.width(); const auto w = size.width();
if (const auto &prepared = image->image) { if (const auto &prepared = image->image) {
const auto h = size.height(); const auto h = size.height();
const auto &c = st::msgStickerOverlay; const auto pixmap = context.selected()
const auto pixmap = selected ? prepared->pixColored(context.st->msgStickerOverlay(), w, h)
? prepared->pixColored(c, w, h)
: prepared->pix(w, h); : prepared->pix(w, h);
p.drawPixmap(x, y, pixmap); p.drawPixmap(x, y, pixmap);
} else if (image->load) { } else if (image->load) {

View file

@ -27,7 +27,10 @@ public:
const Ui::Text::IsolatedEmoji &emoji); const Ui::Text::IsolatedEmoji &emoji);
QSize size() override; QSize size() override;
void draw(Painter &p, const QRect &r, bool selected) override; void draw(
Painter &p,
const PaintContext &context,
const QRect &r) override;
bool alwaysShowOutTimestamp() override { bool alwaysShowOutTimestamp() override {
return true; return true;

View file

@ -152,6 +152,7 @@ void Location::draw(Painter &p, const PaintContext &context) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintx = 0, painty = 0, paintw = width(), painth = height(); auto paintx = 0, painty = 0, paintw = width(), painth = height();
bool bubble = _parent->hasBubble(); bool bubble = _parent->hasBubble();
const auto st = context.st;
const auto sti = context.imageStyle(); const auto sti = context.imageStyle();
const auto stm = context.messageStyle(); const auto stm = context.messageStyle();
@ -200,8 +201,8 @@ void Location::draw(Painter &p, const PaintContext &context) const {
rthumb.y() + (rthumb.height() / 2) - icon.height(), rthumb.y() + (rthumb.height() / 2) - icon.height(),
width()); width());
}; };
paintMarker(st::historyMapPoint); paintMarker(st->historyMapPoint());
paintMarker(st::historyMapPointInner); paintMarker(st->historyMapPointInner());
if (context.selected()) { if (context.selected()) {
Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners); Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners);
} }

View file

@ -335,15 +335,14 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const {
} }
// date // date
const auto selected = (selection == FullSelection);
if (!_caption.isEmpty()) { if (!_caption.isEmpty()) {
const auto captionw = width() - st::msgPadding.left() - st::msgPadding.right(); const auto captionw = width() - st::msgPadding.left() - st::msgPadding.right();
const auto outbg = _parent->hasOutLayout();
const auto captiony = height() const auto captiony = height()
- groupPadding.bottom() - groupPadding.bottom()
- (isBubbleBottom() ? st::msgPadding.bottom() : 0) - (isBubbleBottom() ? st::msgPadding.bottom() : 0)
- _caption.countHeight(captionw); - _caption.countHeight(captionw);
p.setPen(outbg ? (selected ? st::historyTextOutFgSelected : st::historyTextOutFg) : (selected ? st::historyTextInFgSelected : st::historyTextInFg)); const auto stm = context.messageStyle();
p.setPen(stm->historyTextFg);
_caption.draw(p, st::msgPadding.left(), captiony, captionw, style::al_left, 0, -1, selection); _caption.draw(p, st::msgPadding.left(), captiony, captionw, style::al_left, 0, -1, selection);
} else if (_parent->media() == this) { } else if (_parent->media() == this) {
auto fullRight = width(); auto fullRight = width();

View file

@ -137,7 +137,7 @@ void UnwrappedMedia::draw(Painter &p, const PaintContext &context) const {
height() - st::msgDateImgPadding.y() * 2 - st::msgDateFont->height) height() - st::msgDateImgPadding.y() * 2 - st::msgDateFont->height)
: _contentSize.height(); : _contentSize.height();
const auto inner = QRect(usex, usey, usew, useh); const auto inner = QRect(usex, usey, usew, useh);
_content->draw(p, inner, selected); _content->draw(p, context, inner);
if (!inWebPage) { if (!inWebPage) {
drawSurrounding(p, inner, context, via, reply, forwarded); drawSurrounding(p, inner, context, via, reply, forwarded);
@ -205,7 +205,7 @@ void UnwrappedMedia::drawSurrounding(
if (rtl()) rectx = width() - rectx - rectw; if (rtl()) rectx = width() - rectx - rectw;
Ui::FillRoundRect(p, rectx, recty, rectw, recth, sti->msgServiceBg, sti->msgServiceBgCorners); Ui::FillRoundRect(p, rectx, recty, rectw, recth, sti->msgServiceBg, sti->msgServiceBgCorners);
p.setPen(st::msgServiceFg); p.setPen(st->msgServiceFg());
rectx += st::msgReplyPadding.left(); rectx += st::msgReplyPadding.left();
rectw -= st::msgReplyPadding.left() + st::msgReplyPadding.right(); rectw -= st::msgReplyPadding.left() + st::msgReplyPadding.right();
if (forwarded) { if (forwarded) {

View file

@ -23,7 +23,10 @@ public:
public: public:
[[nodiscard]] virtual QSize size() = 0; [[nodiscard]] virtual QSize size() = 0;
virtual void draw(Painter &p, const QRect &r, bool selected) = 0; virtual void draw(
Painter &p,
const PaintContext &context,
const QRect &r) = 0;
[[nodiscard]] virtual ClickHandlerPtr link() { [[nodiscard]] virtual ClickHandlerPtr link() {
return nullptr; return nullptr;

View file

@ -723,10 +723,7 @@ void Poll::draw(Painter &p, const PaintContext &context) const {
checkSendingAnimation(); checkSendingAnimation();
_poll->checkResultsReload(_parent->data(), context.now); _poll->checkResultsReload(_parent->data(), context.now);
const auto outbg = _parent->hasOutLayout(); const auto stm = context.messageStyle();
const auto selected = (context.selection == FullSelection);
const auto &regular = selected ? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected) : (outbg ? st::msgOutDateFg : st::msgInDateFg);
const auto padding = st::msgPadding; const auto padding = st::msgPadding;
auto tshift = st::historyPollQuestionTop; auto tshift = st::historyPollQuestionTop;
if (!isBubbleTop()) { if (!isBubbleTop()) {
@ -734,11 +731,11 @@ void Poll::draw(Painter &p, const PaintContext &context) const {
} }
paintw -= padding.left() + padding.right(); paintw -= padding.left() + padding.right();
p.setPen(outbg ? st::webPageTitleOutFg : st::webPageTitleInFg); p.setPen(stm->webPageTitleFg);
_question.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, context.selection); _question.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, context.selection);
tshift += _question.countHeight(paintw) + st::historyPollSubtitleSkip; tshift += _question.countHeight(paintw) + st::historyPollSubtitleSkip;
p.setPen(regular); p.setPen(stm->msgDateFg);
_subtitle.drawLeftElided(p, padding.left(), tshift, paintw, width()); _subtitle.drawLeftElided(p, padding.left(), tshift, paintw, width());
paintRecentVoters(p, padding.left() + _subtitle.maxWidth(), tshift, context); paintRecentVoters(p, padding.left() + _subtitle.maxWidth(), tshift, context);
paintCloseByTimer(p, padding.left() + paintw, tshift, context); paintCloseByTimer(p, padding.left() + paintw, tshift, context);
@ -791,10 +788,8 @@ void Poll::paintInlineFooter(
int top, int top,
int paintw, int paintw,
const PaintContext &context) const { const PaintContext &context) const {
const auto selected = context.selected(); const auto stm = context.messageStyle();
const auto outbg = _parent->hasOutLayout(); p.setPen(stm->msgDateFg);
const auto &regular = selected ? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected) : (outbg ? st::msgOutDateFg : st::msgInDateFg);
p.setPen(regular);
_totalVotesLabel.drawLeftElided( _totalVotesLabel.drawLeftElided(
p, p,
left, left,
@ -812,11 +807,9 @@ void Poll::paintBottom(
int paintw, int paintw,
const PaintContext &context) const { const PaintContext &context) const {
const auto stringtop = top + st::msgPadding.bottom() + st::historyPollBottomButtonTop; const auto stringtop = top + st::msgPadding.bottom() + st::historyPollBottomButtonTop;
const auto selected = context.selected(); const auto stm = context.messageStyle();
const auto outbg = _parent->hasOutLayout();
const auto &regular = selected ? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected) : (outbg ? st::msgOutDateFg : st::msgInDateFg);
if (showVotersCount()) { if (showVotersCount()) {
p.setPen(regular); p.setPen(stm->msgDateFg);
_totalVotesLabel.draw(p, left, stringtop, paintw, style::al_top); _totalVotesLabel.draw(p, left, stringtop, paintw, style::al_top);
} else { } else {
const auto link = showVotes() const auto link = showVotes()
@ -834,11 +827,7 @@ void Poll::paintBottom(
p.setOpacity(1.); p.setOpacity(1.);
} }
p.setFont(st::semiboldFont); p.setFont(st::semiboldFont);
if (!link) { p.setPen(link ? stm->msgFileThumbLinkFg : stm->msgDateFg);
p.setPen(regular);
} else {
p.setPen(outbg ? (selected ? st::msgFileThumbLinkOutFgSelected : st::msgFileThumbLinkOutFg) : (selected ? st::msgFileThumbLinkInFgSelected : st::msgFileThumbLinkInFg));
}
const auto string = showVotes() const auto string = showVotes()
? tr::lng_polls_view_results(tr::now, Ui::Text::Upper) ? tr::lng_polls_view_results(tr::now, Ui::Text::Upper)
: tr::lng_polls_submit_votes(tr::now, Ui::Text::Upper); : tr::lng_polls_submit_votes(tr::now, Ui::Text::Upper);
@ -875,11 +864,8 @@ void Poll::paintRecentVoters(
+ (count - 1) * st::historyPollRecentVoterSkip; + (count - 1) * st::historyPollRecentVoterSkip;
auto y = top; auto y = top;
const auto size = st::historyPollRecentVoterSize; const auto size = st::historyPollRecentVoterSize;
const auto outbg = _parent->hasOutLayout(); const auto stm = context.messageStyle();
const auto selected = (context.selection == FullSelection); auto pen = stm->msgBg->p;
auto pen = (selected
? (outbg ? st::msgOutBgSelected : st::msgInBgSelected)
: (outbg ? st::msgOutBg : st::msgInBg))->p;
pen.setWidth(st::lineWidth); pen.setWidth(st::lineWidth);
auto created = false; auto created = false;
@ -947,22 +933,16 @@ void Poll::paintCloseByTimer(
_close->radial.stop(); _close->radial.stop();
} }
const auto time = Ui::FormatDurationText(int(std::ceil(left / 1000.))); const auto time = Ui::FormatDurationText(int(std::ceil(left / 1000.)));
const auto outbg = _parent->hasOutLayout(); const auto st = context.st;
const auto selected = context.selected(); const auto stm = context.messageStyle();
const auto &icon = selected const auto &icon = stm->historyQuizTimer;
? (outbg
? st::historyQuizTimerOutSelected
: st::historyQuizTimerInSelected)
: (outbg ? st::historyQuizTimerOut : st::historyQuizTimerIn);
const auto x = right - icon.width(); const auto x = right - icon.width();
const auto y = top const auto y = top
+ (st::normalFont->height - icon.height()) / 2 + (st::normalFont->height - icon.height()) / 2
- st::lineWidth; - st::lineWidth;
const auto &regular = (left < kCriticalCloseDuration) const auto &regular = (left < kCriticalCloseDuration)
? st::boxTextFgError ? st->boxTextFgError()
: selected : stm->msgDateFg;
? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected)
: (outbg ? st::msgOutDateFg : st::msgInDateFg);
p.setPen(regular); p.setPen(regular);
const auto timeWidth = st::normalFont->width(time); const auto timeWidth = st::normalFont->width(time);
p.drawTextLeft(x - timeWidth, top, width(), time, timeWidth); p.drawTextLeft(x - timeWidth, top, width(), time, timeWidth);
@ -1004,12 +984,8 @@ void Poll::paintShowSolution(
_showSolutionLink = std::make_shared<LambdaClickHandler>( _showSolutionLink = std::make_shared<LambdaClickHandler>(
crl::guard(this, [=] { showSolution(); })); crl::guard(this, [=] { showSolution(); }));
} }
const auto outbg = _parent->hasOutLayout(); const auto stm = context.messageStyle();
const auto &icon = context.selected() const auto &icon = stm->historyQuizExplain;
? (outbg
? st::historyQuizExplainOutSelected
: st::historyQuizExplainInSelected)
: (outbg ? st::historyQuizExplainOut : st::historyQuizExplainIn);
const auto x = right - icon.width(); const auto x = right - icon.width();
const auto y = top + (st::normalFont->height - icon.height()) / 2; const auto y = top + (st::normalFont->height - icon.height()) / 2;
if (shown == 1.) { if (shown == 1.) {
@ -1034,7 +1010,7 @@ int Poll::paintAnswer(
int outerWidth, int outerWidth,
const PaintContext &context) const { const PaintContext &context) const {
const auto height = countAnswerHeight(answer, width); const auto height = countAnswerHeight(answer, width);
const auto outbg = _parent->hasOutLayout(); const auto stm = context.messageStyle();
const auto aleft = left + st::historyPollAnswerPadding.left(); const auto aleft = left + st::historyPollAnswerPadding.left();
const auto awidth = width const auto awidth = width
- st::historyPollAnswerPadding.left() - st::historyPollAnswerPadding.left()
@ -1106,7 +1082,7 @@ int Poll::paintAnswer(
} }
top += st::historyPollAnswerPadding.top(); top += st::historyPollAnswerPadding.top();
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); p.setPen(stm->webPageDescriptionFg);
answer.text.drawLeft(p, aleft, top, awidth, outerWidth); answer.text.drawLeft(p, aleft, top, awidth, outerWidth);
return height; return height;
@ -1120,14 +1096,13 @@ void Poll::paintRadio(
const PaintContext &context) const { const PaintContext &context) const {
top += st::historyPollAnswerPadding.top(); top += st::historyPollAnswerPadding.top();
const auto outbg = _parent->hasOutLayout();
const auto selected = context.selected();
const auto st = context.st; const auto st = context.st;
const auto stm = context.messageStyle();
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
const auto &radio = st::historyPollRadio; const auto &radio = st::historyPollRadio;
const auto over = ClickHandler::showAsActive(answer.handler); const auto over = ClickHandler::showAsActive(answer.handler);
const auto &regular = selected ? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected) : (outbg ? st::msgOutDateFg : st::msgInDateFg); const auto &regular = stm->msgDateFg;
const auto checkmark = answer.selectedAnimation.value(answer.selected ? 1. : 0.); const auto checkmark = answer.selectedAnimation.value(answer.selected ? 1. : 0.);
@ -1139,11 +1114,7 @@ void Poll::paintRadio(
const auto rect = QRectF(left, top, radio.diameter, radio.diameter).marginsRemoved(QMarginsF(radio.thickness / 2., radio.thickness / 2., radio.thickness / 2., radio.thickness / 2.)); const auto rect = QRectF(left, top, radio.diameter, radio.diameter).marginsRemoved(QMarginsF(radio.thickness / 2., radio.thickness / 2., radio.thickness / 2., radio.thickness / 2.));
if (_sendingAnimation && _sendingAnimation->option == answer.option) { if (_sendingAnimation && _sendingAnimation->option == answer.option) {
const auto &active = selected const auto &active = stm->msgServiceFg;
? (outbg
? st::msgOutServiceFgSelected
: st::msgInServiceFgSelected)
: (outbg ? st->msgOutServiceFg() : st->msgInServiceFg());
if (anim::Disabled()) { if (anim::Disabled()) {
anim::DrawStaticLoading(p, rect, radio.thickness, active); anim::DrawStaticLoading(p, rect, radio.thickness, active);
} else { } else {
@ -1167,13 +1138,13 @@ void Poll::paintRadio(
if (checkmark > 0.) { if (checkmark > 0.) {
const auto removeFull = (radio.diameter / 2 - radio.thickness); const auto removeFull = (radio.diameter / 2 - radio.thickness);
const auto removeNow = removeFull * (1. - checkmark); const auto removeNow = removeFull * (1. - checkmark);
const auto color = outbg ? (selected ? st::msgFileThumbLinkOutFgSelected : st::msgFileThumbLinkOutFg) : (selected ? st::msgFileThumbLinkInFgSelected : st::msgFileThumbLinkInFg); const auto color = stm->msgFileThumbLinkFg;
auto pen = color->p; auto pen = color->p;
pen.setWidth(radio.thickness); pen.setWidth(radio.thickness);
p.setPen(pen); p.setPen(pen);
p.setBrush(color); p.setBrush(color);
p.drawEllipse(rect.marginsRemoved({ removeNow, removeNow, removeNow, removeNow })); p.drawEllipse(rect.marginsRemoved({ removeNow, removeNow, removeNow, removeNow }));
const auto &icon = outbg ? (selected ? st::historyPollOutChosenSelected : st::historyPollOutChosen) : (selected ? st::historyPollInChosenSelected : st::historyPollInChosen); const auto &icon = stm->historyPollChosen;
icon.paint(p, left + (radio.diameter - icon.width()) / 2, top + (radio.diameter - icon.height()) / 2, width()); icon.paint(p, left + (radio.diameter - icon.width()) / 2, top + (radio.diameter - icon.height()) / 2, width());
} }
} }
@ -1189,13 +1160,13 @@ void Poll::paintPercent(
int top, int top,
int outerWidth, int outerWidth,
const PaintContext &context) const { const PaintContext &context) const {
const auto outbg = _parent->hasOutLayout(); const auto stm = context.messageStyle();
const auto aleft = left + st::historyPollAnswerPadding.left(); const auto aleft = left + st::historyPollAnswerPadding.left();
top += st::historyPollAnswerPadding.top(); top += st::historyPollAnswerPadding.top();
p.setFont(st::historyPollPercentFont); p.setFont(st::historyPollPercentFont);
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); p.setPen(stm->webPageDescriptionFg);
const auto pleft = aleft - percentWidth - st::historyPollPercentSkip; const auto pleft = aleft - percentWidth - st::historyPollPercentSkip;
p.drawTextLeft(pleft, top + st::historyPollPercentTop, outerWidth, percent, percentWidth); p.drawTextLeft(pleft, top + st::historyPollPercentTop, outerWidth, percent, percentWidth);
} }
@ -1211,8 +1182,8 @@ void Poll::paintFilling(
int height, int height,
const PaintContext &context) const { const PaintContext &context) const {
const auto bottom = top + height; const auto bottom = top + height;
const auto outbg = _parent->hasOutLayout(); const auto st = context.st;
const auto selected = context.selected(); const auto stm = context.messageStyle();
const auto aleft = left + st::historyPollAnswerPadding.left(); const auto aleft = left + st::historyPollAnswerPadding.left();
const auto awidth = width const auto awidth = width
- st::historyPollAnswerPadding.left() - st::historyPollAnswerPadding.left()
@ -1229,19 +1200,18 @@ void Poll::paintFilling(
const auto ftop = bottom - st::historyPollFillingBottom - thickness; const auto ftop = bottom - st::historyPollFillingBottom - thickness;
if (chosen && !correct) { if (chosen && !correct) {
p.setBrush(st::boxTextFgError); p.setBrush(st->boxTextFgError());
} else if (chosen && correct && _poll->quiz() && !outbg) { } else if (chosen && correct && _poll->quiz() && !context.outbg) {
p.setBrush(st::boxTextFgGood); p.setBrush(st->boxTextFgGood());
} else { } else {
const auto bar = outbg ? (selected ? st::msgWaveformOutActiveSelected : st::msgWaveformOutActive) : (selected ? st::msgWaveformInActiveSelected : st::msgWaveformInActive); p.setBrush(stm->msgWaveformActive);
p.setBrush(bar);
} }
auto barleft = aleft; auto barleft = aleft;
auto barwidth = size; auto barwidth = size;
if (chosen || correct) { if (chosen || correct) {
const auto &icon = (chosen && !correct) const auto &icon = (chosen && !correct)
? st::historyPollChoiceWrong ? st->historyPollChoiceWrong()
: st::historyPollChoiceRight; : st->historyPollChoiceRight();
const auto cleft = aleft - st::historyPollPercentSkip - icon.width(); const auto cleft = aleft - st::historyPollPercentSkip - icon.width();
const auto ctop = ftop - (icon.height() - thickness) / 2; const auto ctop = ftop - (icon.height() - thickness) / 2;
p.drawEllipse(cleft, ctop, icon.width(), icon.height()); p.drawEllipse(cleft, ctop, icon.width(), icon.height());

View file

@ -148,7 +148,10 @@ ClickHandlerPtr SlotMachine::link() {
return _link; return _link;
} }
void SlotMachine::draw(Painter &p, const QRect &r, bool selected) { void SlotMachine::draw(
Painter &p,
const PaintContext &context,
const QRect &r) {
resolveStarts(true); resolveStarts(true);
resolveEnds(_dice->value()); resolveEnds(_dice->value());
@ -194,9 +197,9 @@ void SlotMachine::draw(Painter &p, const QRect &r, bool selected) {
for (auto i = 0; i != 4; ++i) { for (auto i = 0; i != 4; ++i) {
if (switchedToEnd[i]) { if (switchedToEnd[i]) {
_end[i]->draw(p, r, selected); _end[i]->draw(p, context, r);
} else { } else {
_start[i]->draw(p, r, selected); _start[i]->draw(p, context, r);
if (_end[i] if (_end[i]
&& _end[i]->readyToDrawLottie() && _end[i]->readyToDrawLottie()
&& _start[i]->atTheEnd()) { && _start[i]->atTheEnd()) {
@ -204,7 +207,7 @@ void SlotMachine::draw(Painter &p, const QRect &r, bool selected) {
} }
} }
} }
_pull->draw(p, r, selected); _pull->draw(p, context, r);
} }
} // namespace HistoryView } // namespace HistoryView

View file

@ -22,7 +22,10 @@ public:
~SlotMachine(); ~SlotMachine();
QSize size() override; QSize size() override;
void draw(Painter &p, const QRect &r, bool selected) override; void draw(
Painter &p,
const PaintContext &context,
const QRect &r) override;
ClickHandlerPtr link() override; ClickHandlerPtr link() override;

View file

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_cursor_state.h" #include "history/view/history_view_cursor_state.h"
#include "history/view/media/history_view_media_common.h" #include "history/view/media/history_view_media_common.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "ui/chat/chat_style.h"
#include "ui/effects/path_shift_gradient.h" #include "ui/effects/path_shift_gradient.h"
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "core/application.h" #include "core/application.h"
@ -148,22 +149,28 @@ QSize Sticker::GetAnimatedEmojiSize(
return { convert(documentSize.width()), convert(documentSize.height()) }; return { convert(documentSize.width()), convert(documentSize.height()) };
} }
void Sticker::draw(Painter &p, const QRect &r, bool selected) { void Sticker::draw(
Painter &p,
const PaintContext &context,
const QRect &r) {
ensureDataMediaCreated(); ensureDataMediaCreated();
if (readyToDrawLottie()) { if (readyToDrawLottie()) {
paintLottie(p, r, selected); paintLottie(p, context, r);
} else if (!_data->sticker() } else if (!_data->sticker()
|| (_data->sticker()->animated && _replacements) || (_data->sticker()->animated && _replacements)
|| !paintPixmap(p, r, selected)) { || !paintPixmap(p, context, r)) {
paintPath(p, r, selected); paintPath(p, context, r);
} }
} }
void Sticker::paintLottie(Painter &p, const QRect &r, bool selected) { void Sticker::paintLottie(
Painter &p,
const PaintContext &context,
const QRect &r) {
auto request = Lottie::FrameRequest(); auto request = Lottie::FrameRequest();
request.box = _size * cIntRetinaFactor(); request.box = _size * cIntRetinaFactor();
if (selected && !_nextLastDiceFrame) { if (context.selected() && !_nextLastDiceFrame) {
request.colored = st::msgStickerOverlay->c; request.colored = context.st->msgStickerOverlay()->c;
} }
const auto frame = _lottie const auto frame = _lottie
? _lottie->frameInfo(request) ? _lottie->frameInfo(request)
@ -175,8 +182,8 @@ void Sticker::paintLottie(Painter &p, const QRect &r, bool selected) {
const auto &image = _lastDiceFrame.isNull() const auto &image = _lastDiceFrame.isNull()
? frame.image ? frame.image
: _lastDiceFrame; : _lastDiceFrame;
const auto prepared = (!_lastDiceFrame.isNull() && selected) const auto prepared = (!_lastDiceFrame.isNull() && context.selected())
? Images::prepareColored(st::msgStickerOverlay->c, image) ? Images::prepareColored(context.st->msgStickerOverlay()->c, image)
: image; : image;
const auto size = prepared.size() / cIntRetinaFactor(); const auto size = prepared.size() / cIntRetinaFactor();
p.drawImage( p.drawImage(
@ -216,8 +223,11 @@ void Sticker::paintLottie(Painter &p, const QRect &r, bool selected) {
} }
} }
bool Sticker::paintPixmap(Painter &p, const QRect &r, bool selected) { bool Sticker::paintPixmap(
const auto pixmap = paintedPixmap(selected); Painter &p,
const PaintContext &context,
const QRect &r) {
const auto pixmap = paintedPixmap(context);
if (pixmap.isNull()) { if (pixmap.isNull()) {
return false; return false;
} }
@ -229,16 +239,19 @@ bool Sticker::paintPixmap(Painter &p, const QRect &r, bool selected) {
return true; return true;
} }
void Sticker::paintPath(Painter &p, const QRect &r, bool selected) { void Sticker::paintPath(
Painter &p,
const PaintContext &context,
const QRect &r) {
const auto pathGradient = _parent->delegate()->elementPathShiftGradient(); const auto pathGradient = _parent->delegate()->elementPathShiftGradient();
if (selected) { if (context.selected()) {
pathGradient->overrideColors( pathGradient->overrideColors(
st::msgServiceBgSelected, context.st->msgServiceBgSelected(),
st::msgServiceBg); context.st->msgServiceBg());
} else { } else {
pathGradient->clearOverridenColors(); pathGradient->clearOverridenColors();
} }
p.setBrush(selected ? st::msgServiceBgSelected : st::msgServiceBg); p.setBrush(context.imageStyle()->msgServiceBg);
ChatHelpers::PaintStickerThumbnailPath( ChatHelpers::PaintStickerThumbnailPath(
p, p,
_dataMedia.get(), _dataMedia.get(),
@ -246,28 +259,28 @@ void Sticker::paintPath(Painter &p, const QRect &r, bool selected) {
pathGradient); pathGradient);
} }
QPixmap Sticker::paintedPixmap(bool selected) const { QPixmap Sticker::paintedPixmap(const PaintContext &context) const {
const auto w = _size.width(); const auto w = _size.width();
const auto h = _size.height(); const auto h = _size.height();
const auto &c = st::msgStickerOverlay; const auto &c = context.st->msgStickerOverlay();
const auto good = _dataMedia->goodThumbnail(); const auto good = _dataMedia->goodThumbnail();
if (const auto image = _dataMedia->getStickerLarge()) { if (const auto image = _dataMedia->getStickerLarge()) {
return selected return context.selected()
? image->pixColored(c, w, h) ? image->pixColored(c, w, h)
: image->pix(w, h); : image->pix(w, h);
// //
// Inline thumbnails can't have alpha channel. // Inline thumbnails can't have alpha channel.
// //
//} else if (const auto blurred = _data->thumbnailInline()) { //} else if (const auto blurred = _data->thumbnailInline()) {
// return selected // return context.selected()
// ? blurred->pixBlurredColored(c, w, h) // ? blurred->pixBlurredColored(c, w, h)
// : blurred->pixBlurred(w, h); // : blurred->pixBlurred(w, h);
} else if (good) { } else if (good) {
return selected return context.selected()
? good->pixColored(c, w, h) ? good->pixColored(c, w, h)
: good->pix(w, h); : good->pix(w, h);
} else if (const auto thumbnail = _dataMedia->thumbnail()) { } else if (const auto thumbnail = _dataMedia->thumbnail()) {
return selected return context.selected()
? thumbnail->pixBlurredColored(c, w, h) ? thumbnail->pixBlurredColored(c, w, h)
: thumbnail->pixBlurred(w, h); : thumbnail->pixBlurred(w, h);
} }

View file

@ -39,7 +39,10 @@ public:
void initSize(); void initSize();
QSize size() override; QSize size() override;
void draw(Painter &p, const QRect &r, bool selected) override; void draw(
Painter &p,
const PaintContext &context,
const QRect &r) override;
ClickHandlerPtr link() override { ClickHandlerPtr link() override {
return _link; return _link;
} }
@ -83,10 +86,10 @@ public:
private: private:
[[nodiscard]] bool isEmojiSticker() const; [[nodiscard]] bool isEmojiSticker() const;
void paintLottie(Painter &p, const QRect &r, bool selected); void paintLottie(Painter &p, const PaintContext &context, const QRect &r);
bool paintPixmap(Painter &p, const QRect &r, bool selected); bool paintPixmap(Painter &p, const PaintContext &context, const QRect &r);
void paintPath(Painter &p, const QRect &r, bool selected); void paintPath(Painter &p, const PaintContext &context, const QRect &r);
[[nodiscard]] QPixmap paintedPixmap(bool selected) const; [[nodiscard]] QPixmap paintedPixmap(const PaintContext &context) const;
void ensureDataMediaCreated() const; void ensureDataMediaCreated() const;
void dataMediaCreated() const; void dataMediaCreated() const;

View file

@ -190,7 +190,7 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const {
auto statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y(); auto statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y();
Ui::FillRoundRect(p, style::rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), sti->msgDateImgBg, sti->msgDateImgBgCorners); Ui::FillRoundRect(p, style::rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), sti->msgDateImgBg, sti->msgDateImgBgCorners);
p.setFont(st::normalFont); p.setFont(st::normalFont);
p.setPen(st::msgDateImgFg); p.setPen(st->msgDateImgFg());
p.drawTextLeft(statusX, statusY, width(), _statusText, statusW - 2 * st::msgDateImgPadding.x()); p.drawTextLeft(statusX, statusY, width(), _statusText, statusW - 2 * st::msgDateImgPadding.x());
if (radial || (!loaded && !_data->loading())) { if (radial || (!loaded && !_data->loading())) {
const auto radialOpacity = (radial && loaded && !_data->uploading()) const auto radialOpacity = (radial && loaded && !_data->uploading())

View file

@ -563,9 +563,9 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
&& !_data->document) { && !_data->document) {
if (_attach->isReadyForOpen()) { if (_attach->isReadyForOpen()) {
if (_data->siteName == qstr("YouTube")) { if (_data->siteName == qstr("YouTube")) {
st::youtubeIcon.paint(p, (pixwidth - st::youtubeIcon.width()) / 2, (pixheight - st::youtubeIcon.height()) / 2, width()); st->youtubeIcon().paint(p, (pixwidth - st::youtubeIcon.width()) / 2, (pixheight - st::youtubeIcon.height()) / 2, width());
} else { } else {
st::videoIcon.paint(p, (pixwidth - st::videoIcon.width()) / 2, (pixheight - st::videoIcon.height()) / 2, width()); st->videoIcon().paint(p, (pixwidth - st::videoIcon.width()) / 2, (pixheight - st::videoIcon.height()) / 2, width());
} }
} }
if (_durationWidth) { if (_durationWidth) {
@ -577,7 +577,7 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
Ui::FillRoundRect(p, dateX, dateY, dateW, dateH, sti->msgDateImgBg, sti->msgDateImgBgCorners); Ui::FillRoundRect(p, dateX, dateY, dateW, dateH, sti->msgDateImgBg, sti->msgDateImgBgCorners);
p.setFont(st::msgDateFont); p.setFont(st::msgDateFont);
p.setPen(st::msgDateImgFg); p.setPen(st->msgDateImgFg());
p.drawTextLeft(dateX + st::msgDateImgPadding.x(), dateY + st::msgDateImgPadding.y(), pixwidth, _duration); p.drawTextLeft(dateX + st::msgDateImgPadding.x(), dateY + st::msgDateImgPadding.y(), pixwidth, _duration);
} }
} }

View file

@ -719,11 +719,12 @@ object_ptr<Ui::RpWidget> ForwardsPrivacyController::setupAboveWidget(
Painter p(widget); Painter p(widget);
const auto theme = _controller->defaultChatTheme().get(); const auto theme = _controller->defaultChatTheme().get();
const auto context = theme->preparePaintContext( auto context = theme->preparePaintContext(
_chatStyle.get(), _chatStyle.get(),
widget->rect(), widget->rect(),
widget->rect()); widget->rect());
p.translate(0, padding + view->marginBottom()); p.translate(0, padding + view->marginBottom());
context.outbg = view->hasOutLayout();
view->draw(p, context); view->draw(p, context);
PaintForwardedTooltip(p, view, *option); PaintForwardedTooltip(p, view, *option);

View file

@ -570,15 +570,17 @@ void ConfirmContactBox::paintEvent(QPaintEvent *e) {
p.fillRect(e->rect(), st::boxBg); p.fillRect(e->rect(), st::boxBg);
const auto theme = controller()->defaultChatTheme().get(); const auto theme = controller()->defaultChatTheme().get();
const auto context = theme->preparePaintContext( auto context = theme->preparePaintContext(
_chatStyle.get(), _chatStyle.get(),
rect(), rect(),
rect()); rect());
p.translate(st::boxPadding.left(), 0); p.translate(st::boxPadding.left(), 0);
if (_comment) { if (_comment) {
context.outbg = _comment->hasOutLayout();
_comment->draw(p, context); _comment->draw(p, context);
p.translate(0, _comment->height()); p.translate(0, _comment->height());
} }
context.outbg = _contact->hasOutLayout();
_contact->draw(p, context); _contact->draw(p, context);
} }

View file

@ -82,6 +82,12 @@ ChatStyle::ChatStyle() {
make(_historyFastCommentsIcon, st::historyFastCommentsIcon); make(_historyFastCommentsIcon, st::historyFastCommentsIcon);
make(_historyFastShareIcon, st::historyFastShareIcon); make(_historyFastShareIcon, st::historyFastShareIcon);
make(_historyGoToOriginalIcon, st::historyGoToOriginalIcon); make(_historyGoToOriginalIcon, st::historyGoToOriginalIcon);
make(_historyMapPoint, st::historyMapPoint);
make(_historyMapPointInner, st::historyMapPointInner);
make(_youtubeIcon, st::youtubeIcon);
make(_videoIcon, st::videoIcon);
make(_historyPollChoiceRight, st::historyPollChoiceRight);
make(_historyPollChoiceWrong, st::historyPollChoiceWrong);
make( make(
&MessageStyle::msgBg, &MessageStyle::msgBg,
st::msgInBg, st::msgInBg,
@ -334,6 +340,24 @@ ChatStyle::ChatStyle() {
st::historyAudioInCancelSelected, st::historyAudioInCancelSelected,
st::historyAudioOutCancel, st::historyAudioOutCancel,
st::historyAudioOutCancelSelected); st::historyAudioOutCancelSelected);
make(
&MessageStyle::historyQuizTimer,
st::historyQuizTimerIn,
st::historyQuizTimerInSelected,
st::historyQuizTimerOut,
st::historyQuizTimerOutSelected);
make(
&MessageStyle::historyQuizExplain,
st::historyQuizExplainIn,
st::historyQuizExplainInSelected,
st::historyQuizExplainOut,
st::historyQuizExplainOutSelected);
make(
&MessageStyle::historyPollChosen,
st::historyPollInChosen,
st::historyPollInChosenSelected,
st::historyPollOutChosen,
st::historyPollOutChosenSelected);
make( make(
&MessageImageStyle::msgDateImgBg, &MessageImageStyle::msgDateImgBg,
st::msgDateImgBg, st::msgDateImgBg,

View file

@ -61,6 +61,9 @@ struct MessageStyle {
style::icon historyFileDocument = { Qt::Uninitialized }; style::icon historyFileDocument = { Qt::Uninitialized };
style::icon historyAudioDownload = { Qt::Uninitialized }; style::icon historyAudioDownload = { Qt::Uninitialized };
style::icon historyAudioCancel = { Qt::Uninitialized }; style::icon historyAudioCancel = { Qt::Uninitialized };
style::icon historyQuizTimer = { Qt::Uninitialized };
style::icon historyQuizExplain = { Qt::Uninitialized };
style::icon historyPollChosen = { Qt::Uninitialized };
}; };
struct MessageImageStyle { struct MessageImageStyle {
@ -195,6 +198,24 @@ public:
[[nodiscard]] const style::icon &historyGoToOriginalIcon() const { [[nodiscard]] const style::icon &historyGoToOriginalIcon() const {
return _historyGoToOriginalIcon; return _historyGoToOriginalIcon;
} }
[[nodiscard]] const style::icon &historyMapPoint() const {
return _historyMapPoint;
}
[[nodiscard]] const style::icon &historyMapPointInner() const {
return _historyMapPointInner;
}
[[nodiscard]] const style::icon &youtubeIcon() const {
return _youtubeIcon;
}
[[nodiscard]] const style::icon &videoIcon() const {
return _videoIcon;
}
[[nodiscard]] const style::icon &historyPollChoiceRight() const {
return _historyPollChoiceRight;
}
[[nodiscard]] const style::icon &historyPollChoiceWrong() const {
return _historyPollChoiceWrong;
}
private: private:
void assignPalette(not_null<const style::palette*> palette); void assignPalette(not_null<const style::palette*> palette);
@ -255,6 +276,12 @@ private:
style::icon _historyFastCommentsIcon = { Qt::Uninitialized }; style::icon _historyFastCommentsIcon = { Qt::Uninitialized };
style::icon _historyFastShareIcon = { Qt::Uninitialized }; style::icon _historyFastShareIcon = { Qt::Uninitialized };
style::icon _historyGoToOriginalIcon = { Qt::Uninitialized }; style::icon _historyGoToOriginalIcon = { Qt::Uninitialized };
style::icon _historyMapPoint = { Qt::Uninitialized };
style::icon _historyMapPointInner = { Qt::Uninitialized };
style::icon _youtubeIcon = { Qt::Uninitialized };
style::icon _videoIcon = { Qt::Uninitialized };
style::icon _historyPollChoiceRight = { Qt::Uninitialized };
style::icon _historyPollChoiceWrong = { Qt::Uninitialized };
rpl::lifetime _defaultPaletteChangeLifetime; rpl::lifetime _defaultPaletteChangeLifetime;