mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to provide custom top bar mask to Window::SlideAnimation.
This commit is contained in:
parent
ef3e139b85
commit
3fde5b56a1
4 changed files with 47 additions and 0 deletions
|
@ -157,6 +157,7 @@ void SectionWidget::showAnimated(
|
||||||
_showAnimation->setTopBarShadow(params.withTopBarShadow);
|
_showAnimation->setTopBarShadow(params.withTopBarShadow);
|
||||||
_showAnimation->setWithFade(params.withFade);
|
_showAnimation->setWithFade(params.withFade);
|
||||||
_showAnimation->setTopSkip(params.topSkip);
|
_showAnimation->setTopSkip(params.topSkip);
|
||||||
|
_showAnimation->setTopBarMask(params.topMask);
|
||||||
_showAnimation->start();
|
_showAnimation->start();
|
||||||
|
|
||||||
show();
|
show();
|
||||||
|
|
|
@ -72,6 +72,7 @@ class SectionMemento;
|
||||||
struct SectionSlideParams {
|
struct SectionSlideParams {
|
||||||
QPixmap oldContentCache;
|
QPixmap oldContentCache;
|
||||||
int topSkip = 0;
|
int topSkip = 0;
|
||||||
|
QPixmap topMask;
|
||||||
bool withTopBarShadow = false;
|
bool withTopBarShadow = false;
|
||||||
bool withTabs = false;
|
bool withTabs = false;
|
||||||
bool withFade = false;
|
bool withFade = false;
|
||||||
|
|
|
@ -39,6 +39,45 @@ void SlideAnimation::paintContents(Painter &p) const {
|
||||||
const auto leftWidth = (leftWidthFull + leftCoord);
|
const auto leftWidth = (leftWidthFull + leftCoord);
|
||||||
const auto rightWidth = rightWidthFull - rightCoord;
|
const auto rightWidth = rightWidthFull - rightCoord;
|
||||||
|
|
||||||
|
if (!_mask.isNull()) {
|
||||||
|
auto frame = QImage(
|
||||||
|
_mask.size(),
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
frame.setDevicePixelRatio(_mask.devicePixelRatio());
|
||||||
|
frame.fill(Qt::transparent);
|
||||||
|
QPainter q(&frame);
|
||||||
|
|
||||||
|
if (leftWidth > 0) {
|
||||||
|
q.setOpacity(leftAlpha);
|
||||||
|
q.drawPixmap(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
_cacheUnder,
|
||||||
|
(_cacheUnder.width() - leftWidth * cIntRetinaFactor()),
|
||||||
|
0,
|
||||||
|
leftWidth * cIntRetinaFactor(),
|
||||||
|
_topSkip * retina);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightWidth > 0) {
|
||||||
|
q.setOpacity(rightAlpha);
|
||||||
|
q.drawPixmap(
|
||||||
|
rightCoord,
|
||||||
|
0,
|
||||||
|
_cacheOver,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
rightWidth * cIntRetinaFactor(),
|
||||||
|
_topSkip * retina);
|
||||||
|
}
|
||||||
|
|
||||||
|
q.setOpacity(1.);
|
||||||
|
q.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||||
|
q.drawPixmap(0, 0, _mask);
|
||||||
|
|
||||||
|
p.drawImage(0, 0, frame);
|
||||||
|
}
|
||||||
|
|
||||||
if (leftWidth > 0) {
|
if (leftWidth > 0) {
|
||||||
p.setOpacity(leftAlpha);
|
p.setOpacity(leftAlpha);
|
||||||
p.drawPixmap(
|
p.drawPixmap(
|
||||||
|
@ -133,6 +172,10 @@ void SlideAnimation::setFinishedCallback(FinishedCallback &&callback) {
|
||||||
_finishedCallback = std::move(callback);
|
_finishedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SlideAnimation::setTopBarMask(const QPixmap &mask) {
|
||||||
|
_mask = mask;
|
||||||
|
}
|
||||||
|
|
||||||
void SlideAnimation::start() {
|
void SlideAnimation::start() {
|
||||||
const auto fromLeft = (_direction == SlideDirection::FromLeft);
|
const auto fromLeft = (_direction == SlideDirection::FromLeft);
|
||||||
if (fromLeft) {
|
if (fromLeft) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
const QPixmap &newContentCache);
|
const QPixmap &newContentCache);
|
||||||
void setTopBarShadow(bool enabled);
|
void setTopBarShadow(bool enabled);
|
||||||
void setTopSkip(int skip);
|
void setTopSkip(int skip);
|
||||||
|
void setTopBarMask(const QPixmap &mask);
|
||||||
void setWithFade(bool withFade);
|
void setWithFade(bool withFade);
|
||||||
|
|
||||||
using RepaintCallback = Fn<void()>;
|
using RepaintCallback = Fn<void()>;
|
||||||
|
@ -50,6 +51,7 @@ private:
|
||||||
|
|
||||||
mutable Ui::Animations::Simple _animation;
|
mutable Ui::Animations::Simple _animation;
|
||||||
QPixmap _cacheUnder, _cacheOver;
|
QPixmap _cacheUnder, _cacheOver;
|
||||||
|
QPixmap _mask;
|
||||||
|
|
||||||
RepaintCallback _repaintCallback;
|
RepaintCallback _repaintCallback;
|
||||||
FinishedCallback _finishedCallback;
|
FinishedCallback _finishedCallback;
|
||||||
|
|
Loading…
Add table
Reference in a new issue