mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Fixed animation processing after selecting part of pie chart.
This commit is contained in:
parent
7ac9ab3a51
commit
6ffe555f6a
2 changed files with 18 additions and 4 deletions
|
@ -447,6 +447,9 @@ void StackLinearChartView::paintZoomed(QPainter &p, const PaintContext &c) {
|
||||||
selectedLineIndex = k;
|
selectedLineIndex = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_piePartController.isFinished()) {
|
||||||
|
_piePartAnimation.stop();
|
||||||
|
}
|
||||||
paintPieText(p, c);
|
paintPieText(p, c);
|
||||||
|
|
||||||
if (selectedLineIndex >= 0) {
|
if (selectedLineIndex >= 0) {
|
||||||
|
@ -591,7 +594,7 @@ void StackLinearChartView::PiePartController::update(int id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float64 StackLinearChartView::PiePartController::progress(int id) {
|
float64 StackLinearChartView::PiePartController::progress(int id) const {
|
||||||
const auto it = _startedAt.find(id);
|
const auto it = _startedAt.find(id);
|
||||||
if (it == end(_startedAt)) {
|
if (it == end(_startedAt)) {
|
||||||
return 0.;
|
return 0.;
|
||||||
|
@ -607,7 +610,7 @@ float64 StackLinearChartView::PiePartController::progress(int id) {
|
||||||
|
|
||||||
QPointF StackLinearChartView::PiePartController::offset(
|
QPointF StackLinearChartView::PiePartController::offset(
|
||||||
LineId id,
|
LineId id,
|
||||||
float64 angle) {
|
float64 angle) const {
|
||||||
const auto offset = st::statisticsPieChartPartOffset * progress(id);
|
const auto offset = st::statisticsPieChartPartOffset * progress(id);
|
||||||
const auto radians = angle * M_PI / 180.;
|
const auto radians = angle * M_PI / 180.;
|
||||||
return { std::cos(radians) * offset, std::sin(radians) * offset };
|
return { std::cos(radians) * offset, std::sin(radians) * offset };
|
||||||
|
@ -617,6 +620,16 @@ auto StackLinearChartView::PiePartController::selected() const -> LineId {
|
||||||
return _selected;
|
return _selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StackLinearChartView::PiePartController::isFinished() const {
|
||||||
|
for (const auto &[id, _] : _startedAt) {
|
||||||
|
const auto p = progress(id);
|
||||||
|
if (p > 0 && p < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void StackLinearChartView::handleMouseMove(
|
void StackLinearChartView::handleMouseMove(
|
||||||
const Data::StatisticalChart &chartData,
|
const Data::StatisticalChart &chartData,
|
||||||
const QPoint ¢er,
|
const QPoint ¢er,
|
||||||
|
|
|
@ -105,9 +105,10 @@ private:
|
||||||
public:
|
public:
|
||||||
using LineId = int;
|
using LineId = int;
|
||||||
bool set(LineId id);
|
bool set(LineId id);
|
||||||
[[nodiscard]] float64 progress(LineId id);
|
[[nodiscard]] float64 progress(LineId id) const;
|
||||||
[[nodiscard]] QPointF offset(LineId id, float64 angle);
|
[[nodiscard]] QPointF offset(LineId id, float64 angle) const;
|
||||||
[[nodiscard]] LineId selected() const;
|
[[nodiscard]] LineId selected() const;
|
||||||
|
[[nodiscard]] bool isFinished() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update(LineId id);
|
void update(LineId id);
|
||||||
|
|
Loading…
Add table
Reference in a new issue