init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
120
Telegram/SourceFiles/ui/effects/premium_top_bar.h
Normal file
120
Telegram/SourceFiles/ui/effects/premium_top_bar.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/object_ptr.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/effects/premium_stars_colored.h"
|
||||
|
||||
namespace style {
|
||||
struct PremiumCover;
|
||||
} // namespace style
|
||||
|
||||
namespace st {
|
||||
extern const style::PremiumCover &defaultPremiumCover;
|
||||
} // namespace st
|
||||
|
||||
namespace Ui {
|
||||
class FlatLabel;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Lottie {
|
||||
class Icon;
|
||||
} // namespace Lottie
|
||||
|
||||
namespace Ui::Premium {
|
||||
|
||||
class TopBarAbstract : public RpWidget {
|
||||
public:
|
||||
TopBarAbstract(
|
||||
QWidget *parent = nullptr,
|
||||
const style::PremiumCover &st = st::defaultPremiumCover);
|
||||
|
||||
void setRoundEdges(bool value);
|
||||
|
||||
virtual void setPaused(bool paused) = 0;
|
||||
virtual void setTextPosition(int x, int y) = 0;
|
||||
|
||||
[[nodiscard]] virtual rpl::producer<int> additionalHeight() const = 0;
|
||||
|
||||
[[nodiscard]] const style::PremiumCover &st() const {
|
||||
return _st;
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEdges(QPainter &p, const QBrush &brush) const;
|
||||
void paintEdges(QPainter &p) const;
|
||||
|
||||
[[nodiscard]] QRectF starRect(
|
||||
float64 topProgress,
|
||||
float64 sizeProgress) const;
|
||||
|
||||
[[nodiscard]] bool isDark() const;
|
||||
void computeIsDark();
|
||||
|
||||
private:
|
||||
const style::PremiumCover &_st;
|
||||
bool _roundEdges = true;
|
||||
bool _isDark = false;
|
||||
|
||||
};
|
||||
|
||||
struct TopBarDescriptor {
|
||||
Fn<QVariant()> clickContextOther;
|
||||
QString logo;
|
||||
rpl::producer<QString> title;
|
||||
rpl::producer<TextWithEntities> about;
|
||||
bool light = false;
|
||||
bool optimizeMinistars = true;
|
||||
std::optional<QGradientStops> gradientStops;
|
||||
};
|
||||
|
||||
class TopBar final : public TopBarAbstract {
|
||||
public:
|
||||
TopBar(
|
||||
not_null<QWidget*> parent,
|
||||
const style::PremiumCover &st,
|
||||
TopBarDescriptor &&descriptor);
|
||||
~TopBar();
|
||||
|
||||
void setPaused(bool paused) override;
|
||||
void setTextPosition(int x, int y) override;
|
||||
|
||||
rpl::producer<int> additionalHeight() const override;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
const bool _light = false;
|
||||
const QString _logo;
|
||||
const style::font &_titleFont;
|
||||
const style::margins &_titlePadding;
|
||||
const int _aboutMaxWidth = 0;
|
||||
object_ptr<FlatLabel> _about;
|
||||
ColoredMiniStars _ministars;
|
||||
QSvgRenderer _star;
|
||||
QImage _dollar;
|
||||
std::unique_ptr<Lottie::Icon> _lottie;
|
||||
|
||||
struct {
|
||||
float64 top = 0.;
|
||||
float64 body = 0.;
|
||||
float64 title = 0.;
|
||||
float64 scaleTitle = 0.;
|
||||
} _progress;
|
||||
|
||||
QRectF _starRect;
|
||||
|
||||
QPoint _titlePosition;
|
||||
QPainterPath _titlePath;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui::Premium
|
||||
Reference in New Issue
Block a user