mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Moved out class for cached selected points on chart from private space.
This commit is contained in:
parent
4c6d33fd54
commit
bc6556ebc4
4 changed files with 16 additions and 26 deletions
|
@ -25,6 +25,15 @@ struct PaintContext final {
|
|||
bool footer = false;
|
||||
};
|
||||
|
||||
struct CachedSelectedPoints final {
|
||||
[[nodiscard]] bool isSame(int x, const PaintContext &c) const;
|
||||
|
||||
int lastXIndex = -1;
|
||||
Limits lastHeightLimits;
|
||||
Limits lastXLimits;
|
||||
base::flat_map<int, QPointF> points;
|
||||
};
|
||||
|
||||
class AbstractChartView {
|
||||
public:
|
||||
virtual ~AbstractChartView() = default;
|
||||
|
@ -82,24 +91,14 @@ public:
|
|||
const QPoint &p) {
|
||||
}
|
||||
|
||||
void setUpdateCallback(Fn<void()> callback) {
|
||||
_updateCallback = std::move(callback);
|
||||
}
|
||||
void update() {
|
||||
if (_updateCallback) {
|
||||
_updateCallback();
|
||||
}
|
||||
}
|
||||
void setUpdateCallback(Fn<void()> callback);
|
||||
void update();
|
||||
|
||||
void setLinesFilterController(std::shared_ptr<LinesFilterController> c) {
|
||||
_linesFilterController = std::move(c);
|
||||
}
|
||||
void setLinesFilterController(std::shared_ptr<LinesFilterController> c);
|
||||
|
||||
protected:
|
||||
using LinesFilterControllerPtr = std::shared_ptr<LinesFilterController>;
|
||||
[[nodiscard]] LinesFilterControllerPtr linesFilterController() {
|
||||
return _linesFilterController;
|
||||
}
|
||||
[[nodiscard]] LinesFilterControllerPtr linesFilterController() const;
|
||||
|
||||
private:
|
||||
LinesFilterControllerPtr _linesFilterController;
|
||||
|
|
|
@ -140,11 +140,7 @@ void LinearChartView::paintSelectedXIndex(
|
|||
p.setBrush(st::boxBg);
|
||||
const auto r = st::statisticsDetailsDotRadius;
|
||||
const auto i = selectedXIndex;
|
||||
const auto isSameToken = (_selectedPoints.lastXIndex == selectedXIndex)
|
||||
&& (_selectedPoints.lastHeightLimits.min == c.heightLimits.min)
|
||||
&& (_selectedPoints.lastHeightLimits.max == c.heightLimits.max)
|
||||
&& (_selectedPoints.lastXLimits.min == c.xPercentageLimits.min)
|
||||
&& (_selectedPoints.lastXLimits.max == c.xPercentageLimits.max);
|
||||
const auto isSameToken = _selectedPoints.isSame(selectedXIndex, c);
|
||||
auto linePainted = false;
|
||||
for (const auto &line : c.chartData.lines) {
|
||||
const auto lineAlpha = linesFilter->alpha(line.id);
|
||||
|
|
|
@ -90,13 +90,7 @@ private:
|
|||
base::flat_map<int, Cache> _mainCaches;
|
||||
base::flat_map<int, Cache> _footerCaches;
|
||||
|
||||
struct SelectedPoints final {
|
||||
int lastXIndex = -1;
|
||||
Limits lastHeightLimits;
|
||||
Limits lastXLimits;
|
||||
base::flat_map<int, QPointF> points;
|
||||
};
|
||||
SelectedPoints _selectedPoints;
|
||||
CachedSelectedPoints _selectedPoints;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -183,6 +183,7 @@ PRIVATE
|
|||
statistics/statistics_common.h
|
||||
statistics/statistics_data_deserialize.cpp
|
||||
statistics/statistics_data_deserialize.h
|
||||
statistics/view/abstract_chart_view.cpp
|
||||
statistics/view/abstract_chart_view.h
|
||||
statistics/view/chart_rulers_view.cpp
|
||||
statistics/view/chart_rulers_view.h
|
||||
|
|
Loading…
Add table
Reference in a new issue