Custom colors in history_view_document module.

This commit is contained in:
John Preston 2021-09-03 16:09:43 +03:00
parent 23e9e7b9f0
commit cbfe57c51d
23 changed files with 528 additions and 395 deletions

View file

@ -109,7 +109,8 @@ void KeyboardStyle::paintButtonBg(
float64 howMuchOver) const { float64 howMuchOver) const {
Expects(st != nullptr); Expects(st != nullptr);
Ui::FillRoundRect(p, rect, st->msgServiceBg(), st->msgServiceBgCorners()); const auto sti = &st->imageStyle(false);
Ui::FillRoundRect(p, rect, sti->msgServiceBg, sti->msgServiceBgCorners);
if (howMuchOver > 0) { if (howMuchOver > 0) {
auto o = p.opacity(); auto o = p.opacity();
p.setOpacity(o * howMuchOver); p.setOpacity(o * howMuchOver);
@ -1691,8 +1692,9 @@ void Message::drawInfo(
InfoDisplayType type) const { InfoDisplayType type) const {
p.setFont(st::msgDateFont); p.setFont(st::msgDateFont);
const auto stm = context.messageStyle();
const auto st = context.st; const auto st = context.st;
const auto sti = context.imageStyle();
const auto stm = context.messageStyle();
bool invertedsprites = (type == InfoDisplayType::Image) bool invertedsprites = (type == InfoDisplayType::Image)
|| (type == InfoDisplayType::Background); || (type == InfoDisplayType::Background);
int32 infoRight = right, infoBottom = bottom; int32 infoRight = right, infoBottom = bottom;
@ -1723,10 +1725,10 @@ void Message::drawInfo(
auto dateY = infoBottom - st::msgDateFont->height; auto dateY = infoBottom - st::msgDateFont->height;
if (type == InfoDisplayType::Image) { if (type == InfoDisplayType::Image) {
auto dateW = infoW + 2 * st::msgDateImgPadding.x(), dateH = st::msgDateFont->height + 2 * st::msgDateImgPadding.y(); auto dateW = infoW + 2 * st::msgDateImgPadding.x(), dateH = st::msgDateFont->height + 2 * st::msgDateImgPadding.y();
Ui::FillRoundRect(p, dateX - st::msgDateImgPadding.x(), dateY - st::msgDateImgPadding.y(), dateW, dateH, selected ? st->msgDateImgBgSelected() : st->msgDateImgBg(), selected ? st->msgDateImgBgSelectedCorners() : st->msgDateImgBgCorners()); Ui::FillRoundRect(p, dateX - st::msgDateImgPadding.x(), dateY - st::msgDateImgPadding.y(), dateW, dateH, sti->msgDateImgBg, sti->msgDateImgBgCorners);
} else if (type == InfoDisplayType::Background) { } else if (type == InfoDisplayType::Background) {
auto dateW = infoW + 2 * st::msgDateImgPadding.x(), dateH = st::msgDateFont->height + 2 * st::msgDateImgPadding.y(); auto dateW = infoW + 2 * st::msgDateImgPadding.x(), dateH = st::msgDateFont->height + 2 * st::msgDateImgPadding.y();
Ui::FillRoundRect(p, dateX - st::msgDateImgPadding.x(), dateY - st::msgDateImgPadding.y(), dateW, dateH, selected ? st->msgServiceBgSelected() : st->msgServiceBg(), selected ? st->msgServiceBgSelectedCorners() : st->msgServiceBgCorners()); Ui::FillRoundRect(p, dateX - st::msgDateImgPadding.x(), dateY - st::msgDateImgPadding.y(), dateW, dateH, sti->msgServiceBg, sti->msgServiceBgCorners);
} }
dateX += timeLeft(); dateX += timeLeft();

View file

@ -77,8 +77,7 @@ void Call::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 paintw = width(); auto paintw = width();
auto outbg = _parent->hasOutLayout(); const auto stm = context.messageStyle();
auto selected = (context.selection == FullSelection);
accumulate_min(paintw, maxWidth()); accumulate_min(paintw, maxWidth());
@ -90,27 +89,25 @@ void Call::draw(Painter &p, const PaintContext &context) const {
statustop = st::historyCallStatusTop - topMinus; statustop = st::historyCallStatusTop - topMinus;
p.setFont(st::semiboldFont); p.setFont(st::semiboldFont);
p.setPen(outbg ? (selected ? st::historyFileNameOutFgSelected : st::historyFileNameOutFg) : (selected ? st::historyFileNameInFgSelected : st::historyFileNameInFg)); p.setPen(stm->historyFileNameFg);
p.drawTextLeft(nameleft, nametop, paintw, _text); p.drawTextLeft(nameleft, nametop, paintw, _text);
auto statusleft = nameleft; auto statusleft = nameleft;
auto missed = (_reason == FinishReason::Missed || _reason == FinishReason::Busy); auto missed = (_reason == FinishReason::Missed)
auto &arrow = outbg ? (selected ? st::historyCallArrowOutSelected : st::historyCallArrowOut) : missed ? (selected ? st::historyCallArrowMissedInSelected : st::historyCallArrowMissedIn) : (selected ? st::historyCallArrowInSelected : st::historyCallArrowIn); || (_reason == FinishReason::Busy);
const auto &arrow = missed
? stm->historyCallArrowMissed
: stm->historyCallArrow;
arrow.paint(p, statusleft + st::historyCallArrowPosition.x(), statustop + st::historyCallArrowPosition.y(), paintw); arrow.paint(p, statusleft + st::historyCallArrowPosition.x(), statustop + st::historyCallArrowPosition.y(), paintw);
statusleft += arrow.width() + st::historyCallStatusSkip; statusleft += arrow.width() + st::historyCallStatusSkip;
auto &statusFg = outbg ? (selected ? st::mediaOutFgSelected : st::mediaOutFg) : (selected ? st::mediaInFgSelected : st::mediaInFg);
p.setFont(st::normalFont); p.setFont(st::normalFont);
p.setPen(statusFg); p.setPen(stm->mediaFg);
p.drawTextLeft(statusleft, statustop, paintw, _status); p.drawTextLeft(statusleft, statustop, paintw, _status);
const auto &icon = _video const auto &icon = _video
? (outbg ? stm->historyCallCameraIcon
? (selected ? st::historyCallCameraOutIconSelected : st::historyCallCameraOutIcon) : stm->historyCallIcon;
: (selected ? st::historyCallCameraInIconSelected : st::historyCallCameraInIcon))
: (outbg
? (selected ? st::historyCallOutIconSelected : st::historyCallOutIcon)
: (selected ? st::historyCallInIconSelected : st::historyCallInIcon));
icon.paint(p, paintw - st::historyCallIconPosition.x() - icon.width(), st::historyCallIconPosition.y() - topMinus, paintw); icon.paint(p, paintw - st::historyCallIconPosition.x() - icon.width(), st::historyCallIconPosition.y() - topMinus, paintw);
} }

View file

@ -158,8 +158,7 @@ void Contact::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 paintw = width(); auto paintw = width();
auto outbg = _parent->hasOutLayout(); const auto stm = context.messageStyle();
bool selected = (context.selection == FullSelection);
accumulate_min(paintw, maxWidth()); accumulate_min(paintw, maxWidth());
@ -182,7 +181,7 @@ void Contact::draw(Painter &p, const PaintContext &context) const {
} else { } else {
_photoEmpty->paint(p, st.padding.left(), st.padding.top() - topMinus, paintw, st.thumbSize); _photoEmpty->paint(p, st.padding.left(), st.padding.top() - topMinus, paintw, st.thumbSize);
} }
if (selected) { if (context.selected()) {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.setBrush(p.textPalette().selectOverlay); p.setBrush(p.textPalette().selectOverlay);
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
@ -191,7 +190,7 @@ void Contact::draw(Painter &p, const PaintContext &context) const {
bool over = ClickHandler::showAsActive(_linkl); bool over = ClickHandler::showAsActive(_linkl);
p.setFont(over ? st::semiboldFont->underline() : st::semiboldFont); p.setFont(over ? st::semiboldFont->underline() : st::semiboldFont);
p.setPen(outbg ? (selected ? st::msgFileThumbLinkOutFgSelected : st::msgFileThumbLinkOutFg) : (selected ? st::msgFileThumbLinkInFgSelected : st::msgFileThumbLinkInFg)); p.setPen(stm->msgFileThumbLinkFg);
p.drawTextLeft(nameleft, linktop, paintw, _link, _linkw); p.drawTextLeft(nameleft, linktop, paintw, _link, _linkw);
} else { } else {
_photoEmpty->paint(p, st.padding.left(), st.padding.top() - topMinus, paintw, st.thumbSize); _photoEmpty->paint(p, st.padding.left(), st.padding.top() - topMinus, paintw, st.thumbSize);
@ -199,12 +198,11 @@ void Contact::draw(Painter &p, const PaintContext &context) const {
const auto namewidth = paintw - nameleft - nameright; const auto namewidth = paintw - nameleft - nameright;
p.setFont(st::semiboldFont); p.setFont(st::semiboldFont);
p.setPen(outbg ? (selected ? st::historyFileNameOutFgSelected : st::historyFileNameOutFg) : (selected ? st::historyFileNameInFgSelected : st::historyFileNameInFg)); p.setPen(stm->historyFileNameFg);
_name.drawLeftElided(p, nameleft, nametop, namewidth, paintw); _name.drawLeftElided(p, nameleft, nametop, namewidth, paintw);
auto &status = outbg ? (selected ? st::mediaOutFgSelected : st::mediaOutFg) : (selected ? st::mediaInFgSelected : st::mediaInFg);
p.setFont(st::normalFont); p.setFont(st::normalFont);
p.setPen(status); p.setPen(stm->mediaFg);
p.drawTextLeft(nameleft, statustop, paintw, _phone); p.drawTextLeft(nameleft, statustop, paintw, _phone);
} }

View file

@ -68,10 +68,9 @@ constexpr auto kAudioVoiceMsgUpdateView = crl::time(100);
void PaintWaveform( void PaintWaveform(
Painter &p, Painter &p,
const PaintContext &context,
const VoiceData *voiceData, const VoiceData *voiceData,
int availableWidth, int availableWidth,
bool selected,
bool outbg,
float64 progress) { float64 progress) {
const auto wf = [&]() -> const VoiceWaveform* { const auto wf = [&]() -> const VoiceWaveform* {
if (!voiceData) { if (!voiceData) {
@ -84,22 +83,11 @@ void PaintWaveform(
} }
return &voiceData->waveform; return &voiceData->waveform;
}(); }();
const auto stm = context.messageStyle();
// Rescale waveform by going in waveform.size * bar_count 1D grid. // Rescale waveform by going in waveform.size * bar_count 1D grid.
const auto active = outbg const auto active = stm->msgWaveformActive;
? (selected const auto inactive = stm->msgWaveformInactive;
? st::msgWaveformOutActiveSelected
: st::msgWaveformOutActive)
: (selected
? st::msgWaveformInActiveSelected
: st::msgWaveformInActive);
const auto inactive = outbg
? (selected
? st::msgWaveformOutInactiveSelected
: st::msgWaveformOutInactive)
: (selected
? st::msgWaveformInInactiveSelected
: st::msgWaveformInInactive);
const auto wfSize = wf const auto wfSize = wf
? wf->size() ? wf->size()
: ::Media::Player::kWaveformSamplesCount; : ::Media::Player::kWaveformSamplesCount;
@ -327,13 +315,13 @@ QSize Document::countCurrentSize(int newWidth) {
} }
void Document::draw(Painter &p, const PaintContext &context) const { void Document::draw(Painter &p, const PaintContext &context) const {
draw(p, width(), context, LayoutMode::Full); draw(p, context, width(), LayoutMode::Full);
} }
void Document::draw( void Document::draw(
Painter &p, Painter &p,
int width,
const PaintContext &context, const PaintContext &context,
int width,
LayoutMode mode) const { LayoutMode mode) const {
if (width < st::msgPadding.left() + st::msgPadding.right() + 1) return; if (width < st::msgPadding.left() + st::msgPadding.right() + 1) return;
@ -345,10 +333,10 @@ void Document::draw(
_dataMedia->automaticLoad(_realParent->fullId(), _realParent); _dataMedia->automaticLoad(_realParent->fullId(), _realParent);
} }
bool loaded = dataLoaded(), displayLoading = _data->displayLoading(); bool loaded = dataLoaded(), displayLoading = _data->displayLoading();
bool selected = (context.selection == FullSelection); const auto sti = context.imageStyle();
const auto stm = context.messageStyle();
int captionw = width - st::msgPadding.left() - st::msgPadding.right(); int captionw = width - st::msgPadding.left() - st::msgPadding.right();
auto outbg = _parent->hasOutLayout();
if (displayLoading) { if (displayLoading) {
ensureAnimation(); ensureAnimation();
@ -384,7 +372,7 @@ void Document::draw(
thumb = blurred->pixBlurredSingle(thumbed->_thumbw, 0, st.thumbSize, st.thumbSize, roundRadius); thumb = blurred->pixBlurredSingle(thumbed->_thumbw, 0, st.thumbSize, st.thumbSize, roundRadius);
} }
p.drawPixmap(rthumb.topLeft(), thumb); p.drawPixmap(rthumb.topLeft(), thumb);
if (selected) { if (context.selected()) {
auto overlayCorners = inWebPage ? Ui::SelectedOverlaySmallCorners : Ui::SelectedOverlayLargeCorners; auto overlayCorners = inWebPage ? Ui::SelectedOverlaySmallCorners : Ui::SelectedOverlayLargeCorners;
Ui::FillRoundRect(p, rthumb, p.textPalette().selectOverlay, overlayCorners); Ui::FillRoundRect(p, rthumb, p.textPalette().selectOverlay, overlayCorners);
} }
@ -392,11 +380,7 @@ void Document::draw(
if (radial || (!loaded && !_data->loading()) || _data->waitingForAlbum()) { if (radial || (!loaded && !_data->loading()) || _data->waitingForAlbum()) {
const auto backOpacity = (loaded && !_data->uploading()) ? radialOpacity : 1.; const auto backOpacity = (loaded && !_data->uploading()) ? radialOpacity : 1.;
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
if (selected) { p.setBrush(sti->msgDateImgBg);
p.setBrush(st::msgDateImgBgSelected);
} else {
p.setBrush(st::msgDateImgBg);
}
p.setOpacity(backOpacity * p.opacity()); p.setOpacity(backOpacity * p.opacity());
{ {
@ -404,30 +388,24 @@ void Document::draw(
p.drawEllipse(inner); p.drawEllipse(inner);
} }
const auto icon = [&] { const auto &icon = _data->waitingForAlbum()
if (_data->waitingForAlbum()) { ? sti->historyFileThumbWaiting
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting); : (radial || _data->loading())
} else if (radial || _data->loading()) { ? sti->historyFileThumbCancel
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); : sti->historyFileThumbDownload;
} const auto previous = _data->waitingForAlbum()
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload); ? &sti->historyFileThumbCancel
}(); : nullptr;
const auto previous = [&]() -> const style::icon* {
if (_data->waitingForAlbum()) {
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
}
return nullptr;
}();
p.setOpacity(backOpacity); p.setOpacity(backOpacity);
if (previous && radialOpacity > 0. && radialOpacity < 1.) { if (previous && radialOpacity > 0. && radialOpacity < 1.) {
PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner); PaintInterpolatedIcon(p, icon, *previous, radialOpacity, inner);
} else { } else {
icon->paintInCenter(p, inner); icon.paintInCenter(p, inner);
} }
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)));
_animation->radial.draw(p, rinner, st::msgFileRadialLine, selected ? st::historyFileThumbRadialFgSelected : st::historyFileThumbRadialFg); _animation->radial.draw(p, rinner, st::msgFileRadialLine, sti->historyFileThumbRadialFg);
} }
} }
@ -439,82 +417,67 @@ void Document::draw(
: thumbed->_linksavel; : thumbed->_linksavel;
bool over = ClickHandler::showAsActive(lnk); bool over = ClickHandler::showAsActive(lnk);
p.setFont(over ? st::semiboldFont->underline() : st::semiboldFont); p.setFont(over ? st::semiboldFont->underline() : st::semiboldFont);
p.setPen(outbg ? (selected ? st::msgFileThumbLinkOutFgSelected : st::msgFileThumbLinkOutFg) : (selected ? st::msgFileThumbLinkInFgSelected : st::msgFileThumbLinkInFg)); p.setPen(stm->msgFileThumbLinkFg);
p.drawTextLeft(nameleft, linktop, width, thumbed->_link, thumbed->_linkw); p.drawTextLeft(nameleft, linktop, width, thumbed->_link, thumbed->_linkw);
} }
} else { } else {
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
const auto coverDrawn = _data->isSongWithCover() const auto coverDrawn = _data->isSongWithCover()
&& DrawThumbnailAsSongCover(p, _dataMedia, inner, selected); && DrawThumbnailAsSongCover(
p,
context.st->songCoverOverlayFg(),
_dataMedia,
inner,
context.selected());
if (!coverDrawn) { if (!coverDrawn) {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.setBrush(selected p.setBrush(stm->msgFileBg);
? (outbg ? st::msgFileOutBgSelected : st::msgFileInBgSelected)
: (outbg ? st::msgFileOutBg : st::msgFileInBg));
p.drawEllipse(inner); p.drawEllipse(inner);
} }
const auto icon = [&] { const auto &icon = [&]() -> const style::icon& {
if (_data->waitingForAlbum()) { if (_data->waitingForAlbum()) {
if (_data->isSongWithCover()) { return _data->isSongWithCover()
return &(selected ? sti->historyFileThumbWaiting
? st::historyFileSongWaitingSelected : stm->historyFileWaiting;
: st::historyFileSongWaiting); } else if (!cornerDownload
} && (_data->loading() || _data->uploading())) {
return &(outbg ? (selected ? st::historyFileOutWaitingSelected : st::historyFileOutWaiting) : (selected ? st::historyFileInWaitingSelected : st::historyFileInWaiting)); return _data->isSongWithCover()
} else if (!cornerDownload && (_data->loading() || _data->uploading())) { ? sti->historyFileThumbCancel
if (_data->isSongWithCover()) { : stm->historyFileCancel;
return &(selected
? st::historyFileSongCancelSelected
: st::historyFileSongCancel);
}
return &(outbg ? (selected ? st::historyFileOutCancelSelected : st::historyFileOutCancel) : (selected ? st::historyFileInCancelSelected : st::historyFileInCancel));
} else if (showPause) { } else if (showPause) {
if (_data->isSongWithCover()) { return _data->isSongWithCover()
return &(selected ? sti->historyFileThumbPause
? st::historyFileSongPauseSelected : stm->historyFilePause;
: st::historyFileSongPause);
}
return &(outbg ? (selected ? st::historyFileOutPauseSelected : st::historyFileOutPause) : (selected ? st::historyFileInPauseSelected : st::historyFileInPause));
} else if (loaded || _dataMedia->canBePlayed()) { } else if (loaded || _dataMedia->canBePlayed()) {
if (_dataMedia->canBePlayed()) { return _dataMedia->canBePlayed()
if (_data->isSongWithCover()) { ? (_data->isSongWithCover()
return &(selected ? sti->historyFileThumbPlay
? st::historyFileSongPlaySelected : stm->historyFilePlay)
: st::historyFileSongPlay); : _data->isImage()
} ? stm->historyFileImage
return &(outbg ? (selected ? st::historyFileOutPlaySelected : st::historyFileOutPlay) : (selected ? st::historyFileInPlaySelected : st::historyFileInPlay)); : stm->historyFileDocument;
} else if (_data->isImage()) { } else {
return &(outbg ? (selected ? st::historyFileOutImageSelected : st::historyFileOutImage) : (selected ? st::historyFileInImageSelected : st::historyFileInImage)); return _data->isSongWithCover()
} ? sti->historyFileThumbDownload
return &(outbg ? (selected ? st::historyFileOutDocumentSelected : st::historyFileOutDocument) : (selected ? st::historyFileInDocumentSelected : st::historyFileInDocument)); : stm->historyFileDownload;
} }
if (_data->isSongWithCover()) {
return &(selected
? st::historyFileSongDownloadSelected
: st::historyFileSongDownload);
}
return &(outbg ? (selected ? st::historyFileOutDownloadSelected : st::historyFileOutDownload) : (selected ? st::historyFileInDownloadSelected : st::historyFileInDownload));
}();
const auto previous = [&]() -> const style::icon* {
if (_data->waitingForAlbum()) {
return &(outbg ? (selected ? st::historyFileOutCancelSelected : st::historyFileOutCancel) : (selected ? st::historyFileInCancelSelected : st::historyFileInCancel));
}
return nullptr;
}(); }();
const auto previous = _data->waitingForAlbum()
? &stm->historyFileCancel
: nullptr;
const auto paintContent = [&](Painter &q) { const auto paintContent = [&](Painter &q) {
if (previous && radialOpacity > 0. && radialOpacity < 1.) { if (previous && radialOpacity > 0. && radialOpacity < 1.) {
PaintInterpolatedIcon(q, *icon, *previous, radialOpacity, inner); PaintInterpolatedIcon(q, icon, *previous, radialOpacity, inner);
} else { } else {
icon->paintInCenter(q, inner); icon.paintInCenter(q, inner);
} }
if (radial && !cornerDownload) { if (radial && !cornerDownload) {
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)));
auto fg = outbg ? (selected ? st::historyFileOutRadialFgSelected : st::historyFileOutRadialFg) : (selected ? st::historyFileInRadialFgSelected : st::historyFileInRadialFg); _animation->radial.draw(q, rinner, st::msgFileRadialLine, stm->historyFileRadialFg);
_animation->radial.draw(q, rinner, st::msgFileRadialLine, fg);
} }
}; };
if (_data->isSongWithCover() || !usesBubblePattern(context)) { if (_data->isSongWithCover() || !usesBubblePattern(context)) {
@ -547,7 +510,7 @@ void Document::draw(
} }
const auto progress = [&] { const auto progress = [&] {
if (!outbg if (!context.outbg
&& !voice->_playback && !voice->_playback
&& _realParent->hasUnreadMediaFlag()) { && _realParent->hasUnreadMediaFlag()) {
return 1.; return 1.;
@ -568,15 +531,14 @@ void Document::draw(
p.save(); p.save();
p.translate(nameleft, st.padding.top() - topMinus); p.translate(nameleft, st.padding.top() - topMinus);
PaintWaveform(p, PaintWaveform(p,
context,
_data->voice(), _data->voice(),
namewidth + st::msgWaveformSkip, namewidth + st::msgWaveformSkip,
selected,
outbg,
progress); progress);
p.restore(); p.restore();
} else if (auto named = Get<HistoryDocumentNamed>()) { } else if (auto named = Get<HistoryDocumentNamed>()) {
p.setFont(st::semiboldFont); p.setFont(st::semiboldFont);
p.setPen(outbg ? (selected ? st::historyFileNameOutFgSelected : st::historyFileNameOutFg) : (selected ? st::historyFileNameInFgSelected : st::historyFileNameInFg)); p.setPen(stm->historyFileNameFg);
if (namewidth < named->_namew) { if (namewidth < named->_namew) {
p.drawTextLeft(nameleft, nametop, width, st::semiboldFont->elided(named->_name, namewidth, Qt::ElideMiddle)); p.drawTextLeft(nameleft, nametop, width, st::semiboldFont->elided(named->_name, namewidth, Qt::ElideMiddle));
} else { } else {
@ -585,16 +547,15 @@ void Document::draw(
} }
auto statusText = voiceStatusOverride.isEmpty() ? _statusText : voiceStatusOverride; auto statusText = voiceStatusOverride.isEmpty() ? _statusText : voiceStatusOverride;
auto status = outbg ? (selected ? st::mediaOutFgSelected : st::mediaOutFg) : (selected ? st::mediaInFgSelected : st::mediaInFg);
p.setFont(st::normalFont); p.setFont(st::normalFont);
p.setPen(status); p.setPen(stm->mediaFg);
p.drawTextLeft(nameleft, statustop, width, statusText); p.drawTextLeft(nameleft, statustop, width, statusText);
if (_realParent->hasUnreadMediaFlag()) { if (_realParent->hasUnreadMediaFlag()) {
auto w = st::normalFont->width(statusText); auto w = st::normalFont->width(statusText);
if (w + st::mediaUnreadSkip + st::mediaUnreadSize <= statuswidth) { if (w + st::mediaUnreadSkip + st::mediaUnreadSize <= statuswidth) {
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(outbg ? (selected ? st::msgFileOutBgSelected : st::msgFileOutBg) : (selected ? st::msgFileInBgSelected : st::msgFileInBg)); p.setBrush(stm->msgFileBg);
{ {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
@ -604,7 +565,7 @@ void Document::draw(
} }
if (auto captioned = Get<HistoryDocumentCaptioned>()) { if (auto captioned = Get<HistoryDocumentCaptioned>()) {
p.setPen(outbg ? (selected ? st::historyTextOutFgSelected : st::historyTextOutFg) : (selected ? st::historyTextInFgSelected : st::historyTextInFg)); p.setPen(stm->historyTextFg);
captioned->_caption.draw(p, st::msgPadding.left(), bottom, captionw, style::al_left, 0, -1, context.selection); captioned->_caption.draw(p, st::msgPadding.left(), bottom, captionw, style::al_left, 0, -1, context.selection);
} }
} }
@ -644,9 +605,8 @@ void Document::drawCornerDownload(
|| !downloadInCorner()) { || !downloadInCorner()) {
return; return;
} }
auto outbg = _parent->hasOutLayout();
auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus; auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus;
const auto selected = (context.selection == FullSelection); const auto stm = context.messageStyle();
const auto thumbed = false; const auto thumbed = false;
const auto &st = (mode == LayoutMode::Full) const auto &st = (mode == LayoutMode::Full)
? (thumbed ? st::msgFileThumbLayout : st::msgFileLayout) ? (thumbed ? st::msgFileThumbLayout : st::msgFileLayout)
@ -658,41 +618,31 @@ void Document::drawCornerDownload(
if (bubblePattern) { if (bubblePattern) {
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
} else { } else {
auto pen = (selected auto pen = stm->msgBg->p;
? (outbg ? st::msgOutBgSelected : st::msgInBgSelected)
: (outbg ? st::msgOutBg : st::msgInBg))->p;
pen.setWidth(st::lineWidth); pen.setWidth(st::lineWidth);
p.setPen(pen); p.setPen(pen);
} }
if (selected) { p.setBrush(stm->msgFileBg);
p.setBrush(outbg ? st::msgFileOutBgSelected : st::msgFileInBgSelected);
} else {
p.setBrush(outbg ? st::msgFileOutBg : st::msgFileInBg);
}
{ {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.drawEllipse(inner); p.drawEllipse(inner);
} }
const auto icon = [&] { const auto &icon = _data->loading()
if (_data->loading()) { ? stm->historyAudioCancel
return &(outbg ? (selected ? st::historyAudioOutCancelSelected : st::historyAudioOutCancel) : (selected ? st::historyAudioInCancelSelected : st::historyAudioInCancel)); : stm->historyAudioDownload;
}
return &(outbg ? (selected ? st::historyAudioOutDownloadSelected : st::historyAudioOutDownload) : (selected ? st::historyAudioInDownloadSelected : st::historyAudioInDownload));
}();
const auto paintContent = [&](Painter &q) { const auto paintContent = [&](Painter &q) {
if (bubblePattern) { if (bubblePattern) {
auto hq = PainterHighQualityEnabler(q); auto hq = PainterHighQualityEnabler(q);
auto pen = st::msgOutBg->p; auto pen = stm->msgBg->p;
pen.setWidth(st::lineWidth); pen.setWidth(st::lineWidth);
q.setPen(pen); q.setPen(pen);
q.setBrush(Qt::NoBrush); q.setBrush(Qt::NoBrush);
q.drawEllipse(inner); q.drawEllipse(inner);
} }
icon->paintInCenter(q, inner); icon.paintInCenter(q, inner);
if (_animation && _animation->radial.animating()) { if (_animation && _animation->radial.animating()) {
const auto rinner = inner.marginsRemoved(QMargins(st::historyAudioRadialLine, st::historyAudioRadialLine, st::historyAudioRadialLine, st::historyAudioRadialLine)); const auto rinner = inner.marginsRemoved(QMargins(st::historyAudioRadialLine, st::historyAudioRadialLine, st::historyAudioRadialLine, st::historyAudioRadialLine));
auto fg = outbg ? (selected ? st::historyFileOutRadialFgSelected : st::historyFileOutRadialFg) : (selected ? st::historyFileInRadialFgSelected : st::historyFileInRadialFg); _animation->radial.draw(q, rinner, st::historyAudioRadialLine, stm->historyFileRadialFg);
_animation->radial.draw(q, rinner, st::historyAudioRadialLine, fg);
} }
}; };
if (bubblePattern) { if (bubblePattern) {
@ -1030,8 +980,8 @@ void Document::drawGrouped(
p.translate(geometry.topLeft()); p.translate(geometry.topLeft());
draw( draw(
p, p,
geometry.width(),
context.translated(-geometry.topLeft()), context.translated(-geometry.topLeft()),
geometry.width(),
LayoutMode::Grouped); LayoutMode::Grouped);
p.translate(-geometry.topLeft()); p.translate(-geometry.topLeft());
} }
@ -1147,6 +1097,7 @@ Ui::Text::String Document::createCaption() {
bool DrawThumbnailAsSongCover( bool DrawThumbnailAsSongCover(
Painter &p, Painter &p,
const style::color &colored,
const std::shared_ptr<Data::DocumentMedia> &dataMedia, const std::shared_ptr<Data::DocumentMedia> &dataMedia,
const QRect &rect, const QRect &rect,
const bool selected) { const bool selected) {
@ -1160,7 +1111,6 @@ bool DrawThumbnailAsSongCover(
const auto oh = rect.height(); const auto oh = rect.height();
const auto r = ImageRoundRadius::Ellipse; const auto r = ImageRoundRadius::Ellipse;
const auto c = RectPart::AllCorners; const auto c = RectPart::AllCorners;
const auto color = &st::songCoverOverlayFg;
const auto aspectRatio = Qt::KeepAspectRatioByExpanding; const auto aspectRatio = Qt::KeepAspectRatioByExpanding;
const auto scaled = [&](not_null<Image*> image) -> std::pair<int, int> { const auto scaled = [&](not_null<Image*> image) -> std::pair<int, int> {
@ -1170,10 +1120,10 @@ bool DrawThumbnailAsSongCover(
if (const auto normal = dataMedia->thumbnail()) { if (const auto normal = dataMedia->thumbnail()) {
const auto &[w, h] = scaled(normal); const auto &[w, h] = scaled(normal);
cover = normal->pixSingle(w, h, ow, oh, r, c, color); cover = normal->pixSingle(w, h, ow, oh, r, c, &colored);
} else if (const auto blurred = dataMedia->thumbnailInline()) { } else if (const auto blurred = dataMedia->thumbnailInline()) {
const auto &[w, h] = scaled(blurred); const auto &[w, h] = scaled(blurred);
cover = blurred->pixBlurredSingle(w, h, ow, oh, r, c, color); cover = blurred->pixBlurredSingle(w, h, ow, oh, r, c, &colored);
} else { } else {
return false; return false;
} }

View file

@ -106,8 +106,8 @@ private:
void draw( void draw(
Painter &p, Painter &p,
int width,
const PaintContext &context, const PaintContext &context,
int width,
LayoutMode mode) const; LayoutMode mode) const;
[[nodiscard]] TextState textState( [[nodiscard]] TextState textState(
QPoint point, QPoint point,
@ -146,6 +146,7 @@ private:
bool DrawThumbnailAsSongCover( bool DrawThumbnailAsSongCover(
Painter &p, Painter &p,
const style::color &colored,
const std::shared_ptr<Data::DocumentMedia> &dataMedia, const std::shared_ptr<Data::DocumentMedia> &dataMedia,
const QRect &rect, const QRect &rect,
const bool selected = false); const bool selected = false);

View file

@ -202,16 +202,12 @@ void Game::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 paintw = width(); auto paintw = width();
const auto outbg = _parent->hasOutLayout();
const auto selected = context.selected();
const auto st = context.st; const auto st = context.st;
const auto sti = context.imageStyle();
const auto stm = context.messageStyle();
const auto &barfg = selected const auto &barfg = stm->msgReplyBarColor;
? (outbg ? st::msgOutReplyBarSelColor : st::msgInReplyBarSelColor) const auto &semibold = stm->msgServiceFg;
: (outbg ? st->msgOutReplyBarColor() : st->msgInReplyBarColor());
const auto &semibold = selected
? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected)
: (outbg ? st->msgOutServiceFg() : st->msgInServiceFg());
QMargins bubble(_attach ? _attach->bubbleMargins() : QMargins()); QMargins bubble(_attach ? _attach->bubbleMargins() : QMargins());
auto padding = inBubblePadding(); auto padding = inBubblePadding();
@ -236,7 +232,7 @@ void Game::draw(Painter &p, const PaintContext &context) const {
tshift += _titleLines * lineHeight; tshift += _titleLines * lineHeight;
} }
if (_descriptionLines) { if (_descriptionLines) {
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); p.setPen(stm->webPageDescriptionFg);
auto endskip = 0; auto endskip = 0;
if (_description.hasSkipBlock()) { if (_description.hasSkipBlock()) {
endskip = _parent->skipBlockWidth(); endskip = _parent->skipBlockWidth();
@ -256,7 +252,9 @@ void Game::draw(Painter &p, const PaintContext &context) const {
_attach->draw(p, context.translated( _attach->draw(p, context.translated(
-attachLeft, -attachLeft,
-attachTop -attachTop
).withSelection(selected ? FullSelection : TextSelection())); ).withSelection(context.selected()
? FullSelection
: TextSelection()));
auto pixwidth = _attach->width(); auto pixwidth = _attach->width();
auto pixheight = _attach->height(); auto pixheight = _attach->height();
@ -265,7 +263,7 @@ void Game::draw(Painter &p, const PaintContext &context) const {
auto gameX = pixwidth - st::msgDateImgDelta - gameW; auto gameX = pixwidth - st::msgDateImgDelta - gameW;
auto gameY = pixheight - st::msgDateImgDelta - gameH; auto gameY = pixheight - st::msgDateImgDelta - gameH;
Ui::FillRoundRect(p, style::rtlrect(gameX, gameY, gameW, gameH, pixwidth), selected ? st->msgDateImgBgSelected() : st->msgDateImgBg(), selected ? st->msgDateImgBgSelectedCorners() : st->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);

View file

@ -284,6 +284,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
const auto loaded = dataLoaded(); const auto loaded = dataLoaded();
const auto displayLoading = item->isSending() || _data->displayLoading(); const auto displayLoading = item->isSending() || _data->displayLoading();
const auto st = context.st; const auto st = context.st;
const auto sti = context.imageStyle();
const auto stm = context.messageStyle(); const auto stm = context.messageStyle();
const auto selected = (context.selection == FullSelection); const auto selected = (context.selection == FullSelection);
const auto autoPaused = _parent->delegate()->elementIsGifPaused(); const auto autoPaused = _parent->delegate()->elementIsGifPaused();
@ -346,7 +347,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
} }
} }
} else if (!isRound) { } else if (!isRound) {
Ui::FillRoundShadow(p, 0, 0, paintw, height(), selected ? st::msgInShadowSelected : st::msgInShadow, selected ? Ui::InSelectedShadowCorners : Ui::InShadowCorners); Ui::FillRoundShadow(p, 0, 0, paintw, height(), sti->msgShadow, sti->msgShadowCorners);
} }
auto usex = 0, usew = paintw; auto usex = 0, usew = paintw;
@ -479,14 +480,14 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
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 (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.);
p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, over)); p.setBrush(anim::brush(st->msgDateImgBg(), st->msgDateImgBgOver(), over));
} else { } else {
const auto over = ClickHandler::showAsActive( const auto over = ClickHandler::showAsActive(
(_data->loading() || _data->uploading()) ? _cancell : _savel); (_data->loading() || _data->uploading()) ? _cancell : _savel);
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); p.setBrush(over ? st->msgDateImgBgOver() : st->msgDateImgBg());
} }
p.setOpacity(radialOpacity * p.opacity()); p.setOpacity(radialOpacity * p.opacity());
@ -539,7 +540,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
if (displayMute) { if (displayMute) {
auto muteRect = style::rtlrect(rthumb.x() + (rthumb.width() - st::historyVideoMessageMuteSize) / 2, rthumb.y() + st::msgDateImgDelta, st::historyVideoMessageMuteSize, st::historyVideoMessageMuteSize, width()); auto muteRect = style::rtlrect(rthumb.x() + (rthumb.width() - st::historyVideoMessageMuteSize) / 2, rthumb.y() + st::msgDateImgDelta, st::historyVideoMessageMuteSize, st::historyVideoMessageMuteSize, width());
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
p.setBrush(selected ? st::msgDateImgBgSelected : st::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); (selected ? st::historyVideoMessageMuteSelected : st::historyVideoMessageMute).paintInCenter(p, muteRect);
@ -558,7 +559,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
if (mediaUnread) { if (mediaUnread) {
statusW += st::mediaUnreadSkip + st::mediaUnreadSize; statusW += st::mediaUnreadSkip + st::mediaUnreadSize;
} }
Ui::FillRoundRect(p, style::rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), selected ? st->msgServiceBgSelected() : st->msgServiceBg(), selected ? st->msgServiceBgSelectedCorners() : st->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());
@ -589,12 +590,12 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
int recty = painty; int recty = painty;
if (rtl()) rectx = width() - rectx - rectw; if (rtl()) rectx = width() - rectx - rectw;
Ui::FillRoundRect(p, rectx, recty, rectw, recth, selected ? st->msgServiceBgSelected() : st->msgServiceBg(), selected ? st->msgServiceBgSelectedCorners() : st->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) {
p.setTextPalette(st::serviceTextPalette); p.setTextPalette(st->serviceTextPalette());
auto breakEverywhere = (forwardedHeightReal > forwardedHeight); auto breakEverywhere = (forwardedHeightReal > forwardedHeight);
forwarded->text.drawElided(p, rectx, recty + st::msgReplyPadding.top(), rectw, kMaxGifForwardedBarLines, style::al_left, 0, -1, 0, breakEverywhere); forwarded->text.drawElided(p, rectx, recty + st::msgReplyPadding.top(), rectw, kMaxGifForwardedBarLines, style::al_left, 0, -1, 0, breakEverywhere);
p.restoreTextPalette(); p.restoreTextPalette();
@ -674,7 +675,8 @@ void Gif::drawCornerStatus(
} }
const auto own = activeOwnStreamed(); const auto own = activeOwnStreamed();
const auto st = context.st; const auto st = context.st;
const auto selected = context.selected(); const auto sti = context.imageStyle();
const auto stm = context.messageStyle();
const auto text = (own && !own->frozenStatusText.isEmpty()) const auto text = (own && !own->frozenStatusText.isEmpty())
? own->frozenStatusText ? own->frozenStatusText
: _statusText; : _statusText;
@ -691,7 +693,7 @@ void Gif::drawCornerStatus(
const auto statusY = position.y() + st::msgDateImgDelta + padding.y(); const auto statusY = position.y() + st::msgDateImgDelta + padding.y();
const auto around = style::rtlrect(statusX - padding.x(), statusY - padding.y(), statusW, statusH, width()); const auto around = style::rtlrect(statusX - padding.x(), statusY - padding.y(), statusW, statusH, width());
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, selected ? st->msgDateImgBgSelected() : st->msgDateImgBg(), selected ? st->msgDateImgBgSelectedCorners() : st->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());
@ -699,21 +701,16 @@ void Gif::drawCornerStatus(
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();
p.drawTextLeft(statusX + addLeft, downloadTextTop, width(), _downloadSize, statusW - 2 * padding.x()); p.drawTextLeft(statusX + addLeft, downloadTextTop, width(), _downloadSize, statusW - 2 * padding.x());
const auto inner = QRect(statusX + padding.y() - padding.x(), statusY, st::historyVideoDownloadSize, st::historyVideoDownloadSize); const auto inner = QRect(statusX + padding.y() - padding.x(), statusY, st::historyVideoDownloadSize, st::historyVideoDownloadSize);
const auto icon = [&]() -> const style::icon * { const auto &icon = _data->loading()
if (_data->loading()) { ? sti->historyVideoCancel
return &(selected ? st::historyVideoCancelSelected : st::historyVideoCancel); : sti->historyVideoDownload;
} icon.paintInCenter(p, inner);
return &(selected ? st::historyVideoDownloadSelected : st::historyVideoDownload);
}();
if (icon) {
icon->paintInCenter(p, inner);
}
if (radial) { if (radial) {
QRect rinner(inner.marginsRemoved(QMargins(st::historyVideoRadialLine, st::historyVideoRadialLine, st::historyVideoRadialLine, st::historyVideoRadialLine))); QRect rinner(inner.marginsRemoved(QMargins(st::historyVideoRadialLine, st::historyVideoRadialLine, st::historyVideoRadialLine, st::historyVideoRadialLine)));
_animation->radial.draw(p, rinner, st::historyVideoRadialLine, selected ? st::historyFileThumbRadialFgSelected : st::historyFileThumbRadialFg); _animation->radial.draw(p, rinner, st::historyVideoRadialLine, sti->historyFileThumbRadialFg);
} }
} else if (cornerMute) { } else if (cornerMute) {
(selected ? st::historyVideoMessageMuteSelected : st::historyVideoMessageMute).paint(p, statusX - padding.x() - padding.y() + statusW - addRight, statusY - padding.y() + (statusH - st::historyVideoMessageMute.height()) / 2, width()); sti->historyVideoMessageMute.paint(p, statusX - padding.x() - padding.y() + statusW - addRight, statusY - padding.y() + (statusH - st::historyVideoMessageMute.height()) / 2, width());
} }
} }
@ -918,7 +915,8 @@ void Gif::drawGrouped(
const auto item = _parent->data(); const auto item = _parent->data();
const auto loaded = dataLoaded(); const auto loaded = dataLoaded();
const auto displayLoading = (item->id < 0) || _data->displayLoading(); const auto displayLoading = (item->id < 0) || _data->displayLoading();
const auto selected = (context.selection == FullSelection); const auto st = context.st;
const auto sti = context.imageStyle();
const auto autoPaused = _parent->delegate()->elementIsGifPaused(); const auto autoPaused = _parent->delegate()->elementIsGifPaused();
const auto fullFeatured = fullFeaturedGrouped(sides); const auto fullFeatured = fullFeaturedGrouped(sides);
const auto cornerDownload = fullFeatured && downloadInCorner(); const auto cornerDownload = fullFeatured && downloadInCorner();
@ -997,13 +995,13 @@ void Gif::drawGrouped(
p.drawPixmap(geometry, *cache); p.drawPixmap(geometry, *cache);
} }
const auto overlayOpacity = selected const auto overlayOpacity = context.selected()
? (1. - highlightOpacity) ? (1. - highlightOpacity)
: highlightOpacity; : highlightOpacity;
if (overlayOpacity > 0.) { if (overlayOpacity > 0.) {
p.setOpacity(overlayOpacity); p.setOpacity(overlayOpacity);
Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners); Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners);
if (!selected) { if (!context.selected()) {
Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners); Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners);
} }
p.setOpacity(1.); p.setOpacity(1.);
@ -1026,15 +1024,15 @@ void Gif::drawGrouped(
radialSize, radialSize,
radialSize); radialSize);
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.);
p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, over)); p.setBrush(anim::brush(st->msgDateImgBg(), st->msgDateImgBgOver(), over));
} else { } else {
auto over = ClickHandler::showAsActive( auto over = ClickHandler::showAsActive(
(_data->loading() || _data->uploading()) ? _cancell : _savel); (_data->loading() || _data->uploading()) ? _cancell : _savel);
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); p.setBrush(over ? st->msgDateImgBgOver() : st->msgDateImgBg());
} }
p.setOpacity(radialOpacity * p.opacity()); p.setOpacity(radialOpacity * p.opacity());
@ -1046,25 +1044,22 @@ void Gif::drawGrouped(
p.setOpacity(radialOpacity); p.setOpacity(radialOpacity);
const auto icon = [&]() -> const style::icon * { const auto icon = [&]() -> const style::icon * {
if (_data->waitingForAlbum()) { if (_data->waitingForAlbum()) {
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting); return &sti->historyFileThumbWaiting;
} else if (streamingMode && !_data->uploading()) { } else 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;
}();
const auto previous = [&]() -> const style::icon* {
if (_data->waitingForAlbum()) {
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
}
return nullptr;
}(); }();
const auto previous = _data->waitingForAlbum()
? &sti->historyFileThumbCancel
: nullptr;
if (icon) { if (icon) {
if (previous && radialOpacity > 0. && radialOpacity < 1.) { if (previous && radialOpacity > 0. && radialOpacity < 1.) {
PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner); PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner);
@ -1076,9 +1071,6 @@ void Gif::drawGrouped(
if (radial) { if (radial) {
const auto line = st::historyGroupRadialLine; const auto line = st::historyGroupRadialLine;
const auto rinner = inner.marginsRemoved({ line, line, line, line }); const auto rinner = inner.marginsRemoved({ line, line, line, line });
const auto fg = selected
? st::historyFileThumbRadialFgSelected
: st::historyFileThumbRadialFg;
if (streamedForWaiting && !_data->uploading()) { if (streamedForWaiting && !_data->uploading()) {
Ui::InfiniteRadialAnimation::Draw( Ui::InfiniteRadialAnimation::Draw(
p, p,
@ -1086,14 +1078,14 @@ void Gif::drawGrouped(
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);
} }
} }
} }

View file

@ -203,13 +203,11 @@ void Invoice::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 paintw = width(); auto paintw = width();
const auto outbg = _parent->hasOutLayout();
const auto selected = context.selected();
const auto st = context.st; const auto st = context.st;
const auto sti = context.imageStyle();
const auto stm = context.messageStyle();
auto &semibold = selected auto &semibold = stm->msgServiceFg;
? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected)
: (outbg ? st->msgOutServiceFg() : st->msgInServiceFg());
QMargins bubble(_attach ? _attach->bubbleMargins() : QMargins()); QMargins bubble(_attach ? _attach->bubbleMargins() : QMargins());
auto padding = inBubblePadding(); auto padding = inBubblePadding();
@ -223,7 +221,7 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
auto lineHeight = unitedLineHeight(); auto lineHeight = unitedLineHeight();
if (_titleHeight) { if (_titleHeight) {
p.setPen(semibold); p.setPen(semibold);
p.setTextPalette(selected ? (outbg ? st::outTextPaletteSelected : st::inTextPaletteSelected) : (outbg ? st::outSemiboldPalette : st::inSemiboldPalette)); p.setTextPalette(stm->semiboldPalette);
auto endskip = 0; auto endskip = 0;
if (_title.hasSkipBlock()) { if (_title.hasSkipBlock()) {
@ -232,10 +230,10 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
_title.drawLeftElided(p, padding.left(), tshift, paintw, width(), _titleHeight / lineHeight, style::al_left, 0, -1, endskip, false, context.selection); _title.drawLeftElided(p, padding.left(), tshift, paintw, width(), _titleHeight / lineHeight, style::al_left, 0, -1, endskip, false, context.selection);
tshift += _titleHeight; tshift += _titleHeight;
p.setTextPalette(selected ? (outbg ? st::outTextPaletteSelected : st::inTextPaletteSelected) : (outbg ? st::outTextPalette : st::inTextPalette)); p.setTextPalette(stm->textPalette);
} }
if (_descriptionHeight) { if (_descriptionHeight) {
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); p.setPen(stm->webPageDescriptionFg);
_description.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, toDescriptionSelection(context.selection)); _description.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, toDescriptionSelection(context.selection));
tshift += _descriptionHeight; tshift += _descriptionHeight;
} }
@ -251,7 +249,9 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
_attach->draw(p, context.translated( _attach->draw(p, context.translated(
-attachLeft, -attachLeft,
-attachTop -attachTop
).withSelection(selected ? FullSelection : TextSelection())); ).withSelection(context.selected()
? FullSelection
: TextSelection()));
auto pixwidth = _attach->width(); auto pixwidth = _attach->width();
auto available = _status.maxWidth(); auto available = _status.maxWidth();
@ -260,7 +260,7 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
auto statusX = st::msgDateImgDelta; auto statusX = st::msgDateImgDelta;
auto statusY = st::msgDateImgDelta; auto statusY = st::msgDateImgDelta;
Ui::FillRoundRect(p, style::rtlrect(statusX, statusY, statusW, statusH, pixwidth), selected ? st->msgDateImgBgSelected() : st->msgDateImgBg(), selected ? st->msgDateImgBgSelectedCorners() : st->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);
@ -268,7 +268,7 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
p.translate(-attachLeft, -attachTop); p.translate(-attachLeft, -attachTop);
} else { } else {
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); p.setPen(stm->webPageDescriptionFg);
_status.drawLeft(p, padding.left(), tshift + st::mediaInBubbleSkip, paintw, width()); _status.drawLeft(p, padding.left(), tshift + st::mediaInBubbleSkip, paintw, width());
} }
} }

