/* 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/view/chart_horizontal_lines_view.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 ChartLinesFilterWidget; class AbstractChartView; class ChartWidget : public Ui::RpWidget { public: ChartWidget(not_null parent); void setChartData(Data::StatisticalChart chartData, ChartViewType type); void setTitle(rpl::producer &&title); void setZoomedChartData( Data::StatisticalChart chartData, float64 x, ChartViewType type); void addHorizontalLine(Limits newHeight, bool animated); [[nodiscard]] rpl::producer zoomRequests(); struct BottomCaptionLineData final { int step = 0; int stepMax = 0; int stepMin = 0; int stepMinFast = 0; int stepRaw = 0; float64 alpha = 0.; float64 fixedAlpha = 0.; }; protected: int resizeGetHeight(int newWidth) override; private: class Header; class Footer; class ChartAnimationController final { public: ChartAnimationController(Fn &&updateCallback); void setXPercentageLimits( Data::StatisticalChart &chartData, Limits xPercentageLimits, const std::unique_ptr &AbstractChartView, crl::time now); void start(); void finish(); void resetAlpha(); void restartBottomLineAlpha(); void tick( crl::time now, ChartHorizontalLinesView &horizontalLinesView, std::vector &dateLines, const std::unique_ptr &AbstractChartView); [[nodiscard]] Limits currentXLimits() const; [[nodiscard]] Limits currentXIndices() const; [[nodiscard]] Limits finalXLimits() const; [[nodiscard]] Limits currentHeightLimits() const; [[nodiscard]] Limits currentFooterHeightLimits() const; [[nodiscard]] Limits finalHeightLimits() const; [[nodiscard]] bool animating() const; [[nodiscard]] bool footerAnimating() const; [[nodiscard]] bool isFPSSlow() const; [[nodiscard]] rpl::producer<> addHorizontalLineRequests() const; private: Ui::Animations::Basic _animation; crl::time _lastUserInteracted = 0; crl::time _bottomLineAlphaAnimationStartedAt = 0; anim::value _animationValueXMin; anim::value _animationValueXMax; anim::value _animationValueHeightMin; anim::value _animationValueHeightMax; anim::value _animationValueFooterHeightMin; anim::value _animationValueFooterHeightMax; anim::value _animationValueHeightAlpha; anim::value _animValueBottomLineAlpha; Limits _finalHeightLimits; Limits _currentXIndices; struct { float speed = 0.; Limits current; float64 currentAlpha = 0.; } _dtHeight; Limits _previousFullHeightLimits; struct { crl::time lastTickedAt = 0; bool lastFPSSlow = false; } _benchmark; rpl::event_stream<> _addHorizontalLineRequests; }; [[nodiscard]] QRect chartAreaRect() const; void setupChartArea(); void setupFooter(); void setupDetails(); void setupFilterButtons(); void updateBottomDates(); void updateHeader(); void updateChartFullWidth(int w); const base::unique_qptr _chartArea; const std::unique_ptr
_header; const std::unique_ptr