diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 904d21a21b..d211ed2a92 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -109,7 +109,8 @@ void KeyboardStyle::paintButtonBg( float64 howMuchOver) const { 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) { auto o = p.opacity(); p.setOpacity(o * howMuchOver); @@ -1691,8 +1692,9 @@ void Message::drawInfo( InfoDisplayType type) const { p.setFont(st::msgDateFont); - const auto stm = context.messageStyle(); const auto st = context.st; + const auto sti = context.imageStyle(); + const auto stm = context.messageStyle(); bool invertedsprites = (type == InfoDisplayType::Image) || (type == InfoDisplayType::Background); int32 infoRight = right, infoBottom = bottom; @@ -1723,10 +1725,10 @@ void Message::drawInfo( auto dateY = infoBottom - st::msgDateFont->height; if (type == InfoDisplayType::Image) { 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) { 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(); diff --git a/Telegram/SourceFiles/history/view/media/history_view_call.cpp b/Telegram/SourceFiles/history/view/media/history_view_call.cpp index c63b818f21..96c56df1a1 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_call.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_call.cpp @@ -77,8 +77,7 @@ void Call::draw(Painter &p, const PaintContext &context) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintw = width(); - auto outbg = _parent->hasOutLayout(); - auto selected = (context.selection == FullSelection); + const auto stm = context.messageStyle(); accumulate_min(paintw, maxWidth()); @@ -90,27 +89,25 @@ void Call::draw(Painter &p, const PaintContext &context) const { statustop = st::historyCallStatusTop - topMinus; 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); auto statusleft = nameleft; - auto missed = (_reason == FinishReason::Missed || _reason == FinishReason::Busy); - auto &arrow = outbg ? (selected ? st::historyCallArrowOutSelected : st::historyCallArrowOut) : missed ? (selected ? st::historyCallArrowMissedInSelected : st::historyCallArrowMissedIn) : (selected ? st::historyCallArrowInSelected : st::historyCallArrowIn); + auto missed = (_reason == FinishReason::Missed) + || (_reason == FinishReason::Busy); + const auto &arrow = missed + ? stm->historyCallArrowMissed + : stm->historyCallArrow; arrow.paint(p, statusleft + st::historyCallArrowPosition.x(), statustop + st::historyCallArrowPosition.y(), paintw); statusleft += arrow.width() + st::historyCallStatusSkip; - auto &statusFg = outbg ? (selected ? st::mediaOutFgSelected : st::mediaOutFg) : (selected ? st::mediaInFgSelected : st::mediaInFg); p.setFont(st::normalFont); - p.setPen(statusFg); + p.setPen(stm->mediaFg); p.drawTextLeft(statusleft, statustop, paintw, _status); const auto &icon = _video - ? (outbg - ? (selected ? st::historyCallCameraOutIconSelected : st::historyCallCameraOutIcon) - : (selected ? st::historyCallCameraInIconSelected : st::historyCallCameraInIcon)) - : (outbg - ? (selected ? st::historyCallOutIconSelected : st::historyCallOutIcon) - : (selected ? st::historyCallInIconSelected : st::historyCallInIcon)); + ? stm->historyCallCameraIcon + : stm->historyCallIcon; icon.paint(p, paintw - st::historyCallIconPosition.x() - icon.width(), st::historyCallIconPosition.y() - topMinus, paintw); } diff --git a/Telegram/SourceFiles/history/view/media/history_view_contact.cpp b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp index d89a081b56..18d3d0017f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_contact.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp @@ -158,8 +158,7 @@ void Contact::draw(Painter &p, const PaintContext &context) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintw = width(); - auto outbg = _parent->hasOutLayout(); - bool selected = (context.selection == FullSelection); + const auto stm = context.messageStyle(); accumulate_min(paintw, maxWidth()); @@ -182,7 +181,7 @@ void Contact::draw(Painter &p, const PaintContext &context) const { } else { _photoEmpty->paint(p, st.padding.left(), st.padding.top() - topMinus, paintw, st.thumbSize); } - if (selected) { + if (context.selected()) { PainterHighQualityEnabler hq(p); p.setBrush(p.textPalette().selectOverlay); p.setPen(Qt::NoPen); @@ -191,7 +190,7 @@ void Contact::draw(Painter &p, const PaintContext &context) const { bool over = ClickHandler::showAsActive(_linkl); 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); } else { _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; 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); - auto &status = outbg ? (selected ? st::mediaOutFgSelected : st::mediaOutFg) : (selected ? st::mediaInFgSelected : st::mediaInFg); p.setFont(st::normalFont); - p.setPen(status); + p.setPen(stm->mediaFg); p.drawTextLeft(nameleft, statustop, paintw, _phone); } diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index 9ab49b96ee..3e204f1451 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -68,10 +68,9 @@ constexpr auto kAudioVoiceMsgUpdateView = crl::time(100); void PaintWaveform( Painter &p, + const PaintContext &context, const VoiceData *voiceData, int availableWidth, - bool selected, - bool outbg, float64 progress) { const auto wf = [&]() -> const VoiceWaveform* { if (!voiceData) { @@ -84,22 +83,11 @@ void PaintWaveform( } return &voiceData->waveform; }(); + const auto stm = context.messageStyle(); // Rescale waveform by going in waveform.size * bar_count 1D grid. - const auto active = outbg - ? (selected - ? 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 active = stm->msgWaveformActive; + const auto inactive = stm->msgWaveformInactive; const auto wfSize = wf ? wf->size() : ::Media::Player::kWaveformSamplesCount; @@ -327,13 +315,13 @@ QSize Document::countCurrentSize(int newWidth) { } void Document::draw(Painter &p, const PaintContext &context) const { - draw(p, width(), context, LayoutMode::Full); + draw(p, context, width(), LayoutMode::Full); } void Document::draw( Painter &p, - int width, const PaintContext &context, + int width, LayoutMode mode) const { if (width < st::msgPadding.left() + st::msgPadding.right() + 1) return; @@ -345,10 +333,10 @@ void Document::draw( _dataMedia->automaticLoad(_realParent->fullId(), _realParent); } 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(); - auto outbg = _parent->hasOutLayout(); if (displayLoading) { ensureAnimation(); @@ -384,7 +372,7 @@ void Document::draw( thumb = blurred->pixBlurredSingle(thumbed->_thumbw, 0, st.thumbSize, st.thumbSize, roundRadius); } p.drawPixmap(rthumb.topLeft(), thumb); - if (selected) { + if (context.selected()) { auto overlayCorners = inWebPage ? Ui::SelectedOverlaySmallCorners : Ui::SelectedOverlayLargeCorners; Ui::FillRoundRect(p, rthumb, p.textPalette().selectOverlay, overlayCorners); } @@ -392,11 +380,7 @@ void Document::draw( if (radial || (!loaded && !_data->loading()) || _data->waitingForAlbum()) { const auto backOpacity = (loaded && !_data->uploading()) ? radialOpacity : 1.; p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgDateImgBgSelected); - } else { - p.setBrush(st::msgDateImgBg); - } + p.setBrush(sti->msgDateImgBg); p.setOpacity(backOpacity * p.opacity()); { @@ -404,30 +388,24 @@ void Document::draw( p.drawEllipse(inner); } - const auto icon = [&] { - if (_data->waitingForAlbum()) { - return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting); - } else if (radial || _data->loading()) { - return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); - } - return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload); - }(); - const auto previous = [&]() -> const style::icon* { - if (_data->waitingForAlbum()) { - return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); - } - return nullptr; - }(); + const auto &icon = _data->waitingForAlbum() + ? sti->historyFileThumbWaiting + : (radial || _data->loading()) + ? sti->historyFileThumbCancel + : sti->historyFileThumbDownload; + const auto previous = _data->waitingForAlbum() + ? &sti->historyFileThumbCancel + : nullptr; p.setOpacity(backOpacity); if (previous && radialOpacity > 0. && radialOpacity < 1.) { - PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner); + PaintInterpolatedIcon(p, icon, *previous, radialOpacity, inner); } else { - icon->paintInCenter(p, inner); + icon.paintInCenter(p, inner); } p.setOpacity(1.); if (radial) { 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; bool over = ClickHandler::showAsActive(lnk); 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); } } else { p.setPen(Qt::NoPen); const auto coverDrawn = _data->isSongWithCover() - && DrawThumbnailAsSongCover(p, _dataMedia, inner, selected); + && DrawThumbnailAsSongCover( + p, + context.st->songCoverOverlayFg(), + _dataMedia, + inner, + context.selected()); if (!coverDrawn) { PainterHighQualityEnabler hq(p); - p.setBrush(selected - ? (outbg ? st::msgFileOutBgSelected : st::msgFileInBgSelected) - : (outbg ? st::msgFileOutBg : st::msgFileInBg)); + p.setBrush(stm->msgFileBg); p.drawEllipse(inner); } - const auto icon = [&] { + const auto &icon = [&]() -> const style::icon& { if (_data->waitingForAlbum()) { - if (_data->isSongWithCover()) { - return &(selected - ? st::historyFileSongWaitingSelected - : st::historyFileSongWaiting); - } - return &(outbg ? (selected ? st::historyFileOutWaitingSelected : st::historyFileOutWaiting) : (selected ? st::historyFileInWaitingSelected : st::historyFileInWaiting)); - } else if (!cornerDownload && (_data->loading() || _data->uploading())) { - if (_data->isSongWithCover()) { - return &(selected - ? st::historyFileSongCancelSelected - : st::historyFileSongCancel); - } - return &(outbg ? (selected ? st::historyFileOutCancelSelected : st::historyFileOutCancel) : (selected ? st::historyFileInCancelSelected : st::historyFileInCancel)); + return _data->isSongWithCover() + ? sti->historyFileThumbWaiting + : stm->historyFileWaiting; + } else if (!cornerDownload + && (_data->loading() || _data->uploading())) { + return _data->isSongWithCover() + ? sti->historyFileThumbCancel + : stm->historyFileCancel; } else if (showPause) { - if (_data->isSongWithCover()) { - return &(selected - ? st::historyFileSongPauseSelected - : st::historyFileSongPause); - } - return &(outbg ? (selected ? st::historyFileOutPauseSelected : st::historyFileOutPause) : (selected ? st::historyFileInPauseSelected : st::historyFileInPause)); + return _data->isSongWithCover() + ? sti->historyFileThumbPause + : stm->historyFilePause; } else if (loaded || _dataMedia->canBePlayed()) { - if (_dataMedia->canBePlayed()) { - if (_data->isSongWithCover()) { - return &(selected - ? st::historyFileSongPlaySelected - : st::historyFileSongPlay); - } - return &(outbg ? (selected ? st::historyFileOutPlaySelected : st::historyFileOutPlay) : (selected ? st::historyFileInPlaySelected : st::historyFileInPlay)); - } else if (_data->isImage()) { - return &(outbg ? (selected ? st::historyFileOutImageSelected : st::historyFileOutImage) : (selected ? st::historyFileInImageSelected : st::historyFileInImage)); - } - return &(outbg ? (selected ? st::historyFileOutDocumentSelected : st::historyFileOutDocument) : (selected ? st::historyFileInDocumentSelected : st::historyFileInDocument)); + return _dataMedia->canBePlayed() + ? (_data->isSongWithCover() + ? sti->historyFileThumbPlay + : stm->historyFilePlay) + : _data->isImage() + ? stm->historyFileImage + : stm->historyFileDocument; + } else { + return _data->isSongWithCover() + ? sti->historyFileThumbDownload + : 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) { if (previous && radialOpacity > 0. && radialOpacity < 1.) { - PaintInterpolatedIcon(q, *icon, *previous, radialOpacity, inner); + PaintInterpolatedIcon(q, icon, *previous, radialOpacity, inner); } else { - icon->paintInCenter(q, inner); + icon.paintInCenter(q, inner); } if (radial && !cornerDownload) { 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, fg); + _animation->radial.draw(q, rinner, st::msgFileRadialLine, stm->historyFileRadialFg); } }; if (_data->isSongWithCover() || !usesBubblePattern(context)) { @@ -547,7 +510,7 @@ void Document::draw( } const auto progress = [&] { - if (!outbg + if (!context.outbg && !voice->_playback && _realParent->hasUnreadMediaFlag()) { return 1.; @@ -568,15 +531,14 @@ void Document::draw( p.save(); p.translate(nameleft, st.padding.top() - topMinus); PaintWaveform(p, + context, _data->voice(), namewidth + st::msgWaveformSkip, - selected, - outbg, progress); p.restore(); } else if (auto named = Get()) { 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) { p.drawTextLeft(nameleft, nametop, width, st::semiboldFont->elided(named->_name, namewidth, Qt::ElideMiddle)); } else { @@ -585,16 +547,15 @@ void Document::draw( } auto statusText = voiceStatusOverride.isEmpty() ? _statusText : voiceStatusOverride; - auto status = outbg ? (selected ? st::mediaOutFgSelected : st::mediaOutFg) : (selected ? st::mediaInFgSelected : st::mediaInFg); p.setFont(st::normalFont); - p.setPen(status); + p.setPen(stm->mediaFg); p.drawTextLeft(nameleft, statustop, width, statusText); if (_realParent->hasUnreadMediaFlag()) { auto w = st::normalFont->width(statusText); if (w + st::mediaUnreadSkip + st::mediaUnreadSize <= statuswidth) { p.setPen(Qt::NoPen); - p.setBrush(outbg ? (selected ? st::msgFileOutBgSelected : st::msgFileOutBg) : (selected ? st::msgFileInBgSelected : st::msgFileInBg)); + p.setBrush(stm->msgFileBg); { PainterHighQualityEnabler hq(p); @@ -604,7 +565,7 @@ void Document::draw( } if (auto captioned = Get()) { - 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); } } @@ -644,9 +605,8 @@ void Document::drawCornerDownload( || !downloadInCorner()) { return; } - auto outbg = _parent->hasOutLayout(); auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus; - const auto selected = (context.selection == FullSelection); + const auto stm = context.messageStyle(); const auto thumbed = false; const auto &st = (mode == LayoutMode::Full) ? (thumbed ? st::msgFileThumbLayout : st::msgFileLayout) @@ -658,41 +618,31 @@ void Document::drawCornerDownload( if (bubblePattern) { p.setPen(Qt::NoPen); } else { - auto pen = (selected - ? (outbg ? st::msgOutBgSelected : st::msgInBgSelected) - : (outbg ? st::msgOutBg : st::msgInBg))->p; + auto pen = stm->msgBg->p; pen.setWidth(st::lineWidth); p.setPen(pen); } - if (selected) { - p.setBrush(outbg ? st::msgFileOutBgSelected : st::msgFileInBgSelected); - } else { - p.setBrush(outbg ? st::msgFileOutBg : st::msgFileInBg); - } + p.setBrush(stm->msgFileBg); { PainterHighQualityEnabler hq(p); p.drawEllipse(inner); } - const auto icon = [&] { - if (_data->loading()) { - return &(outbg ? (selected ? st::historyAudioOutCancelSelected : st::historyAudioOutCancel) : (selected ? st::historyAudioInCancelSelected : st::historyAudioInCancel)); - } - return &(outbg ? (selected ? st::historyAudioOutDownloadSelected : st::historyAudioOutDownload) : (selected ? st::historyAudioInDownloadSelected : st::historyAudioInDownload)); - }(); + const auto &icon = _data->loading() + ? stm->historyAudioCancel + : stm->historyAudioDownload; const auto paintContent = [&](Painter &q) { if (bubblePattern) { auto hq = PainterHighQualityEnabler(q); - auto pen = st::msgOutBg->p; + auto pen = stm->msgBg->p; pen.setWidth(st::lineWidth); q.setPen(pen); q.setBrush(Qt::NoBrush); q.drawEllipse(inner); } - icon->paintInCenter(q, inner); + icon.paintInCenter(q, inner); if (_animation && _animation->radial.animating()) { 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, fg); + _animation->radial.draw(q, rinner, st::historyAudioRadialLine, stm->historyFileRadialFg); } }; if (bubblePattern) { @@ -1030,8 +980,8 @@ void Document::drawGrouped( p.translate(geometry.topLeft()); draw( p, - geometry.width(), context.translated(-geometry.topLeft()), + geometry.width(), LayoutMode::Grouped); p.translate(-geometry.topLeft()); } @@ -1147,6 +1097,7 @@ Ui::Text::String Document::createCaption() { bool DrawThumbnailAsSongCover( Painter &p, + const style::color &colored, const std::shared_ptr &dataMedia, const QRect &rect, const bool selected) { @@ -1160,7 +1111,6 @@ bool DrawThumbnailAsSongCover( const auto oh = rect.height(); const auto r = ImageRoundRadius::Ellipse; const auto c = RectPart::AllCorners; - const auto color = &st::songCoverOverlayFg; const auto aspectRatio = Qt::KeepAspectRatioByExpanding; const auto scaled = [&](not_null image) -> std::pair { @@ -1170,10 +1120,10 @@ bool DrawThumbnailAsSongCover( if (const auto normal = dataMedia->thumbnail()) { 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()) { 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 { return false; } diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.h b/Telegram/SourceFiles/history/view/media/history_view_document.h index 420495104b..8834b4e3bf 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.h +++ b/Telegram/SourceFiles/history/view/media/history_view_document.h @@ -106,8 +106,8 @@ private: void draw( Painter &p, - int width, const PaintContext &context, + int width, LayoutMode mode) const; [[nodiscard]] TextState textState( QPoint point, @@ -146,6 +146,7 @@ private: bool DrawThumbnailAsSongCover( Painter &p, + const style::color &colored, const std::shared_ptr &dataMedia, const QRect &rect, const bool selected = false); diff --git a/Telegram/SourceFiles/history/view/media/history_view_game.cpp b/Telegram/SourceFiles/history/view/media/history_view_game.cpp index de4d3b57fc..eede604294 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_game.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_game.cpp @@ -202,16 +202,12 @@ void Game::draw(Painter &p, const PaintContext &context) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintw = width(); - const auto outbg = _parent->hasOutLayout(); - const auto selected = context.selected(); const auto st = context.st; + const auto sti = context.imageStyle(); + const auto stm = context.messageStyle(); - const auto &barfg = selected - ? (outbg ? st::msgOutReplyBarSelColor : st::msgInReplyBarSelColor) - : (outbg ? st->msgOutReplyBarColor() : st->msgInReplyBarColor()); - const auto &semibold = selected - ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) - : (outbg ? st->msgOutServiceFg() : st->msgInServiceFg()); + const auto &barfg = stm->msgReplyBarColor; + const auto &semibold = stm->msgServiceFg; QMargins bubble(_attach ? _attach->bubbleMargins() : QMargins()); auto padding = inBubblePadding(); @@ -236,7 +232,7 @@ void Game::draw(Painter &p, const PaintContext &context) const { tshift += _titleLines * lineHeight; } if (_descriptionLines) { - p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); + p.setPen(stm->webPageDescriptionFg); auto endskip = 0; if (_description.hasSkipBlock()) { endskip = _parent->skipBlockWidth(); @@ -256,7 +252,9 @@ void Game::draw(Painter &p, const PaintContext &context) const { _attach->draw(p, context.translated( -attachLeft, -attachTop - ).withSelection(selected ? FullSelection : TextSelection())); + ).withSelection(context.selected() + ? FullSelection + : TextSelection())); auto pixwidth = _attach->width(); auto pixheight = _attach->height(); @@ -265,7 +263,7 @@ void Game::draw(Painter &p, const PaintContext &context) const { auto gameX = pixwidth - st::msgDateImgDelta - gameW; 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.setPen(st::msgDateImgFg); diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 5fc6d6049b..7ad7b1c324 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -284,6 +284,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { const auto loaded = dataLoaded(); const auto displayLoading = item->isSending() || _data->displayLoading(); const auto st = context.st; + const auto sti = context.imageStyle(); const auto stm = context.messageStyle(); const auto selected = (context.selection == FullSelection); const auto autoPaused = _parent->delegate()->elementIsGifPaused(); @@ -346,7 +347,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { } } } 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; @@ -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); p.setPen(Qt::NoPen); if (selected) { - p.setBrush(st::msgDateImgBgSelected); + p.setBrush(st->msgDateImgBgSelected()); } else if (isThumbAnimation()) { 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 { const auto over = ClickHandler::showAsActive( (_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()); @@ -539,7 +540,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { if (displayMute) { 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.setBrush(selected ? st::msgDateImgBgSelected : st::msgDateImgBg); + p.setBrush(sti->msgDateImgBg); PainterHighQualityEnabler hq(p); p.drawEllipse(muteRect); (selected ? st::historyVideoMessageMuteSelected : st::historyVideoMessageMute).paintInCenter(p, muteRect); @@ -558,7 +559,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { if (mediaUnread) { 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.setPen(st::msgServiceFg); 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; 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); rectx += st::msgReplyPadding.left(); rectw = innerw; if (forwarded) { - p.setTextPalette(st::serviceTextPalette); + p.setTextPalette(st->serviceTextPalette()); auto breakEverywhere = (forwardedHeightReal > forwardedHeight); forwarded->text.drawElided(p, rectx, recty + st::msgReplyPadding.top(), rectw, kMaxGifForwardedBarLines, style::al_left, 0, -1, 0, breakEverywhere); p.restoreTextPalette(); @@ -674,7 +675,8 @@ void Gif::drawCornerStatus( } const auto own = activeOwnStreamed(); 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()) ? own->frozenStatusText : _statusText; @@ -691,7 +693,7 @@ void Gif::drawCornerStatus( 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 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.setPen(st::msgDateImgFg); 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(); 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 icon = [&]() -> const style::icon * { - if (_data->loading()) { - return &(selected ? st::historyVideoCancelSelected : st::historyVideoCancel); - } - return &(selected ? st::historyVideoDownloadSelected : st::historyVideoDownload); - }(); - if (icon) { - icon->paintInCenter(p, inner); - } + const auto &icon = _data->loading() + ? sti->historyVideoCancel + : sti->historyVideoDownload; + icon.paintInCenter(p, inner); if (radial) { 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) { - (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 loaded = dataLoaded(); 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 fullFeatured = fullFeaturedGrouped(sides); const auto cornerDownload = fullFeatured && downloadInCorner(); @@ -997,13 +995,13 @@ void Gif::drawGrouped( p.drawPixmap(geometry, *cache); } - const auto overlayOpacity = selected + const auto overlayOpacity = context.selected() ? (1. - highlightOpacity) : highlightOpacity; if (overlayOpacity > 0.) { p.setOpacity(overlayOpacity); Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners); - if (!selected) { + if (!context.selected()) { Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners); } p.setOpacity(1.); @@ -1026,15 +1024,15 @@ void Gif::drawGrouped( radialSize, radialSize); p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgDateImgBgSelected); + if (context.selected()) { + p.setBrush(st->msgDateImgBgSelected()); } else if (isThumbAnimation()) { 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 { auto over = ClickHandler::showAsActive( (_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()); @@ -1046,25 +1044,22 @@ void Gif::drawGrouped( p.setOpacity(radialOpacity); const auto icon = [&]() -> const style::icon * { if (_data->waitingForAlbum()) { - return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting); + return &sti->historyFileThumbWaiting; } else if (streamingMode && !_data->uploading()) { return nullptr; } else if ((loaded || canBePlayed) && (!radial || cornerDownload)) { - return &(selected ? st::historyFileThumbPlaySelected : st::historyFileThumbPlay); + return &sti->historyFileThumbPlay; } else if (radial || _data->loading()) { if (!item->isSending() || _data->uploading()) { - return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); + return &sti->historyFileThumbCancel; } return nullptr; } - return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload); - }(); - const auto previous = [&]() -> const style::icon* { - if (_data->waitingForAlbum()) { - return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); - } - return nullptr; + return &sti->historyFileThumbDownload; }(); + const auto previous = _data->waitingForAlbum() + ? &sti->historyFileThumbCancel + : nullptr; if (icon) { if (previous && radialOpacity > 0. && radialOpacity < 1.) { PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner); @@ -1076,9 +1071,6 @@ void Gif::drawGrouped( if (radial) { const auto line = st::historyGroupRadialLine; const auto rinner = inner.marginsRemoved({ line, line, line, line }); - const auto fg = selected - ? st::historyFileThumbRadialFgSelected - : st::historyFileThumbRadialFg; if (streamedForWaiting && !_data->uploading()) { Ui::InfiniteRadialAnimation::Draw( p, @@ -1086,14 +1078,14 @@ void Gif::drawGrouped( rinner.topLeft(), rinner.size(), width(), - fg, + sti->historyFileThumbRadialFg, st::msgFileRadialLine); } else if (!cornerDownload) { _animation->radial.draw( p, rinner, st::msgFileRadialLine, - fg); + sti->historyFileThumbRadialFg); } } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp b/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp index bf8db0c2d1..5a09d05909 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp @@ -203,13 +203,11 @@ void Invoice::draw(Painter &p, const PaintContext &context) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintw = width(); - const auto outbg = _parent->hasOutLayout(); - const auto selected = context.selected(); const auto st = context.st; + const auto sti = context.imageStyle(); + const auto stm = context.messageStyle(); - auto &semibold = selected - ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) - : (outbg ? st->msgOutServiceFg() : st->msgInServiceFg()); + auto &semibold = stm->msgServiceFg; QMargins bubble(_attach ? _attach->bubbleMargins() : QMargins()); auto padding = inBubblePadding(); @@ -223,7 +221,7 @@ void Invoice::draw(Painter &p, const PaintContext &context) const { auto lineHeight = unitedLineHeight(); if (_titleHeight) { p.setPen(semibold); - p.setTextPalette(selected ? (outbg ? st::outTextPaletteSelected : st::inTextPaletteSelected) : (outbg ? st::outSemiboldPalette : st::inSemiboldPalette)); + p.setTextPalette(stm->semiboldPalette); auto endskip = 0; 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); tshift += _titleHeight; - p.setTextPalette(selected ? (outbg ? st::outTextPaletteSelected : st::inTextPaletteSelected) : (outbg ? st::outTextPalette : st::inTextPalette)); + p.setTextPalette(stm->textPalette); } 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)); tshift += _descriptionHeight; } @@ -251,7 +249,9 @@ void Invoice::draw(Painter &p, const PaintContext &context) const { _attach->draw(p, context.translated( -attachLeft, -attachTop - ).withSelection(selected ? FullSelection : TextSelection())); + ).withSelection(context.selected() + ? FullSelection + : TextSelection())); auto pixwidth = _attach->width(); auto available = _status.maxWidth(); @@ -260,7 +260,7 @@ void Invoice::draw(Painter &p, const PaintContext &context) const { auto statusX = 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.setPen(st::msgDateImgFg); @@ -268,7 +268,7 @@ void Invoice::draw(Painter &p, const PaintContext &context) const { p.translate(-attachLeft, -attachTop); } else { - p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg); + p.setPen(stm->webPageDescriptionFg); _status.drawLeft(p, padding.left(), tshift + st::mediaInBubbleSkip, paintw, width()); } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_location.cpp b/Telegram/SourceFiles/history/view/media/history_view_location.cpp index 96607b8fea..abbfb06d9f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_location.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_location.cpp @@ -152,8 +152,8 @@ void Location::draw(Painter &p, const PaintContext &context) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintx = 0, painty = 0, paintw = width(), painth = height(); bool bubble = _parent->hasBubble(); - auto outbg = _parent->hasOutLayout(); - bool selected = (context.selection == FullSelection); + const auto sti = context.imageStyle(); + const auto stm = context.messageStyle(); if (bubble) { 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(); 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); painty += qMin(_title.countHeight(textw), 2 * st::webPageTitleFont->height); } 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)); painty += qMin(_description.countHeight(textw), 3 * st::webPageDescriptionFont->height); } @@ -179,7 +179,7 @@ void Location::draw(Painter &p, const PaintContext &context) const { } painth -= painty; } 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; @@ -202,7 +202,7 @@ void Location::draw(Painter &p, const PaintContext &context) const { }; paintMarker(st::historyMapPoint); paintMarker(st::historyMapPointInner); - if (selected) { + if (context.selected()) { Ui::FillComplexOverlayRect(p, rthumb, roundRadius, roundCorners); } diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp index 994f1a4e66..e99b436bd1 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp @@ -180,8 +180,8 @@ void UnwrappedMedia::drawSurrounding( const HistoryMessageVia *via, const HistoryMessageReply *reply, const HistoryMessageForwarded *forwarded) const { - const auto selected = context.selected(); const auto st = context.st; + const auto sti = context.imageStyle(); const auto rightAligned = _parent->hasOutLayout() && !_parent->delegate()->elementIsChatWide(); const auto rightActionSize = _parent->rightActionSize(); @@ -204,12 +204,12 @@ void UnwrappedMedia::drawSurrounding( int recty = 0; 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); rectx += st::msgReplyPadding.left(); rectw -= st::msgReplyPadding.left() + st::msgReplyPadding.right(); 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); p.restoreTextPalette(); } else if (via) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index 0d16252c06..0b95e5b182 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -228,7 +228,9 @@ void Photo::draw(Painter &p, const PaintContext &context) const { ensureDataMediaCreated(); _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 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()); if (_serviceWidth > 0) { - paintUserpicFrame(p, rthumb.topLeft(), selected); + paintUserpicFrame(p, context, rthumb.topLeft()); } else { if (bubble) { if (!_caption.isEmpty()) { @@ -259,7 +261,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const { rthumb = style::rtlrect(paintx, painty, paintw, painth, width()); } } 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 roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large; @@ -281,7 +283,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const { } }(); p.drawPixmap(rthumb.topLeft(), pix); - if (selected) { + if (context.selected()) { 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; QRect inner(rthumb.x() + (rthumb.width() - innerSize) / 2, rthumb.y() + (rthumb.height() - innerSize) / 2, innerSize, innerSize); p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgDateImgBgSelected); + if (context.selected()) { + p.setBrush(st->msgDateImgBgSelected()); } else if (isThumbAnimation()) { - auto over = _animation->a_thumbOver.value(1.); - p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, over)); + const auto over = _animation->a_thumbOver.value(1.); + p.setBrush(anim::brush(st->msgDateImgBg(), st->msgDateImgBgOver(), over)); } else { - auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel); - p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); + const auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel); + p.setBrush(over ? st->msgDateImgBgOver() : st->msgDateImgBg()); } p.setOpacity(radialOpacity * p.opacity()); @@ -310,26 +312,20 @@ void Photo::draw(Painter &p, const PaintContext &context) const { } p.setOpacity(radialOpacity); - auto icon = [&]() -> const style::icon* { - if (radial || _data->loading()) { - return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); - } - return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload); - }(); - if (icon) { - icon->paintInCenter(p, inner); - } + const auto &icon = (radial || _data->loading()) + ? sti->historyFileThumbCancel + : sti->historyFileThumbDownload; + icon.paintInCenter(p, inner); p.setOpacity(1); if (radial) { 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 if (!_caption.isEmpty()) { - auto outbg = _parent->hasOutLayout(); - p.setPen(outbg ? (selected ? st::historyTextOutFgSelected : st::historyTextOutFg) : (selected ? st::historyTextInFgSelected : st::historyTextInFg)); + p.setPen(stm->historyTextFg); _caption.draw(p, st::msgPadding.left(), painty + painth + st::mediaCaptionSkip, captionw, style::al_left, 0, -1, context.selection); } else if (!inWebPage) { auto fullRight = paintx + paintw; @@ -353,8 +349,8 @@ void Photo::draw(Painter &p, const PaintContext &context) const { void Photo::paintUserpicFrame( Painter &p, - QPoint photoPosition, - bool selected) const { + const PaintContext &context, + QPoint photoPosition) const { const auto autoplay = _data->videoCanBePlayed() && videoAutoplayEnabled(); const auto startPlay = autoplay && !_streamed; if (startPlay) { @@ -365,6 +361,8 @@ void Photo::paintUserpicFrame( const auto size = QSize{ _pixw, _pixh }; const auto rect = QRect(photoPosition, size); + const auto st = context.st; + const auto sti = context.imageStyle(); if (_streamed && _streamed->instance.player().ready() @@ -409,22 +407,17 @@ void Photo::paintUserpicFrame( const auto innerSize = st::msgFileLayout.thumbSize; auto inner = QRect(rect.x() + (rect.width() - innerSize) / 2, rect.y() + (rect.height() - innerSize) / 2, innerSize, innerSize); p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgDateImgBgSelected); + if (context.selected()) { + p.setBrush(st->msgDateImgBgSelected()); } else { const auto over = ClickHandler::showAsActive(_openl); - p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); + p.setBrush(over ? st->msgDateImgBgOver() : st->msgDateImgBg()); } { PainterHighQualityEnabler hq(p); p.drawEllipse(inner); } - const auto icon = [&]() -> const style::icon * { - return &(selected ? st::historyFileThumbPlaySelected : st::historyFileThumbPlay); - }(); - if (icon) { - icon->paintInCenter(p, inner); - } + sti->historyFileThumbPlay.paintInCenter(p, inner); } } @@ -507,7 +500,8 @@ void Photo::drawGrouped( 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 displayLoading = _data->displayLoading(); const auto bubble = _parent->hasBubble(); @@ -520,19 +514,16 @@ void Photo::drawGrouped( } 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); - const auto overlayOpacity = selected + const auto overlayOpacity = context.selected() ? (1. - highlightOpacity) : highlightOpacity; if (overlayOpacity > 0.) { p.setOpacity(overlayOpacity); const auto roundRadius = ImageRoundRadius::Large; Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners); - if (!selected) { + if (!context.selected()) { Ui::FillComplexOverlayRect(p, geometry, roundRadius, corners); } p.setOpacity(1.); @@ -555,14 +546,14 @@ void Photo::drawGrouped( radialSize, radialSize); p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgDateImgBgSelected); + if (context.selected()) { + p.setBrush(st->msgDateImgBgSelected()); } else if (isThumbAnimation()) { 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 { 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()); @@ -572,36 +563,25 @@ void Photo::drawGrouped( p.drawEllipse(inner); } - const auto icon = [&]() -> const style::icon* { - if (_data->waitingForAlbum()) { - return &(selected ? st::historyFileThumbWaitingSelected : st::historyFileThumbWaiting); - } else if (radial || _data->loading()) { - return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); - } - return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload); - }(); - const auto previous = [&]() -> const style::icon* { - if (_data->waitingForAlbum()) { - return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); - } - return nullptr; - }(); + const auto &icon = _data->waitingForAlbum() + ? sti->historyFileThumbWaiting + : (radial || _data->loading()) + ? sti->historyFileThumbCancel + : sti->historyFileThumbDownload; + const auto previous = _data->waitingForAlbum() + ? &sti->historyFileThumbCancel + : nullptr; p.setOpacity(backOpacity); - if (icon) { - if (previous && radialOpacity > 0. && radialOpacity < 1.) { - PaintInterpolatedIcon(p, *icon, *previous, radialOpacity, inner); - } else { - icon->paintInCenter(p, inner); - } + if (previous && radialOpacity > 0. && radialOpacity < 1.) { + PaintInterpolatedIcon(p, icon, *previous, radialOpacity, inner); + } else { + icon.paintInCenter(p, inner); } p.setOpacity(1); if (radial) { const auto line = st::historyGroupRadialLine; const auto rinner = inner.marginsRemoved({ line, line, line, line }); - const auto color = selected - ? st::historyFileThumbRadialFgSelected - : st::historyFileThumbRadialFg; - _animation->radial.draw(p, rinner, line, color); + _animation->radial.draw(p, rinner, line, sti->historyFileThumbRadialFg); } } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.h b/Telegram/SourceFiles/history/view/media/history_view_photo.h index a265d8c5e1..3c60661ece 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.h +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.h @@ -131,8 +131,8 @@ private: void streamingReady(::Media::Streaming::Information &&info); void paintUserpicFrame( Painter &p, - QPoint photoPosition, - bool selected) const; + const PaintContext &context, + QPoint photoPosition) const; not_null _data; int _serviceWidth = 0; diff --git a/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp index a632dc91b1..5bee093d50 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp @@ -160,7 +160,7 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const { _dataMedia->automaticLoad(_realParent->fullId(), _parent->data()); } const auto st = context.st; - auto selected = (context.selection == FullSelection); + const auto sti = context.imageStyle(); auto loaded = dataLoaded(); auto displayLoading = _data && _data->displayLoading(); @@ -179,7 +179,7 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const { auto roundCorners = RectPart::AllCorners; validateThumbnail(); p.drawPixmap(rthumb.topLeft(), _thumbnail); - if (selected) { + if (context.selected()) { 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 statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x(); 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.setPen(st::msgDateImgFg); 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; QRect inner(rthumb.x() + (rthumb.width() - innerSize) / 2, rthumb.y() + (rthumb.height() - innerSize) / 2, innerSize, innerSize); p.setPen(Qt::NoPen); - if (selected) { - p.setBrush(st::msgDateImgBgSelected); + if (context.selected()) { + p.setBrush(st->msgDateImgBgSelected()); } else if (isThumbAnimation()) { 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 { 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()); @@ -217,19 +217,14 @@ void ThemeDocument::draw(Painter &p, const PaintContext &context) const { } p.setOpacity(radialOpacity); - auto icon = ([radial, this, selected]() -> const style::icon* { - if (radial || _data->loading()) { - return &(selected ? st::historyFileThumbCancelSelected : st::historyFileThumbCancel); - } - return &(selected ? st::historyFileThumbDownloadSelected : st::historyFileThumbDownload); - })(); - if (icon) { - icon->paintInCenter(p, inner); - } + const auto &icon = (radial || _data->loading()) + ? sti->historyFileThumbCancel + : sti->historyFileThumbDownload; + icon.paintInCenter(p, inner); p.setOpacity(1); if (radial) { 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); } } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 79db9195ad..952460e4d6 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -453,6 +453,7 @@ void WebPage::draw(Painter &p, const PaintContext &context) const { auto paintw = width(); const auto st = context.st; + const auto sti = context.imageStyle(); const auto stm = context.messageStyle(); 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 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.setPen(st::msgDateImgFg); diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index 2a15d3d341..583a9e0469 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -874,7 +874,11 @@ void File::paint(Painter &p, const QRect &clip, const PaintContext *context) con p.setPen(Qt::NoPen); const auto coverDrawn = _document->isSongWithCover() - && HistoryView::DrawThumbnailAsSongCover(p, _documentMedia, inner); + && HistoryView::DrawThumbnailAsSongCover( + p, + st::songCoverOverlayFg, + _documentMedia, + inner); if (!coverDrawn) { PainterHighQualityEnabler hq(p); if (isThumbAnimation()) { @@ -903,7 +907,7 @@ void File::paint(Painter &p, const QRect &clip, const PaintContext *context) con } else if (_document->isImage()) { return &st::historyFileInImage; } else if (_document->isSongWithCover()) { - return &st::historyFileSongPlay; + return &st::historyFileThumbPlay; } else if (_document->isVoiceMessage() || _document->isAudioFile()) { return &st::historyFileInPlay; diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 2b9da2f51e..6a99f75fec 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -1022,7 +1022,12 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con using namespace HistoryView; const auto coverDrawn = _data->isSongWithCover() - && DrawThumbnailAsSongCover(p, _dataMedia, inner, selected); + && DrawThumbnailAsSongCover( + p, + st::songCoverOverlayFg, + _dataMedia, + inner, + selected); if (!coverDrawn) { if (selected) { p.setBrush(st::msgFileInBgSelected); diff --git a/Telegram/SourceFiles/ui/cached_round_corners.cpp b/Telegram/SourceFiles/ui/cached_round_corners.cpp index 07c3e0901b..8e82a41ce4 100644 --- a/Telegram/SourceFiles/ui/cached_round_corners.cpp +++ b/Telegram/SourceFiles/ui/cached_round_corners.cpp @@ -80,14 +80,11 @@ void CreatePaletteCorners() { PrepareCorners(DateCorners, st::dateRadius, st::msgDateImgBg); PrepareCorners(OverviewVideoCorners, st::overviewVideoStatusRadius, st::msgDateImgBg); 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(MediaviewSaveCorners, st::mediaviewControllerRadius, st::mediaviewSaveMsgBg); PrepareCorners(EmojiHoverCorners, st::roundRadiusSmall, st::emojiPanHover); PrepareCorners(StickerHoverCorners, st::roundRadiusSmall, st::emojiPanHover); PrepareCorners(BotKeyboardCorners, st::roundRadiusSmall, st::botKbBg); - PrepareCorners(PhotoSelectOverlayCorners, st::roundRadiusSmall, st::overviewPhotoSelectOverlay); PrepareCorners(Doc1Corners, st::roundRadiusSmall, st::msgFile1Bg); 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) { - 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 cornerHeight = corner.p[0].height() / style::DevicePixelRatio(); if (parts & RectPart::Bottom) { diff --git a/Telegram/SourceFiles/ui/cached_round_corners.h b/Telegram/SourceFiles/ui/cached_round_corners.h index cd3e705700..a561f199cf 100644 --- a/Telegram/SourceFiles/ui/cached_round_corners.h +++ b/Telegram/SourceFiles/ui/cached_round_corners.h @@ -32,16 +32,12 @@ enum CachedRoundCorners : int { EmojiHoverCorners, StickerHoverCorners, BotKeyboardCorners, - PhotoSelectOverlayCorners, Doc1Corners, Doc2Corners, Doc3Corners, Doc4Corners, - InShadowCorners, // for photos without bg - InSelectedShadowCorners, - MessageInCorners, // with shadow 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) { 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 FinishCachedCorners(); diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_abstract_single_file_preview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_abstract_single_file_preview.cpp index 9913d9299b..dd64ab6341 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_abstract_single_file_preview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_abstract_single_file_preview.cpp @@ -114,7 +114,7 @@ void AbstractSingleFilePreview::paintEvent(QPaintEvent *e) { auto &icon = _data.fileIsAudio ? (_data.fileThumb.isNull() ? st::historyFileInPlay - : st::historyFileSongPlay) + : st::historyFileThumbPlay) : _data.fileIsImage ? st::historyFileInImage : st::historyFileInDocument; diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_item_single_file_preview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_item_single_file_preview.cpp index b4eb473cdf..ac86b65ded 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_item_single_file_preview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_item_single_file_preview.cpp @@ -93,6 +93,7 @@ void ItemSingleFilePreview::preparePreview(not_null document) { HistoryView::DrawThumbnailAsSongCover( p, + st::songCoverOverlayFg, _documentMedia, QRect(QPoint(), size)); data.fileThumb = std::move(thumb); diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index 6dc263fa63..87dc221490 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -159,17 +159,8 @@ historyFileOutWaitingSelected: icon {{ "mediaview_save_check", historyFileOutIco historyFileInWaiting: icon {{ "mediaview_save_check", historyFileInIconFg }}; historyFileInWaitingSelected: icon {{ "mediaview_save_check", historyFileInIconFgSelected }}; -historyFileSongPause: icon {{ "history_file_pause", historyFileThumbIconFg }}; -historyFileSongPauseSelected: 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 }}; - +historyFileThumbPause: icon {{ "history_file_pause", historyFileThumbIconFg }}; +historyFileThumbPauseSelected: icon {{ "history_file_pause", historyFileThumbIconFgSelected }}; historyFileThumbDownload: icon {{ "history_file_download", historyFileThumbIconFg }}; historyFileThumbDownloadSelected: icon {{ "history_file_download", historyFileThumbIconFgSelected }}; historyFileThumbCancel: icon {{ "history_file_cancel", historyFileThumbIconFg }}; diff --git a/Telegram/SourceFiles/ui/chat/chat_style.cpp b/Telegram/SourceFiles/ui/chat/chat_style.cpp index 58e0f37e69..b85643ef34 100644 --- a/Telegram/SourceFiles/ui/chat/chat_style.cpp +++ b/Telegram/SourceFiles/ui/chat/chat_style.cpp @@ -31,6 +31,10 @@ not_null ChatPaintContext::messageStyle() const { return &st->messageStyle(outbg, selected()); } +not_null ChatPaintContext::imageStyle() const { + return &st->imageStyle(selected()); +} + int HistoryServiceMsgRadius() { static const auto result = [] { const auto minMessageHeight = st::msgServicePadding.top() @@ -114,6 +118,24 @@ ChatStyle::ChatStyle() { st::msgFileInBgSelected, st::msgFileOutBg, 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( &MessageStyle::historyTextFg, st::historyTextInFg, @@ -121,11 +143,23 @@ ChatStyle::ChatStyle() { st::historyTextOutFg, st::historyTextOutFgSelected); make( - &MessageStyle::msgReplyBarColor, - st::msgInReplyBarColor, - st::msgInReplyBarSelColor, - st::msgOutReplyBarColor, - st::msgOutReplyBarSelColor); + &MessageStyle::historyFileNameFg, + st::historyFileNameInFg, + st::historyFileNameInFgSelected, + st::historyFileNameOutFg, + 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( &MessageStyle::webPageTitleFg, st::webPageTitleInFg, @@ -144,6 +178,12 @@ ChatStyle::ChatStyle() { st::inTextPaletteSelected, st::outTextPalette, st::outTextPaletteSelected); + make( + &MessageStyle::semiboldPalette, + st::inSemiboldPalette, + st::inTextPaletteSelected, + st::outSemiboldPalette, + st::outTextPaletteSelected); make( &MessageStyle::fwdTextPalette, st::inFwdTextPalette, @@ -216,6 +256,132 @@ ChatStyle::ChatStyle() { st::historyCommentsInSelected, st::historyCommentsOut, 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 theme) { @@ -239,13 +405,14 @@ void ChatStyle::assignPalette(not_null palette) { for (auto &style : _messageStyles) { style.corners = {}; } + for (auto &style : _imageStyles) { + style.msgDateImgBgCorners = {}; + style.msgServiceBgCorners = {}; + style.msgShadowCorners = {}; + } _serviceBgCornersNormal = {}; _serviceBgCornersInverted = {}; - _msgServiceBgCorners = {}; - _msgServiceBgSelectedCorners = {}; _msgBotKbOverBgAddCorners = {}; - _msgDateImgBgCorners = {}; - _msgDateImgBgSelectedCorners = {}; } const CornersPixmaps &ChatStyle::serviceBgCornersNormal() const { @@ -286,17 +453,21 @@ const MessageStyle &ChatStyle::messageStyle(bool outbg, bool selected) const { return result; } -const CornersPixmaps &ChatStyle::msgServiceBgCorners() const { - EnsureCorners(_msgServiceBgCorners, st::dateRadius, msgServiceBg()); - return _msgServiceBgCorners; -} - -const CornersPixmaps &ChatStyle::msgServiceBgSelectedCorners() const { +const MessageImageStyle &ChatStyle::imageStyle(bool selected) const { + auto &result = imageStyleRaw(selected); EnsureCorners( - _msgServiceBgSelectedCorners, + result.msgDateImgBgCorners, st::dateRadius, - msgServiceBgSelected()); - return _msgServiceBgSelectedCorners; + result.msgDateImgBg); + EnsureCorners( + result.msgServiceBgCorners, + st::dateRadius, + result.msgServiceBg); + EnsureCorners( + result.msgShadowCorners, + st::historyMessageRadius, + result.msgShadow); + return result; } const CornersPixmaps &ChatStyle::msgBotKbOverBgAddCorners() const { @@ -307,26 +478,38 @@ const CornersPixmaps &ChatStyle::msgBotKbOverBgAddCorners() const { 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 { 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) { my = _colors[style::main_palette::indexOfColor(original)]; } @@ -347,22 +530,6 @@ void ChatStyle::make( 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 void ChatStyle::make( Type MessageStyle::*my, @@ -376,4 +543,13 @@ void ChatStyle::make( make(messageOutSelected().*my, originalOutSelected); } +template +void ChatStyle::make( + Type MessageImageStyle::*my, + const Type &original, + const Type &originalSelected) { + make(image().*my, original); + make(imageSelected().*my, originalSelected); +} + } // namespace Ui diff --git a/Telegram/SourceFiles/ui/chat/chat_style.h b/Telegram/SourceFiles/ui/chat/chat_style.h index e899f4d007..c884da6f87 100644 --- a/Telegram/SourceFiles/ui/chat/chat_style.h +++ b/Telegram/SourceFiles/ui/chat/chat_style.h @@ -25,11 +25,17 @@ struct MessageStyle { style::color msgDateFg; style::color msgFileThumbLinkFg; style::color msgFileBg; - style::color historyTextFg; 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 webPageDescriptionFg; style::TextPalette textPalette; + style::TextPalette semiboldPalette; style::TextPalette fwdTextPalette; style::TextPalette replyTextPalette; style::icon tailLeft = { Qt::Uninitialized }; @@ -42,6 +48,37 @@ struct MessageStyle { style::icon historyPsaIcon = { Qt::Uninitialized }; style::icon historyCommentsOpen = { 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 { @@ -65,6 +102,7 @@ struct ChatPaintContext { return (selection == FullSelection); } [[nodiscard]] not_null messageStyle() const; + [[nodiscard]] not_null imageStyle() const; [[nodiscard]] ChatPaintContext translated(int x, int y) const { auto result = *this; @@ -99,12 +137,9 @@ public: [[nodiscard]] const MessageStyle &messageStyle( bool outbg, 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 &msgDateImgBgCorners() const; - [[nodiscard]] const CornersPixmaps &msgDateImgBgSelectedCorners() const; [[nodiscard]] const style::TextPalette &historyPsaForwardPalette() const { return _historyPsaForwardPalette; @@ -176,6 +211,10 @@ private: [[nodiscard]] MessageStyle &messageOut(); [[nodiscard]] MessageStyle &messageOutSelected(); + [[nodiscard]] MessageImageStyle &imageStyleRaw(bool selected) const; + [[nodiscard]] MessageImageStyle &image(); + [[nodiscard]] MessageImageStyle &imageSelected(); + template void make( Type MessageStyle::*my, @@ -184,16 +223,19 @@ private: const Type &originalOut, const Type &originalOutSelected); + template + void make( + Type MessageImageStyle::*my, + const Type &original, + const Type &originalSelected); + mutable CornersPixmaps _serviceBgCornersNormal; mutable CornersPixmaps _serviceBgCornersInverted; mutable std::array _messageStyles; + mutable std::array _imageStyles; - mutable CornersPixmaps _msgServiceBgCorners; - mutable CornersPixmaps _msgServiceBgSelectedCorners; mutable CornersPixmaps _msgBotKbOverBgAddCorners; - mutable CornersPixmaps _msgDateImgBgCorners; - mutable CornersPixmaps _msgDateImgBgSelectedCorners; style::TextPalette _historyPsaForwardPalette; style::TextPalette _imgReplyTextPalette;