View file

@ -152,8 +152,8 @@ 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();
auto outbg = _parent->hasOutLayout(); const auto sti = context.imageStyle();
bool selected = (context.selection == FullSelection); const auto stm = context.messageStyle();
if (bubble) { if (bubble) {
if (!_title.isEmpty() || !_description.isEmpty()) { if (!_title.isEmpty() || !_description.isEmpty()) {
@ -165,12 +165,12 @@ void Location::draw(Painter &p, const PaintContext &context) const {
auto textw = width() - st::msgPadding.left() - st::msgPadding.right(); auto textw = width() - st::msgPadding.left() - st::msgPadding.right();
if (!_title.isEmpty()) { if (!_title.isEmpty()) {
p.setPen(outbg ? st::webPageTitleOutFg : st::webPageTitleInFg); p.setPen(stm->webPageTitleFg);
_title.drawLeftElided(p, paintx + st::msgPadding.left(), painty, textw, width(), 2, style::al_left, 0, -1, 0, false, context.selection); _title.drawLeftElided(p, paintx + st::msgPadding.left(), painty, textw, width(), 2, style::al_left, 0, -1, 0, false, context.selection);
painty += qMin(_title.countHeight(textw), 2 * st::webPageTitleFont->height); painty += qMin(_title.countHeight(textw), 2 * st::webPageTitleFont->height);
} }
if (!_description.isEmpty()) { if (!_description.isEmpty()) {
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); p.setPen(stm->webPageDescriptionFg);
_description.drawLeftElided(p, paintx + st::msgPadding.left(), painty, textw, width(), 3, style::al_left, 0, -1, 0, false, toDescriptionSelection(context.selection)); _description.drawLeftElided(p, paintx + st::msgPadding.left(), painty, textw, width(), 3, style::al_left, 0, -1, 0, false, toDescriptionSelection(context.selection));
painty += qMin(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height); painty += qMin(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height);
} }
@ -179,7 +179,7 @@ void Location::draw(Painter &p, const PaintContext &context) const {
} }
painth -= painty; painth -= painty;
} else { } else {
Ui::FillRoundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? Ui::InSelectedShadowCorners : Ui::InShadowCorners); Ui::FillRoundShadow(p, 0, 0, paintw, painth, sti->msgShadow, sti->msgShadowCorners);
} }
auto roundRadius = ImageRoundRadius::Large; auto roundRadius = ImageRoundRadius::Large;
@ -202,7 +202,7 @@ void Location::draw(Painter &p, const PaintContext &context) const {
}; };
paintMarker(st::historyMapPoint); paintMarker(st::historyMapPoint);
paintMarker(st::historyMapPointInner); paintMarker(st::historyMapPointInner);
if (selected) { if (context.selected()) {
Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners); Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners);
} }

