| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /*
- 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 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;
- object_ptr<FlatLabel> _about;
- ColoredMiniStars _ministars;
- QSvgRenderer _star;
- QImage _dollar;
- struct {
- float64 top = 0.;
- float64 body = 0.;
- float64 title = 0.;
- float64 scaleTitle = 0.;
- } _progress;
- QRectF _starRect;
- QPoint _titlePosition;
- QPainterPath _titlePath;
- };
- } // namespace Ui::Premium
|