mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Added ministars to buttons in section of peer gifts.
This commit is contained in:
parent
1a1e777b87
commit
a8a1b08127
4 changed files with 27 additions and 6 deletions
|
@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/dynamic_image.h"
|
||||
#include "ui/dynamic_thumbnails.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/painter.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_credits.h"
|
||||
|
@ -39,7 +40,9 @@ GiftButton::GiftButton(
|
|||
QWidget *parent,
|
||||
not_null<GiftButtonDelegate*> delegate)
|
||||
: AbstractButton(parent)
|
||||
, _delegate(delegate) {
|
||||
, _delegate(delegate)
|
||||
, _stars(this, true, Ui::Premium::MiniStars::Type::SlowStars) {
|
||||
_stars.setColorOverride(Ui::Premium::CreditsIconGradientStops());
|
||||
}
|
||||
|
||||
GiftButton::~GiftButton() {
|
||||
|
@ -159,6 +162,8 @@ void GiftButton::setGeometry(QRect inner, QMargins extend) {
|
|||
void GiftButton::resizeEvent(QResizeEvent *e) {
|
||||
if (!_button.isEmpty()) {
|
||||
_button.moveLeft((width() - _button.width()) / 2);
|
||||
const auto padding = _button.height() / 2;
|
||||
_stars.setCenter(_button - QMargins(padding, 0, padding, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,6 +312,13 @@ void GiftButton::paintEvent(QPaintEvent *e) {
|
|||
if (!premium) {
|
||||
p.setOpacity(1.);
|
||||
}
|
||||
{
|
||||
auto clipPath = QPainterPath();
|
||||
clipPath.addRoundedRect(geometry, radius, radius);
|
||||
p.setClipPath(clipPath);
|
||||
_stars.paint(p);
|
||||
p.setClipping(false);
|
||||
}
|
||||
|
||||
if (!_text.isEmpty()) {
|
||||
p.setPen(st::windowFg);
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "ui/abstract_button.h"
|
||||
#include "ui/effects/premium_stars_colored.h"
|
||||
#include "ui/text/text.h"
|
||||
|
||||
class StickerPremiumMark;
|
||||
|
@ -101,6 +102,7 @@ private:
|
|||
Ui::Text::String _text;
|
||||
Ui::Text::String _price;
|
||||
std::shared_ptr<Ui::DynamicImage> _userpic;
|
||||
Ui::Premium::ColoredMiniStars _stars;
|
||||
bool _subscribed = false;
|
||||
|
||||
QRect _button;
|
||||
|
|
|
@ -21,19 +21,25 @@ MiniStars::MiniStars(
|
|||
Fn<void(const QRect &r)> updateCallback,
|
||||
bool opaque,
|
||||
Type type)
|
||||
: _availableAngles({
|
||||
: _availableAngles((type != Type::SlowStars)
|
||||
? std::vector<Interval>{
|
||||
Interval{ -10, 40 },
|
||||
Interval{ 180 + 10 - 40, 40 },
|
||||
Interval{ 180 + 15, 50 },
|
||||
Interval{ -15 - 50, 50 },
|
||||
})
|
||||
, _lifeLength({ 150 / 5, 200 / 5 })
|
||||
, _deathTime({ 1500, 2000 })
|
||||
}
|
||||
: std::vector<Interval>{ Interval{ -90, 180 }, Interval{ 90, 180 } })
|
||||
, _lifeLength((type != Type::SlowStars)
|
||||
? Interval{ 150 / 5, 200 / 5 }
|
||||
: Interval{ 150 * 2, 200 * 2 })
|
||||
, _deathTime((type != Type::SlowStars)
|
||||
? Interval{ 1500, 2000 }
|
||||
: Interval{ 1500 * 2, 2000 * 2 })
|
||||
, _size({ 5, 10 })
|
||||
, _alpha({ opaque ? 100 : 40, opaque ? 100 : 60 })
|
||||
, _sinFactor({ 10, 190 })
|
||||
, _spritesCount({ 0, ((type == Type::MonoStars) ? 1 : 2) })
|
||||
, _appearProgressTill(0.2)
|
||||
, _appearProgressTill((type != Type::SlowStars) ? 0.2 : 0.01)
|
||||
, _disappearProgressAfter(0.8)
|
||||
, _distanceProgressStart(0.5)
|
||||
, _sprite(u":/gui/icons/settings/starmini.svg"_q)
|
||||
|
|
|
@ -19,6 +19,7 @@ public:
|
|||
enum class Type {
|
||||
MonoStars,
|
||||
BiStars,
|
||||
SlowStars,
|
||||
};
|
||||
|
||||
MiniStars(
|
||||
|
|
Loading…
Add table
Reference in a new issue