View file

@ -180,8 +180,8 @@ void UnwrappedMedia::drawSurrounding(
const HistoryMessageVia *via, const HistoryMessageVia *via,
const HistoryMessageReply *reply, const HistoryMessageReply *reply,
const HistoryMessageForwarded *forwarded) const { const HistoryMessageForwarded *forwarded) const {
const auto selected = context.selected();
const auto st = context.st; const auto st = context.st;
const auto sti = context.imageStyle();
const auto rightAligned = _parent->hasOutLayout() const auto rightAligned = _parent->hasOutLayout()
&& !_parent->delegate()->elementIsChatWide(); && !_parent->delegate()->elementIsChatWide();
const auto rightActionSize = _parent->rightActionSize(); const auto rightActionSize = _parent->rightActionSize();
@ -204,12 +204,12 @@ void UnwrappedMedia::drawSurrounding(
int recty = 0; int recty = 0;
if (rtl()) rectx = width() - rectx - rectw; if (rtl()) rectx = width() - rectx - rectw;
Ui::FillRoundRect(p, rectx, recty, rectw, recth, selected ? st->msgServiceBgSelected() : st->msgServiceBg(), selected ? st->msgServiceBgSelectedCorners() : st->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) {
p.setTextPalette(st::serviceTextPalette); p.setTextPalette(st->serviceTextPalette());
forwarded->text.drawElided(p, rectx, recty + st::msgReplyPadding.top(), rectw, kMaxForwardedBarLines, style::al_left, 0, -1, 0, surrounding.forwardedBreakEverywhere); forwarded->text.drawElided(p, rectx, recty + st::msgReplyPadding.top(), rectw, kMaxForwardedBarLines, style::al_left, 0, -1, 0, surrounding.forwardedBreakEverywhere);
p.restoreTextPalette(); p.restoreTextPalette();
} else if (via) { } else if (via) {

View file

@ -228,7 +228,9 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
ensureDataMediaCreated(); ensureDataMediaCreated();
_dataMedia->automaticLoad(_realParent->fullId(), _parent->data()); _dataMedia->automaticLoad(_realParent->fullId(), _parent->data());
auto selected = (context.selection == FullSelection); const auto st = context.st;
const auto sti = context.imageStyle();
const auto stm = context.messageStyle();
auto loaded = _dataMedia->loaded(); auto loaded = _dataMedia->loaded();
auto displayLoading = _data->displayLoading(); auto displayLoading = _data->displayLoading();
@ -248,7 +250,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
auto rthumb = style::rtlrect(paintx, painty, paintw, painth, width()); auto rthumb = style::rtlrect(paintx, painty, paintw, painth, width());
if (_serviceWidth > 0) { if (_serviceWidth > 0) {
paintUserpicFrame(p, rthumb.topLeft(), selected); paintUserpicFrame(p, context, rthumb.topLeft());
} else { } else {
if (bubble) { if (bubble) {
if (!_caption.isEmpty()) { if (!_caption.isEmpty()) {
@ -259,7 +261,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
rthumb = style::rtlrect(paintx, painty, paintw, painth, width()); rthumb = style::rtlrect(paintx, painty, paintw, painth, width());
} }
} else { } else {
Ui::FillRoundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? Ui::InSelectedShadowCorners : Ui::InShadowCorners); Ui::FillRoundShadow(p, 0, 0, paintw, painth, sti->msgShadow, sti->msgShadowCorners);
} }
auto inWebPage = (_parent->media() != this); auto inWebPage = (_parent->media() != this);
auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large; auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large;
@ -281,7 +283,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
} }
}(); }();
p.drawPixmap(rthumb.topLeft(), pix); p.drawPixmap(rthumb.topLeft(), pix);
if (selected) { if (context.selected()) {
Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners); Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners);
} }
} }
@ -292,14 +294,14 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
const auto innerSize = st::msgFileLayout.thumbSize; const auto innerSize = st::msgFileLayout.thumbSize;
QRect inner(rthumb.x() + (rthumb.width() - innerSize) / 2, rthumb.y() + (rthumb.height() - innerSize) / 2, innerSize, innerSize); QRect inner(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.); const auto over = _animation->a_thumbOver.value(1.);
p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, over)); p.setBrush(anim::brush(st->msgDateImgBg(), st->msgDateImgBgOver(), over));
} else { } else {
auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel); const auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel);
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); p.setBrush(over ? st->msgDateImgBgOver() : st->msgDateImgBg());
} }
p.setOpacity(radialOpacity * p.opacity()); p.setOpacity(radialOpacity * p.opacity());
@ -310,26 +312,20 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
} }
p.setOpacity(radialOpacity); p.setOpacity(radialOpacity);
auto icon = [&]() -> const style::icon* { const auto &icon = (radial || _data->loading())
if (radial || _data->loading()) { ? sti->historyFileThumbCancel
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); : sti->historyFileThumbDownload;
} icon.paintInCenter(p, inner);
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
}();
if (icon) {
icon->paintInCenter(p, inner);
}
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)));
_animation->radial.draw(p, rinner, st::msgFileRadialLine, selected ? st::historyFileThumbRadialFgSelected : st::historyFileThumbRadialFg); _animation->radial.draw(p, rinner, st::msgFileRadialLine, sti->historyFileThumbRadialFg);
} }
} }
// date // date
if (!_caption.isEmpty()) { if (!_caption.isEmpty()) {
auto outbg = _parent->hasOutLayout(); p.setPen(stm->historyTextFg);
p.setPen(outbg ? (selected ? st::historyTextOutFgSelected : st::historyTextOutFg) : (selected ? st::historyTextInFgSelected : st::historyTextInFg));
_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 + paintw; auto fullRight = paintx + paintw;
@ -353,8 +349,8 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
void Photo::paintUserpicFrame( void Photo::paintUserpicFrame(
Painter &p, Painter &p,
QPoint photoPosition, const PaintContext &context,
bool selected) const { QPoint photoPosition) const {
const auto autoplay = _data->videoCanBePlayed() && videoAutoplayEnabled(); const auto autoplay = _data->videoCanBePlayed() && videoAutoplayEnabled();
const auto startPlay = autoplay && !_streamed; const auto startPlay = autoplay && !_streamed;
if (startPlay) { if (startPlay) {
@ -365,6 +361,8 @@ void Photo::paintUserpicFrame(
const auto size = QSize{ _pixw, _pixh }; const auto size = QSize{ _pixw, _pixh };
const auto rect = QRect(photoPosition, size); const auto rect = QRect(photoPosition, size);
const auto st = context.st;
const auto sti = context.imageStyle();
if (_streamed if (_streamed
&& _streamed->instance.player().ready() && _streamed->instance.player().ready()
@ -409,22 +407,17 @@ void Photo::paintUserpicFrame(
const auto innerSize = st::msgFileLayout.thumbSize; const auto innerSize = st::msgFileLayout.thumbSize;
auto inner = QRect(rect.x() + (rect.width() - innerSize) / 2, rect.y() + (rect.height() - innerSize) / 2, innerSize, innerSize); auto inner = QRect(rect.x() + (rect.width() - innerSize) / 2, rect.y() + (rect.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 { } else {
const auto over = ClickHandler::showAsActive(_openl); const auto over = ClickHandler::showAsActive(_openl);
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); p.setBrush(over ? st->msgDateImgBgOver() : st->msgDateImgBg());
} }
{ {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.drawEllipse(inner); p.drawEllipse(inner);
} }
const auto icon = [&]() -> const style::icon * { sti->historyFileThumbPlay.paintInCenter(p, inner);
return &(selected ? st::historyFileThumbPlaySelected : st::historyFileThumbPlay);
}();
if (icon) {
icon->paintInCenter(p, inner);
}
} }
} }
@ -507,7 +500,8 @@ void Photo::drawGrouped(
validateGroupedCache(geometry, corners, cacheKey, cache); validateGroupedCache(geometry, corners, cacheKey, cache);
const auto selected = (context.selection == FullSelection); const auto st = context.st;
const auto sti = context.imageStyle();
const auto loaded = _dataMedia->loaded(); const auto loaded = _dataMedia->loaded();
const auto displayLoading = _data->displayLoading(); const auto displayLoading = _data->displayLoading();
const auto bubble = _parent->hasBubble(); const auto bubble = _parent->hasBubble();
@ -520,19 +514,16 @@ void Photo::drawGrouped(
} }
const auto radial = isRadialAnimation(); const auto radial = isRadialAnimation();
if (!bubble) {
// App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners);
}
p.drawPixmap(geometry.topLeft(), *cache); p.drawPixmap(geometry.topLeft(), *cache);
const auto overlayOpacity = selected const auto overlayOpacity = context.selected()
? (1. - highlightOpacity) ? (1. - highlightOpacity)
: highlightOpacity; : highlightOpacity;
if (overlayOpacity > 0.) { if (overlayOpacity > 0.) {
p.setOpacity(overlayOpacity); p.setOpacity(overlayOpacity);
const auto roundRadius = ImageRoundRadius::Large; const auto roundRadius = ImageRoundRadius::Large;
Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners); Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners);
if (!selected) { if (!context.selected()) {
Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners); Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners);
} }
p.setOpacity(1.); p.setOpacity(1.);
@ -555,14 +546,14 @@ void Photo::drawGrouped(
radialSize, radialSize,
radialSize); radialSize);
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.);
p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, over)); p.setBrush(anim::brush(st->msgDateImgBg(), st->msgDateImgBgOver(), over));
} else { } else {
auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel); auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel);
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); p.setBrush(over ? st->msgDateImgBgOver() : st->msgDateImgBg());
} }
p.setOpacity(backOpacity * p.opacity()); p.setOpacity(backOpacity * p.opacity());
@ -572,36 +563,25 @@ void Photo::drawGrouped(
p.drawEllipse(inner); p.drawEllipse(inner);
} }
const auto icon = [&]() -> const style::icon* { const auto &icon = _data->waitingForAlbum()
if (_data->waitingForAlbum()) { ? sti->historyFileThumbWaiting
return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting); : (radial || _data->loading())
} else if (radial || _data->loading()) { ? sti->historyFileThumbCancel
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); : sti->historyFileThumbDownload;
} const auto previous = _data->waitingForAlbum()
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload); ? &sti->historyFileThumbCancel
}(); : nullptr;
const auto previous = [&]() -> const style::icon* {
if (_data->waitingForAlbum()) {
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel);
}
return nullptr;
}();
p.setOpacity(backOpacity); p.setOpacity(backOpacity);
if (icon) { if (previous && radialOpacity > 0. && radialOpacity < 1.) {
if (previous && radialOpacity > 0. && radialOpacity < 1.) { PaintInterpolatedIcon(p, icon, *previous, radialOpacity, inner);
PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner); } else {
} else { icon.paintInCenter(p, inner);
icon->paintInCenter(p, inner);
}
} }
p.setOpacity(1); p.setOpacity(1);
if (radial) { if (radial) {
const auto line = st::historyGroupRadialLine; const auto line = st::historyGroupRadialLine;
const auto rinner = inner.marginsRemoved({ line, line, line, line }); const auto rinner = inner.marginsRemoved({ line, line, line, line });
const auto color = selected _animation->radial.draw(p, rinner, line, sti->historyFileThumbRadialFg);
? st::historyFileThumbRadialFgSelected
: st::historyFileThumbRadialFg;
_animation->radial.draw(p, rinner, line, color);
} }
} }
} }

