diff --git a/Telegram/Resources/art/sprite.png b/Telegram/Resources/art/sprite.png index 8ff946cf2..def492ee1 100644 Binary files a/Telegram/Resources/art/sprite.png and b/Telegram/Resources/art/sprite.png differ diff --git a/Telegram/Resources/art/sprite_200x.png b/Telegram/Resources/art/sprite_200x.png index bdb2af1b9..9098c1f0d 100644 Binary files a/Telegram/Resources/art/sprite_200x.png and b/Telegram/Resources/art/sprite_200x.png differ diff --git a/Telegram/Resources/basic.style b/Telegram/Resources/basic.style index a9fa919e9..50f2cbc91 100644 --- a/Telegram/Resources/basic.style +++ b/Telegram/Resources/basic.style @@ -91,15 +91,6 @@ boxTitleFont: font(boxFontSize bold); boxTitlePosition: point(26px, 28px); boxTitleHeight: 54px; -boxBlueTitleBg: #6393b5; -boxBlueTitleAdditionalFg: #dae9f5; -boxBlueTitleAdditionalSkip: 12px; -boxBlueTitlePosition: point(23px, 18px); -boxBlueCloseIcon: sprite(120px, 108px, 12px, 12px); -boxBlueCloseBg: #c8e1f0; -boxBlueCloseDuration: 150; -boxBlueShadow: sprite(132px, 108px, 1px, 4px); - boxButtonFont: font(boxFontSize semibold); defaultBoxButton: RoundButton { textFg: #2f9fea; @@ -337,8 +328,6 @@ boxScrollShadowBg: #00000012; titleBg: #6389a8; titleHeight: 39px; -titleIconPos: point(7px, 7px); -titleIconImg: sprite(161px, 100px, 26px, 26px); titleFont: font(17px); titlePos: point(44px, 29px); titleMenuOffset: 36px; @@ -908,8 +897,6 @@ msgDateImgBgSelected: #1c4a7187; msgDateImgPadding: point(8px, 2px); msgDateImgCheckSpace: 4px; -msgDogImg: sprite(216px, 92px, 126px, 126px); - collapseButton: flatButton(btnDefFlat) { font: msgServiceFont; overFont: msgServiceFont; @@ -1289,9 +1276,6 @@ layerPadding: margins(10px, 10px, 10px, 10px); contactPadding: margins(49px, 22px, 0px, 6px); contactSkip: 13px; contactPhoneSkip: 30px; -contactUserIcon: sprite(120px, 90px, 18px, 18px); -contactPhoneIcon: sprite(138px, 90px, 18px, 18px); -contactIconTop: 10px; contactsPhotoSize: 42px; contactsPadding: margins(16px, 7px, 16px, 7px); @@ -1304,11 +1288,6 @@ contactsStatusFgOver: #7c99b2; contactsStatusFgOnline: #3b8dcc; contactsBgOver: overBg; contactsCheckPosition: point(8px, 16px); -contactsNewItemHeight: 53px; -contactsNewItemIcon: sprite(307px, 248px, 22px, 16px); -contactsNewItemIconPosition: point(29px, 19px); -contactsNewItemTop: 18px; -contactsNewItemFg: #4b82af; contactsAboutBg: #f7f7f7; contactsAboutShadow: #0000001F; contactsAdminCheckbox: Checkbox(defaultBoxCheckbox) { @@ -1832,8 +1811,6 @@ medviewSaveMsgShown: 2000; medviewSaveMsgHiding: 2500; medviewSaveMsg: #000000b2; -mvTransparentBrush: sprite(9px, 124px, 8px, 8px); - // Mac specific macAccessoryWidth: 450.; diff --git a/Telegram/Resources/icons/add_contact_phone.png b/Telegram/Resources/icons/add_contact_phone.png new file mode 100644 index 000000000..f649ba2fd Binary files /dev/null and b/Telegram/Resources/icons/add_contact_phone.png differ diff --git a/Telegram/Resources/icons/add_contact_phone@2x.png b/Telegram/Resources/icons/add_contact_phone@2x.png new file mode 100644 index 000000000..b01522770 Binary files /dev/null and b/Telegram/Resources/icons/add_contact_phone@2x.png differ diff --git a/Telegram/Resources/icons/add_contact_user.png b/Telegram/Resources/icons/add_contact_user.png new file mode 100644 index 000000000..1d494cde8 Binary files /dev/null and b/Telegram/Resources/icons/add_contact_user.png differ diff --git a/Telegram/Resources/icons/add_contact_user@2x.png b/Telegram/Resources/icons/add_contact_user@2x.png new file mode 100644 index 000000000..a45ef3073 Binary files /dev/null and b/Telegram/Resources/icons/add_contact_user@2x.png differ diff --git a/Telegram/Resources/icons/box_button_close.png b/Telegram/Resources/icons/box_button_close.png new file mode 100644 index 000000000..57abcfb82 Binary files /dev/null and b/Telegram/Resources/icons/box_button_close.png differ diff --git a/Telegram/Resources/icons/box_button_close@2x.png b/Telegram/Resources/icons/box_button_close@2x.png new file mode 100644 index 000000000..bf2a19e72 Binary files /dev/null and b/Telegram/Resources/icons/box_button_close@2x.png differ diff --git a/Telegram/Resources/icons/box_title_shadow.png b/Telegram/Resources/icons/box_title_shadow.png new file mode 100644 index 000000000..bba09b240 Binary files /dev/null and b/Telegram/Resources/icons/box_title_shadow.png differ diff --git a/Telegram/Resources/icons/box_title_shadow@2x.png b/Telegram/Resources/icons/box_title_shadow@2x.png new file mode 100644 index 000000000..7d97eb59e Binary files /dev/null and b/Telegram/Resources/icons/box_title_shadow@2x.png differ diff --git a/Telegram/Resources/icons/contacts_add.png b/Telegram/Resources/icons/contacts_add.png new file mode 100644 index 000000000..98f770cc6 Binary files /dev/null and b/Telegram/Resources/icons/contacts_add.png differ diff --git a/Telegram/Resources/icons/contacts_add@2x.png b/Telegram/Resources/icons/contacts_add@2x.png new file mode 100644 index 000000000..7fc3c170f Binary files /dev/null and b/Telegram/Resources/icons/contacts_add@2x.png differ diff --git a/Telegram/Resources/icons/history_empty_dog.png b/Telegram/Resources/icons/history_empty_dog.png new file mode 100644 index 000000000..3e6fef342 Binary files /dev/null and b/Telegram/Resources/icons/history_empty_dog.png differ diff --git a/Telegram/Resources/icons/history_empty_dog@2x.png b/Telegram/Resources/icons/history_empty_dog@2x.png new file mode 100644 index 000000000..248860d6b Binary files /dev/null and b/Telegram/Resources/icons/history_empty_dog@2x.png differ diff --git a/Telegram/Resources/icons/title_icon.png b/Telegram/Resources/icons/title_icon.png new file mode 100644 index 000000000..12772e6a3 Binary files /dev/null and b/Telegram/Resources/icons/title_icon.png differ diff --git a/Telegram/Resources/icons/title_icon@2x.png b/Telegram/Resources/icons/title_icon@2x.png new file mode 100644 index 000000000..ad40f1fea Binary files /dev/null and b/Telegram/Resources/icons/title_icon@2x.png differ diff --git a/Telegram/Resources/icons/title_icon_bg.png b/Telegram/Resources/icons/title_icon_bg.png new file mode 100644 index 000000000..ebdf86291 Binary files /dev/null and b/Telegram/Resources/icons/title_icon_bg.png differ diff --git a/Telegram/Resources/icons/title_icon_bg@2x.png b/Telegram/Resources/icons/title_icon_bg@2x.png new file mode 100644 index 000000000..33924433d Binary files /dev/null and b/Telegram/Resources/icons/title_icon_bg@2x.png differ diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index facd674d1..6bfed1347 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -2819,41 +2819,7 @@ namespace { uint64 max = qMax(1ULL, components[maxtomin[0]]), mid = qMax(1ULL, components[maxtomin[1]]), min = qMax(1ULL, components[maxtomin[2]]); - QImage dog = App::sprite().toImage().copy(st::msgDogImg.rect()); - QImage::Format f = dog.format(); - if (f != QImage::Format_ARGB32 && f != QImage::Format_ARGB32_Premultiplied) { - dog = dog.convertToFormat(QImage::Format_ARGB32_Premultiplied); - } - uchar *dogBits = dog.bits(); - if (max != min) { - float64 coef = float64(mid - min) / float64(max - min); - for (int i = 0, s = dog.width() * dog.height() * 4; i < s; i += 4) { - int dogmaxtomin[3] = { i, i + 1, i + 2 }; - if (dogBits[dogmaxtomin[0]] < dogBits[dogmaxtomin[1]]) { - qSwap(dogmaxtomin[0], dogmaxtomin[1]); - } - if (dogBits[dogmaxtomin[1]] < dogBits[dogmaxtomin[2]]) { - qSwap(dogmaxtomin[1], dogmaxtomin[2]); - if (dogBits[dogmaxtomin[0]] < dogBits[dogmaxtomin[1]]) { - qSwap(dogmaxtomin[0], dogmaxtomin[1]); - } - } - uchar result[3]; - result[maxtomin[0]] = dogBits[dogmaxtomin[0]]; - result[maxtomin[2]] = dogBits[dogmaxtomin[2]]; - result[maxtomin[1]] = uchar(qRound(result[maxtomin[2]] + (result[maxtomin[0]] - result[maxtomin[2]]) * coef)); - dogBits[i] = result[2]; - dogBits[i + 1] = result[1]; - dogBits[i + 2] = result[0]; - } - } else { - for (int i = 0, s = dog.width() * dog.height() * 4; i < s; i += 4) { - uchar b = dogBits[i], g = dogBits[i + 1], r = dogBits[i + 2]; - dogBits[i] = dogBits[i + 1] = dogBits[i + 2] = (r + r + b + g + g + g) / 6; - } - } - - Window::chatBackground()->init(id, pixmapFromImageInPlace(std_::move(img)), pixmapFromImageInPlace(std_::move(dog))); + Window::chatBackground()->init(id, pixmapFromImageInPlace(std_::move(img))); memcpy(componentsScroll, components, sizeof(components)); memcpy(componentsPoint, components, sizeof(components)); diff --git a/Telegram/SourceFiles/boxes/abstractbox.cpp b/Telegram/SourceFiles/boxes/abstractbox.cpp index 4fcf2a68b..6df51ba70 100644 --- a/Telegram/SourceFiles/boxes/abstractbox.cpp +++ b/Telegram/SourceFiles/boxes/abstractbox.cpp @@ -26,16 +26,17 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" #include "mainwidget.h" #include "mainwindow.h" +#include "styles/style_boxes.h" void BlueTitleShadow::paintEvent(QPaintEvent *e) { Painter p(this); QRect r(e->rect()); - p.drawPixmap(QRect(r.left(), 0, r.width(), height()), App::sprite(), st::boxBlueShadow.rect()); + st::boxBlueTitleShadow.fill(p, QRect(r.left(), 0, r.width(), height())); } BlueTitleClose::BlueTitleClose(QWidget *parent) : Button(parent) -, a_iconFg(st::boxBlueCloseBg->c) +, a_iconFg(st::boxBlueCloseFg->c) , _a_over(animation(this, &BlueTitleClose::step_over)) { resize(st::boxTitleHeight, st::boxTitleHeight); setCursor(style::cur_pointer); @@ -44,7 +45,7 @@ BlueTitleClose::BlueTitleClose(QWidget *parent) : Button(parent) void BlueTitleClose::onStateChange(int oldState, ButtonStateChangeSource source) { if ((oldState & StateOver) != (_state & StateOver)) { - a_iconFg.start(((_state & StateOver) ? st::white : st::boxBlueCloseBg)->c); + a_iconFg.start(((_state & StateOver) ? st::boxBlueCloseOverFg : st::boxBlueCloseFg)->c); _a_over.start(); } } @@ -57,28 +58,23 @@ void BlueTitleClose::step_over(float64 ms, bool timer) { } else { a_iconFg.update(dt, anim::linear); } - if (timer) update((st::boxTitleHeight - st::boxBlueCloseIcon.pxWidth()) / 2, (st::boxTitleHeight - st::boxBlueCloseIcon.pxHeight()) / 2, st::boxBlueCloseIcon.pxWidth(), st::boxBlueCloseIcon.pxHeight()); + if (timer) update((st::boxTitleHeight - st::boxBlueCloseIcon.width()) / 2, (st::boxTitleHeight - st::boxBlueCloseIcon.height()) / 2, st::boxBlueCloseIcon.width(), st::boxBlueCloseIcon.height()); } void BlueTitleClose::paintEvent(QPaintEvent *e) { Painter p(this); - QRect r(e->rect()), s((st::boxTitleHeight - st::boxBlueCloseIcon.pxWidth()) / 2, (st::boxTitleHeight - st::boxBlueCloseIcon.pxHeight()) / 2, st::boxBlueCloseIcon.pxWidth(), st::boxBlueCloseIcon.pxHeight()); + QRect r(e->rect()), s((st::boxTitleHeight - st::boxBlueCloseIcon.width()) / 2, (st::boxTitleHeight - st::boxBlueCloseIcon.height()) / 2, st::boxBlueCloseIcon.width(), st::boxBlueCloseIcon.height()); if (!s.contains(r)) { - p.fillRect(r, st::boxBlueTitleBg->b); + p.fillRect(r, st::boxBlueTitleBg); } if (s.intersects(r)) { p.fillRect(s.intersected(r), a_iconFg.current()); - p.drawSprite(s.topLeft(), st::boxBlueCloseIcon); + st::boxBlueCloseIcon.paint(p, s.topLeft(), width()); } } -AbstractBox::AbstractBox(int32 w) : LayerWidget() -, _maxHeight(0) -, _closed(false) -, _blueTitle(false) -, _blueClose(0) -, _blueShadow(0) { +AbstractBox::AbstractBox(int w) : LayerWidget() { setAttribute(Qt::WA_OpaquePaintEvent); resize(w, 0); } @@ -101,7 +97,7 @@ void AbstractBox::resizeEvent(QResizeEvent *e) { } if (_blueShadow) { _blueShadow->moveToLeft(0, st::boxTitleHeight); - _blueShadow->resize(width(), st::boxBlueShadow.pxHeight()); + _blueShadow->resize(width(), st::boxBlueTitleShadow.height()); } LayerWidget::resizeEvent(e); } @@ -165,8 +161,8 @@ void AbstractBox::resizeMaxHeight(int32 newWidth, int32 maxHeight) { } } -int32 AbstractBox::countHeight() const { - return qMin(_maxHeight, App::wnd()->height() - int32(2 * st::boxVerticalMargin)); +int AbstractBox::countHeight() const { + return qMin(_maxHeight, App::wnd()->height() - 2 * st::boxVerticalMargin); } void AbstractBox::onClose() { diff --git a/Telegram/SourceFiles/boxes/abstractbox.h b/Telegram/SourceFiles/boxes/abstractbox.h index bd21001cc..4c6e28b1a 100644 --- a/Telegram/SourceFiles/boxes/abstractbox.h +++ b/Telegram/SourceFiles/boxes/abstractbox.h @@ -52,7 +52,7 @@ class AbstractBox : public LayerWidget, protected base::Subscriber { Q_OBJECT public: - AbstractBox(int32 w = st::boxWideWidth); + AbstractBox(int w = st::boxWideWidth); void parentResized() override; void showDone() override { showAll(); @@ -83,14 +83,14 @@ protected: } private: - int32 _maxHeight; - int32 countHeight() const; + int _maxHeight = 0; + int countHeight() const; - bool _closed; + bool _closed = false; - bool _blueTitle; - BlueTitleClose *_blueClose; - BlueTitleShadow *_blueShadow; + bool _blueTitle = false; + BlueTitleClose *_blueClose = nullptr; + BlueTitleShadow *_blueShadow = nullptr; }; diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 5e561ff33..2ef31e477 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -109,8 +109,8 @@ void AddContactBox::paintEvent(QPaintEvent *e) { paintTitle(p, _boxTitle); if (_retry.isHidden()) { - p.drawSpriteLeft(st::boxPadding.left(), _first.y() + st::contactIconTop, width(), st::contactUserIcon); - p.drawSpriteLeft(st::boxPadding.left(), _phone.y() + st::contactIconTop, width(), st::contactPhoneIcon); + st::contactUserIcon.paint(p, st::boxPadding.left(), _first.y() + st::contactIconTop, width()); + st::contactPhoneIcon.paint(p, st::boxPadding.left(), _phone.y() + st::contactIconTop, width()); } else { p.setPen(st::black->p); p.setFont(st::boxTextFont->f); diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 2ce8107c1..dd6031904 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -21,6 +21,16 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org using "basic.style"; using "ui/widgets/widgets.style"; +boxBlueTitleBg: #6393b5; +boxBlueTitleAdditionalFg: #dae9f5; +boxBlueTitleAdditionalSkip: 12px; +boxBlueTitlePosition: point(23px, 18px); +boxBlueTitleShadow: icon {{ "box_title_shadow", windowShadowFg }}; +boxBlueCloseFg: #c8e1f0; +boxBlueCloseOverFg: #ffffff; +boxBlueCloseIcon: icon {{ "box_button_close", boxBlueTitleBg }}; +boxBlueCloseDuration: 150; + confirmInviteTitle: flatLabel(labelDefFlat) { font: font(16px semibold); align: align(center); @@ -68,6 +78,15 @@ aboutRevokePublicLabel: flatLabel(labelDefFlat) { textFg: windowTextFg; } +contactUserIcon: icon {{ "add_contact_user", #999999 }}; +contactPhoneIcon: icon {{ "add_contact_phone", #999999 }}; +contactIconTop: 10px; + +contactsNewItemHeight: 53px; +contactsNewItemIcon: icon {{ "contacts_add", #749fc2, point(29px, 19px) }}; +contactsNewItemTop: 18px; +contactsNewItemFg: #4b82af; + contactsMultiSelect: MultiSelect { padding: margins(8px, 8px, 8px, 8px); maxHeight: 104px; diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index 090bbf80c..1a7c2cb13 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -100,6 +100,7 @@ ContactsBox::ContactsBox(UserData *bot) : ItemListBox(st::contactsScroll) void ContactsBox::init() { _select->resizeToWidth(st::boxWideWidth); + myEnsureResized(_select); auto inviting = (_inner->creating() == CreatingGroupGroup) || (_inner->channel() && _inner->membersFilter() == MembersFilter::Recent) || _inner->chat(); auto topSkip = getTopScrollSkip(); @@ -1073,7 +1074,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { } else { p.fillRect(0, 0, width(), st::contactsNewItemHeight, (_newItemSel ? st::contactsBgOver : st::white)->b); p.setFont(st::contactsNameFont); - p.drawSpriteLeft(st::contactsNewItemIconPosition.x(), st::contactsNewItemIconPosition.y(), width(), st::contactsNewItemIcon); + st::contactsNewItemIcon.paint(p, 0, 0, width()); p.setPen(st::contactsNewItemFg); p.drawTextLeft(st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left(), st::contactsNewItemTop, width(), lang(lng_add_contact_button)); } diff --git a/Telegram/SourceFiles/boxes/members_box.cpp b/Telegram/SourceFiles/boxes/members_box.cpp index a2c3c972c..8290a5bec 100644 --- a/Telegram/SourceFiles/boxes/members_box.cpp +++ b/Telegram/SourceFiles/boxes/members_box.cpp @@ -21,6 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "stdafx.h" #include "boxes/members_box.h" +#include "styles/style_boxes.h" #include "styles/style_dialogs.h" #include "lang.h" #include "mainwidget.h" @@ -149,7 +150,7 @@ void MembersBox::Inner::paintEvent(QPaintEvent *e) { } else { if (_newItemHeight) { p.fillRect(0, 0, width(), _newItemHeight, (_newItemSel ? st::contactsBgOver : st::white)->b); - p.drawSpriteLeft(st::contactsNewItemIconPosition.x(), st::contactsNewItemIconPosition.y(), width(), st::contactsNewItemIcon); + st::contactsNewItemIcon.paint(p, 0, 0, width()); p.setFont(st::contactsNameFont); p.setPen(st::contactsNewItemFg); p.drawTextLeft(st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left(), st::contactsNewItemTop, width(), lang(_filter == MembersFilter::Admins ? lng_channel_add_admins : lng_channel_add_members)); diff --git a/Telegram/SourceFiles/boxes/sharebox.cpp b/Telegram/SourceFiles/boxes/sharebox.cpp index 76c99e7a4..10602c077 100644 --- a/Telegram/SourceFiles/boxes/sharebox.cpp +++ b/Telegram/SourceFiles/boxes/sharebox.cpp @@ -48,6 +48,7 @@ ShareBox::ShareBox(CopyCallback &©Callback, SubmitCallback &&submitCallback, , _topShadow(this) , _bottomShadow(this) { _select->resizeToWidth(st::boxWideWidth); + myEnsureResized(_select); auto topSkip = getTopScrollSkip(); auto bottomSkip = st::boxButtonPadding.top() + _share->height() + st::boxButtonPadding.bottom(); diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index d09ad184b..ae7d0e116 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -35,6 +35,9 @@ historyToDownPaddingTop: 10px; historyToDownBadgeFont: semiboldFont; historyToDownBadgeSize: 22px; +historyEmptyDog: icon {{ "history_empty_dog", #ffffff }}; +historyEmptySize: 128px; + membersInnerScroll: flatScroll(solidScroll) { deltat: 3px; deltab: 3px; diff --git a/Telegram/SourceFiles/history/history_service_layout.cpp b/Telegram/SourceFiles/history/history_service_layout.cpp index fa0db9f69..b69742070 100644 --- a/Telegram/SourceFiles/history/history_service_layout.cpp +++ b/Telegram/SourceFiles/history/history_service_layout.cpp @@ -334,6 +334,16 @@ QVector ServiceMessagePainter::countLineWidths(const Text &text, const QRec return lineWidths; } +void paintEmpty(Painter &p, int width, int height) { + auto position = QPoint((width - st::historyEmptySize) / 2, ((height - st::historyEmptySize) * 4) / 9); + p.setPen(Qt::NoPen); + p.setBrush(App::msgServiceBg()); + p.setRenderHint(QPainter::HighQualityAntialiasing); + p.drawEllipse(rtlrect(position.x(), position.y(), st::historyEmptySize, st::historyEmptySize, width)); + p.setRenderHint(QPainter::HighQualityAntialiasing, false); + st::historyEmptyDog.paint(p, position.x() + (st::historyEmptySize - st::historyEmptyDog.width()) / 2, position.y() + (st::historyEmptySize - st::historyEmptyDog.height()) / 2, width); +} + void serviceColorsUpdated() { if (serviceMessageStyle) { for (auto &corner : serviceMessageStyle->corners) { diff --git a/Telegram/SourceFiles/history/history_service_layout.h b/Telegram/SourceFiles/history/history_service_layout.h index 4c9beee4d..faae5d450 100644 --- a/Telegram/SourceFiles/history/history_service_layout.h +++ b/Telegram/SourceFiles/history/history_service_layout.h @@ -48,6 +48,8 @@ private: }; +void paintEmpty(Painter &p, int width, int height); + void serviceColorsUpdated(); } // namespace HistoryLayout diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index a8917224e..e9a7beee6 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -376,8 +376,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) { textstyleRestore(); } } else if (noHistoryDisplayed) { - QPoint dogPos((width() - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9); - p.drawPixmap(dogPos, Window::chatBackground()->dog()); + HistoryLayout::paintEmpty(p, width(), height()); } if (!noHistoryDisplayed) { adjustCurrent(r.top()); @@ -8776,8 +8775,7 @@ void HistoryWidget::paintEvent(QPaintEvent *e) { } if (_scroll.isHidden()) { p.setClipRect(_scroll.geometry()); - QPoint dogPos((width() - st::msgDogImg.pxWidth()) / 2, ((height() - _field.height() - 2 * st::sendPadding - st::msgDogImg.pxHeight()) * 4) / 9); - p.drawPixmap(dogPos, Window::chatBackground()->dog()); + HistoryLayout::paintEmpty(p, width(), height() - _field.height() - 2 * st::sendPadding); } } else { style::font font(st::msgServiceFont); diff --git a/Telegram/SourceFiles/layout.cpp b/Telegram/SourceFiles/layout.cpp index 4aa94953a..bcdcd1e2e 100644 --- a/Telegram/SourceFiles/layout.cpp +++ b/Telegram/SourceFiles/layout.cpp @@ -230,11 +230,6 @@ style::color documentSelectedColor(int32 colorIndex) { 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]; -} - RoundCorners documentCorners(int32 colorIndex) { return RoundCorners(DocBlueCorners + (colorIndex & 3)); } diff --git a/Telegram/SourceFiles/layout.h b/Telegram/SourceFiles/layout.h index 385050401..bb5ff4307 100644 --- a/Telegram/SourceFiles/layout.h +++ b/Telegram/SourceFiles/layout.h @@ -86,7 +86,6 @@ 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); bool documentIsValidMediaFile(const QString &filepath); diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index e48dcbaeb..7ce562e00 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -715,7 +715,7 @@ HitTestType MainWindow::hitTest(const QPoint &p) const { } QRect MainWindow::iconRect() const { - return QRect(st::titleIconPos + title->geometry().topLeft(), st::titleIconImg.pxSize()); + return title->iconRect(); } bool MainWindow::eventFilter(QObject *obj, QEvent *e) { diff --git a/Telegram/SourceFiles/media/view/mediaview.style b/Telegram/SourceFiles/media/view/mediaview.style index e2888cc70..7f43918ef 100644 --- a/Telegram/SourceFiles/media/view/mediaview.style +++ b/Telegram/SourceFiles/media/view/mediaview.style @@ -85,19 +85,28 @@ mediaviewClose: icon {{ "mediaview_close", #ffffff }}; mediaviewSave: icon {{ "mediaview_download", #ffffff }}; mediaviewMore: icon {{ "mediaview_more", #ffffff }}; +mediaviewFileRedCornerFg: #d55959; +mediaviewFileYellowCornerFg: #e8a659; +mediaviewFileGreenCornerFg: #49a957; +mediaviewFileBlueCornerFg: #599dcf; + mediaviewFileRed: icon { { size(25px, 25px), #ffffff }, - { "mediaview_file_corner", #d55959 }, + { "mediaview_file_corner", mediaviewFileRedCornerFg }, }; mediaviewFileYellow: icon { { size(25px, 25px), #ffffff }, - { "mediaview_file_corner", #e8a659 }, + { "mediaview_file_corner", mediaviewFileYellowCornerFg }, }; mediaviewFileGreen: icon { { size(25px, 25px), #ffffff }, - { "mediaview_file_corner", #49a957 }, + { "mediaview_file_corner", mediaviewFileGreenCornerFg }, }; mediaviewFileBlue: icon { { size(25px, 25px), #ffffff }, - { "mediaview_file_corner", #599dcf }, + { "mediaview_file_corner", mediaviewFileBlueCornerFg }, }; + +mediaviewTransparentBg: #ffffff; +mediaviewTransparentFg: #cccccc; +mediaviewTransparentSize: 4px; diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 82d603b4c..eb3c30909 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -103,7 +103,7 @@ MediaView::MediaView() : TWidget(App::wnd()) } }); - _transparentBrush = QBrush(App::sprite().copy(st::mvTransparentBrush.rect())); + generateTransparentBrush(); setWindowFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Tool | Qt::NoDropShadowWindowHint); moveToScreen(); @@ -2628,6 +2628,19 @@ void MediaView::loadBack() { } } +void MediaView::generateTransparentBrush() { + auto size = st::mediaviewTransparentSize * cIntRetinaFactor(); + auto transparent = QImage(2 * size, 2 * size, QImage::Format_ARGB32_Premultiplied); + transparent.fill(st::mediaviewTransparentBg->c); + { + Painter p(&transparent); + p.fillRect(rtlrect(0, size, size, size, 2 * size), st::mediaviewTransparentFg); + p.fillRect(rtlrect(size, 0, size, size, 2 * size), st::mediaviewTransparentFg); + } + transparent.setDevicePixelRatio(cRetinaFactor()); + _transparentBrush = QBrush(transparent); +} + MediaView::LastChatPhoto MediaView::computeLastOverviewChatPhoto() { LastChatPhoto emptyResult = { nullptr, nullptr }; auto lastPhotoInOverview = [&emptyResult](auto history, auto list) -> LastChatPhoto { diff --git a/Telegram/SourceFiles/mediaview.h b/Telegram/SourceFiles/mediaview.h index 320b86fb5..b86383165 100644 --- a/Telegram/SourceFiles/mediaview.h +++ b/Telegram/SourceFiles/mediaview.h @@ -136,6 +136,8 @@ private: void findCurrent(); void loadBack(); + void generateTransparentBrush(); + void updateCursor(); void setZoomLevel(int newZoom); diff --git a/Telegram/SourceFiles/overview/overview.style b/Telegram/SourceFiles/overview/overview.style index c010d0191..7250e6d15 100644 --- a/Telegram/SourceFiles/overview/overview.style +++ b/Telegram/SourceFiles/overview/overview.style @@ -20,6 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ using "basic.style"; using "history/history.style"; +using "media/view/mediaview.style"; OverviewFileLayout { maxWidth: pixels; diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index b58b9a468..ff5f18a72 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -34,6 +34,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "application.h" #include "overview/overview_layout.h" #include "history/history_media_types.h" +#include "history/history_service_layout.h" #include "media/media_audio.h" // flick scroll taken from http://qt-project.org/doc/qt-4.8/demos-embedded-anomaly-src-flickcharm-cpp.html @@ -778,8 +779,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) { Overview::Layout::PaintContext context(ms, _selMode); if (_history->overview[_type].isEmpty() && (!_migrated || !_history->overviewLoaded(_type) || _migrated->overview[_type].isEmpty())) { - QPoint dogPos((_width - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9); - p.drawPixmap(dogPos, Window::chatBackground()->dog()); + HistoryLayout::paintEmpty(p, _width, height()); return; } else if (_inSearch && _searchResults.isEmpty() && _searchFull && (!_migrated || _searchFullMigrated) && !_searchTimer.isActive()) { p.setFont(st::noContactsFont->f); diff --git a/Telegram/SourceFiles/stickers/stickers.style b/Telegram/SourceFiles/stickers/stickers.style index c215aadcf..c1a9168a1 100644 --- a/Telegram/SourceFiles/stickers/stickers.style +++ b/Telegram/SourceFiles/stickers/stickers.style @@ -20,6 +20,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ using "basic.style"; +using "boxes/boxes.style"; + featuredStickersHeader: 45px; featuredStickersSkip: 15px; diff --git a/Telegram/SourceFiles/title.cpp b/Telegram/SourceFiles/title.cpp index 0a34528a2..9722ac9d4 100644 --- a/Telegram/SourceFiles/title.cpp +++ b/Telegram/SourceFiles/title.cpp @@ -31,6 +31,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "media/player/media_player_title_button.h" #include "media/player/media_player_panel.h" #include "media/player/media_player_instance.h" +#include "styles/style_window.h" class TitleWidget::Hider : public TWidget { public: @@ -126,9 +127,9 @@ void TitleWidget::paintEvent(QPaintEvent *e) { auto chooseText = lang(inlineSwitchChoose ? lng_inline_switch_choose : lng_forward_choose); p.drawText(st::titleMenuOffset - st::titleTextButton.width / 2, st::titleTextButton.textTop + st::titleTextButton.font->ascent, chooseText); } - p.drawSprite(st::titleIconPos, st::titleIconImg); + st::titleIcon.paint(p, st::titleIconPosition, width()); if (Adaptive::OneColumn() && !_counter.isNull() && App::main()) { - p.drawPixmap(st::titleIconPos.x() + st::titleIconImg.pxWidth() - (_counter.width() / cIntRetinaFactor()), st::titleIconPos.y() + st::titleIconImg.pxHeight() - (_counter.height() / cIntRetinaFactor()), _counter); + p.drawPixmap(st::titleCounterPosition, _counter); } } @@ -335,11 +336,11 @@ void TitleWidget::updateCounter() { } _counter = App::pixmapFromImageInPlace(App::wnd()->iconWithCounter(size, counter, bg, false)); _counter.setDevicePixelRatio(cRetinaFactor()); - update(QRect(st::titleIconPos, st::titleIconImg.pxSize())); + update(QRect(st::titleCounterPosition, _counter.size() / cIntRetinaFactor())); } else { if (!_counter.isNull()) { + update(QRect(st::titleCounterPosition, _counter.size() / cIntRetinaFactor())); _counter = QPixmap(); - update(QRect(st::titleIconPos, st::titleIconImg.pxSize())); } } } @@ -395,7 +396,7 @@ HitTestType TitleWidget::hitTest(const QPoint &p) { int x(p.x()), y(p.y()), w(width()), h(height()); if (!Adaptive::OneColumn() && _hider && x >= App::main()->dlgsWidth()) return HitTestType::None; - if (x >= st::titleIconPos.x() && y >= st::titleIconPos.y() && x < st::titleIconPos.x() + st::titleIconImg.pxWidth() && y < st::titleIconPos.y() + st::titleIconImg.pxHeight()) { + if (x >= st::titleIconPosition.x() && y >= st::titleIconPosition.y() && x < st::titleIconPosition.x() + st::titleIcon.width() && y < st::titleIconPosition.y() + st::titleIcon.height()) { return HitTestType::Icon; } else if (false || (_player && _player->geometry().contains(p)) @@ -420,3 +421,7 @@ HitTestType TitleWidget::hitTest(const QPoint &p) { } return HitTestType::None; } + +QRect TitleWidget::iconRect() const { + return myrtlrect(QRect(st::titleIconPosition, st::titleIcon.size())); +} diff --git a/Telegram/SourceFiles/title.h b/Telegram/SourceFiles/title.h index 6cfd8edff..ea278669e 100644 --- a/Telegram/SourceFiles/title.h +++ b/Telegram/SourceFiles/title.h @@ -42,6 +42,7 @@ public: void maximizedChanged(bool maximized, bool force = false); HitTestType hitTest(const QPoint &p); + QRect iconRect() const; void setHideLevel(float64 level); diff --git a/Telegram/SourceFiles/ui/style/style_core_icon.cpp b/Telegram/SourceFiles/ui/style/style_core_icon.cpp index acad1c618..2df173ae9 100644 --- a/Telegram/SourceFiles/ui/style/style_core_icon.cpp +++ b/Telegram/SourceFiles/ui/style/style_core_icon.cpp @@ -134,7 +134,7 @@ void MonoIcon::ensureLoaded() const { if (size > sizeTag.size() && !memcmp(data, sizeTag.data(), sizeTag.size())) { size -= sizeTag.size(); data += sizeTag.size(); - QByteArray baForStream(reinterpret_cast(data), size); + auto baForStream = QByteArray::fromRawData(reinterpret_cast(data), size); QBuffer buffer(&baForStream); buffer.open(QIODevice::ReadOnly); @@ -207,7 +207,7 @@ int Icon::width() const { int Icon::height() const { if (_height < 0) { _height = 0; - for_const (const auto &part, _parts) { + for_const (auto &part, _parts) { accumulate_max(_height, part.offset().x() + part.height()); } } diff --git a/Telegram/SourceFiles/ui/style/style_core_icon.h b/Telegram/SourceFiles/ui/style/style_core_icon.h index 7fb337a3f..c4e6b73a7 100644 --- a/Telegram/SourceFiles/ui/style/style_core_icon.h +++ b/Telegram/SourceFiles/ui/style/style_core_icon.h @@ -118,6 +118,9 @@ public: void fill(QPainter &p, const QRect &rect) const; int width() const; int height() const; + QSize size() const { + return QSize(width(), height()); + } private: struct ColoredCopy { diff --git a/Telegram/SourceFiles/window/chat_background.cpp b/Telegram/SourceFiles/window/chat_background.cpp index 294e53471..315ac129f 100644 --- a/Telegram/SourceFiles/window/chat_background.cpp +++ b/Telegram/SourceFiles/window/chat_background.cpp @@ -41,10 +41,9 @@ void ChatBackground::initIfEmpty() { } } -void ChatBackground::init(int32 id, QPixmap &&image, QPixmap &&dog) { +void ChatBackground::init(int32 id, QPixmap &&image) { _id = id; _image = std_::move(image); - _dog = std_::move(dog); notify(ChatBackgroundUpdate(ChatBackgroundUpdate::Type::New, _tile)); } @@ -52,7 +51,6 @@ void ChatBackground::init(int32 id, QPixmap &&image, QPixmap &&dog) { void ChatBackground::reset() { _id = 0; _image = QPixmap(); - _dog = QPixmap(); _tile = false; notify(ChatBackgroundUpdate(ChatBackgroundUpdate::Type::New, _tile)); @@ -66,10 +64,6 @@ const QPixmap &ChatBackground::image() const { return _image; } -const QPixmap &ChatBackground::dog() const { - return _dog; -} - bool ChatBackground::tile() const { return _tile; } diff --git a/Telegram/SourceFiles/window/chat_background.h b/Telegram/SourceFiles/window/chat_background.h index 67a2bf72d..6840dbc2f 100644 --- a/Telegram/SourceFiles/window/chat_background.h +++ b/Telegram/SourceFiles/window/chat_background.h @@ -39,19 +39,17 @@ class ChatBackground : public base::Observable { public: bool empty() const; void initIfEmpty(); - void init(int32 id, QPixmap &&image, QPixmap &&dog); + void init(int32 id, QPixmap &&image); void reset(); int32 id() const; const QPixmap &image() const; - const QPixmap &dog() const; bool tile() const; void setTile(bool tile); private: int32 _id = 0; QPixmap _image; - QPixmap _dog; bool _tile = false; }; diff --git a/Telegram/SourceFiles/window/window.style b/Telegram/SourceFiles/window/window.style index 721d756c9..8722c4d3b 100644 --- a/Telegram/SourceFiles/window/window.style +++ b/Telegram/SourceFiles/window/window.style @@ -21,6 +21,13 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org using "basic.style"; +titleIconPosition: point(9px, 9px); +titleIcon: icon { + { "title_icon_bg", #49708f }, + { "title_icon", #ffffff, point(4px, 4px) } +}; +titleCounterPosition: point(17px, 17px); + notifyBg: white; notifyBorder: #f1f1f1; notifyBorderWidth: 1px;