/* 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 "data/data_statistics.h" #include "statistics/chart_horizontal_lines_data.h" #include "statistics/statistics_common.h" #include "ui/effects/animation_value.h" #include "ui/effects/animations.h" #include "ui/rp_widget.h" namespace Statistic { class RpMouseWidget; class PointDetailsWidget; class ChartWidget : public Ui::RpWidget { public: ChartWidget(not_null parent); void setChartData(Data::StatisticalChart chartData); void addHorizontalLine(Limits newHeight, bool animated); struct BottomCaptionLineData final { int step = 0; int stepMax = 0; int stepMin = 0; float64 alpha = 0.; float64 fixedAlpha = 0.; }; private: class Footer; class ChartAnimationController final { public: ChartAnimationController(Fn &&updateCallback); void setXPercentageLimits( Data::StatisticalChart &chartData, Limits xPercentageLimits, crl::time now); void start(); void finish(); void resetAlpha(); void tick( crl::time now, std::vector &horizontalLines); [[nodiscard]] Limits currentXLimits() const; [[nodiscard]] Limits finalXLimits() const; [[nodiscard]] Limits currentHeightLimits() const; [[nodiscard]] Limits finalHeightLimits() const; [[nodiscard]] float64 detailsProgress(crl::time now) const; [[nodiscard]] bool animating() const; [[nodiscard]] rpl::producer<> heightAnimationStarts() const; private: Ui::Animations::Basic _animation; crl::time _lastUserInteracted = 0; crl::time _alphaAnimationStartedAt = 0; bool _heightAnimationStarted = false; anim::value _animationValueXMin; anim::value _animationValueXMax; anim::value _animationValueHeightMin; anim::value _animationValueHeightMax; anim::value _animValueYAlpha; Limits _finalHeightLimits; float _dtHeightSpeed = 0.; Limits _dtCurrent; rpl::event_stream<> _heightAnimationStarts; }; [[nodiscard]] QRect chartAreaRect() const; void setupChartArea(); void setupFooter(); void setupDetails(); void updateBottomDates(); const base::unique_qptr _chartArea; const std::unique_ptr