View file

@ -131,8 +131,8 @@ private:
void streamingReady(::Media::Streaming::Information &&info); void streamingReady(::Media::Streaming::Information &&info);
void paintUserpicFrame( void paintUserpicFrame(
Painter &p, Painter &p,
QPoint photoPosition, const PaintContext &context,
bool selected) const; QPoint photoPosition) const;
not_null<PhotoData*> _data; not_null<PhotoData*> _data;
int _serviceWidth = 0; int _serviceWidth = 0;

View file

@ -160,7 +160,7 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const {
_dataMedia->automaticLoad(_realParent->fullId(), _parent->data()); _dataMedia->automaticLoad(_realParent->fullId(), _parent->data());
} }
const auto st = context.st; const auto st = context.st;
auto selected = (context.selection == FullSelection); const auto sti = context.imageStyle();
auto loaded = dataLoaded(); auto loaded = dataLoaded();
auto displayLoading = _data && _data->displayLoading(); auto displayLoading = _data && _data->displayLoading();
@ -179,7 +179,7 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const {
auto roundCorners = RectPart::AllCorners; auto roundCorners = RectPart::AllCorners;
validateThumbnail(); validateThumbnail();
p.drawPixmap(rthumb.topLeft(), _thumbnail); p.drawPixmap(rthumb.topLeft(), _thumbnail);
if (selected) { if (context.selected()) {
Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners); Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners);
} }
@ -188,7 +188,7 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const {
auto statusY = painty + st::msgDateImgDelta + st::msgDateImgPadding.y(); auto statusY = painty + st::msgDateImgDelta + st::msgDateImgPadding.y();
auto statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x(); auto statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x();
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()), selected ? st->msgDateImgBgSelected() : st->msgDateImgBg(), selected ? st->msgDateImgBgSelectedCorners() : st->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());
@ -199,14 +199,14 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const {
const auto innerSize = st::msgFileLayout.thumbSize; const auto innerSize = st::msgFileLayout.thumbSize;
QRect inner(rthumb.x() + (rthumb.width() - innerSize) / 2, rthumb.y() + (rthumb.height() - innerSize) / 2, innerSize, innerSize); QRect inner(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.);
p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, over)); p.setBrush(anim::brush(st->msgDateImgBg(), st->msgDateImgBgOver(), over));
} else { } else {
auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _openl); auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _openl);
p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); p.setBrush(over ? st->msgDateImgBgOver() : st->msgDateImgBg());
} }
p.setOpacity(radialOpacity * p.opacity()); p.setOpacity(radialOpacity * p.opacity());
@ -217,19 +217,14 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const {
} }
p.setOpacity(radialOpacity); p.setOpacity(radialOpacity);
auto icon = ([radial, this, selected]() -> const style::icon* { const auto &icon = (radial || _data->loading())
if (radial || _data->loading()) { ? sti->historyFileThumbCancel
return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); : sti->historyFileThumbDownload;
} icon.paintInCenter(p, inner);
return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload);
})();
if (icon) {
icon->paintInCenter(p, inner);
}
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)));
_animation->radial.draw(p, rinner, st::msgFileRadialLine, selected ? st::historyFileThumbRadialFgSelected : st::historyFileThumbRadialFg); _animation->radial.draw(p, rinner, st::msgFileRadialLine, sti->historyFileThumbRadialFg);
} }
} }
} }

