Fix premium counter bubble with disabled animations.
This commit is contained in:
parent
2159307643
commit
137fca73bd
|
@ -399,6 +399,15 @@ protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct GradientParams {
|
||||||
|
int left = 0;
|
||||||
|
int width = 0;
|
||||||
|
int outer = 0;
|
||||||
|
|
||||||
|
friend inline constexpr bool operator==(
|
||||||
|
GradientParams,
|
||||||
|
GradientParams) = default;
|
||||||
|
};
|
||||||
void animateTo(BubbleRowState state);
|
void animateTo(BubbleRowState state);
|
||||||
|
|
||||||
const style::PremiumBubble &_st;
|
const style::PremiumBubble &_st;
|
||||||
|
@ -414,6 +423,7 @@ private:
|
||||||
QSize _spaceForDeflection;
|
QSize _spaceForDeflection;
|
||||||
|
|
||||||
QLinearGradient _cachedGradient;
|
QLinearGradient _cachedGradient;
|
||||||
|
std::optional<GradientParams> _cachedGradientParams;
|
||||||
|
|
||||||
float64 _deflection;
|
float64 _deflection;
|
||||||
|
|
||||||
|
@ -580,13 +590,19 @@ void BubbleWidget::paintEvent(QPaintEvent *e) {
|
||||||
0);
|
0);
|
||||||
const auto bubbleRect = rect() - padding;
|
const auto bubbleRect = rect() - padding;
|
||||||
|
|
||||||
if (_appearanceAnimation.animating()) {
|
const auto params = GradientParams{
|
||||||
auto gradient = ComputeGradient(
|
.left = x(),
|
||||||
|
.width = bubbleRect.width(),
|
||||||
|
.outer = parentWidget()->parentWidget()->width(),
|
||||||
|
};
|
||||||
|
if (_cachedGradientParams != params) {
|
||||||
|
_cachedGradient = ComputeGradient(
|
||||||
parentWidget(),
|
parentWidget(),
|
||||||
x(),
|
params.left,
|
||||||
bubbleRect.width());
|
params.width);
|
||||||
_cachedGradient = std::move(gradient);
|
_cachedGradientParams = params;
|
||||||
|
}
|
||||||
|
if (_appearanceAnimation.animating()) {
|
||||||
const auto progress = _appearanceAnimation.value(1.);
|
const auto progress = _appearanceAnimation.value(1.);
|
||||||
const auto finalScale = (_animatingFromResultRatio > 0.)
|
const auto finalScale = (_animatingFromResultRatio > 0.)
|
||||||
|| (_state.current().ratio < 0.001);
|
|| (_state.current().ratio < 0.001);
|
||||||
|
|
Loading…
Reference in New Issue