diff --git a/Telegram/Resources/style.txt b/Telegram/Resources/style.txt index 155785981..962d11509 100644 --- a/Telegram/Resources/style.txt +++ b/Telegram/Resources/style.txt @@ -1197,6 +1197,18 @@ msgFileRedColor: #e47272; msgFileYellowColor: #efc274; msgFileGreenColor: #61b96e; msgFileBlueColor: #72b1df; +msgFileRedDark: #cd5b5e; +msgFileYellowDark: #e6a561; +msgFileGreenDark: #4da859; +msgFileBlueDark: #5c9ece; +msgFileRedOver: #c35154; +msgFileYellowOver: #dc9c5a; +msgFileGreenOver: #44a050; +msgFileBlueOver: #5294c4; +msgFileRedSelected: #9f6a82; +msgFileYellowSelected: #b19d84; +msgFileGreenSelected: #46a07e; +msgFileBlueSelected: #5099d0; msgFileMenuSize: size(36px, 36px); msgFileSize: 44px; diff --git a/Telegram/SourceFiles/layout.cpp b/Telegram/SourceFiles/layout.cpp index a35dc7de6..9622f3e11 100644 --- a/Telegram/SourceFiles/layout.cpp +++ b/Telegram/SourceFiles/layout.cpp @@ -193,6 +193,21 @@ style::color documentColor(int32 colorIndex) { return colors[colorIndex & 3]; } +style::color documentDarkColor(int32 colorIndex) { + static style::color colors[] = { st::msgFileBlueDark, st::msgFileGreenDark, st::msgFileRedDark, st::msgFileYellowDark }; + return colors[colorIndex & 3]; +} + +style::color documentOverColor(int32 colorIndex) { + static style::color colors[] = { st::msgFileBlueOver, st::msgFileGreenOver, st::msgFileRedOver, st::msgFileYellowOver }; + return colors[colorIndex & 3]; +} + +style::color documentSelectedColor(int32 colorIndex) { + static style::color colors[] = { st::msgFileBlueSelected, st::msgFileGreenSelected, st::msgFileRedSelected, st::msgFileYellowSelected }; + return colors[colorIndex & 3]; +} + style::sprite documentCorner(int32 colorIndex) { static style::sprite corners[] = { st::msgFileBlue, st::msgFileGreen, st::msgFileRed, st::msgFileYellow }; return corners[colorIndex & 3]; @@ -727,6 +742,7 @@ LayoutOverviewDocument::LayoutOverviewDocument(DocumentData *document, HistoryIt , _data(document) , _msgl(new MessageLink(parent)) , _namel(new DocumentOpenLink(_data)) +, _thumbForLoaded(false) , _name(documentName(_data)) , _date(langDateTime(date(_data->date))) , _namew(st::semiboldFont->width(_name)) @@ -843,25 +859,24 @@ void LayoutOverviewDocument::paint(Painter &p, const QRect &clip, uint32 selecti if (clip.intersects(rthumb)) { if (wthumb) { if (_data->thumb->loaded()) { - QPixmap thumb = loaded ? _data->thumb->pixSingle(_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize) : _data->thumb->pixBlurredSingle(_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize); - p.drawPixmap(rthumb.topLeft(), thumb); + if (_thumb.isNull() || loaded != _thumbForLoaded) { + _thumbForLoaded = loaded; + _thumb = _data->thumb->pixNoCache(_thumbw, 0, true, !_thumbForLoaded, false, st::msgFileThumbSize, st::msgFileThumbSize); + } + p.drawPixmap(rthumb.topLeft(), _thumb); } else { - App::roundRect(p, rthumb, st::black, BlackCorners); + p.fillRect(rthumb, st::black); } } else { - App::roundRect(p, rthumb, documentColor(_colorIndex), documentCorners(_colorIndex)); - if (!radial && loaded) { - style::sprite icon = documentCorner(_colorIndex); - p.drawSprite(rthumb.topLeft() + QPoint(rtl() ? 0 : (rthumb.width() - icon.pxWidth()), 0), icon); - if (!_ext.isEmpty()) { - p.setFont(st::semiboldFont); - p.setPen(st::white); - p.drawText(rthumb.left() + (rthumb.width() - _extw) / 2, rthumb.top() + st::msgFileExtTop + st::semiboldFont->ascent, _ext); - } + p.fillRect(rthumb, documentColor(_colorIndex)); + if (!radial && loaded && !_ext.isEmpty()) { + p.setFont(st::semiboldFont); + p.setPen(st::white); + p.drawText(rthumb.left() + (rthumb.width() - _extw) / 2, rthumb.top() + st::msgFileExtTop + st::semiboldFont->ascent, _ext); } } if (selected) { - App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayCorners); + p.fillRect(rthumb, textstyleCurrent()->selectOverlay); } if (radial || (!loaded && !_data->loading())) { @@ -870,15 +885,19 @@ void LayoutOverviewDocument::paint(Painter &p, const QRect &clip, uint32 selecti float64 radialOpacity = (radial && loaded && !_data->uploading()) ? _radial->opacity() : 1; p.setPen(Qt::NoPen); if (selected) { - p.setBrush(st::msgDateImgBgSelected); + p.setBrush(wthumb ? st::msgDateImgBgSelected : documentSelectedColor(_colorIndex)); } else if (_a_iconOver.animating()) { _a_iconOver.step(context->ms); float64 over = a_iconOver.current(); - p.setOpacity((st::msgDateImgBg->c.alphaF() * (1 - over)) + (st::msgDateImgBgOver->c.alphaF() * over)); - p.setBrush(st::black); + if (wthumb) { + p.setOpacity((st::msgDateImgBg->c.alphaF() * (1 - over)) + (st::msgDateImgBgOver->c.alphaF() * over)); + p.setBrush(st::black); + } else { + p.setBrush(style::interpolate(documentDarkColor(_colorIndex), documentOverColor(_colorIndex), over)); + } } else { bool over = textlnkDrawOver(_data->loading() ? _cancell : _savel); - p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); + p.setBrush(over ? (wthumb ? st::msgDateImgBgOver : documentOverColor(_colorIndex)) : (wthumb ? st::msgDateImgBg : documentDarkColor(_colorIndex))); } p.setOpacity(radialOpacity * p.opacity()); diff --git a/Telegram/SourceFiles/layout.h b/Telegram/SourceFiles/layout.h index b06906738..21d93c5d2 100644 --- a/Telegram/SourceFiles/layout.h +++ b/Telegram/SourceFiles/layout.h @@ -75,6 +75,9 @@ QString formatPlayedText(qint64 played, qint64 duration); QString documentName(DocumentData *document); int32 documentColorIndex(DocumentData *document, QString &ext); style::color documentColor(int32 colorIndex); +style::color documentDarkColor(int32 colorIndex); +style::color documentOverColor(int32 colorIndex); +style::color documentSelectedColor(int32 colorIndex); style::sprite documentCorner(int32 colorIndex); RoundCorners documentCorners(int32 colorIndex); @@ -267,7 +270,7 @@ public: void setTop(int32 top) { _top = top; } - + private: int32 _top; @@ -276,7 +279,7 @@ private: class LayoutOverviewDate : public LayoutItem { public: LayoutOverviewDate(const QDate &date, bool month); - + virtual void initDimensions(); virtual void paint(Painter &p, const QRect &clip, uint32 selection, const PaintContext *context) const; @@ -426,6 +429,9 @@ private: DocumentData *_data; TextLinkPtr _msgl, _namel; + mutable bool _thumbForLoaded; + mutable QPixmap _thumb; + QString _name, _date, _ext; int32 _namew, _datew, _extw; int32 _thumbw, _colorIndex; @@ -492,7 +498,7 @@ class LayoutInlineItem : public LayoutItem { public: LayoutInlineItem(InlineResult *result, DocumentData *doc, PhotoData *photo); - + virtual void setPosition(int32 position); int32 position() const;