mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Fixed display of summary header in history view on unload heavy parts.
This commit is contained in:
@@ -43,14 +43,12 @@ SummaryHeader::~SummaryHeader() = default;
|
||||
void SummaryHeader::update(not_null<Element*> view) {
|
||||
const auto item = view->data();
|
||||
|
||||
using namespace Ui;
|
||||
_animation = std::make_unique<Animation>(Animation{
|
||||
.particles = StarParticles(
|
||||
StarParticles::Type::Right,
|
||||
15,
|
||||
st::lineWidth * 8),
|
||||
});
|
||||
_animation->particles.setSpeed(0.05);
|
||||
if (!_animation) {
|
||||
ensureAnimation();
|
||||
}
|
||||
if (!_lottie) {
|
||||
ensureLottie();
|
||||
}
|
||||
|
||||
_text.setText(
|
||||
st::defaultTextStyle,
|
||||
@@ -64,14 +62,6 @@ void SummaryHeader::update(not_null<Element*> view) {
|
||||
+ st::maxSignatureSize / 2
|
||||
+ st::historyReplyPadding.right();
|
||||
|
||||
_lottie = Lottie::MakeIcon(Lottie::IconDescriptor{
|
||||
.name = u"cocoon"_q,
|
||||
.sizeOverride = Size(st::historySummaryHeaderIconSize
|
||||
- st::historySummaryHeaderIconSizeInner * 2),
|
||||
.color = &st::attentionButtonFg,
|
||||
.colorizeUsingAlpha = true,
|
||||
});
|
||||
|
||||
const auto session = &item->history()->session();
|
||||
const auto itemId = item->fullId();
|
||||
_link = std::make_shared<LambdaClickHandler>([=](ClickContext context) {
|
||||
@@ -140,7 +130,10 @@ void SummaryHeader::paint(
|
||||
cache->bg = rippleColor;
|
||||
}
|
||||
|
||||
if (_lottie) {
|
||||
if (!_lottie) {
|
||||
ensureLottie();
|
||||
}
|
||||
{
|
||||
const auto r = iconRect().translated(x, y);
|
||||
const auto lottieX = r.x() + st::historySummaryHeaderIconSizeInner;
|
||||
const auto lottieY = r.y() + st::historySummaryHeaderIconSizeInner;
|
||||
@@ -159,7 +152,10 @@ void SummaryHeader::paint(
|
||||
}
|
||||
}
|
||||
|
||||
if (_animation) {
|
||||
if (!_animation) {
|
||||
ensureAnimation();
|
||||
}
|
||||
{
|
||||
const auto size = QSize(w, _height);
|
||||
if (_animation->cachedSize != size) {
|
||||
_animation->path = QPainterPath();
|
||||
@@ -287,6 +283,7 @@ void SummaryHeader::stopLastRipple() {
|
||||
}
|
||||
|
||||
void SummaryHeader::unloadHeavyPart() {
|
||||
_unloadTime = crl::now();
|
||||
_animation = nullptr;
|
||||
_ripple.animation = nullptr;
|
||||
_iconRipple.animation = nullptr;
|
||||
@@ -299,4 +296,25 @@ QRect SummaryHeader::iconRect() const {
|
||||
return QRect(_width - size - shift, (_height - size) / 2, size, size);
|
||||
}
|
||||
|
||||
void SummaryHeader::ensureAnimation() const {
|
||||
using namespace Ui;
|
||||
_animation = std::make_unique<Animation>(Animation{
|
||||
.particles = StarParticles(
|
||||
StarParticles::Type::Right,
|
||||
15,
|
||||
st::lineWidth * 8),
|
||||
});
|
||||
_animation->particles.setSpeed(0.05);
|
||||
}
|
||||
|
||||
void SummaryHeader::ensureLottie() const {
|
||||
_lottie = Lottie::MakeIcon(Lottie::IconDescriptor{
|
||||
.name = u"cocoon"_q,
|
||||
.sizeOverride = Size(st::historySummaryHeaderIconSize
|
||||
- st::historySummaryHeaderIconSizeInner * 2),
|
||||
.color = &st::attentionButtonFg,
|
||||
.colorizeUsingAlpha = true,
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
||||
@@ -53,6 +53,9 @@ public:
|
||||
void unloadHeavyPart();
|
||||
|
||||
private:
|
||||
void ensureAnimation() const;
|
||||
void ensureLottie() const;
|
||||
|
||||
[[nodiscard]] QRect iconRect() const;
|
||||
struct Animation {
|
||||
Ui::StarParticles particles;
|
||||
@@ -61,7 +64,7 @@ private:
|
||||
};
|
||||
|
||||
ClickHandlerPtr _link;
|
||||
std::unique_ptr<Animation> _animation;
|
||||
mutable std::unique_ptr<Animation> _animation;
|
||||
mutable struct {
|
||||
mutable std::unique_ptr<Ui::RippleAnimation> animation;
|
||||
QPoint lastPoint;
|
||||
@@ -75,7 +78,8 @@ private:
|
||||
mutable int _maxWidth = 0;
|
||||
mutable int _height = 0;
|
||||
mutable int _width = 0;
|
||||
std::unique_ptr<Lottie::Icon> _lottie;
|
||||
mutable std::unique_ptr<Lottie::Icon> _lottie;
|
||||
mutable crl::time _unloadTime = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user