2023-07-06 11:09:16 +00:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
2023-09-29 13:41:18 +00:00
|
|
|
#include "data/data_statistics_chart.h"
|
2023-10-03 02:19:41 +00:00
|
|
|
#include "ui/abstract_button.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class RippleAnimation;
|
|
|
|
} // namespace Ui
|
2023-07-06 11:09:16 +00:00
|
|
|
|
|
|
|
namespace Statistic {
|
|
|
|
|
2023-09-15 09:41:14 +00:00
|
|
|
void PaintDetails(
|
|
|
|
QPainter &p,
|
|
|
|
const Data::StatisticalChart::Line &line,
|
|
|
|
int absoluteValue,
|
|
|
|
const QRect &rect);
|
|
|
|
|
2023-10-03 02:19:41 +00:00
|
|
|
class PointDetailsWidget : public Ui::AbstractButton {
|
2023-07-06 11:09:16 +00:00
|
|
|
public:
|
|
|
|
PointDetailsWidget(
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
2023-07-11 00:58:46 +00:00
|
|
|
const Data::StatisticalChart &chartData,
|
2023-07-27 04:05:33 +00:00
|
|
|
float64 maxAbsoluteValue,
|
|
|
|
bool zoomEnabled);
|
2023-07-06 11:09:16 +00:00
|
|
|
|
2023-07-07 08:28:50 +00:00
|
|
|
[[nodiscard]] int xIndex() const;
|
2023-07-06 11:09:16 +00:00
|
|
|
void setXIndex(int xIndex);
|
2023-07-07 11:41:30 +00:00
|
|
|
void setAlpha(float64 alpha);
|
2023-09-05 14:03:08 +00:00
|
|
|
[[nodiscard]] float64 alpha() const;
|
2023-07-14 16:01:33 +00:00
|
|
|
void setLineAlpha(int lineId, float64 alpha);
|
2023-07-06 11:09:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2023-10-03 02:19:41 +00:00
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
2023-09-08 12:08:13 +00:00
|
|
|
|
2023-07-06 11:09:16 +00:00
|
|
|
private:
|
2023-07-27 04:05:33 +00:00
|
|
|
const bool _zoomEnabled;
|
2023-07-06 11:09:16 +00:00
|
|
|
const Data::StatisticalChart &_chartData;
|
|
|
|
const style::TextStyle &_textStyle;
|
|
|
|
const style::TextStyle &_headerStyle;
|
|
|
|
Ui::Text::String _header;
|
|
|
|
|
2023-10-03 02:19:41 +00:00
|
|
|
void invalidateCache();
|
|
|
|
|
2023-07-14 16:01:33 +00:00
|
|
|
[[nodiscard]] int lineYAt(int index) const;
|
|
|
|
|
|
|
|
void resizeHeight();
|
2023-07-06 11:09:16 +00:00
|
|
|
|
|
|
|
struct Line final {
|
2023-07-14 16:01:33 +00:00
|
|
|
int id = 0;
|
2023-07-06 11:09:16 +00:00
|
|
|
Ui::Text::String name;
|
|
|
|
Ui::Text::String value;
|
2023-10-05 15:45:48 +00:00
|
|
|
Ui::Text::String percentage;
|
2023-07-06 11:09:16 +00:00
|
|
|
QColor valueColor;
|
2023-07-14 16:01:33 +00:00
|
|
|
float64 alpha = 1.;
|
2023-07-06 11:09:16 +00:00
|
|
|
};
|
|
|
|
|
2023-10-21 08:14:49 +00:00
|
|
|
bool _hasPositiveValues = true;
|
|
|
|
|
2023-10-05 15:45:48 +00:00
|
|
|
int _maxPercentageWidth = 0;
|
|
|
|
|
2023-07-06 11:09:16 +00:00
|
|
|
QRect _innerRect;
|
|
|
|
QRect _textRect;
|
2023-09-08 12:08:13 +00:00
|
|
|
QImage _arrow;
|
2023-07-06 11:09:16 +00:00
|
|
|
|
2023-10-03 02:19:41 +00:00
|
|
|
QImage _cache;
|
|
|
|
|
2023-07-07 08:28:50 +00:00
|
|
|
int _xIndex = -1;
|
2023-07-07 11:41:30 +00:00
|
|
|
float64 _alpha = 1.;
|
2023-07-07 08:28:50 +00:00
|
|
|
|
2023-07-06 11:09:16 +00:00
|
|
|
std::vector<Line> _lines;
|
|
|
|
|
2023-10-03 02:19:41 +00:00
|
|
|
std::unique_ptr<Ui::RippleAnimation> _ripple;
|
|
|
|
|
2023-07-06 11:09:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Statistic
|