View file

@ -453,6 +453,7 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
auto paintw = width(); auto paintw = width();
const auto st = context.st; const auto st = context.st;
const auto sti = context.imageStyle();
const auto stm = context.messageStyle(); const auto stm = context.messageStyle();
const auto selected = context.selected(); const auto selected = context.selected();
@ -573,7 +574,7 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
auto dateW = pixwidth - dateX - st::msgDateImgDelta; auto dateW = pixwidth - dateX - st::msgDateImgDelta;
auto dateH = pixheight - dateY - st::msgDateImgDelta; auto dateH = pixheight - dateY - st::msgDateImgDelta;
Ui::FillRoundRect(p, dateX, dateY, dateW, dateH, selected ? st->msgDateImgBgSelected() : st->msgDateImgBg(), selected ? st->msgDateImgBgSelectedCorners() : st->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);

View file

@ -874,7 +874,11 @@ void File::paint(Painter &p, const QRect &clip, const PaintContext *context) con
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
const auto coverDrawn = _document->isSongWithCover() const auto coverDrawn = _document->isSongWithCover()
&& HistoryView::DrawThumbnailAsSongCover(p, _documentMedia, inner); && HistoryView::DrawThumbnailAsSongCover(
p,
st::songCoverOverlayFg,
_documentMedia,
inner);
if (!coverDrawn) { if (!coverDrawn) {
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
if (isThumbAnimation()) { if (isThumbAnimation()) {
@ -903,7 +907,7 @@ void File::paint(Painter &p, const QRect &clip, const PaintContext *context) con
} else if (_document->isImage()) { } else if (_document->isImage()) {
return &st::historyFileInImage; return &st::historyFileInImage;
} else if (_document->isSongWithCover()) { } else if (_document->isSongWithCover()) {
return &st::historyFileSongPlay; return &st::historyFileThumbPlay;
} else if (_document->isVoiceMessage() } else if (_document->isVoiceMessage()
|| _document->isAudioFile()) { || _document->isAudioFile()) {
return &st::historyFileInPlay; return &st::historyFileInPlay;

View file

@ -1022,7 +1022,12 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
using namespace HistoryView; using namespace HistoryView;
const auto coverDrawn = _data->isSongWithCover() const auto coverDrawn = _data->isSongWithCover()
&& DrawThumbnailAsSongCover(p, _dataMedia, inner, selected); && DrawThumbnailAsSongCover(
p,
st::songCoverOverlayFg,
_dataMedia,
inner,
selected);
if (!coverDrawn) { if (!coverDrawn) {
if (selected) { if (selected) {
p.setBrush(st::msgFileInBgSelected); p.setBrush(st::msgFileInBgSelected);

View file

@ -80,14 +80,11 @@ void CreatePaletteCorners() {
PrepareCorners(DateCorners, st::dateRadius, st::msgDateImgBg); PrepareCorners(DateCorners, st::dateRadius, st::msgDateImgBg);
PrepareCorners(OverviewVideoCorners, st::overviewVideoStatusRadius, st::msgDateImgBg); PrepareCorners(OverviewVideoCorners, st::overviewVideoStatusRadius, st::msgDateImgBg);
PrepareCorners(OverviewVideoSelectedCorners, st::overviewVideoStatusRadius, st::msgDateImgBgSelected); PrepareCorners(OverviewVideoSelectedCorners, st::overviewVideoStatusRadius, st::msgDateImgBgSelected);
PrepareCorners(InShadowCorners, st::historyMessageRadius, st::msgInShadow);
PrepareCorners(InSelectedShadowCorners, st::historyMessageRadius, st::msgInShadowSelected);
PrepareCorners(ForwardCorners, st::historyMessageRadius, st::historyForwardChooseBg); PrepareCorners(ForwardCorners, st::historyMessageRadius, st::historyForwardChooseBg);
PrepareCorners(MediaviewSaveCorners, st::mediaviewControllerRadius, st::mediaviewSaveMsgBg); PrepareCorners(MediaviewSaveCorners, st::mediaviewControllerRadius, st::mediaviewSaveMsgBg);
PrepareCorners(EmojiHoverCorners, st::roundRadiusSmall, st::emojiPanHover); PrepareCorners(EmojiHoverCorners, st::roundRadiusSmall, st::emojiPanHover);
PrepareCorners(StickerHoverCorners, st::roundRadiusSmall, st::emojiPanHover); PrepareCorners(StickerHoverCorners, st::roundRadiusSmall, st::emojiPanHover);
PrepareCorners(BotKeyboardCorners, st::roundRadiusSmall, st::botKbBg); PrepareCorners(BotKeyboardCorners, st::roundRadiusSmall, st::botKbBg);
PrepareCorners(PhotoSelectOverlayCorners, st::roundRadiusSmall, st::overviewPhotoSelectOverlay);
PrepareCorners(Doc1Corners, st::roundRadiusSmall, st::msgFile1Bg); PrepareCorners(Doc1Corners, st::roundRadiusSmall, st::msgFile1Bg);
PrepareCorners(Doc2Corners, st::roundRadiusSmall, st::msgFile2Bg); PrepareCorners(Doc2Corners, st::roundRadiusSmall, st::msgFile2Bg);
@ -207,7 +204,10 @@ void FillRoundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color
} }
void FillRoundShadow(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color shadow, CachedRoundCorners index, RectParts parts) { void FillRoundShadow(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color shadow, CachedRoundCorners index, RectParts parts) {
auto &corner = Corners[index]; FillRoundShadow(p, x, y, w, h, shadow, Corners[index], parts);
}
void FillRoundShadow(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color shadow, const CornersPixmaps &corner, RectParts parts) {
auto cornerWidth = corner.p[0].width() / style::DevicePixelRatio(); auto cornerWidth = corner.p[0].width() / style::DevicePixelRatio();
auto cornerHeight = corner.p[0].height() / style::DevicePixelRatio(); auto cornerHeight = corner.p[0].height() / style::DevicePixelRatio();
if (parts & RectPart::Bottom) { if (parts & RectPart::Bottom) {

View file

@ -32,16 +32,12 @@ enum CachedRoundCorners : int {
EmojiHoverCorners, EmojiHoverCorners,
StickerHoverCorners, StickerHoverCorners,
BotKeyboardCorners, BotKeyboardCorners,
PhotoSelectOverlayCorners,
Doc1Corners, Doc1Corners,
Doc2Corners, Doc2Corners,
Doc3Corners, Doc3Corners,
Doc4Corners, Doc4Corners,
InShadowCorners, // for photos without bg
InSelectedShadowCorners,
MessageInCorners, // with shadow MessageInCorners, // with shadow
RoundCornersCount RoundCornersCount
@ -75,6 +71,10 @@ void FillRoundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color
inline void FillRoundRect(Painter &p, const QRect &rect, style::color bg, const CornersPixmaps &corner, const style::color *shadow = nullptr, RectParts parts = RectPart::Full) { inline void FillRoundRect(Painter &p, const QRect &rect, style::color bg, const CornersPixmaps &corner, const style::color *shadow = nullptr, RectParts parts = RectPart::Full) {
return FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, corner, shadow, parts); return FillRoundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, corner, shadow, parts);
} }
void FillRoundShadow(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color shadow, const CornersPixmaps &corner, RectParts parts = RectPart::Full);
inline void FillRoundShadow(Painter &p, const QRect &rect, style::color shadow, const CornersPixmaps &corner, RectParts parts = RectPart::Full) {
FillRoundShadow(p, rect.x(), rect.y(), rect.width(), rect.height(), shadow, corner, parts);
}
void StartCachedCorners(); void StartCachedCorners();
void FinishCachedCorners(); void FinishCachedCorners();

View file

@ -114,7 +114,7 @@ void AbstractSingleFilePreview::paintEvent(QPaintEvent *e) {
auto &icon = _data.fileIsAudio auto &icon = _data.fileIsAudio
? (_data.fileThumb.isNull() ? (_data.fileThumb.isNull()
? st::historyFileInPlay ? st::historyFileInPlay
: st::historyFileSongPlay) : st::historyFileThumbPlay)
: _data.fileIsImage : _data.fileIsImage
? st::historyFileInImage ? st::historyFileInImage
: st::historyFileInDocument; : st::historyFileInDocument;

View file

@ -93,6 +93,7 @@ void ItemSingleFilePreview::preparePreview(not_null<DocumentData*> document) {
HistoryView::DrawThumbnailAsSongCover( HistoryView::DrawThumbnailAsSongCover(
p, p,
st::songCoverOverlayFg,
_documentMedia, _documentMedia,
QRect(QPoint(), size)); QRect(QPoint(), size));
data.fileThumb = std::move(thumb); data.fileThumb = std::move(thumb);

View file

@ -159,17 +159,8 @@ historyFileOutWaitingSelected: icon {{ "mediaview_save_check", historyFileOutIco
historyFileInWaiting: icon {{ "mediaview_save_check", historyFileInIconFg }}; historyFileInWaiting: icon {{ "mediaview_save_check", historyFileInIconFg }};
historyFileInWaitingSelected: icon {{ "mediaview_save_check", historyFileInIconFgSelected }}; historyFileInWaitingSelected: icon {{ "mediaview_save_check", historyFileInIconFgSelected }};
historyFileSongPause: icon {{ "history_file_pause", historyFileThumbIconFg }}; historyFileThumbPause: icon {{ "history_file_pause", historyFileThumbIconFg }};
historyFileSongPauseSelected: icon {{ "history_file_pause", historyFileThumbIconFgSelected }}; historyFileThumbPauseSelected: icon {{ "history_file_pause", historyFileThumbIconFgSelected }};
historyFileSongPlay: icon {{ "history_file_play", historyFileThumbIconFg }};
historyFileSongPlaySelected: icon {{ "history_file_play", historyFileThumbIconFgSelected }};
historyFileSongCancel: icon {{ "history_file_cancel", historyFileThumbIconFg }};
historyFileSongCancelSelected: icon {{ "history_file_cancel", historyFileThumbIconFgSelected }};
historyFileSongDownload: icon {{ "history_file_download", historyFileThumbIconFg }};
historyFileSongDownloadSelected: icon {{ "history_file_download", historyFileThumbIconFgSelected }};
historyFileSongWaiting: icon {{ "mediaview_save_check", historyFileThumbIconFg }};
historyFileSongWaitingSelected: icon {{ "mediaview_save_check", historyFileThumbIconFgSelected }};
historyFileThumbDownload: icon {{ "history_file_download", historyFileThumbIconFg }}; historyFileThumbDownload: icon {{ "history_file_download", historyFileThumbIconFg }};
historyFileThumbDownloadSelected: icon {{ "history_file_download", historyFileThumbIconFgSelected }}; historyFileThumbDownloadSelected: icon {{ "history_file_download", historyFileThumbIconFgSelected }};
historyFileThumbCancel: icon {{ "history_file_cancel", historyFileThumbIconFg }}; historyFileThumbCancel: icon {{ "history_file_cancel", historyFileThumbIconFg }};

View file

@ -31,6 +31,10 @@ not_null<const MessageStyle*> ChatPaintContext::messageStyle() const {
return &st->messageStyle(outbg, selected()); return &st->messageStyle(outbg, selected());
} }
not_null<const MessageImageStyle*> ChatPaintContext::imageStyle() const {
return &st->imageStyle(selected());
}
int HistoryServiceMsgRadius() { int HistoryServiceMsgRadius() {
static const auto result = [] { static const auto result = [] {
const auto minMessageHeight = st::msgServicePadding.top() const auto minMessageHeight = st::msgServicePadding.top()
@ -114,6 +118,24 @@ ChatStyle::ChatStyle() {
st::msgFileInBgSelected, st::msgFileInBgSelected,
st::msgFileOutBg, st::msgFileOutBg,
st::msgFileOutBgSelected); st::msgFileOutBgSelected);
make(
&MessageStyle::msgReplyBarColor,
st::msgInReplyBarColor,
st::msgInReplyBarSelColor,
st::msgOutReplyBarColor,
st::msgOutReplyBarSelColor);
make(
&MessageStyle::msgWaveformActive,
st::msgWaveformInActive,
st::msgWaveformInActiveSelected,
st::msgWaveformOutActive,
st::msgWaveformOutActiveSelected);
make(
&MessageStyle::msgWaveformInactive,
st::msgWaveformInInactive,
st::msgWaveformInInactiveSelected,
st::msgWaveformOutInactive,
st::msgWaveformOutInactiveSelected);
make( make(
&MessageStyle::historyTextFg, &MessageStyle::historyTextFg,
st::historyTextInFg, st::historyTextInFg,
@ -121,11 +143,23 @@ ChatStyle::ChatStyle() {
st::historyTextOutFg, st::historyTextOutFg,
st::historyTextOutFgSelected); st::historyTextOutFgSelected);
make( make(
&MessageStyle::msgReplyBarColor, &MessageStyle::historyFileNameFg,
st::msgInReplyBarColor, st::historyFileNameInFg,
st::msgInReplyBarSelColor, st::historyFileNameInFgSelected,
st::msgOutReplyBarColor, st::historyFileNameOutFg,
st::msgOutReplyBarSelColor); st::historyFileNameOutFgSelected);
make(
&MessageStyle::historyFileRadialFg,
st::historyFileInRadialFg,
st::historyFileInRadialFgSelected,
st::historyFileOutRadialFg,
st::historyFileOutRadialFgSelected);
make(
&MessageStyle::mediaFg,
st::mediaInFg,
st::mediaInFgSelected,
st::mediaOutFg,
st::mediaOutFgSelected);
make( make(
&MessageStyle::webPageTitleFg, &MessageStyle::webPageTitleFg,
st::webPageTitleInFg, st::webPageTitleInFg,
@ -144,6 +178,12 @@ ChatStyle::ChatStyle() {
st::inTextPaletteSelected, st::inTextPaletteSelected,
st::outTextPalette, st::outTextPalette,
st::outTextPaletteSelected); st::outTextPaletteSelected);
make(
&MessageStyle::semiboldPalette,
st::inSemiboldPalette,
st::inTextPaletteSelected,
st::outSemiboldPalette,
st::outTextPaletteSelected);
make( make(
&MessageStyle::fwdTextPalette, &MessageStyle::fwdTextPalette,
st::inFwdTextPalette, st::inFwdTextPalette,
@ -216,6 +256,132 @@ ChatStyle::ChatStyle() {
st::historyCommentsInSelected, st::historyCommentsInSelected,
st::historyCommentsOut, st::historyCommentsOut,
st::historyCommentsOutSelected); st::historyCommentsOutSelected);
make(
&MessageStyle::historyCallArrow,
st::historyCallArrowIn,
st::historyCallArrowInSelected,
st::historyCallArrowOut,
st::historyCallArrowOutSelected);
make(
&MessageStyle::historyCallArrowMissed,
st::historyCallArrowMissedIn,
st::historyCallArrowMissedInSelected,
st::historyCallArrowMissedIn,
st::historyCallArrowMissedInSelected);
make(
&MessageStyle::historyCallIcon,
st::historyCallInIcon,
st::historyCallInIconSelected,
st::historyCallOutIcon,
st::historyCallOutIconSelected);
make(
&MessageStyle::historyCallCameraIcon,
st::historyCallCameraInIcon,
st::historyCallCameraInIconSelected,
st::historyCallCameraOutIcon,
st::historyCallCameraOutIconSelected);
make(
&MessageStyle::historyFilePlay,
st::historyFileInPlay,
st::historyFileInPlaySelected,
st::historyFileOutPlay,
st::historyFileOutPlaySelected);
make(
&MessageStyle::historyFileWaiting,
st::historyFileInWaiting,
st::historyFileInWaitingSelected,
st::historyFileOutWaiting,
st::historyFileOutWaitingSelected);
make(
&MessageStyle::historyFileDownload,
st::historyFileInDownload,
st::historyFileInDownloadSelected,
st::historyFileOutDownload,
st::historyFileOutDownloadSelected);
make(
&MessageStyle::historyFileCancel,
st::historyFileInCancel,
st::historyFileInCancelSelected,
st::historyFileOutCancel,
st::historyFileOutCancelSelected);
make(
&MessageStyle::historyFilePause,
st::historyFileInPause,
st::historyFileInPauseSelected,
st::historyFileOutPause,
st::historyFileOutPauseSelected);
make(
&MessageStyle::historyFileImage,
st::historyFileInImage,
st::historyFileInImageSelected,
st::historyFileOutImage,
st::historyFileOutImageSelected);
make(
&MessageStyle::historyFileDocument,
st::historyFileInDocument,
st::historyFileInDocumentSelected,
st::historyFileOutDocument,
st::historyFileOutDocumentSelected);
make(
&MessageStyle::historyAudioDownload,
st::historyAudioInDownload,
st::historyAudioInDownloadSelected,
st::historyAudioOutDownload,
st::historyAudioOutDownloadSelected);
make(
&MessageStyle::historyAudioCancel,
st::historyAudioInCancel,
st::historyAudioInCancelSelected,
st::historyAudioOutCancel,
st::historyAudioOutCancelSelected);
make(
&MessageImageStyle::msgDateImgBg,
st::msgDateImgBg,
st::msgDateImgBgSelected);
make(
&MessageImageStyle::msgServiceBg,
st::msgServiceBg,
st::msgServiceBgSelected);
make(
&MessageImageStyle::msgShadow,
st::msgInShadow,
st::msgInShadowSelected);
make(
&MessageImageStyle::historyFileThumbRadialFg,
st::historyFileThumbRadialFg,
st::historyFileThumbRadialFgSelected);
make(
&MessageImageStyle::historyFileThumbPlay,
st::historyFileThumbPlay,
st::historyFileThumbPlaySelected);
make(
&MessageImageStyle::historyFileThumbWaiting,
st::historyFileThumbWaiting,
st::historyFileThumbWaitingSelected);
make(
&MessageImageStyle::historyFileThumbDownload,
st::historyFileThumbDownload,
st::historyFileThumbDownloadSelected);
make(
&MessageImageStyle::historyFileThumbCancel,
st::historyFileThumbCancel,
st::historyFileThumbCancelSelected);
make(
&MessageImageStyle::historyFileThumbPause,
st::historyFileThumbPause,
st::historyFileThumbPauseSelected);
make(
&MessageImageStyle::historyVideoDownload,
st::historyVideoDownload,
st::historyVideoDownloadSelected);
make(
&MessageImageStyle::historyVideoCancel,
st::historyVideoCancel,
st::historyVideoCancelSelected);
make(
&MessageImageStyle::historyVideoMessageMute,
st::historyVideoMessageMute,
st::historyVideoMessageMuteSelected);
} }
void ChatStyle::apply(not_null<ChatTheme*> theme) { void ChatStyle::apply(not_null<ChatTheme*> theme) {
@ -239,13 +405,14 @@ void ChatStyle::assignPalette(not_null<const style::palette*> palette) {
for (auto &style : _messageStyles) { for (auto &style : _messageStyles) {
style.corners = {}; style.corners = {};
} }
for (auto &style : _imageStyles) {
style.msgDateImgBgCorners = {};
style.msgServiceBgCorners = {};
style.msgShadowCorners = {};
}
_serviceBgCornersNormal = {}; _serviceBgCornersNormal = {};
_serviceBgCornersInverted = {}; _serviceBgCornersInverted = {};
_msgServiceBgCorners = {};
_msgServiceBgSelectedCorners = {};
_msgBotKbOverBgAddCorners = {}; _msgBotKbOverBgAddCorners = {};
_msgDateImgBgCorners = {};
_msgDateImgBgSelectedCorners = {};
} }
const CornersPixmaps &ChatStyle::serviceBgCornersNormal() const { const CornersPixmaps &ChatStyle::serviceBgCornersNormal() const {
@ -286,17 +453,21 @@ const MessageStyle &ChatStyle::messageStyle(bool outbg, bool selected) const {
return result; return result;
} }
const CornersPixmaps &ChatStyle::msgServiceBgCorners() const { const MessageImageStyle &ChatStyle::imageStyle(bool selected) const {
EnsureCorners(_msgServiceBgCorners, st::dateRadius, msgServiceBg()); auto &result = imageStyleRaw(selected);
return _msgServiceBgCorners;
}
const CornersPixmaps &ChatStyle::msgServiceBgSelectedCorners() const {
EnsureCorners( EnsureCorners(
_msgServiceBgSelectedCorners, result.msgDateImgBgCorners,
st::dateRadius, st::dateRadius,
msgServiceBgSelected()); result.msgDateImgBg);
return _msgServiceBgSelectedCorners; EnsureCorners(
result.msgServiceBgCorners,
st::dateRadius,
result.msgServiceBg);
EnsureCorners(
result.msgShadowCorners,
st::historyMessageRadius,
result.msgShadow);
return result;
} }
const CornersPixmaps &ChatStyle::msgBotKbOverBgAddCorners() const { const CornersPixmaps &ChatStyle::msgBotKbOverBgAddCorners() const {
@ -307,26 +478,38 @@ const CornersPixmaps &ChatStyle::msgBotKbOverBgAddCorners() const {
return _msgBotKbOverBgAddCorners; return _msgBotKbOverBgAddCorners;
} }
const CornersPixmaps &ChatStyle::msgDateImgBgCorners() const {
EnsureCorners(
_msgDateImgBgCorners,
st::dateRadius,
msgDateImgBg());
return _msgDateImgBgCorners;
}
const CornersPixmaps &ChatStyle::msgDateImgBgSelectedCorners() const {
EnsureCorners(
_msgDateImgBgSelectedCorners,
st::dateRadius,
msgDateImgBgSelected());
return _msgDateImgBgSelectedCorners;
}
MessageStyle &ChatStyle::messageStyleRaw(bool outbg, bool selected) const { MessageStyle &ChatStyle::messageStyleRaw(bool outbg, bool selected) const {
return _messageStyles[(outbg ? 2 : 0) + (selected ? 1 : 0)]; return _messageStyles[(outbg ? 2 : 0) + (selected ? 1 : 0)];
} }
MessageStyle &ChatStyle::messageIn() {
return messageStyleRaw(false, false);
}
MessageStyle &ChatStyle::messageInSelected() {
return messageStyleRaw(false, true);
}
MessageStyle &ChatStyle::messageOut() {
return messageStyleRaw(true, false);
}
MessageStyle &ChatStyle::messageOutSelected() {
return messageStyleRaw(true, true);
}
MessageImageStyle &ChatStyle::imageStyleRaw(bool selected) const {
return _imageStyles[selected ? 1 : 0];
}
MessageImageStyle &ChatStyle::image() {
return imageStyleRaw(false);
}
MessageImageStyle &ChatStyle::imageSelected() {
return imageStyleRaw(true);
}
void ChatStyle::make(style::color &my, const style::color &original) { void ChatStyle::make(style::color &my, const style::color &original) {
my = _colors[style::main_palette::indexOfColor(original)]; my = _colors[style::main_palette::indexOfColor(original)];
} }
@ -347,22 +530,6 @@ void ChatStyle::make(
make(my.selectOverlay, original.selectOverlay); make(my.selectOverlay, original.selectOverlay);
} }
MessageStyle &ChatStyle::messageIn() {
return messageStyleRaw(false, false);
}
MessageStyle &ChatStyle::messageInSelected() {
return messageStyleRaw(false, true);
}
MessageStyle &ChatStyle::messageOut() {
return messageStyleRaw(true, false);
}
MessageStyle &ChatStyle::messageOutSelected() {
return messageStyleRaw(true, true);
}
template <typename Type> template <typename Type>
void ChatStyle::make( void ChatStyle::make(
Type MessageStyle::*my, Type MessageStyle::*my,
@ -376,4 +543,13 @@ void ChatStyle::make(
make(messageOutSelected().*my, originalOutSelected); make(messageOutSelected().*my, originalOutSelected);
} }
template <typename Type>
void ChatStyle::make(
Type MessageImageStyle::*my,
const Type &original,
const Type &originalSelected) {
make(image().*my, original);
make(imageSelected().*my, originalSelected);
}
} // namespace Ui } // namespace Ui

View file

@ -25,11 +25,17 @@ struct MessageStyle {
style::color msgDateFg; style::color msgDateFg;
style::color msgFileThumbLinkFg; style::color msgFileThumbLinkFg;
style::color msgFileBg; style::color msgFileBg;
style::color historyTextFg;
style::color msgReplyBarColor; style::color msgReplyBarColor;
style::color msgWaveformActive;
style::color msgWaveformInactive;
style::color historyTextFg;
style::color historyFileNameFg;
style::color historyFileRadialFg;
style::color mediaFg;
style::color webPageTitleFg; style::color webPageTitleFg;
style::color webPageDescriptionFg; style::color webPageDescriptionFg;
style::TextPalette textPalette; style::TextPalette textPalette;
style::TextPalette semiboldPalette;
style::TextPalette fwdTextPalette; style::TextPalette fwdTextPalette;
style::TextPalette replyTextPalette; style::TextPalette replyTextPalette;
style::icon tailLeft = { Qt::Uninitialized }; style::icon tailLeft = { Qt::Uninitialized };
@ -42,6 +48,37 @@ struct MessageStyle {
style::icon historyPsaIcon = { Qt::Uninitialized }; style::icon historyPsaIcon = { Qt::Uninitialized };
style::icon historyCommentsOpen = { Qt::Uninitialized }; style::icon historyCommentsOpen = { Qt::Uninitialized };
style::icon historyComments = { Qt::Uninitialized }; style::icon historyComments = { Qt::Uninitialized };
style::icon historyCallArrow = { Qt::Uninitialized };
style::icon historyCallArrowMissed = { Qt::Uninitialized };
style::icon historyCallIcon = { Qt::Uninitialized };
style::icon historyCallCameraIcon = { Qt::Uninitialized };
style::icon historyFilePlay = { Qt::Uninitialized };
style::icon historyFileWaiting = { Qt::Uninitialized };
style::icon historyFileDownload = { Qt::Uninitialized };
style::icon historyFileCancel = { Qt::Uninitialized };
style::icon historyFilePause = { Qt::Uninitialized };
style::icon historyFileImage = { Qt::Uninitialized };
style::icon historyFileDocument = { Qt::Uninitialized };
style::icon historyAudioDownload = { Qt::Uninitialized };
style::icon historyAudioCancel = { Qt::Uninitialized };
};
struct MessageImageStyle {
CornersPixmaps msgDateImgBgCorners;
CornersPixmaps msgServiceBgCorners;
CornersPixmaps msgShadowCorners;
style::color msgServiceBg;
style::color msgDateImgBg;
style::color msgShadow;
style::color historyFileThumbRadialFg;
style::icon historyFileThumbPlay = { Qt::Uninitialized };
style::icon historyFileThumbWaiting = { Qt::Uninitialized };
style::icon historyFileThumbDownload = { Qt::Uninitialized };
style::icon historyFileThumbCancel = { Qt::Uninitialized };
style::icon historyFileThumbPause = { Qt::Uninitialized };
style::icon historyVideoDownload = { Qt::Uninitialized };
style::icon historyVideoCancel = { Qt::Uninitialized };
style::icon historyVideoMessageMute = { Qt::Uninitialized };
}; };
struct ChatPaintContext { struct ChatPaintContext {
@ -65,6 +102,7 @@ struct ChatPaintContext {
return (selection == FullSelection); return (selection == FullSelection);
} }
[[nodiscard]] not_null<const MessageStyle*> messageStyle() const; [[nodiscard]] not_null<const MessageStyle*> messageStyle() const;
[[nodiscard]] not_null<const MessageImageStyle*> imageStyle() const;
[[nodiscard]] ChatPaintContext translated(int x, int y) const { [[nodiscard]] ChatPaintContext translated(int x, int y) const {
auto result = *this; auto result = *this;
@ -99,12 +137,9 @@ public:
[[nodiscard]] const MessageStyle &messageStyle( [[nodiscard]] const MessageStyle &messageStyle(
bool outbg, bool outbg,
bool selected) const; bool selected) const;
[[nodiscard]] const MessageImageStyle &imageStyle(bool selected) const;
[[nodiscard]] const CornersPixmaps &msgServiceBgCorners() const;
[[nodiscard]] const CornersPixmaps &msgServiceBgSelectedCorners() const;
[[nodiscard]] const CornersPixmaps &msgBotKbOverBgAddCorners() const; [[nodiscard]] const CornersPixmaps &msgBotKbOverBgAddCorners() const;
[[nodiscard]] const CornersPixmaps &msgDateImgBgCorners() const;
[[nodiscard]] const CornersPixmaps &msgDateImgBgSelectedCorners() const;
[[nodiscard]] const style::TextPalette &historyPsaForwardPalette() const { [[nodiscard]] const style::TextPalette &historyPsaForwardPalette() const {
return _historyPsaForwardPalette; return _historyPsaForwardPalette;
@ -176,6 +211,10 @@ private:
[[nodiscard]] MessageStyle &messageOut(); [[nodiscard]] MessageStyle &messageOut();
[[nodiscard]] MessageStyle &messageOutSelected(); [[nodiscard]] MessageStyle &messageOutSelected();
[[nodiscard]] MessageImageStyle &imageStyleRaw(bool selected) const;
[[nodiscard]] MessageImageStyle &image();
[[nodiscard]] MessageImageStyle &imageSelected();
template <typename Type> template <typename Type>
void make( void make(
Type MessageStyle::*my, Type MessageStyle::*my,
@ -184,16 +223,19 @@ private:
const Type &originalOut, const Type &originalOut,
const Type &originalOutSelected); const Type &originalOutSelected);
template <typename Type>
void make(
Type MessageImageStyle::*my,
const Type &original,
const Type &originalSelected);
mutable CornersPixmaps _serviceBgCornersNormal; mutable CornersPixmaps _serviceBgCornersNormal;
mutable CornersPixmaps _serviceBgCornersInverted; mutable CornersPixmaps _serviceBgCornersInverted;
mutable std::array<MessageStyle, 4> _messageStyles; mutable std::array<MessageStyle, 4> _messageStyles;
mutable std::array<MessageImageStyle, 2> _imageStyles;
mutable CornersPixmaps _msgServiceBgCorners;
mutable CornersPixmaps _msgServiceBgSelectedCorners;
mutable CornersPixmaps _msgBotKbOverBgAddCorners; mutable CornersPixmaps _msgBotKbOverBgAddCorners;
mutable CornersPixmaps _msgDateImgBgCorners;
mutable CornersPixmaps _msgDateImgBgSelectedCorners;
style::TextPalette _historyPsaForwardPalette; style::TextPalette _historyPsaForwardPalette;
style::TextPalette _imgReplyTextPalette; style::TextPalette _imgReplyTextPalette;