diff --git a/Telegram/SourceFiles/statistics/chart_widget.cpp b/Telegram/SourceFiles/statistics/chart_widget.cpp index 4fecc711b..7fdc58255 100644 --- a/Telegram/SourceFiles/statistics/chart_widget.cpp +++ b/Telegram/SourceFiles/statistics/chart_widget.cpp @@ -192,6 +192,51 @@ void RpMouseWidget::mouseReleaseEvent(QMouseEvent *e) { _mouseStateChanged.fire({ e->pos(), QEvent::MouseButtonRelease }); } +class ChartWidget::Header final : public RpWidget { +public: + using RpWidget::RpWidget; + + void setTitle(QString title); + void setRightInfo(QString rightInfo); + +protected: + void paintEvent(QPaintEvent *e) override; + +private: + Ui::Text::String _title; + Ui::Text::String _rightInfo; + int _titleWidth = 0; + +}; + +void ChartWidget::Header::setTitle(QString title) { + _titleWidth = st::statisticsHeaderTitleTextStyle.font->width(title); + _title.setText(st::statisticsHeaderTitleTextStyle, std::move(title)); +} + +void ChartWidget::Header::setRightInfo(QString rightInfo) { + _rightInfo.setText( + st::statisticsHeaderDatesTextStyle, + std::move(rightInfo)); +} + +void ChartWidget::Header::paintEvent(QPaintEvent *e) { + auto p = Painter(this); + + p.setPen(st::boxTextFg); + const auto top = (height() + - st::statisticsHeaderTitleTextStyle.font->height) / 2; + _title.drawLeftElided(p, 0, top, width(), width()); + _rightInfo.drawRightElided( + p, + 0, + top, + width() - _titleWidth, + width(), + 1, + style::al_right); +} + class ChartWidget::Footer final : public RpMouseWidget { public: using PaintCallback = Fn; @@ -823,6 +868,7 @@ bool ChartWidget::ChartAnimationController::isFPSSlow() const { ChartWidget::ChartWidget(not_null parent) : Ui::RpWidget(parent) , _chartArea(base::make_unique_q(this)) +, _header(std::make_unique
(this)) , _footer(std::make_unique