mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Use spoiler animation for ExtendedMedia.
This commit is contained in:
parent
20b5138e00
commit
a919978a37
3 changed files with 22 additions and 17 deletions
Telegram/SourceFiles
core
history/view/media
|
@ -74,6 +74,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/text_options.h"
|
||||
#include "ui/emoji_config.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/effects/spoiler_mess.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
#include "storage/serialize_common.h"
|
||||
#include "storage/storage_domain.h"
|
||||
|
@ -255,6 +256,7 @@ void Application::run() {
|
|||
Ui::InitTextOptions();
|
||||
Ui::StartCachedCorners();
|
||||
Ui::Emoji::Init();
|
||||
Ui::PrepareDefaultSpoilerMess();
|
||||
startEmojiImageLoader();
|
||||
startSystemDarkModeViewer();
|
||||
Media::Player::start(_audio.get());
|
||||
|
|
|
@ -84,11 +84,12 @@ void ExtendedPreview::ensureThumbnailRead() const {
|
|||
}
|
||||
|
||||
bool ExtendedPreview::hasHeavyPart() const {
|
||||
return !_inlineThumbnail.isNull();
|
||||
return _animation || !_inlineThumbnail.isNull();
|
||||
}
|
||||
|
||||
void ExtendedPreview::unloadHeavyPart() {
|
||||
_inlineThumbnail = _imageCache = QImage();
|
||||
_animation = nullptr;
|
||||
_caption.unloadCustomEmoji();
|
||||
}
|
||||
|
||||
|
@ -192,7 +193,7 @@ void ExtendedPreview::draw(Painter &p, const PaintContext &context) const {
|
|||
| ((isRoundedInBubbleBottom() && _caption.isEmpty()) ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None));
|
||||
validateImageCache(rthumb.size(), roundRadius, roundCorners);
|
||||
p.drawImage(rthumb.topLeft(), _imageCache);
|
||||
fillSpoilerMess(p, rthumb, roundRadius, roundCorners);
|
||||
fillSpoilerMess(p, context.now, rthumb, roundRadius, roundCorners);
|
||||
if (context.selected()) {
|
||||
Ui::FillComplexOverlayRect(p, st, rthumb, roundRadius, roundCorners);
|
||||
}
|
||||
|
@ -267,25 +268,21 @@ QImage ExtendedPreview::prepareImageCache(QSize outer) const {
|
|||
|
||||
void ExtendedPreview::fillSpoilerMess(
|
||||
QPainter &p,
|
||||
crl::time now,
|
||||
QRect rect,
|
||||
ImageRoundRadius radius,
|
||||
RectParts corners) const {
|
||||
const auto size = style::ConvertScale(100);
|
||||
static const auto test = [&] {
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
return Ui::GenerateSpoilerMess({
|
||||
.particleFadeInDuration = 200,
|
||||
.particleFadeOutDuration = 200,
|
||||
.particleSizeMin = style::ConvertScaleExact(1.5) * ratio,
|
||||
.particleSizeMax = style::ConvertScaleExact(2.) * ratio,
|
||||
.particleSpritesCount = 5,
|
||||
.particlesCount = 2000,
|
||||
.canvasSize = size * ratio,
|
||||
.framesCount = 60,
|
||||
.frameDuration = 33,
|
||||
if (!_animation) {
|
||||
_animation = std::make_unique<Ui::SpoilerAnimation>([=] {
|
||||
_parent->customEmojiRepaint();
|
||||
});
|
||||
}();
|
||||
const auto frame = test.frame();
|
||||
history()->owner().registerHeavyViewPart(_parent);
|
||||
}
|
||||
_parent->clearCustomEmojiRepaint();
|
||||
const auto &spoiler = Ui::DefaultImageSpoiler();
|
||||
const auto size = spoiler.canvasSize() / style::DevicePixelRatio();
|
||||
const auto frame = spoiler.frame(
|
||||
_animation->index(now, _parent->delegate()->elementIsGifPaused()));
|
||||
const auto columns = (rect.width() + size - 1) / size;
|
||||
const auto rows = (rect.height() + size - 1) / size;
|
||||
p.setClipRect(rect);
|
||||
|
|
|
@ -11,6 +11,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
enum class ImageRoundRadius;
|
||||
|
||||
namespace Ui {
|
||||
class SpoilerAnimation;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Data {
|
||||
struct Invoice;
|
||||
} // namespace Data
|
||||
|
@ -84,6 +88,7 @@ private:
|
|||
|
||||
void fillSpoilerMess(
|
||||
QPainter &p,
|
||||
crl::time now,
|
||||
QRect rect,
|
||||
ImageRoundRadius radius,
|
||||
RectParts corners) const;
|
||||
|
@ -91,6 +96,7 @@ private:
|
|||
const not_null<Data::Invoice*> _invoice;
|
||||
ClickHandlerPtr _link;
|
||||
Ui::Text::String _caption;
|
||||
mutable std::unique_ptr<Ui::SpoilerAnimation> _animation;
|
||||
mutable QImage _inlineThumbnail;
|
||||
mutable QImage _imageCache;
|
||||
mutable int _imageCacheRoundRadius : 4 = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue