2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 15:45:12 +00:00

Profile done as a new generic Window::SectionWidget.

Slide animation reimplemented.
This commit is contained in:
John Preston
2016-05-19 15:03:51 +03:00
parent 6e2dea7030
commit 1d42144c95
37 changed files with 1052 additions and 373 deletions

View File

@@ -1987,15 +1987,25 @@ void OverviewWidget::paintEvent(QPaintEvent *e) {
Painter p(this);
if (_a_show.animating()) {
if (a_coordOver.current() > 0) {
p.drawPixmap(QRect(0, 0, a_coordOver.current(), height()), _cacheUnder, QRect(-a_coordUnder.current() * cRetinaFactor(), 0, a_coordOver.current() * cRetinaFactor(), height() * cRetinaFactor()));
p.setOpacity(a_shadow.current() * st::slideFadeOut);
p.fillRect(0, 0, a_coordOver.current(), height(), st::black->b);
p.setOpacity(1);
int retina = cIntRetinaFactor();
int inCacheTop = st::topBarHeight;
if (a_progress.current() < 1) {
int underLeft = a_coordUnder.current();
int underWidth = _cacheUnder.width() / retina;
int underHeight = height();
p.fillRect(e->rect(), st::white);
QRect underDst(0, 0, underWidth + underLeft, underHeight);
QRect underSrc(-underLeft * retina, inCacheTop * retina, (underWidth + underLeft) * retina, underHeight * retina);
p.setOpacity(1. - a_progress.current());
p.drawPixmap(underDst, _cacheUnder, underSrc);
p.setOpacity(a_progress.current());
}
p.drawPixmap(a_coordOver.current(), 0, _cacheOver);
p.setOpacity(a_shadow.current());
p.drawPixmap(QRect(a_coordOver.current() - st::slideShadow.pxWidth(), 0, st::slideShadow.pxWidth(), height()), App::sprite(), st::slideShadow.rect());
int overLeft = a_coordOver.current();
int overWidth = _cacheOver.width() / retina;
int overHeight = height();
QRect overDst(overLeft, 0, overWidth - overLeft, overHeight);
QRect overSrc(0, inCacheTop * retina, (overWidth - overLeft) * retina, overHeight * retina);
p.drawPixmap(overDst, _cacheOver, overSrc);
return;
}
@@ -2020,10 +2030,24 @@ void OverviewWidget::scrollReset() {
void OverviewWidget::paintTopBar(Painter &p, float64 over, int32 decreaseWidth) {
if (_a_show.animating()) {
p.drawPixmap(a_coordUnder.current(), 0, _cacheTopBarUnder);
p.drawPixmap(a_coordOver.current(), 0, _cacheTopBarOver);
p.setOpacity(a_shadow.current());
p.drawPixmap(QRect(a_coordOver.current() - st::slideShadow.pxWidth(), 0, st::slideShadow.pxWidth(), st::topBarHeight), App::sprite(), st::slideShadow.rect());
int retina = cIntRetinaFactor();
if (a_progress.current() < 1) {
int underLeft = a_coordUnder.current();
int underWidth = _cacheUnder.width() / retina;
int underHeight = st::topBarHeight;
p.fillRect(0, 0, underWidth, underHeight, st::white);
QRect underDst(0, 0, underWidth + underLeft, underHeight);
QRect underSrc(-underLeft * retina, 0, (underWidth + underLeft) * retina, underHeight * retina);
p.setOpacity(1. - a_progress.current());
p.drawPixmap(underDst, _cacheUnder, underSrc);
p.setOpacity(a_progress.current());
}
int overLeft = a_coordOver.current();
int overWidth = _cacheOver.width() / retina;
int overHeight = st::topBarHeight;
QRect overDst(overLeft, 0, overWidth - overLeft, overHeight);
QRect overSrc(0, 0, (overWidth - overLeft) * retina, overHeight * retina);
p.drawPixmap(overDst, _cacheOver, overSrc);
return;
}
p.setOpacity(st::topBarBackAlpha + (1 - st::topBarBackAlpha) * over);
@@ -2127,31 +2151,40 @@ void OverviewWidget::fastShow(bool back, int32 lastScrollTop) {
if (App::app()) App::app()->mtpUnpause();
}
void OverviewWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTopBarCache, bool back, int32 lastScrollTop) {
if (App::app()) App::app()->mtpPause();
(back ? _cacheOver : _cacheUnder) = bgAnimCache;
(back ? _cacheTopBarOver : _cacheTopBarUnder) = bgAnimTopBarCache;
void OverviewWidget::setLastScrollTop(int lastScrollTop) {
resizeEvent(0);
_scroll.scrollToY(lastScrollTop < 0 ? countBestScroll() : lastScrollTop);
(back ? _cacheUnder : _cacheOver) = myGrab(this);
App::main()->topBar()->stopAnim();
(back ? _cacheTopBarUnder : _cacheTopBarOver) = myGrab(App::main()->topBar());
}
void OverviewWidget::showAnimated(Window::SlideDirection direction, const Window::SectionSlideParams &params) {
if (App::app()) App::app()->mtpPause();
resizeEvent(0);
_cacheUnder = params.oldContentCache;
show();
_topShadow.setVisible(params.withTopBarShadow ? false : true);
_cacheOver = App::main()->grabForShowAnimation(params);
_topShadow.setVisible(params.withTopBarShadow ? true : false);
App::main()->topBar()->startAnim();
_scrollSetAfterShow = _scroll.scrollTop();
_scroll.hide();
_topShadow.hide();
a_coordUnder = back ? anim::ivalue(-st::slideShift, 0) : anim::ivalue(0, -st::slideShift);
a_coordOver = back ? anim::ivalue(0, width()) : anim::ivalue(width(), 0);
a_shadow = back ? anim::fvalue(1, 0) : anim::fvalue(0, 1);
int delta = st::slideShift;
a_progress = anim::fvalue(0, 1);
if (direction == Window::SlideDirection::FromLeft) {
a_coordUnder = anim::ivalue(0, delta);
a_coordOver = anim::ivalue(-delta, 0);
} else {
a_coordUnder = anim::ivalue(0, -delta);
a_coordOver = anim::ivalue(delta, 0);
}
_a_show.start();
show();
App::main()->topBar()->update();
_inner.activate();
activate();
}
void OverviewWidget::step_show(float64 ms, bool timer) {
@@ -2162,8 +2195,8 @@ void OverviewWidget::step_show(float64 ms, bool timer) {
a_coordUnder.finish();
a_coordOver.finish();
a_shadow.finish();
_cacheUnder = _cacheOver = _cacheTopBarUnder = _cacheTopBarOver = QPixmap();
a_progress.finish();
_cacheUnder = _cacheOver = QPixmap();
App::main()->topBar()->stopAnim();
doneShow();
@@ -2172,7 +2205,7 @@ void OverviewWidget::step_show(float64 ms, bool timer) {
} else {
a_coordUnder.update(dt, st::slideFunction);
a_coordOver.update(dt, st::slideFunction);
a_shadow.update(dt, st::slideFunction);
a_progress.update(dt, st::slideFunction);
}
if (timer) {
update();