diff --git a/Telegram/Resources/style.txt b/Telegram/Resources/style.txt index dcdbc631f8..9b5461146f 100644 --- a/Telegram/Resources/style.txt +++ b/Telegram/Resources/style.txt @@ -289,8 +289,6 @@ boxSearchCancel: iconedButton { titleBG: #6389a8; titleColor: #0f8dcc;//rgb(20, 136, 210); titleHeight: 39px; -titleShadowColor: rgba(0, 0, 0, 24);//#ebebeb -titleShadow: 1px; titleIconPos: point(7px, 7px); titleIconImg: sprite(160px, 100px, 26px, 26px); titleFont: font(17px); @@ -307,6 +305,13 @@ titleTypingColor: #0080c0; statusFont: font(fsize); versionColor: #777; +shadowColor: rgba(0, 0, 0, 24); + +slideDuration: 4000; +slideShift: 0.3; +slideShadowLeft: sprite(348px, 70px, 48px, 1px); +slideShadowRight: sprite(348px, 71px, 48px, 1px); + btnDefIconed: iconedButton { color: white; bgColor: white; @@ -600,7 +605,7 @@ introPointHideAlphaT: transition(easeOutCirc); introStepSize: size(400px, 200px); introSize: size(400px, 400px); introSlideShift: 500px; // intro hiding animation -introSlideDuration: 200; +introSlideDuration: 4000; introSlideDelta: 0; // between hide start and show start introHideFunc: transition(easeInCirc); introShowFunc: transition(easeOutCirc); @@ -829,9 +834,6 @@ noContactsColor: #777; dlgSep: 8px; -dlgShadowColor: rgba(0, 0, 0, 24);//#ebebeb -dlgShadow: 1px; - dlgMinWidth: 260px; dlgRichMinWidth: 150px; dlgMaxWidth: 540px; @@ -1344,7 +1346,7 @@ newMsgSound: ':/gui/art/newmsg.wav'; unreadBarHeight: 32px; unreadBarFont: font(fsize semibold); unreadBarBG: #fcfbfa; -unreadBarBorder: titleShadowColor; +unreadBarBorder: shadowColor; unreadBarColor: #538bb4; searchedBarHeight: unreadBarHeight; diff --git a/Telegram/SourceFiles/art/sprite.png b/Telegram/SourceFiles/art/sprite.png index edd61be47f..2a8b4f83f8 100644 Binary files a/Telegram/SourceFiles/art/sprite.png and b/Telegram/SourceFiles/art/sprite.png differ diff --git a/Telegram/SourceFiles/art/sprite_200x.png b/Telegram/SourceFiles/art/sprite_200x.png index 2513dd2125..93f74d78a2 100644 Binary files a/Telegram/SourceFiles/art/sprite_200x.png and b/Telegram/SourceFiles/art/sprite_200x.png differ diff --git a/Telegram/SourceFiles/boxes/abstractbox.cpp b/Telegram/SourceFiles/boxes/abstractbox.cpp index d2d8bdae0a..9cb73b1a7b 100644 --- a/Telegram/SourceFiles/boxes/abstractbox.cpp +++ b/Telegram/SourceFiles/boxes/abstractbox.cpp @@ -220,11 +220,6 @@ void AbstractBox::raiseShadow() { } } -void ScrollableBoxShadow::paintEvent(QPaintEvent *e) { - Painter p(this); - p.fillRect(e->rect(), st::boxScrollShadowBg->b); -} - ScrollableBox::ScrollableBox(const style::flatScroll &scroll, int32 w) : AbstractBox(w), _scroll(this, scroll), _innerPtr(0), _topSkip(st::boxTitleHeight), _bottomSkip(st::boxScrollSkip) { setBlueTitle(true); diff --git a/Telegram/SourceFiles/boxes/abstractbox.h b/Telegram/SourceFiles/boxes/abstractbox.h index 5de24cc004..7028319aed 100644 --- a/Telegram/SourceFiles/boxes/abstractbox.h +++ b/Telegram/SourceFiles/boxes/abstractbox.h @@ -104,11 +104,10 @@ private: BlueTitleShadow *_blueShadow; }; -class ScrollableBoxShadow : public TWidget { +class ScrollableBoxShadow : public PlainShadow { public: - ScrollableBoxShadow(QWidget *parent) : TWidget(parent) { + ScrollableBoxShadow(QWidget *parent) : PlainShadow(parent, st::boxScrollShadowBg) { } - void paintEvent(QPaintEvent *e); }; class ScrollableBox : public AbstractBox { diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 12c096521c..0898d7588f 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -1489,8 +1489,7 @@ MsgId DialogsInner::lastSearchId() const { return _lastSearchId; } -DialogsWidget::DialogsWidget(MainWidget *parent) : QWidget(parent) -, _drawShadow(true) +DialogsWidget::DialogsWidget(MainWidget *parent) : TWidget(parent) , _dragInScroll(false) , _dragForward(false) , _dialogsOffset(0) @@ -2137,7 +2136,7 @@ void DialogsWidget::onCompleteHashtag(QString tag) { } void DialogsWidget::resizeEvent(QResizeEvent *e) { - int32 w = width() - st::dlgShadow; + int32 w = width(); _filter.setGeometry(st::dlgPaddingHor, st::dlgFilterPadding, w - 2 * st::dlgPaddingHor, _filter.height()); _newGroup.move(w - _newGroup.width() - st::dlgPaddingHor, _filter.y()); _addContact.move(w - _addContact.width() - st::dlgPaddingHor, _filter.y()); @@ -2198,20 +2197,14 @@ void DialogsWidget::paintEvent(QPaintEvent *e) { p.drawPixmap(a_coord.current(), 0, _animCache); return; } - QRect above(0, 0, width() - (cWideMode() ? st::dlgShadow : 0), _scroll.y()); + QRect above(0, 0, width(), _scroll.y()); if (above.intersects(r)) { p.fillRect(above.intersected(r), st::white->b); } - QRect below(0, _scroll.y() + qMin(_scroll.height(), _inner.height()), width() - (cWideMode() ? st::dlgShadow : 0), height()); + QRect below(0, _scroll.y() + qMin(_scroll.height(), _inner.height()), width(), height()); if (below.intersects(r)) { p.fillRect(below.intersected(r), st::white->b); } - if (cWideMode() && _drawShadow) { - QRect sh(width() - st::dlgShadow, 0, st::dlgShadow, height()); - if (r.intersects(sh)) { - p.fillRect(sh, st::dlgShadowColor->b); - } - } } void DialogsWidget::destroyData() { @@ -2308,7 +2301,3 @@ void DialogsWidget::onDialogMoved(int movedFrom, int movedTo) { _scroll.scrollToY(st + st::dlgHeight); } } - -void DialogsWidget::enableShadow(bool enable) { - _drawShadow = enable; -} diff --git a/Telegram/SourceFiles/dialogswidget.h b/Telegram/SourceFiles/dialogswidget.h index 20d882c25b..85b1f65c53 100644 --- a/Telegram/SourceFiles/dialogswidget.h +++ b/Telegram/SourceFiles/dialogswidget.h @@ -176,7 +176,7 @@ private: }; -class DialogsWidget : public QWidget, public Animated, public RPCSender { +class DialogsWidget : public TWidget, public Animated, public RPCSender { Q_OBJECT public: @@ -222,8 +222,6 @@ public: DialogsIndexed &contactsList(); DialogsIndexed &dialogsList(); - void enableShadow(bool enable = true); - void searchMessages(const QString &query, PeerData *inPeer = 0); void onSearchMore(MsgId minMsgId); @@ -256,8 +254,6 @@ public slots: private: - bool _drawShadow; - bool _dragInScroll, _dragForward; QTimer _chooseByDragTimer; diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp index a374a23f23..125e72d2f0 100644 --- a/Telegram/SourceFiles/dropdown.cpp +++ b/Telegram/SourceFiles/dropdown.cpp @@ -2669,7 +2669,7 @@ void MentionsInner::paintEvent(QPaintEvent *e) { int32 atwidth = st::mentionFont->width('@'), hashwidth = st::mentionFont->width('#'); int32 mentionleft = 2 * st::mentionPadding.left() + st::mentionPhotoSize; int32 mentionwidth = width() - mentionleft - 2 * st::mentionPadding.right(); - int32 htagleft = st::btnAttachPhoto.width + st::taMsgField.textMrg.left() - st::dlgShadow, htagwidth = width() - st::mentionPadding.right() - htagleft - st::mentionScroll.width; + int32 htagleft = st::btnAttachPhoto.width + st::taMsgField.textMrg.left() - st::lineWidth, htagwidth = width() - st::mentionPadding.right() - htagleft - st::mentionScroll.width; int32 from = qFloor(e->rect().top() / st::mentionHeight), to = qFloor(e->rect().bottom() / st::mentionHeight) + 1; int32 last = _rows->isEmpty() ? (_hrows->isEmpty() ? _crows->size() : _hrows->size()) : _rows->size(); @@ -2778,8 +2778,8 @@ void MentionsInner::paintEvent(QPaintEvent *e) { } } - p.fillRect(cWideMode() ? st::dlgShadow : 0, _parent->innerTop(), width() - (cWideMode() ? st::dlgShadow : 0), st::titleShadow, st::titleShadowColor->b); - p.fillRect(cWideMode() ? st::dlgShadow : 0, _parent->innerBottom() - st::titleShadow, width() - (cWideMode() ? st::dlgShadow : 0), st::titleShadow, st::titleShadowColor->b); + p.fillRect(cWideMode() ? st::lineWidth : 0, _parent->innerTop(), width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b); + p.fillRect(cWideMode() ? st::lineWidth : 0, _parent->innerBottom() - st::lineWidth, width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b); } void MentionsInner::mouseMoveEvent(QMouseEvent *e) { diff --git a/Telegram/SourceFiles/gui/twidget.h b/Telegram/SourceFiles/gui/twidget.h index a51bee9374..4481112d4b 100644 --- a/Telegram/SourceFiles/gui/twidget.h +++ b/Telegram/SourceFiles/gui/twidget.h @@ -209,3 +209,16 @@ private: void myEnsureResized(QWidget *target); QPixmap myGrab(QWidget *target, const QRect &rect); + +class PlainShadow : public TWidget { +public: + PlainShadow(QWidget *parent, const style::color &color) : TWidget(parent), _color(color) { + } + void paintEvent(QPaintEvent *e) { + Painter(this).fillRect(e->rect(), _color->b); + } + +private: + const style::color &_color; + +}; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 926ae34cfc..587a2a89e5 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -1712,7 +1712,7 @@ ReportSpamPanel::ReportSpamPanel(HistoryWidget *parent) : TWidget(parent), _report(this, lang(lng_report_spam), st::reportSpamHide), _hide(this, lang(lng_report_spam_hide), st::reportSpamHide), _clear(this, lang(lng_profile_delete_conversation)) { - resize(parent->width(), _hide.height() + st::titleShadow); + resize(parent->width(), _hide.height() + st::lineWidth); connect(&_report, SIGNAL(clicked()), this, SIGNAL(reportClicked())); connect(&_hide, SIGNAL(clicked()), this, SIGNAL(hideClicked())); @@ -1730,12 +1730,8 @@ void ReportSpamPanel::resizeEvent(QResizeEvent *e) { void ReportSpamPanel::paintEvent(QPaintEvent *e) { Painter p(this); - p.fillRect(QRect(0, 0, width(), height() - st::titleShadow), st::reportSpamBg->b); - if (cWideMode()) { - p.fillRect(st::titleShadow, height() - st::titleShadow, width() - st::titleShadow, st::titleShadow, st::titleShadowColor->b); - } else { - p.fillRect(0, height() - st::titleShadow, width(), st::titleShadow, st::titleShadowColor->b); - } + p.fillRect(QRect(0, 0, width(), height() - st::lineWidth), st::reportSpamBg->b); + p.fillRect(cWideMode() ? st::lineWidth : 0, height() - st::lineWidth, width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b); if (!_clear.isHidden()) { p.setPen(st::black->p); p.setFont(st::msgFont->f); @@ -2060,7 +2056,7 @@ void BotKeyboard::updateSelected() { } } -HistoryHider::HistoryHider(MainWidget *parent, bool forwardSelected) : QWidget(parent) +HistoryHider::HistoryHider(MainWidget *parent, bool forwardSelected) : TWidget(parent) , _sharedContact(0) , _forwardSelected(forwardSelected) , _sendPath(false) @@ -2076,7 +2072,7 @@ HistoryHider::HistoryHider(MainWidget *parent, bool forwardSelected) : QWidget(p init(); } -HistoryHider::HistoryHider(MainWidget *parent, UserData *sharedContact) : QWidget(parent) +HistoryHider::HistoryHider(MainWidget *parent, UserData *sharedContact) : TWidget(parent) , _sharedContact(sharedContact) , _forwardSelected(false) , _sendPath(false) @@ -2092,7 +2088,7 @@ HistoryHider::HistoryHider(MainWidget *parent, UserData *sharedContact) : QWidge init(); } -HistoryHider::HistoryHider(MainWidget *parent) : QWidget(parent) +HistoryHider::HistoryHider(MainWidget *parent) : TWidget(parent) , _sharedContact(0) , _forwardSelected(false) , _sendPath(true) @@ -2388,7 +2384,9 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent) , _showAnim(animFunc(this, &HistoryWidget::showStep)) , _scrollDelta(0) , _saveDraftStart(0) -, _saveDraftText(false) { +, _saveDraftText(false) +, _sideShadow(this, st::shadowColor) +, _topShadow(this, st::shadowColor) { _scroll.setFocusPolicy(Qt::NoFocus); setAcceptDrops(true); @@ -4025,7 +4023,11 @@ void HistoryWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTo a_alpha = anim::fvalue(0, 1); a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift); a_bgAlpha = anim::fvalue(1, 0); + + _sideShadow.hide(); + _topShadow.hide(); _showAnim.start(); + App::main()->topBar()->update(); activate(); } @@ -4036,6 +4038,9 @@ bool HistoryWidget::showStep(float64 ms) { bool res = true; if (dt2 >= 1) { _showAnim.stop(); + _sideShadow.show(); + _topShadow.show(); + res = false; a_bgCoord.finish(); a_bgAlpha.finish(); @@ -4043,7 +4048,6 @@ bool HistoryWidget::showStep(float64 ms) { a_alpha.finish(); _bgAnimCache = _animCache = _animTopBarCache = _bgAnimTopBarCache = QPixmap(); App::main()->topBar()->stopAnim(); - App::main()->topBar()->enableShadow(); doneShow(); if (App::app()) App::app()->mtpUnpause(); @@ -4073,6 +4077,8 @@ void HistoryWidget::doneShow() { void HistoryWidget::animStop() { if (!_showAnim.animating()) return; _showAnim.stop(); + _sideShadow.show(); + _topShadow.show(); } bool HistoryWidget::recordStep(float64 ms) { @@ -4644,13 +4650,6 @@ void HistoryWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) } } -void HistoryWidget::topBarShadowParams(int32 &x, float64 &o) { - if (_showAnim.animating() && a_coord.current() >= 0) { - x = a_coord.current(); - o = a_alpha.current(); - } -} - void HistoryWidget::topBarClick() { if (cWideMode()) { if (_history) App::main()->showPeerProfile(_peer); @@ -5275,6 +5274,11 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) { _attachDragPhoto.move(st::dragMargin.left(), st::dragMargin.top()); break; } + + _topShadow.resize(width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth); + _topShadow.moveToLeft(cWideMode() ? st::lineWidth : 0, 0); + _sideShadow.resize(st::lineWidth, height()); + _sideShadow.moveToLeft(0, 0); } void HistoryWidget::itemRemoved(HistoryItem *item) { diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 98668ea51d..928bf42124 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -311,7 +311,7 @@ private: }; -class HistoryHider : public QWidget, public Animated { +class HistoryHider : public TWidget, public Animated { Q_OBJECT public: @@ -412,7 +412,6 @@ public: void checkMentionDropdown(); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); - void topBarShadowParams(int32 &x, float64 &o); void topBarClick(); void loadMessages(); @@ -791,5 +790,7 @@ private: bool _saveDraftText; QTimer _saveDraftTimer; + PlainShadow _sideShadow, _topShadow; + }; diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index e85ced8aa6..4384d2675e 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -35,18 +35,25 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org #include "audio.h" -TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w), - a_over(0), _drawShadow(true), _selPeer(0), _selCount(0), _canDelete(false), _selStrLeft(-st::topBarButton.width / 2), _selStrWidth(0), _animating(false), - _clearSelection(this, lang(lng_selected_clear), st::topBarButton), - _forward(this, lang(lng_selected_forward), st::topBarActionButton), - _delete(this, lang(lng_selected_delete), st::topBarActionButton), - _selectionButtonsWidth(_clearSelection.width() + _forward.width() + _delete.width()), _forwardDeleteWidth(qMax(_forward.textWidth(), _delete.textWidth())), - _info(this, lang(lng_topbar_info), st::topBarButton), - _edit(this, lang(lng_profile_edit_contact), st::topBarButton), - _leaveGroup(this, lang(lng_profile_delete_and_exit), st::topBarButton), - _addContact(this, lang(lng_profile_add_contact), st::topBarButton), - _deleteContact(this, lang(lng_profile_delete_contact), st::topBarButton), - _mediaType(this, lang(lng_media_type), st::topBarButton) { +TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w) +, a_over(0) +, _selPeer(0) +, _selCount(0) +, _canDelete(false) +, _selStrLeft(-st::topBarButton.width / 2) +, _selStrWidth(0) +, _animating(false) +, _clearSelection(this, lang(lng_selected_clear), st::topBarButton) +, _forward(this, lang(lng_selected_forward), st::topBarActionButton) +, _delete(this, lang(lng_selected_delete), st::topBarActionButton) +, _selectionButtonsWidth(_clearSelection.width() + _forward.width() + _delete.width()), _forwardDeleteWidth(qMax(_forward.textWidth(), _delete.textWidth())) +, _info(this, lang(lng_topbar_info), st::topBarButton) +, _edit(this, lang(lng_profile_edit_contact), st::topBarButton) +, _leaveGroup(this, lang(lng_profile_delete_and_exit), st::topBarButton) +, _addContact(this, lang(lng_profile_add_contact), st::topBarButton) +, _deleteContact(this, lang(lng_profile_delete_contact), st::topBarButton) +, _mediaType(this, lang(lng_media_type), st::topBarButton) +, _sideShadow(this, st::shadowColor) { connect(&_forward, SIGNAL(clicked()), this, SLOT(onForwardSelection())); connect(&_delete, SIGNAL(clicked()), this, SLOT(onDeleteSelection())); @@ -170,10 +177,6 @@ bool TopBarWidget::animStep(float64 ms) { return res; } -void TopBarWidget::enableShadow(bool enable) { - _drawShadow = enable; -} - void TopBarWidget::paintEvent(QPaintEvent *e) { QPainter p(this); @@ -189,18 +192,6 @@ void TopBarWidget::paintEvent(QPaintEvent *e) { p.drawText(_selStrLeft, st::topBarButton.textTop + st::linkFont->ascent, _selStr); } } - if (_drawShadow) { - int32 shadowCoord = 0; - float64 shadowOpacity = 1.; - main()->topBarShadowParams(shadowCoord, shadowOpacity); - - p.setOpacity(shadowOpacity); - if (cWideMode()) { - p.fillRect(shadowCoord + st::titleShadow, st::topBarHeight, width() - st::titleShadow, st::titleShadow, st::titleShadowColor->b); - } else { - p.fillRect(shadowCoord, st::topBarHeight, width(), st::titleShadow, st::titleShadowColor->b); - } - } } void TopBarWidget::mousePressEvent(QMouseEvent *e) { @@ -269,6 +260,9 @@ void TopBarWidget::resizeEvent(QResizeEvent *e) { if (!_edit.isHidden()) _edit.move(r -= _edit.width(), 0); if (!_addContact.isHidden()) _addContact.move(r -= _addContact.width(), 0); if (!_mediaType.isHidden()) _mediaType.move(r -= _mediaType.width(), 0); + + _sideShadow.resize(st::lineWidth, height()); + _sideShadow.moveToLeft(0, 0); } void TopBarWidget::startAnim() { @@ -281,12 +275,15 @@ void TopBarWidget::startAnim() { _delete.hide(); _forward.hide(); _mediaType.hide(); - _animating = true; + + _animating = true; + _sideShadow.hide(); } void TopBarWidget::stopAnim() { _animating = false; - showAll(); + _sideShadow.show(); + showAll(); } void TopBarWidget::showAll() { @@ -377,7 +374,7 @@ MainWidget *TopBarWidget::main() { return static_cast(parentWidget()); } -MainWidget::MainWidget(Window *window) : QWidget(window), +MainWidget::MainWidget(Window *window) : TWidget(window), _started(0), failedObjId(0), _toForwardNameVersion(0), _dialogsWidth(st::dlgMinWidth), dialogs(this), history(this), profile(0), overview(0), _player(this), _topBar(this), _forwardConfirm(0), _hider(0), _peerInStack(0), _msgIdInStack(0), @@ -662,11 +659,8 @@ void MainWidget::noHider(HistoryHider *destroyed) { } onHistoryShown(history.history(), history.msgId()); if (profile || overview || (history.peer() && history.peer()->id)) { - dialogs.enableShadow(false); QPixmap animCache = myGrab(this, QRect(0, _playerHeight + st::topBarHeight, _dialogsWidth, height() - _playerHeight - st::topBarHeight)), animTopBarCache = myGrab(this, QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight)); - dialogs.enableShadow(); - _topBar.enableShadow(); dialogs.hide(); if (overview) { overview->show(); @@ -700,10 +694,7 @@ void MainWidget::hiderLayer(HistoryHider *h) { dialogsToUp(); _hider->hide(); - dialogs.enableShadow(false); QPixmap animCache = myGrab(this, QRect(0, _playerHeight, _dialogsWidth, height() - _playerHeight)); - dialogs.enableShadow(); - _topBar.enableShadow(); onHistoryShown(0, 0); if (overview) { @@ -1846,7 +1837,7 @@ void MainWidget::documentPlayProgress(const SongMsgId &songId) { if (playing == songId) { _player.updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); - if (!(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { + if (!(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing && !animating()) { if (_player.isHidden()) { _player.clearSelection(); _player.show(); @@ -2338,9 +2329,7 @@ void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) QPixmap animCache, animTopBarCache; if (!animating() && ((history.isHidden() && (profile || overview)) || (!cWideMode() && (history.isHidden() || !peerId)))) { - dialogs.enableShadow(false); if (peerId) { - _topBar.enableShadow(false); if (cWideMode()) { animCache = myGrab(this, QRect(_dialogsWidth, _playerHeight + st::topBarHeight, width() - _dialogsWidth, height() - _playerHeight - st::topBarHeight)); } else { @@ -2354,8 +2343,6 @@ void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) if (peerId || cWideMode()) { animTopBarCache = myGrab(this, QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight)); } - dialogs.enableShadow(); - _topBar.enableShadow(); history.show(); } if (history.peer() && history.peer()->id != peerId) clearBotStartToken(history.peer()); @@ -2487,8 +2474,6 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool return; } - dialogs.enableShadow(false); - _topBar.enableShadow(false); QRect topBarRect = QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight); QRect historyRect = QRect(history.x(), topBarRect.y() + topBarRect.height(), history.width(), history.y() + history.height() - topBarRect.y() - topBarRect.height()); QPixmap animCache, animTopBarCache; @@ -2496,8 +2481,6 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool animCache = myGrab(this, historyRect); animTopBarCache = myGrab(this, topBarRect); } - dialogs.enableShadow(); - _topBar.enableShadow(); if (!back) { if (overview) { _stack.push_back(new StackItemOverview(overview->peer(), overview->type(), overview->lastWidth(), overview->lastScrollTop())); @@ -2549,11 +2532,7 @@ void MainWidget::showPeerProfile(PeerData *peer, bool back, int32 lastScrollTop) App::wnd()->hideSettings(); if (profile && profile->peer() == peer) return; - dialogs.enableShadow(false); - _topBar.enableShadow(false); QPixmap animCache = myGrab(this, history.geometry()), animTopBarCache = myGrab(this, QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight)); - dialogs.enableShadow(); - _topBar.enableShadow(); if (!back) { if (overview) { _stack.push_back(new StackItemOverview(overview->peer(), overview->type(), overview->lastWidth(), overview->lastScrollTop())); @@ -2775,6 +2754,7 @@ void MainWidget::hideAll() { } _topBar.hide(); _mediaType.hide(); + _player.hide(); } void MainWidget::showAll() { @@ -2834,6 +2814,22 @@ void MainWidget::showAll() { dialogs.hide(); } } + if (audioPlayer()) { + SongMsgId playing; + AudioPlayerState playingState = AudioPlayerStopped; + int64 playingPosition = 0, playingDuration = 0; + int32 playingFrequency = 0; + audioPlayer()->currentState(&playing, &playingState, &playingPosition, &playingDuration, &playingFrequency); + if (playing) { + _player.updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); + if (!(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { + _player.clearSelection(); + _player.show(); + _playerHeight = _player.height(); + } + } + } + App::wnd()->checkHistoryActivation(); } @@ -2841,20 +2837,27 @@ void MainWidget::resizeEvent(QResizeEvent *e) { int32 tbh = _topBar.isHidden() ? 0 : st::topBarHeight; if (cWideMode()) { _dialogsWidth = snap((width() * 5) / 14, st::dlgMinWidth, st::dlgMaxWidth); - dialogs.setGeometry(0, 0, _dialogsWidth + st::dlgShadow, height()); - _player.setGeometry(_dialogsWidth, 0, width() - _dialogsWidth, _player.height()); - _topBar.setGeometry(_dialogsWidth, _playerHeight, width() - _dialogsWidth, st::topBarHeight + st::titleShadow); - history.setGeometry(_dialogsWidth, _playerHeight + tbh, width() - _dialogsWidth, height() - _playerHeight - tbh); - if (_hider) _hider->setGeometry(QRect(_dialogsWidth, 0, width() - _dialogsWidth, height())); + dialogs.resize(_dialogsWidth, height()); + dialogs.moveToLeft(0, 0); + _player.resize(width() - _dialogsWidth, _player.height()); + _player.moveToLeft(_dialogsWidth, 0); + _topBar.resize(width() - _dialogsWidth, st::topBarHeight); + _topBar.moveToLeft(_dialogsWidth, _playerHeight); + history.resize(width() - _dialogsWidth, height() - _playerHeight - tbh); + history.moveToLeft(_dialogsWidth, _playerHeight + tbh); + if (_hider) { + _hider->resize(width() - _dialogsWidth, height()); + _hider->moveToLeft(_dialogsWidth, 0); + } } else { _dialogsWidth = width(); _player.setGeometry(0, 0, _dialogsWidth, _player.height()); - dialogs.setGeometry(0, _playerHeight, _dialogsWidth + st::dlgShadow, height() - _playerHeight); - _topBar.setGeometry(0, _playerHeight, _dialogsWidth, st::topBarHeight + st::titleShadow); + dialogs.setGeometry(0, _playerHeight, _dialogsWidth, height() - _playerHeight); + _topBar.setGeometry(0, _playerHeight, _dialogsWidth, st::topBarHeight); history.setGeometry(0, _playerHeight + tbh, _dialogsWidth, height() - _playerHeight - tbh); - if (_hider) _hider->setGeometry(QRect(0, 0, _dialogsWidth, height())); + if (_hider) _hider->setGeometry(0, 0, _dialogsWidth, height()); } - _mediaType.move(width() - _mediaType.width(), _playerHeight + st::topBarHeight); + _mediaType.moveToLeft(width() - _mediaType.width(), _playerHeight + st::topBarHeight); if (profile) profile->setGeometry(history.geometry()); if (overview) overview->setGeometry(history.geometry()); _contentScrollAddToY = 0; @@ -2890,18 +2893,6 @@ void MainWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) { } } -void MainWidget::topBarShadowParams(int32 &x, float64 &o) { - if (!cWideMode() && dialogs.isHidden()) { - if (profile) { - if (!_peerInStack) profile->topBarShadowParams(x, o); - } else if (overview) { - if (!_peerInStack) overview->topBarShadowParams(x, o); - } else { - history.topBarShadowParams(x, o); - } - } -} - void MainWidget::onPhotosSelect() { if (overview) overview->switchType(OverviewPhotos); _mediaType.hideStart(); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index aac0b9079b..2b375e55c6 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -78,7 +78,6 @@ private: MainWidget *main(); anim::fvalue a_over; - bool _drawShadow; PeerData *_selPeer; uint32 _selCount; @@ -96,6 +95,8 @@ private: FlatButton _edit, _leaveGroup, _addContact, _deleteContact; FlatButton _mediaType; + PlainShadow _sideShadow; + }; enum StackItemType { @@ -176,7 +177,7 @@ enum ForwardWhatMessages { ForwardPressedLinkMessage }; -class MainWidget : public QWidget, public Animated, public RPCSender { +class MainWidget : public TWidget, public Animated, public RPCSender { Q_OBJECT public: @@ -192,7 +193,6 @@ public: void showDialogs(); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); - void topBarShadowParams(int32 &x, float64 &o); TopBarWidget *topBar(); PlayerWidget *player(); diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index b8ac750415..c3ad16339b 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -2540,14 +2540,16 @@ OverviewInner::~OverviewInner() { _links.clear(); } -OverviewWidget::OverviewWidget(QWidget *parent, const PeerData *peer, MediaOverviewType type) : QWidget(parent) +OverviewWidget::OverviewWidget(QWidget *parent, const PeerData *peer, MediaOverviewType type) : TWidget(parent) , _scroll(this, st::historyScroll, false) , _inner(this, &_scroll, peer, type) , _noDropResizeIndex(false) , _showing(false) , _scrollSetAfterShow(0) , _scrollDelta(0) -, _selCount(0) { +, _selCount(0) +, _sideShadow(this, st::shadowColor) +, _topShadow(this, st::shadowColor) { _scroll.setFocusPolicy(Qt::NoFocus); _scroll.setWidget(&_inner); _scroll.move(0, 0); @@ -2601,6 +2603,11 @@ void OverviewWidget::resizeEvent(QResizeEvent *e) { _scroll.scrollToY(newScrollTop); _noDropResizeIndex = false; } + + _topShadow.resize(width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth); + _topShadow.moveToLeft(cWideMode() ? st::lineWidth : 0, 0); + _sideShadow.resize(st::lineWidth, height()); + _sideShadow.moveToLeft(0, 0); } void OverviewWidget::paintEvent(QPaintEvent *e) { @@ -2682,13 +2689,6 @@ void OverviewWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) } } -void OverviewWidget::topBarShadowParams(int32 &x, float64 &o) { - if (animating() && a_coord.current() >= 0) { - x = a_coord.current(); - o = a_alpha.current(); - } -} - void OverviewWidget::topBarClick() { App::main()->showBackFromStack(); } @@ -2798,7 +2798,11 @@ void OverviewWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimT a_alpha = anim::fvalue(0, 1); a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift); a_bgAlpha = anim::fvalue(1, 0); + anim::start(this); + _sideShadow.hide(); + _topShadow.hide(); + _showing = true; show(); _inner.activate(); @@ -2811,6 +2815,9 @@ bool OverviewWidget::animStep(float64 ms) { bool res = true; if (dt2 >= 1) { res = _showing = false; + _sideShadow.show(); + _topShadow.show(); + a_bgCoord.finish(); a_bgAlpha.finish(); a_coord.finish(); diff --git a/Telegram/SourceFiles/overviewwidget.h b/Telegram/SourceFiles/overviewwidget.h index 02baada875..af9ee4e1cd 100644 --- a/Telegram/SourceFiles/overviewwidget.h +++ b/Telegram/SourceFiles/overviewwidget.h @@ -263,7 +263,7 @@ private: ContextMenu *_menu; }; -class OverviewWidget : public QWidget, public RPCSender, public Animated { +class OverviewWidget : public TWidget, public RPCSender, public Animated { Q_OBJECT public: @@ -280,7 +280,6 @@ public: void scrollReset(); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); - void topBarShadowParams(int32 &x, float64 &o); void topBarClick(); PeerData *peer() const; @@ -353,5 +352,7 @@ private: int32 _selCount; + PlainShadow _sideShadow, _topShadow; + }; diff --git a/Telegram/SourceFiles/playerwidget.cpp b/Telegram/SourceFiles/playerwidget.cpp index 472c1759c3..2a102c65f0 100644 --- a/Telegram/SourceFiles/playerwidget.cpp +++ b/Telegram/SourceFiles/playerwidget.cpp @@ -32,12 +32,28 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org #include "audio.h" -PlayerWidget::PlayerWidget(QWidget *parent) : TWidget(parent), -_prevAvailable(false), _nextAvailable(false), _fullAvailable(false), -_over(OverNone), _down(OverNone), _downCoord(0), _downFrequency(AudioVoiceMsgFrequency), _downProgress(0.), -_stateAnim(animFunc(this, &PlayerWidget::stateStep)), -_index(-1), _history(0), _timeWidth(0), _repeat(false), _showPause(false), _position(0), _duration(0), _loaded(0), -a_progress(0., 0.), a_loadProgress(0., 0.), _progressAnim(animFunc(this, &PlayerWidget::progressStep)) { +PlayerWidget::PlayerWidget(QWidget *parent) : TWidget(parent) +, _prevAvailable(false) +, _nextAvailable(false) +, _fullAvailable(false) +, _over(OverNone) +, _down(OverNone) +, _downCoord(0) +, _downFrequency(AudioVoiceMsgFrequency) +, _downProgress(0.) +, _stateAnim(animFunc(this, &PlayerWidget::stateStep)) +, _index(-1) +, _history(0) +, _timeWidth(0) +, _repeat(false) +, _showPause(false) +, _position(0) +, _duration(0) +, _loaded(0) +, a_progress(0., 0.) +, a_loadProgress(0., 0.) +, _progressAnim(animFunc(this, &PlayerWidget::progressStep)) +, _sideShadow(this, st::shadowColor) { resize(st::wndMinWidth, st::playerHeight); setMouseTracking(true); memset(_stateHovers, 0, sizeof(_stateHovers)); @@ -492,7 +508,7 @@ void PlayerWidget::stopPressed() { void PlayerWidget::resizeEvent(QResizeEvent *e) { int32 availh = (height() - st::playerLineHeight); int32 ch = st::playerPlay.pxHeight() + st::playerSkip, ct = (availh - ch) / 2; - _playbackRect = QRect(cWideMode() ? st::dlgShadow : 0, height() - st::playerMoverSize.height(), width() - (cWideMode() ? st::dlgShadow : 0), st::playerMoverSize.height()); + _playbackRect = QRect(cWideMode() ? st::lineWidth : 0, height() - st::playerMoverSize.height(), width() - (cWideMode() ? st::lineWidth : 0), st::playerMoverSize.height()); _prevRect = _fullAvailable ? QRect(st::playerSkip / 2, ct, st::playerPrev.pxWidth() + st::playerSkip, ch) : QRect(); _playRect = QRect(_fullAvailable ? (_prevRect.x() + _prevRect.width()) : (st::playerSkip / 2), ct, st::playerPlay.pxWidth() + st::playerSkip, ch); _nextRect = _fullAvailable ? QRect(_playRect.x() + _playRect.width(), ct, st::playerNext.pxWidth() + st::playerSkip, ch) : QRect(); @@ -504,6 +520,10 @@ void PlayerWidget::resizeEvent(QResizeEvent *e) { int32 infoLeft = (_fullAvailable ? (_nextRect.x() + _nextRect.width()) : (_playRect.x() + _playRect.width())); _infoRect = QRect(infoLeft + st::playerSkip / 2, 0, (_fullAvailable ? _fullRect.x() : _repeatRect.x()) - infoLeft - st::playerSkip, availh); + + _sideShadow.resize(st::lineWidth, height()); + _sideShadow.moveToLeft(0, 0); + update(); } diff --git a/Telegram/SourceFiles/playerwidget.h b/Telegram/SourceFiles/playerwidget.h index 5fee6f57af..5796468e26 100644 --- a/Telegram/SourceFiles/playerwidget.h +++ b/Telegram/SourceFiles/playerwidget.h @@ -113,4 +113,6 @@ private: anim::fvalue a_progress, a_loadProgress; Animation _progressAnim; + PlainShadow _sideShadow; + }; diff --git a/Telegram/SourceFiles/profilewidget.cpp b/Telegram/SourceFiles/profilewidget.cpp index e9222f4776..e24c9b8a40 100644 --- a/Telegram/SourceFiles/profilewidget.cpp +++ b/Telegram/SourceFiles/profilewidget.cpp @@ -1523,11 +1523,12 @@ QString ProfileInner::overviewLinkText(int32 type, int32 count) { return QString(); } -ProfileWidget::ProfileWidget(QWidget *parent, const PeerData *peer) : QWidget(parent) - , _scroll(this, st::setScroll) - , _inner(this, &_scroll, peer) - , _showing(false) -{ +ProfileWidget::ProfileWidget(QWidget *parent, const PeerData *peer) : TWidget(parent) +, _scroll(this, st::setScroll) +, _inner(this, &_scroll, peer) +, _showing(false) +, _sideShadow(this, st::shadowColor) +, _topShadow(this, st::shadowColor) { _scroll.setWidget(&_inner); _scroll.move(0, 0); _inner.move(0, 0); @@ -1556,6 +1557,11 @@ void ProfileWidget::resizeEvent(QResizeEvent *e) { _inner.allowDecreaseHeight(_scroll.scrollTopMax() - _scroll.scrollTop()); } } + + _topShadow.resize(width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth); + _topShadow.moveToLeft(cWideMode() ? st::lineWidth : 0, 0); + _sideShadow.resize(st::lineWidth, height()); + _sideShadow.moveToLeft(0, 0); } void ProfileWidget::mousePressEvent(QMouseEvent *e) { @@ -1596,13 +1602,6 @@ void ProfileWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth) } } -void ProfileWidget::topBarShadowParams(int32 &x, float64 &o) { - if (animating() && a_coord.current() >= 0) { - x = a_coord.current(); - o = a_alpha.current(); - } -} - void ProfileWidget::topBarClick() { App::main()->showBackFromStack(); } @@ -1631,7 +1630,11 @@ void ProfileWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTo a_alpha = anim::fvalue(0, 1); a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift); a_bgAlpha = anim::fvalue(1, 0); + anim::start(this); + _sideShadow.hide(); + _topShadow.hide(); + _showing = true; show(); _inner.setFocus(); @@ -1644,6 +1647,9 @@ bool ProfileWidget::animStep(float64 ms) { bool res = true; if (dt2 >= 1) { res = _showing = false; + _sideShadow.show(); + _topShadow.show(); + a_bgCoord.finish(); a_bgAlpha.finish(); a_coord.finish(); diff --git a/Telegram/SourceFiles/profilewidget.h b/Telegram/SourceFiles/profilewidget.h index 691aaf18a2..22248cca67 100644 --- a/Telegram/SourceFiles/profilewidget.h +++ b/Telegram/SourceFiles/profilewidget.h @@ -201,7 +201,7 @@ private: }; -class ProfileWidget : public QWidget, public RPCSender, public Animated { +class ProfileWidget : public TWidget, public RPCSender, public Animated { Q_OBJECT public: @@ -215,7 +215,6 @@ public: void dropEvent(QDropEvent *e); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); - void topBarShadowParams(int32 &x, float64 &o); void topBarClick(); PeerData *peer() const; @@ -250,5 +249,7 @@ private: anim::ivalue a_coord, a_bgCoord; anim::fvalue a_alpha, a_bgAlpha; + PlainShadow _sideShadow, _topShadow; + }; diff --git a/Telegram/SourceFiles/title.cpp b/Telegram/SourceFiles/title.cpp index 7c81d746de..364d233417 100644 --- a/Telegram/SourceFiles/title.cpp +++ b/Telegram/SourceFiles/title.cpp @@ -35,7 +35,7 @@ TitleHider::TitleHider(QWidget *parent) : QWidget(parent), _level(0) { void TitleHider::paintEvent(QPaintEvent *e) { QPainter p(this); p.setOpacity(_level * st::layerAlpha); - p.fillRect(App::main()->dlgsWidth() - st::dlgShadow, 0, width() + st::dlgShadow - App::main()->dlgsWidth(), height(), st::layerBg->b); + p.fillRect(App::main()->dlgsWidth(), 0, width() - App::main()->dlgsWidth(), height(), st::layerBg->b); } void TitleHider::mousePressEvent(QMouseEvent *e) {