From a774e9b712aa4909579b66661f1f01eee69f7e5f Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 24 Oct 2016 00:25:29 +0300 Subject: [PATCH] Closed beta 0.10.17.2: macOS animation improvements, multiselect design. --- Telegram/Resources/winrc/Telegram.rc | 8 +++--- Telegram/Resources/winrc/Updater.rc | 8 +++--- Telegram/SourceFiles/boxes/boxes.style | 6 ++--- Telegram/SourceFiles/boxes/contactsbox.cpp | 27 ++++++------------- Telegram/SourceFiles/boxes/contactsbox.h | 2 +- Telegram/SourceFiles/boxes/sharebox.cpp | 25 +++++------------ Telegram/SourceFiles/boxes/sharebox.h | 2 +- Telegram/SourceFiles/core/version.h | 4 +-- Telegram/SourceFiles/ui/animation.h | 16 +++++++---- .../ui/effects/round_image_checkbox.cpp | 15 ++++++----- .../ui/effects/round_image_checkbox.h | 2 +- Telegram/SourceFiles/ui/flatinput.cpp | 8 ++++++ .../SourceFiles/ui/widgets/multi_select.cpp | 7 +++-- Telegram/build/version | 4 +-- 14 files changed, 66 insertions(+), 68 deletions(-) diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index ccab91948..ca3820dc3 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,10,17,0 - PRODUCTVERSION 0,10,17,0 + FILEVERSION 0,10,17,2 + PRODUCTVERSION 0,10,17,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "0.10.17.0" + VALUE "FileVersion", "0.10.17.2" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.17.0" + VALUE "ProductVersion", "0.10.17.2" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 9544a3ea8..f959611a4 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,10,17,0 - PRODUCTVERSION 0,10,17,0 + FILEVERSION 0,10,17,2 + PRODUCTVERSION 0,10,17,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Updater" - VALUE "FileVersion", "0.10.17.0" + VALUE "FileVersion", "0.10.17.2" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.17.0" + VALUE "ProductVersion", "0.10.17.2" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index dd6031904..f50ed827e 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -106,11 +106,11 @@ contactsMultiSelect: MultiSelect { font: normalFont; textBg: contactsBgOver; textFg: windowTextFg; - textActiveBg: titleBg; + textActiveBg: windowActiveBg; textActiveFg: white; deleteFg: white; - deleteLeft: 9px; - deleteStroke: 3px; + deleteLeft: 10px; + deleteStroke: 2px; duration: 150; minScale: 0.3; } diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index 1a7c2cb13..dff590fce 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -353,21 +353,9 @@ void ContactsBox::onFilterUpdate(const QString &filter) { } void ContactsBox::addPeerToMultiSelect(PeerData *peer, bool skipAnimation) { - auto getColor = [peer]() -> const style::color & { - switch (peer->colorIndex) { - case 1: return st::historyPeer2UserpicFg; - case 2: return st::historyPeer3UserpicFg; - case 3: return st::historyPeer4UserpicFg; - case 4: return st::historyPeer5UserpicFg; - case 5: return st::historyPeer6UserpicFg; - case 6: return st::historyPeer7UserpicFg; - case 7: return st::historyPeer8UserpicFg; - default: return st::historyPeer1UserpicFg; - } - }; using AddItemWay = Ui::MultiSelect::AddItemWay; auto addItemWay = skipAnimation ? AddItemWay::SkipAnimation : AddItemWay::Default; - _select->entity()->addItem(peer->id, peer->shortName(), getColor(), PaintUserpicCallback(peer), addItemWay); + _select->entity()->addItem(peer->id, peer->shortName(), st::windowActiveBg, PaintUserpicCallback(peer), addItemWay); } void ContactsBox::onPeerSelectedChanged(PeerData *peer, bool checked) { @@ -941,7 +929,7 @@ ContactsBox::Inner::ContactData *ContactsBox::Inner::contactData(Dialogs::Row *r return data; } -void ContactsBox::Inner::paintDialog(Painter &p, PeerData *peer, ContactData *data, bool sel) { +void ContactsBox::Inner::paintDialog(Painter &p, uint64 ms, PeerData *peer, ContactData *data, bool sel) { UserData *user = peer->asUser(); if (_chat && _membersFilter == MembersFilter::Admins) { @@ -967,7 +955,7 @@ void ContactsBox::Inner::paintDialog(Painter &p, PeerData *peer, ContactData *da paintDisabledCheckUserpic(p, peer, st::contactsPadding.left(), st::contactsPadding.top(), width()); } else if (usingMultiSelect()) { checkedRatio = data->checkbox->checkedAnimationRatio(); - data->checkbox->paint(p, st::contactsPadding.left(), st::contactsPadding.top(), width()); + data->checkbox->paint(p, ms, st::contactsPadding.left(), st::contactsPadding.top(), width()); } else { peer->paintUserpicLeft(p, st::contactsPhotoSize, st::contactsPadding.left(), st::contactsPadding.top(), width()); } @@ -1060,6 +1048,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { _time = unixtime(); p.fillRect(r, st::white); + uint64 ms = getms(); int32 yFrom = r.y(), yTo = r.y() + r.height(); if (_filter.isEmpty()) { if (!_contacts->isEmpty() || !_byUsername.isEmpty()) { @@ -1089,7 +1078,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { if ((*i)->pos() * _rowHeight >= yTo) { break; } - paintDialog(p, (*i)->history()->peer, contactData(*i), (*i == _sel)); + paintDialog(p, ms, (*i)->history()->peer, contactData(*i), (*i == _sel)); p.translate(0, _rowHeight); } yFrom -= _contacts->size() * _rowHeight; @@ -1109,7 +1098,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { int32 to = ceilclamp(yTo, _rowHeight, 0, _byUsername.size()); p.translate(0, from * _rowHeight); for (; from < to; ++from) { - paintDialog(p, _byUsername[from], d_byUsername[from], (_byUsernameSel == from)); + paintDialog(p, ms, _byUsername[from], d_byUsername[from], (_byUsernameSel == from)); p.translate(0, _rowHeight); } } @@ -1156,7 +1145,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { int32 to = ceilclamp(yTo, _rowHeight, 0, _filtered.size()); p.translate(0, from * _rowHeight); for (; from < to; ++from) { - paintDialog(p, _filtered[from]->history()->peer, contactData(_filtered[from]), (_filteredSel == from)); + paintDialog(p, ms, _filtered[from]->history()->peer, contactData(_filtered[from]), (_filteredSel == from)); p.translate(0, _rowHeight); } } @@ -1173,7 +1162,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { int32 to = ceilclamp(yTo, _rowHeight, 0, _byUsernameFiltered.size()); p.translate(0, from * _rowHeight); for (; from < to; ++from) { - paintDialog(p, _byUsernameFiltered[from], d_byUsernameFiltered[from], (_byUsernameSel == from)); + paintDialog(p, ms, _byUsernameFiltered[from], d_byUsernameFiltered[from], (_byUsernameSel == from)); p.translate(0, _rowHeight); } } diff --git a/Telegram/SourceFiles/boxes/contactsbox.h b/Telegram/SourceFiles/boxes/contactsbox.h index b5dbdee5c..0db72c0dd 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.h +++ b/Telegram/SourceFiles/boxes/contactsbox.h @@ -232,7 +232,7 @@ private: void addAdminDone(const MTPUpdates &result, mtpRequestId req); bool addAdminFail(const RPCError &error, mtpRequestId req); - void paintDialog(Painter &p, PeerData *peer, ContactData *data, bool sel); + void paintDialog(Painter &p, uint64 ms, PeerData *peer, ContactData *data, bool sel); void paintDisabledCheckUserpic(Painter &p, PeerData *peer, int x, int y, int outerWidth) const; void changeCheckState(Dialogs::Row *row); diff --git a/Telegram/SourceFiles/boxes/sharebox.cpp b/Telegram/SourceFiles/boxes/sharebox.cpp index 10602c077..a0054c2d2 100644 --- a/Telegram/SourceFiles/boxes/sharebox.cpp +++ b/Telegram/SourceFiles/boxes/sharebox.cpp @@ -234,21 +234,9 @@ void ShareBox::onFilterUpdate(const QString &query) { } void ShareBox::addPeerToMultiSelect(PeerData *peer, bool skipAnimation) { - auto getColor = [peer]() -> const style::color & { - switch (peer->colorIndex) { - case 1: return st::historyPeer2UserpicFg; - case 2: return st::historyPeer3UserpicFg; - case 3: return st::historyPeer4UserpicFg; - case 4: return st::historyPeer5UserpicFg; - case 5: return st::historyPeer6UserpicFg; - case 6: return st::historyPeer7UserpicFg; - case 7: return st::historyPeer8UserpicFg; - default: return st::historyPeer1UserpicFg; - } - }; using AddItemWay = Ui::MultiSelect::AddItemWay; auto addItemWay = skipAnimation ? AddItemWay::SkipAnimation : AddItemWay::Default; - _select->addItem(peer->id, peer->shortName(), getColor(), PaintUserpicCallback(peer), addItemWay); + _select->addItem(peer->id, peer->shortName(), st::windowActiveBg, PaintUserpicCallback(peer), addItemWay); } void ShareBox::onPeerSelectedChanged(PeerData *peer, bool checked) { @@ -511,14 +499,14 @@ void ShareBox::Inner::setActive(int active) { emit mustScrollTo(y, y + _rowHeight); } -void ShareBox::Inner::paintChat(Painter &p, Chat *chat, int index) { +void ShareBox::Inner::paintChat(Painter &p, uint64 ms, Chat *chat, int index) { auto x = _rowsLeft + qFloor((index % _columnCount) * _rowWidthReal); auto y = _rowsTop + (index / _columnCount) * _rowHeight; auto outerWidth = width(); auto photoLeft = (_rowWidth - (st::sharePhotoCheckbox.imageRadius * 2)) / 2; auto photoTop = st::sharePhotoTop; - chat->checkbox.paint(p, x + photoLeft, y + photoTop, outerWidth); + chat->checkbox.paint(p, ms, x + photoLeft, y + photoTop, outerWidth); if (chat->nameFg.animating()) { p.setPen(chat->nameFg.current()); @@ -541,6 +529,7 @@ ShareBox::Inner::Chat::Chat(PeerData *peer, base::lambda_wrap updateCall void ShareBox::Inner::paintEvent(QPaintEvent *e) { Painter p(this); + auto ms = getms(); auto r = e->rect(); p.setClipRect(r); p.fillRect(r, st::white); @@ -556,7 +545,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) { if (indexFrom >= indexTo) { break; } - paintChat(p, getChat(*i), indexFrom); + paintChat(p, ms, getChat(*i), indexFrom); ++indexFrom; } } else { @@ -577,7 +566,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) { if (indexFrom >= _filtered.size()) { break; } - paintChat(p, getChat(_filtered[indexFrom]), indexFrom); + paintChat(p, ms, getChat(_filtered[indexFrom]), indexFrom); ++indexFrom; } indexFrom -= filteredSize; @@ -589,7 +578,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) { if (indexFrom >= d_byUsernameFiltered.size()) { break; } - paintChat(p, d_byUsernameFiltered[indexFrom], filteredSize + indexFrom); + paintChat(p, ms, d_byUsernameFiltered[indexFrom], filteredSize + indexFrom); ++indexFrom; } } diff --git a/Telegram/SourceFiles/boxes/sharebox.h b/Telegram/SourceFiles/boxes/sharebox.h index 7629d608e..449c56242 100644 --- a/Telegram/SourceFiles/boxes/sharebox.h +++ b/Telegram/SourceFiles/boxes/sharebox.h @@ -164,7 +164,7 @@ private: Text name; ColorAnimation nameFg; }; - void paintChat(Painter &p, Chat *chat, int index); + void paintChat(Painter &p, uint64 ms, Chat *chat, int index); void updateChat(PeerData *peer); void updateChatName(Chat *chat, PeerData *peer); void repaintChat(PeerData *peer); diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 06798f066..701e8ddc4 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,9 +22,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "core/utils.h" -#define BETA_VERSION_MACRO (0ULL) +#define BETA_VERSION_MACRO (10017002ULL) constexpr int AppVersion = 10017; constexpr str_const AppVersionStr = "0.10.17"; -constexpr bool AppAlphaVersion = true; +constexpr bool AppAlphaVersion = false; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; diff --git a/Telegram/SourceFiles/ui/animation.h b/Telegram/SourceFiles/ui/animation.h index 8e8657815..8f2b7f427 100644 --- a/Telegram/SourceFiles/ui/animation.h +++ b/Telegram/SourceFiles/ui/animation.h @@ -484,6 +484,15 @@ public: using ValueType = typename AnimType::ValueType; using Callback = base::lambda_unique; + void step(uint64 ms) { + if (_data) { + _data->a_animation.step(ms); + if (_data && !_data->a_animation.animating()) { + _data.reset(); + } + } + } + bool animating() const { if (_data) { if (_data->a_animation.animating()) { @@ -494,11 +503,8 @@ public: return false; } bool animating(uint64 ms) { - if (animating()) { - _data->a_animation.step(ms); - return animating(); - } - return false; + step(ms); + return animating(); } ValueType current() const { diff --git a/Telegram/SourceFiles/ui/effects/round_image_checkbox.cpp b/Telegram/SourceFiles/ui/effects/round_image_checkbox.cpp index de70ee3a7..f0fcb5456 100644 --- a/Telegram/SourceFiles/ui/effects/round_image_checkbox.cpp +++ b/Telegram/SourceFiles/ui/effects/round_image_checkbox.cpp @@ -65,7 +65,14 @@ RoundImageCheckbox::RoundImageCheckbox(const style::RoundImageCheckbox &st, base prepareCheckCaches(&_st, _wideCheckBgCache, _wideCheckFullCache); } -void RoundImageCheckbox::paint(Painter &p, int x, int y, int outerWidth) { +void RoundImageCheckbox::paint(Painter &p, uint64 ms, int x, int y, int outerWidth) { + _selection.step(ms); + for (auto &icon : _icons) { + icon.fadeIn.step(ms); + icon.fadeOut.step(ms); + } + removeFadeOutedIcons(); + auto selectionLevel = _selection.current(_checked ? 1. : 0.); if (_selection.animating()) { auto userpicRadius = qRound(kWideScale * (_st.imageRadius + (_st.imageSmallRadius - _st.imageRadius) * selectionLevel)); @@ -101,7 +108,6 @@ void RoundImageCheckbox::paint(Painter &p, int x, int y, int outerWidth) { p.setRenderHint(QPainter::HighQualityAntialiasing, false); } - removeFadeOutedIcons(); p.setRenderHint(QPainter::SmoothPixmapTransform, true); for (auto &icon : _icons) { auto fadeIn = icon.fadeIn.current(1.); @@ -149,10 +155,7 @@ void RoundImageCheckbox::setChecked(bool checked, SetStyle speed) { _icons.back().fadeIn.finish(); } } else { - _icons.back().fadeOut.start([this] { - _updateCallback(); - removeFadeOutedIcons(); // this call can destroy current lambda - }, 1, 0, _st.selectDuration); + _icons.back().fadeOut.start(_updateCallback, 1, 0, _st.selectDuration); if (speed == SetStyle::Animated) { prepareWideCheckIconCache(&_icons.back()); } else { diff --git a/Telegram/SourceFiles/ui/effects/round_image_checkbox.h b/Telegram/SourceFiles/ui/effects/round_image_checkbox.h index c94a3c78d..3b9d0f79a 100644 --- a/Telegram/SourceFiles/ui/effects/round_image_checkbox.h +++ b/Telegram/SourceFiles/ui/effects/round_image_checkbox.h @@ -29,7 +29,7 @@ public: using PaintRoundImage = base::lambda_unique; RoundImageCheckbox(const style::RoundImageCheckbox &st, base::lambda_wrap updateCallback, PaintRoundImage paintRoundImage); - void paint(Painter &p, int x, int y, int outerWidth); + void paint(Painter &p, uint64 ms, int x, int y, int outerWidth); float64 checkedAnimationRatio() const; bool checked() const { diff --git a/Telegram/SourceFiles/ui/flatinput.cpp b/Telegram/SourceFiles/ui/flatinput.cpp index 7b5966b4d..5f835f9a8 100644 --- a/Telegram/SourceFiles/ui/flatinput.cpp +++ b/Telegram/SourceFiles/ui/flatinput.cpp @@ -1438,6 +1438,14 @@ void InputField::touchEvent(QTouchEvent *e) { void InputField::paintEvent(QPaintEvent *e) { Painter p(this); + auto ms = getms(); + if (_a_placeholderShift.animating()) { + _a_placeholderShift.step(ms); + } + if (_a_placeholderFg.animating()) { + _a_placeholderFg.step(ms); + } + QRect r(rect().intersected(e->rect())); if (_st.textBg->c.alphaF() > 0.) { p.fillRect(r, _st.textBg); diff --git a/Telegram/SourceFiles/ui/widgets/multi_select.cpp b/Telegram/SourceFiles/ui/widgets/multi_select.cpp index ef0336f7f..bef2de71b 100644 --- a/Telegram/SourceFiles/ui/widgets/multi_select.cpp +++ b/Telegram/SourceFiles/ui/widgets/multi_select.cpp @@ -579,6 +579,10 @@ int MultiSelect::Inner::resizeGetHeight(int newWidth) { void MultiSelect::Inner::paintEvent(QPaintEvent *e) { Painter p(this); + auto ms = getms(); + _height.step(ms); + _iconOpacity.step(ms); + auto paintRect = e->rect(); p.fillRect(paintRect, st::windowBg); @@ -586,9 +590,8 @@ void MultiSelect::Inner::paintEvent(QPaintEvent *e) { p.translate(offset); paintRect.translate(-offset); - auto ms = getms(); auto outerWidth = width() - _st.padding.left() - _st.padding.right(); - auto iconOpacity = _iconOpacity.current(ms, _items.empty() ? 1. : 0.); + auto iconOpacity = _iconOpacity.current(_items.empty() ? 1. : 0.); if (iconOpacity > 0.) { p.setOpacity(iconOpacity); _st.fieldIcon.paint(p, 0, 0, outerWidth); diff --git a/Telegram/build/version b/Telegram/build/version index 513961b5e..a586bce09 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -2,5 +2,5 @@ AppVersion 10017 AppVersionStrMajor 0.10 AppVersionStrSmall 0.10.17 AppVersionStr 0.10.17 -AlphaChannel 1 -BetaVersion 0 +AlphaChannel 0 +BetaVersion 10017002