moved shadows to widgets where they are displayed

This commit is contained in:
John Preston 2015-10-17 10:31:48 +02:00
parent 48756111a9
commit 5c3d030b9a
20 changed files with 193 additions and 166 deletions

View File

@ -289,8 +289,6 @@ boxSearchCancel: iconedButton {
titleBG: #6389a8; titleBG: #6389a8;
titleColor: #0f8dcc;//rgb(20, 136, 210); titleColor: #0f8dcc;//rgb(20, 136, 210);
titleHeight: 39px; titleHeight: 39px;
titleShadowColor: rgba(0, 0, 0, 24);//#ebebeb
titleShadow: 1px;
titleIconPos: point(7px, 7px); titleIconPos: point(7px, 7px);
titleIconImg: sprite(160px, 100px, 26px, 26px); titleIconImg: sprite(160px, 100px, 26px, 26px);
titleFont: font(17px); titleFont: font(17px);
@ -307,6 +305,13 @@ titleTypingColor: #0080c0;
statusFont: font(fsize); statusFont: font(fsize);
versionColor: #777; 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 { btnDefIconed: iconedButton {
color: white; color: white;
bgColor: white; bgColor: white;
@ -600,7 +605,7 @@ introPointHideAlphaT: transition(easeOutCirc);
introStepSize: size(400px, 200px); introStepSize: size(400px, 200px);
introSize: size(400px, 400px); introSize: size(400px, 400px);
introSlideShift: 500px; // intro hiding animation introSlideShift: 500px; // intro hiding animation
introSlideDuration: 200; introSlideDuration: 4000;
introSlideDelta: 0; // between hide start and show start introSlideDelta: 0; // between hide start and show start
introHideFunc: transition(easeInCirc); introHideFunc: transition(easeInCirc);
introShowFunc: transition(easeOutCirc); introShowFunc: transition(easeOutCirc);
@ -829,9 +834,6 @@ noContactsColor: #777;
dlgSep: 8px; dlgSep: 8px;
dlgShadowColor: rgba(0, 0, 0, 24);//#ebebeb
dlgShadow: 1px;
dlgMinWidth: 260px; dlgMinWidth: 260px;
dlgRichMinWidth: 150px; dlgRichMinWidth: 150px;
dlgMaxWidth: 540px; dlgMaxWidth: 540px;
@ -1344,7 +1346,7 @@ newMsgSound: ':/gui/art/newmsg.wav';
unreadBarHeight: 32px; unreadBarHeight: 32px;
unreadBarFont: font(fsize semibold); unreadBarFont: font(fsize semibold);
unreadBarBG: #fcfbfa; unreadBarBG: #fcfbfa;
unreadBarBorder: titleShadowColor; unreadBarBorder: shadowColor;
unreadBarColor: #538bb4; unreadBarColor: #538bb4;
searchedBarHeight: unreadBarHeight; searchedBarHeight: unreadBarHeight;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

After

Width:  |  Height:  |  Size: 236 KiB

View File

@ -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), ScrollableBox::ScrollableBox(const style::flatScroll &scroll, int32 w) : AbstractBox(w),
_scroll(this, scroll), _innerPtr(0), _topSkip(st::boxTitleHeight), _bottomSkip(st::boxScrollSkip) { _scroll(this, scroll), _innerPtr(0), _topSkip(st::boxTitleHeight), _bottomSkip(st::boxScrollSkip) {
setBlueTitle(true); setBlueTitle(true);

View File

@ -104,11 +104,10 @@ private:
BlueTitleShadow *_blueShadow; BlueTitleShadow *_blueShadow;
}; };
class ScrollableBoxShadow : public TWidget { class ScrollableBoxShadow : public PlainShadow {
public: public:
ScrollableBoxShadow(QWidget *parent) : TWidget(parent) { ScrollableBoxShadow(QWidget *parent) : PlainShadow(parent, st::boxScrollShadowBg) {
} }
void paintEvent(QPaintEvent *e);
}; };
class ScrollableBox : public AbstractBox { class ScrollableBox : public AbstractBox {

View File

@ -1489,8 +1489,7 @@ MsgId DialogsInner::lastSearchId() const {
return _lastSearchId; return _lastSearchId;
} }
DialogsWidget::DialogsWidget(MainWidget *parent) : QWidget(parent) DialogsWidget::DialogsWidget(MainWidget *parent) : TWidget(parent)
, _drawShadow(true)
, _dragInScroll(false) , _dragInScroll(false)
, _dragForward(false) , _dragForward(false)
, _dialogsOffset(0) , _dialogsOffset(0)
@ -2137,7 +2136,7 @@ void DialogsWidget::onCompleteHashtag(QString tag) {
} }
void DialogsWidget::resizeEvent(QResizeEvent *e) { 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()); _filter.setGeometry(st::dlgPaddingHor, st::dlgFilterPadding, w - 2 * st::dlgPaddingHor, _filter.height());
_newGroup.move(w - _newGroup.width() - st::dlgPaddingHor, _filter.y()); _newGroup.move(w - _newGroup.width() - st::dlgPaddingHor, _filter.y());
_addContact.move(w - _addContact.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); p.drawPixmap(a_coord.current(), 0, _animCache);
return; return;
} }
QRect above(0, 0, width() - (cWideMode() ? st::dlgShadow : 0), _scroll.y()); QRect above(0, 0, width(), _scroll.y());
if (above.intersects(r)) { if (above.intersects(r)) {
p.fillRect(above.intersected(r), st::white->b); 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)) { if (below.intersects(r)) {
p.fillRect(below.intersected(r), st::white->b); 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() { void DialogsWidget::destroyData() {
@ -2308,7 +2301,3 @@ void DialogsWidget::onDialogMoved(int movedFrom, int movedTo) {
_scroll.scrollToY(st + st::dlgHeight); _scroll.scrollToY(st + st::dlgHeight);
} }
} }
void DialogsWidget::enableShadow(bool enable) {
_drawShadow = enable;
}

View File

@ -176,7 +176,7 @@ private:
}; };
class DialogsWidget : public QWidget, public Animated, public RPCSender { class DialogsWidget : public TWidget, public Animated, public RPCSender {
Q_OBJECT Q_OBJECT
public: public:
@ -222,8 +222,6 @@ public:
DialogsIndexed &contactsList(); DialogsIndexed &contactsList();
DialogsIndexed &dialogsList(); DialogsIndexed &dialogsList();
void enableShadow(bool enable = true);
void searchMessages(const QString &query, PeerData *inPeer = 0); void searchMessages(const QString &query, PeerData *inPeer = 0);
void onSearchMore(MsgId minMsgId); void onSearchMore(MsgId minMsgId);
@ -256,8 +254,6 @@ public slots:
private: private:
bool _drawShadow;
bool _dragInScroll, _dragForward; bool _dragInScroll, _dragForward;
QTimer _chooseByDragTimer; QTimer _chooseByDragTimer;

View File

@ -2669,7 +2669,7 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
int32 atwidth = st::mentionFont->width('@'), hashwidth = st::mentionFont->width('#'); int32 atwidth = st::mentionFont->width('@'), hashwidth = st::mentionFont->width('#');
int32 mentionleft = 2 * st::mentionPadding.left() + st::mentionPhotoSize; int32 mentionleft = 2 * st::mentionPadding.left() + st::mentionPhotoSize;
int32 mentionwidth = width() - mentionleft - 2 * st::mentionPadding.right(); 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 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(); 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::lineWidth : 0, _parent->innerTop(), width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->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->innerBottom() - st::lineWidth, width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b);
} }
void MentionsInner::mouseMoveEvent(QMouseEvent *e) { void MentionsInner::mouseMoveEvent(QMouseEvent *e) {

View File

@ -209,3 +209,16 @@ private:
void myEnsureResized(QWidget *target); void myEnsureResized(QWidget *target);
QPixmap myGrab(QWidget *target, const QRect &rect); 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;
};

View File

@ -1712,7 +1712,7 @@ ReportSpamPanel::ReportSpamPanel(HistoryWidget *parent) : TWidget(parent),
_report(this, lang(lng_report_spam), st::reportSpamHide), _report(this, lang(lng_report_spam), st::reportSpamHide),
_hide(this, lang(lng_report_spam_hide), st::reportSpamHide), _hide(this, lang(lng_report_spam_hide), st::reportSpamHide),
_clear(this, lang(lng_profile_delete_conversation)) { _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(&_report, SIGNAL(clicked()), this, SIGNAL(reportClicked()));
connect(&_hide, SIGNAL(clicked()), this, SIGNAL(hideClicked())); connect(&_hide, SIGNAL(clicked()), this, SIGNAL(hideClicked()));
@ -1730,12 +1730,8 @@ void ReportSpamPanel::resizeEvent(QResizeEvent *e) {
void ReportSpamPanel::paintEvent(QPaintEvent *e) { void ReportSpamPanel::paintEvent(QPaintEvent *e) {
Painter p(this); Painter p(this);
p.fillRect(QRect(0, 0, width(), height() - st::titleShadow), st::reportSpamBg->b); p.fillRect(QRect(0, 0, width(), height() - st::lineWidth), st::reportSpamBg->b);
if (cWideMode()) { p.fillRect(cWideMode() ? st::lineWidth : 0, height() - st::lineWidth, width() - (cWideMode() ? st::lineWidth : 0), st::lineWidth, st::shadowColor->b);
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);
}
if (!_clear.isHidden()) { if (!_clear.isHidden()) {
p.setPen(st::black->p); p.setPen(st::black->p);
p.setFont(st::msgFont->f); 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) , _sharedContact(0)
, _forwardSelected(forwardSelected) , _forwardSelected(forwardSelected)
, _sendPath(false) , _sendPath(false)
@ -2076,7 +2072,7 @@ HistoryHider::HistoryHider(MainWidget *parent, bool forwardSelected) : QWidget(p
init(); init();
} }
HistoryHider::HistoryHider(MainWidget *parent, UserData *sharedContact) : QWidget(parent) HistoryHider::HistoryHider(MainWidget *parent, UserData *sharedContact) : TWidget(parent)
, _sharedContact(sharedContact) , _sharedContact(sharedContact)
, _forwardSelected(false) , _forwardSelected(false)
, _sendPath(false) , _sendPath(false)
@ -2092,7 +2088,7 @@ HistoryHider::HistoryHider(MainWidget *parent, UserData *sharedContact) : QWidge
init(); init();
} }
HistoryHider::HistoryHider(MainWidget *parent) : QWidget(parent) HistoryHider::HistoryHider(MainWidget *parent) : TWidget(parent)
, _sharedContact(0) , _sharedContact(0)
, _forwardSelected(false) , _forwardSelected(false)
, _sendPath(true) , _sendPath(true)
@ -2388,7 +2384,9 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
, _showAnim(animFunc(this, &HistoryWidget::showStep)) , _showAnim(animFunc(this, &HistoryWidget::showStep))
, _scrollDelta(0) , _scrollDelta(0)
, _saveDraftStart(0) , _saveDraftStart(0)
, _saveDraftText(false) { , _saveDraftText(false)
, _sideShadow(this, st::shadowColor)
, _topShadow(this, st::shadowColor) {
_scroll.setFocusPolicy(Qt::NoFocus); _scroll.setFocusPolicy(Qt::NoFocus);
setAcceptDrops(true); setAcceptDrops(true);
@ -4025,7 +4023,11 @@ void HistoryWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTo
a_alpha = anim::fvalue(0, 1); a_alpha = anim::fvalue(0, 1);
a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift); a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift);
a_bgAlpha = anim::fvalue(1, 0); a_bgAlpha = anim::fvalue(1, 0);
_sideShadow.hide();
_topShadow.hide();
_showAnim.start(); _showAnim.start();
App::main()->topBar()->update(); App::main()->topBar()->update();
activate(); activate();
} }
@ -4036,6 +4038,9 @@ bool HistoryWidget::showStep(float64 ms) {
bool res = true; bool res = true;
if (dt2 >= 1) { if (dt2 >= 1) {
_showAnim.stop(); _showAnim.stop();
_sideShadow.show();
_topShadow.show();
res = false; res = false;
a_bgCoord.finish(); a_bgCoord.finish();
a_bgAlpha.finish(); a_bgAlpha.finish();
@ -4043,7 +4048,6 @@ bool HistoryWidget::showStep(float64 ms) {
a_alpha.finish(); a_alpha.finish();
_bgAnimCache = _animCache = _animTopBarCache = _bgAnimTopBarCache = QPixmap(); _bgAnimCache = _animCache = _animTopBarCache = _bgAnimTopBarCache = QPixmap();
App::main()->topBar()->stopAnim(); App::main()->topBar()->stopAnim();
App::main()->topBar()->enableShadow();
doneShow(); doneShow();
if (App::app()) App::app()->mtpUnpause(); if (App::app()) App::app()->mtpUnpause();
@ -4073,6 +4077,8 @@ void HistoryWidget::doneShow() {
void HistoryWidget::animStop() { void HistoryWidget::animStop() {
if (!_showAnim.animating()) return; if (!_showAnim.animating()) return;
_showAnim.stop(); _showAnim.stop();
_sideShadow.show();
_topShadow.show();
} }
bool HistoryWidget::recordStep(float64 ms) { 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() { void HistoryWidget::topBarClick() {
if (cWideMode()) { if (cWideMode()) {
if (_history) App::main()->showPeerProfile(_peer); if (_history) App::main()->showPeerProfile(_peer);
@ -5275,6 +5274,11 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) {
_attachDragPhoto.move(st::dragMargin.left(), st::dragMargin.top()); _attachDragPhoto.move(st::dragMargin.left(), st::dragMargin.top());
break; 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) { void HistoryWidget::itemRemoved(HistoryItem *item) {

View File

@ -311,7 +311,7 @@ private:
}; };
class HistoryHider : public QWidget, public Animated { class HistoryHider : public TWidget, public Animated {
Q_OBJECT Q_OBJECT
public: public:
@ -412,7 +412,6 @@ public:
void checkMentionDropdown(); void checkMentionDropdown();
void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth);
void topBarShadowParams(int32 &x, float64 &o);
void topBarClick(); void topBarClick();
void loadMessages(); void loadMessages();
@ -791,5 +790,7 @@ private:
bool _saveDraftText; bool _saveDraftText;
QTimer _saveDraftTimer; QTimer _saveDraftTimer;
PlainShadow _sideShadow, _topShadow;
}; };

View File

@ -35,18 +35,25 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
#include "audio.h" #include "audio.h"
TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w), 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), , a_over(0)
_clearSelection(this, lang(lng_selected_clear), st::topBarButton), , _selPeer(0)
_forward(this, lang(lng_selected_forward), st::topBarActionButton), , _selCount(0)
_delete(this, lang(lng_selected_delete), st::topBarActionButton), , _canDelete(false)
_selectionButtonsWidth(_clearSelection.width() + _forward.width() + _delete.width()), _forwardDeleteWidth(qMax(_forward.textWidth(), _delete.textWidth())), , _selStrLeft(-st::topBarButton.width / 2)
_info(this, lang(lng_topbar_info), st::topBarButton), , _selStrWidth(0)
_edit(this, lang(lng_profile_edit_contact), st::topBarButton), , _animating(false)
_leaveGroup(this, lang(lng_profile_delete_and_exit), st::topBarButton), , _clearSelection(this, lang(lng_selected_clear), st::topBarButton)
_addContact(this, lang(lng_profile_add_contact), st::topBarButton), , _forward(this, lang(lng_selected_forward), st::topBarActionButton)
_deleteContact(this, lang(lng_profile_delete_contact), st::topBarButton), , _delete(this, lang(lng_selected_delete), st::topBarActionButton)
_mediaType(this, lang(lng_media_type), st::topBarButton) { , _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(&_forward, SIGNAL(clicked()), this, SLOT(onForwardSelection()));
connect(&_delete, SIGNAL(clicked()), this, SLOT(onDeleteSelection())); connect(&_delete, SIGNAL(clicked()), this, SLOT(onDeleteSelection()));
@ -170,10 +177,6 @@ bool TopBarWidget::animStep(float64 ms) {
return res; return res;
} }
void TopBarWidget::enableShadow(bool enable) {
_drawShadow = enable;
}
void TopBarWidget::paintEvent(QPaintEvent *e) { void TopBarWidget::paintEvent(QPaintEvent *e) {
QPainter p(this); QPainter p(this);
@ -189,18 +192,6 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
p.drawText(_selStrLeft, st::topBarButton.textTop + st::linkFont->ascent, _selStr); 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) { void TopBarWidget::mousePressEvent(QMouseEvent *e) {
@ -269,6 +260,9 @@ void TopBarWidget::resizeEvent(QResizeEvent *e) {
if (!_edit.isHidden()) _edit.move(r -= _edit.width(), 0); if (!_edit.isHidden()) _edit.move(r -= _edit.width(), 0);
if (!_addContact.isHidden()) _addContact.move(r -= _addContact.width(), 0); if (!_addContact.isHidden()) _addContact.move(r -= _addContact.width(), 0);
if (!_mediaType.isHidden()) _mediaType.move(r -= _mediaType.width(), 0); if (!_mediaType.isHidden()) _mediaType.move(r -= _mediaType.width(), 0);
_sideShadow.resize(st::lineWidth, height());
_sideShadow.moveToLeft(0, 0);
} }
void TopBarWidget::startAnim() { void TopBarWidget::startAnim() {
@ -281,12 +275,15 @@ void TopBarWidget::startAnim() {
_delete.hide(); _delete.hide();
_forward.hide(); _forward.hide();
_mediaType.hide(); _mediaType.hide();
_animating = true;
_animating = true;
_sideShadow.hide();
} }
void TopBarWidget::stopAnim() { void TopBarWidget::stopAnim() {
_animating = false; _animating = false;
showAll(); _sideShadow.show();
showAll();
} }
void TopBarWidget::showAll() { void TopBarWidget::showAll() {
@ -377,7 +374,7 @@ MainWidget *TopBarWidget::main() {
return static_cast<MainWidget*>(parentWidget()); return static_cast<MainWidget*>(parentWidget());
} }
MainWidget::MainWidget(Window *window) : QWidget(window), MainWidget::MainWidget(Window *window) : TWidget(window),
_started(0), failedObjId(0), _toForwardNameVersion(0), _dialogsWidth(st::dlgMinWidth), _started(0), failedObjId(0), _toForwardNameVersion(0), _dialogsWidth(st::dlgMinWidth),
dialogs(this), history(this), profile(0), overview(0), _player(this), _topBar(this), dialogs(this), history(this), profile(0), overview(0), _player(this), _topBar(this),
_forwardConfirm(0), _hider(0), _peerInStack(0), _msgIdInStack(0), _forwardConfirm(0), _hider(0), _peerInStack(0), _msgIdInStack(0),
@ -662,11 +659,8 @@ void MainWidget::noHider(HistoryHider *destroyed) {
} }
onHistoryShown(history.history(), history.msgId()); onHistoryShown(history.history(), history.msgId());
if (profile || overview || (history.peer() && history.peer()->id)) { 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)), 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)); animTopBarCache = myGrab(this, QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight));
dialogs.enableShadow();
_topBar.enableShadow();
dialogs.hide(); dialogs.hide();
if (overview) { if (overview) {
overview->show(); overview->show();
@ -700,10 +694,7 @@ void MainWidget::hiderLayer(HistoryHider *h) {
dialogsToUp(); dialogsToUp();
_hider->hide(); _hider->hide();
dialogs.enableShadow(false);
QPixmap animCache = myGrab(this, QRect(0, _playerHeight, _dialogsWidth, height() - _playerHeight)); QPixmap animCache = myGrab(this, QRect(0, _playerHeight, _dialogsWidth, height() - _playerHeight));
dialogs.enableShadow();
_topBar.enableShadow();
onHistoryShown(0, 0); onHistoryShown(0, 0);
if (overview) { if (overview) {
@ -1846,7 +1837,7 @@ void MainWidget::documentPlayProgress(const SongMsgId &songId) {
if (playing == songId) { if (playing == songId) {
_player.updateState(playing, playingState, playingPosition, playingDuration, playingFrequency); _player.updateState(playing, playingState, playingPosition, playingDuration, playingFrequency);
if (!(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { if (!(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing && !animating()) {
if (_player.isHidden()) { if (_player.isHidden()) {
_player.clearSelection(); _player.clearSelection();
_player.show(); _player.show();
@ -2338,9 +2329,7 @@ void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back)
QPixmap animCache, animTopBarCache; QPixmap animCache, animTopBarCache;
if (!animating() && ((history.isHidden() && (profile || overview)) || (!cWideMode() && (history.isHidden() || !peerId)))) { if (!animating() && ((history.isHidden() && (profile || overview)) || (!cWideMode() && (history.isHidden() || !peerId)))) {
dialogs.enableShadow(false);
if (peerId) { if (peerId) {
_topBar.enableShadow(false);
if (cWideMode()) { if (cWideMode()) {
animCache = myGrab(this, QRect(_dialogsWidth, _playerHeight + st::topBarHeight, width() - _dialogsWidth, height() - _playerHeight - st::topBarHeight)); animCache = myGrab(this, QRect(_dialogsWidth, _playerHeight + st::topBarHeight, width() - _dialogsWidth, height() - _playerHeight - st::topBarHeight));
} else { } else {
@ -2354,8 +2343,6 @@ void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back)
if (peerId || cWideMode()) { if (peerId || cWideMode()) {
animTopBarCache = myGrab(this, QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight)); animTopBarCache = myGrab(this, QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight));
} }
dialogs.enableShadow();
_topBar.enableShadow();
history.show(); history.show();
} }
if (history.peer() && history.peer()->id != peerId) clearBotStartToken(history.peer()); if (history.peer() && history.peer()->id != peerId) clearBotStartToken(history.peer());
@ -2487,8 +2474,6 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
return; return;
} }
dialogs.enableShadow(false);
_topBar.enableShadow(false);
QRect topBarRect = QRect(_topBar.x(), _topBar.y(), _topBar.width(), st::topBarHeight); 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()); QRect historyRect = QRect(history.x(), topBarRect.y() + topBarRect.height(), history.width(), history.y() + history.height() - topBarRect.y() - topBarRect.height());
QPixmap animCache, animTopBarCache; QPixmap animCache, animTopBarCache;
@ -2496,8 +2481,6 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
animCache = myGrab(this, historyRect); animCache = myGrab(this, historyRect);
animTopBarCache = myGrab(this, topBarRect); animTopBarCache = myGrab(this, topBarRect);
} }
dialogs.enableShadow();
_topBar.enableShadow();
if (!back) { if (!back) {
if (overview) { if (overview) {
_stack.push_back(new StackItemOverview(overview->peer(), overview->type(), overview->lastWidth(), overview->lastScrollTop())); _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(); App::wnd()->hideSettings();
if (profile && profile->peer() == peer) return; 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)); 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 (!back) {
if (overview) { if (overview) {
_stack.push_back(new StackItemOverview(overview->peer(), overview->type(), overview->lastWidth(), overview->lastScrollTop())); _stack.push_back(new StackItemOverview(overview->peer(), overview->type(), overview->lastWidth(), overview->lastScrollTop()));
@ -2775,6 +2754,7 @@ void MainWidget::hideAll() {
} }
_topBar.hide(); _topBar.hide();
_mediaType.hide(); _mediaType.hide();
_player.hide();
} }
void MainWidget::showAll() { void MainWidget::showAll() {
@ -2834,6 +2814,22 @@ void MainWidget::showAll() {
dialogs.hide(); 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(); App::wnd()->checkHistoryActivation();
} }
@ -2841,20 +2837,27 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
int32 tbh = _topBar.isHidden() ? 0 : st::topBarHeight; int32 tbh = _topBar.isHidden() ? 0 : st::topBarHeight;
if (cWideMode()) { if (cWideMode()) {
_dialogsWidth = snap<int>((width() * 5) / 14, st::dlgMinWidth, st::dlgMaxWidth); _dialogsWidth = snap<int>((width() * 5) / 14, st::dlgMinWidth, st::dlgMaxWidth);
dialogs.setGeometry(0, 0, _dialogsWidth + st::dlgShadow, height()); dialogs.resize(_dialogsWidth, height());
_player.setGeometry(_dialogsWidth, 0, width() - _dialogsWidth, _player.height()); dialogs.moveToLeft(0, 0);
_topBar.setGeometry(_dialogsWidth, _playerHeight, width() - _dialogsWidth, st::topBarHeight + st::titleShadow); _player.resize(width() - _dialogsWidth, _player.height());
history.setGeometry(_dialogsWidth, _playerHeight + tbh, width() - _dialogsWidth, height() - _playerHeight - tbh); _player.moveToLeft(_dialogsWidth, 0);
if (_hider) _hider->setGeometry(QRect(_dialogsWidth, 0, width() - _dialogsWidth, height())); _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 { } else {
_dialogsWidth = width(); _dialogsWidth = width();
_player.setGeometry(0, 0, _dialogsWidth, _player.height()); _player.setGeometry(0, 0, _dialogsWidth, _player.height());
dialogs.setGeometry(0, _playerHeight, _dialogsWidth + st::dlgShadow, height() - _playerHeight); dialogs.setGeometry(0, _playerHeight, _dialogsWidth, height() - _playerHeight);
_topBar.setGeometry(0, _playerHeight, _dialogsWidth, st::topBarHeight + st::titleShadow); _topBar.setGeometry(0, _playerHeight, _dialogsWidth, st::topBarHeight);
history.setGeometry(0, _playerHeight + tbh, _dialogsWidth, height() - _playerHeight - tbh); 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 (profile) profile->setGeometry(history.geometry());
if (overview) overview->setGeometry(history.geometry()); if (overview) overview->setGeometry(history.geometry());
_contentScrollAddToY = 0; _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() { void MainWidget::onPhotosSelect() {
if (overview) overview->switchType(OverviewPhotos); if (overview) overview->switchType(OverviewPhotos);
_mediaType.hideStart(); _mediaType.hideStart();

View File

@ -78,7 +78,6 @@ private:
MainWidget *main(); MainWidget *main();
anim::fvalue a_over; anim::fvalue a_over;
bool _drawShadow;
PeerData *_selPeer; PeerData *_selPeer;
uint32 _selCount; uint32 _selCount;
@ -96,6 +95,8 @@ private:
FlatButton _edit, _leaveGroup, _addContact, _deleteContact; FlatButton _edit, _leaveGroup, _addContact, _deleteContact;
FlatButton _mediaType; FlatButton _mediaType;
PlainShadow _sideShadow;
}; };
enum StackItemType { enum StackItemType {
@ -176,7 +177,7 @@ enum ForwardWhatMessages {
ForwardPressedLinkMessage ForwardPressedLinkMessage
}; };
class MainWidget : public QWidget, public Animated, public RPCSender { class MainWidget : public TWidget, public Animated, public RPCSender {
Q_OBJECT Q_OBJECT
public: public:
@ -192,7 +193,6 @@ public:
void showDialogs(); void showDialogs();
void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth);
void topBarShadowParams(int32 &x, float64 &o);
TopBarWidget *topBar(); TopBarWidget *topBar();
PlayerWidget *player(); PlayerWidget *player();

View File

@ -2540,14 +2540,16 @@ OverviewInner::~OverviewInner() {
_links.clear(); _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) , _scroll(this, st::historyScroll, false)
, _inner(this, &_scroll, peer, type) , _inner(this, &_scroll, peer, type)
, _noDropResizeIndex(false) , _noDropResizeIndex(false)
, _showing(false) , _showing(false)
, _scrollSetAfterShow(0) , _scrollSetAfterShow(0)
, _scrollDelta(0) , _scrollDelta(0)
, _selCount(0) { , _selCount(0)
, _sideShadow(this, st::shadowColor)
, _topShadow(this, st::shadowColor) {
_scroll.setFocusPolicy(Qt::NoFocus); _scroll.setFocusPolicy(Qt::NoFocus);
_scroll.setWidget(&_inner); _scroll.setWidget(&_inner);
_scroll.move(0, 0); _scroll.move(0, 0);
@ -2601,6 +2603,11 @@ void OverviewWidget::resizeEvent(QResizeEvent *e) {
_scroll.scrollToY(newScrollTop); _scroll.scrollToY(newScrollTop);
_noDropResizeIndex = false; _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) { 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() { void OverviewWidget::topBarClick() {
App::main()->showBackFromStack(); App::main()->showBackFromStack();
} }
@ -2798,7 +2798,11 @@ void OverviewWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimT
a_alpha = anim::fvalue(0, 1); a_alpha = anim::fvalue(0, 1);
a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift); a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift);
a_bgAlpha = anim::fvalue(1, 0); a_bgAlpha = anim::fvalue(1, 0);
anim::start(this); anim::start(this);
_sideShadow.hide();
_topShadow.hide();
_showing = true; _showing = true;
show(); show();
_inner.activate(); _inner.activate();
@ -2811,6 +2815,9 @@ bool OverviewWidget::animStep(float64 ms) {
bool res = true; bool res = true;
if (dt2 >= 1) { if (dt2 >= 1) {
res = _showing = false; res = _showing = false;
_sideShadow.show();
_topShadow.show();
a_bgCoord.finish(); a_bgCoord.finish();
a_bgAlpha.finish(); a_bgAlpha.finish();
a_coord.finish(); a_coord.finish();

View File

@ -263,7 +263,7 @@ private:
ContextMenu *_menu; ContextMenu *_menu;
}; };
class OverviewWidget : public QWidget, public RPCSender, public Animated { class OverviewWidget : public TWidget, public RPCSender, public Animated {
Q_OBJECT Q_OBJECT
public: public:
@ -280,7 +280,6 @@ public:
void scrollReset(); void scrollReset();
void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth);
void topBarShadowParams(int32 &x, float64 &o);
void topBarClick(); void topBarClick();
PeerData *peer() const; PeerData *peer() const;
@ -353,5 +352,7 @@ private:
int32 _selCount; int32 _selCount;
PlainShadow _sideShadow, _topShadow;
}; };

View File

@ -32,12 +32,28 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
#include "audio.h" #include "audio.h"
PlayerWidget::PlayerWidget(QWidget *parent) : TWidget(parent), PlayerWidget::PlayerWidget(QWidget *parent) : TWidget(parent)
_prevAvailable(false), _nextAvailable(false), _fullAvailable(false), , _prevAvailable(false)
_over(OverNone), _down(OverNone), _downCoord(0), _downFrequency(AudioVoiceMsgFrequency), _downProgress(0.), , _nextAvailable(false)
_stateAnim(animFunc(this, &PlayerWidget::stateStep)), , _fullAvailable(false)
_index(-1), _history(0), _timeWidth(0), _repeat(false), _showPause(false), _position(0), _duration(0), _loaded(0), , _over(OverNone)
a_progress(0., 0.), a_loadProgress(0., 0.), _progressAnim(animFunc(this, &PlayerWidget::progressStep)) { , _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); resize(st::wndMinWidth, st::playerHeight);
setMouseTracking(true); setMouseTracking(true);
memset(_stateHovers, 0, sizeof(_stateHovers)); memset(_stateHovers, 0, sizeof(_stateHovers));
@ -492,7 +508,7 @@ void PlayerWidget::stopPressed() {
void PlayerWidget::resizeEvent(QResizeEvent *e) { void PlayerWidget::resizeEvent(QResizeEvent *e) {
int32 availh = (height() - st::playerLineHeight); int32 availh = (height() - st::playerLineHeight);
int32 ch = st::playerPlay.pxHeight() + st::playerSkip, ct = (availh - ch) / 2; 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(); _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); _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(); _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())); 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); _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(); update();
} }

View File

@ -113,4 +113,6 @@ private:
anim::fvalue a_progress, a_loadProgress; anim::fvalue a_progress, a_loadProgress;
Animation _progressAnim; Animation _progressAnim;
PlainShadow _sideShadow;
}; };

View File

@ -1523,11 +1523,12 @@ QString ProfileInner::overviewLinkText(int32 type, int32 count) {
return QString(); return QString();
} }
ProfileWidget::ProfileWidget(QWidget *parent, const PeerData *peer) : QWidget(parent) ProfileWidget::ProfileWidget(QWidget *parent, const PeerData *peer) : TWidget(parent)
, _scroll(this, st::setScroll) , _scroll(this, st::setScroll)
, _inner(this, &_scroll, peer) , _inner(this, &_scroll, peer)
, _showing(false) , _showing(false)
{ , _sideShadow(this, st::shadowColor)
, _topShadow(this, st::shadowColor) {
_scroll.setWidget(&_inner); _scroll.setWidget(&_inner);
_scroll.move(0, 0); _scroll.move(0, 0);
_inner.move(0, 0); _inner.move(0, 0);
@ -1556,6 +1557,11 @@ void ProfileWidget::resizeEvent(QResizeEvent *e) {
_inner.allowDecreaseHeight(_scroll.scrollTopMax() - _scroll.scrollTop()); _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) { 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() { void ProfileWidget::topBarClick() {
App::main()->showBackFromStack(); App::main()->showBackFromStack();
} }
@ -1631,7 +1630,11 @@ void ProfileWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTo
a_alpha = anim::fvalue(0, 1); a_alpha = anim::fvalue(0, 1);
a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift); a_bgCoord = back ? anim::ivalue(0, st::introSlideShift) : anim::ivalue(0, -st::introSlideShift);
a_bgAlpha = anim::fvalue(1, 0); a_bgAlpha = anim::fvalue(1, 0);
anim::start(this); anim::start(this);
_sideShadow.hide();
_topShadow.hide();
_showing = true; _showing = true;
show(); show();
_inner.setFocus(); _inner.setFocus();
@ -1644,6 +1647,9 @@ bool ProfileWidget::animStep(float64 ms) {
bool res = true; bool res = true;
if (dt2 >= 1) { if (dt2 >= 1) {
res = _showing = false; res = _showing = false;
_sideShadow.show();
_topShadow.show();
a_bgCoord.finish(); a_bgCoord.finish();
a_bgAlpha.finish(); a_bgAlpha.finish();
a_coord.finish(); a_coord.finish();

View File

@ -201,7 +201,7 @@ private:
}; };
class ProfileWidget : public QWidget, public RPCSender, public Animated { class ProfileWidget : public TWidget, public RPCSender, public Animated {
Q_OBJECT Q_OBJECT
public: public:
@ -215,7 +215,6 @@ public:
void dropEvent(QDropEvent *e); void dropEvent(QDropEvent *e);
void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth); void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth);
void topBarShadowParams(int32 &x, float64 &o);
void topBarClick(); void topBarClick();
PeerData *peer() const; PeerData *peer() const;
@ -250,5 +249,7 @@ private:
anim::ivalue a_coord, a_bgCoord; anim::ivalue a_coord, a_bgCoord;
anim::fvalue a_alpha, a_bgAlpha; anim::fvalue a_alpha, a_bgAlpha;
PlainShadow _sideShadow, _topShadow;
}; };

View File

@ -35,7 +35,7 @@ TitleHider::TitleHider(QWidget *parent) : QWidget(parent), _level(0) {
void TitleHider::paintEvent(QPaintEvent *e) { void TitleHider::paintEvent(QPaintEvent *e) {
QPainter p(this); QPainter p(this);
p.setOpacity(_level * st::layerAlpha); 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) { void TitleHider::mousePressEvent(QMouseEvent *e) {