Pass painting active/inactive state through Painter.
This commit is contained in:
parent
187110f438
commit
6ef5ec3410
5 changed files with 56 additions and 4 deletions
|
|
@ -47,6 +47,7 @@ PRIVATE
|
||||||
ui/effects/cross_line.h
|
ui/effects/cross_line.h
|
||||||
ui/effects/fade_animation.cpp
|
ui/effects/fade_animation.cpp
|
||||||
ui/effects/fade_animation.h
|
ui/effects/fade_animation.h
|
||||||
|
ui/effects/frame_generator.h
|
||||||
ui/effects/gradient.cpp
|
ui/effects/gradient.cpp
|
||||||
ui/effects/gradient.h
|
ui/effects/gradient.h
|
||||||
ui/effects/numbers_animation.cpp
|
ui/effects/numbers_animation.cpp
|
||||||
|
|
|
||||||
29
ui/effects/frame_generator.h
Normal file
29
ui/effects/frame_generator.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// This file is part of Desktop App Toolkit,
|
||||||
|
// a set of libraries for developing nice desktop applications.
|
||||||
|
//
|
||||||
|
// For license and copyright information please follow this link:
|
||||||
|
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QtGui/QImage>
|
||||||
|
|
||||||
|
#include <crl/crl_time.h>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
class FrameGenerator {
|
||||||
|
public:
|
||||||
|
[[nodiscard]] virtual int count() = 0;
|
||||||
|
|
||||||
|
struct Frame {
|
||||||
|
QImage image;
|
||||||
|
crl::time duration = 0;
|
||||||
|
};
|
||||||
|
[[nodiscard]] virtual Frame renderNext(
|
||||||
|
QImage storage,
|
||||||
|
QSize size,
|
||||||
|
Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Ui
|
||||||
|
|
@ -69,12 +69,19 @@ public:
|
||||||
void restoreTextPalette() {
|
void restoreTextPalette() {
|
||||||
_textPalette = nullptr;
|
_textPalette = nullptr;
|
||||||
}
|
}
|
||||||
const style::TextPalette &textPalette() const {
|
[[nodiscard]] const style::TextPalette &textPalette() const {
|
||||||
return _textPalette ? *_textPalette : st::defaultTextPalette;
|
return _textPalette ? *_textPalette : st::defaultTextPalette;
|
||||||
}
|
}
|
||||||
|
void setInactive(bool inactive) {
|
||||||
|
_inactive = inactive;
|
||||||
|
}
|
||||||
|
[[nodiscard]] bool inactive() const {
|
||||||
|
return _inactive;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const style::TextPalette *_textPalette = nullptr;
|
const style::TextPalette *_textPalette = nullptr;
|
||||||
|
bool _inactive = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1686,7 +1686,10 @@ private:
|
||||||
x,
|
x,
|
||||||
y);
|
y);
|
||||||
} else if (const auto custom = static_cast<const CustomEmojiBlock*>(currentBlock)->_custom.get()) {
|
} else if (const auto custom = static_cast<const CustomEmojiBlock*>(currentBlock)->_custom.get()) {
|
||||||
custom->paint(*_p, x, y, _textPalette->spoilerActiveBg->c);
|
if (!_now) {
|
||||||
|
_now = crl::now();
|
||||||
|
}
|
||||||
|
custom->paint(*_p, x, y, _now, _textPalette->spoilerActiveBg->c, _p->inactive());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasSpoiler) {
|
if (hasSpoiler) {
|
||||||
|
|
@ -1920,7 +1923,10 @@ private:
|
||||||
if (!_background.startMs) {
|
if (!_background.startMs) {
|
||||||
return 1.;
|
return 1.;
|
||||||
}
|
}
|
||||||
const auto progress = float64(crl::now() - _background.startMs)
|
if (!_now) {
|
||||||
|
_now = crl::now();
|
||||||
|
}
|
||||||
|
const auto progress = float64(_now - _background.startMs)
|
||||||
/ st::fadeWrapDuration;
|
/ st::fadeWrapDuration;
|
||||||
if ((progress > 1.) && _background.spoilerIndex) {
|
if ((progress > 1.) && _background.spoilerIndex) {
|
||||||
const auto link = _t->_spoilers.at(_background.spoilerIndex - 1);
|
const auto link = _t->_spoilers.at(_background.spoilerIndex - 1);
|
||||||
|
|
@ -2863,6 +2869,7 @@ private:
|
||||||
TextSelection _selection = { 0, 0 };
|
TextSelection _selection = { 0, 0 };
|
||||||
bool _fullWidthSelection = true;
|
bool _fullWidthSelection = true;
|
||||||
const QChar *_str = nullptr;
|
const QChar *_str = nullptr;
|
||||||
|
crl::time _now = 0;
|
||||||
|
|
||||||
int _indexOfElidedBlock = -1; // For spoilers.
|
int _indexOfElidedBlock = -1; // For spoilers.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include <private/qfixed_p.h>
|
#include <private/qfixed_p.h>
|
||||||
|
|
||||||
|
#include <crl/crl_time.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace Text {
|
namespace Text {
|
||||||
|
|
||||||
|
|
@ -168,7 +170,13 @@ class CustomEmoji {
|
||||||
public:
|
public:
|
||||||
virtual ~CustomEmoji() = default;
|
virtual ~CustomEmoji() = default;
|
||||||
[[nodiscard]] virtual QString entityData() = 0;
|
[[nodiscard]] virtual QString entityData() = 0;
|
||||||
virtual void paint(QPainter &p, int x, int y, const QColor &preview) = 0;
|
virtual void paint(
|
||||||
|
QPainter &p,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
crl::time now,
|
||||||
|
const QColor &preview,
|
||||||
|
bool paused) = 0;
|
||||||
virtual void unload() = 0;
|
virtual void unload() = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue