/* 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/weak_ptr.h" #include "data/data_peer_common.h" namespace style { struct Toast; struct LevelShape; } // namespace style namespace Ui::Toast { class Instance; } // namespace Ui::Toast namespace Ui { class ImportantTooltip; class AbstractButton; class FlatLabel; class Show; class StarsRating final { public: StarsRating( QWidget *parent, std::shared_ptr show, const QString &name, rpl::producer value, Fn pending); ~StarsRating(); void raise(); void moveTo(int x, int y); void setOpacity(float64 opacity); void setCustomColors( std::optional textColor, std::optional shapeColor); [[nodiscard]] rpl::producer widthValue() const; [[nodiscard]] int width() const; [[nodiscard]] rpl::lifetime &lifetime(); private: void init(); void paint(QPainter &p); void updateData(Data::StarsRating rating); void updateWidth(); const std::unique_ptr _widget; const std::shared_ptr _show; const QString _name; QString _collapsedText; rpl::variable _value; Fn _pending; rpl::variable _widthValue; const style::LevelShape *_shape = nullptr; QImage _cache; int _cachedLevel = std::numeric_limits::min(); int _currentLevel = 0; float64 _opacity = 1.; std::optional _customTextColor; std::optional _customShapeColor; }; } // namespace Ui