mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed paint glitch of selected bar on stack chart view.
This commit is contained in:
parent
da9720530a
commit
fcdd7ecd61
1 changed files with 8 additions and 10 deletions
|
@ -76,9 +76,8 @@ void StackChartView::paintChartAndSelected(
|
||||||
yPoint);
|
yPoint);
|
||||||
if (hasSelectedXIndex && (x == _lastSelectedXIndex)) {
|
if (hasSelectedXIndex && (x == _lastSelectedXIndex)) {
|
||||||
selectedBottoms[i] = column.y();
|
selectedBottoms[i] = column.y();
|
||||||
} else {
|
|
||||||
path.addRect(column);
|
|
||||||
}
|
}
|
||||||
|
path.addRect(column);
|
||||||
bottoms[bottomIndex] += yPoint;
|
bottoms[bottomIndex] += yPoint;
|
||||||
}
|
}
|
||||||
p.fillPath(path, line.color);
|
p.fillPath(path, line.color);
|
||||||
|
@ -111,10 +110,12 @@ void StackChartView::paintSelectedXIndex(
|
||||||
const PaintContext &c,
|
const PaintContext &c,
|
||||||
int selectedXIndex,
|
int selectedXIndex,
|
||||||
float64 progress) {
|
float64 progress) {
|
||||||
|
const auto was = _lastSelectedXIndex;
|
||||||
_lastSelectedXIndex = selectedXIndex;
|
_lastSelectedXIndex = selectedXIndex;
|
||||||
_lastSelectedXProgress = progress;
|
_lastSelectedXProgress = progress;
|
||||||
[[maybe_unused]] const auto o = ScopedPainterOpacity(p, progress);
|
if ((_lastSelectedXIndex >= 0) || (was >= 0)) {
|
||||||
StackChartView::paintChartAndSelected(p, c);
|
StackChartView::paintChartAndSelected(p, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int StackChartView::findXIndexByPosition(
|
int StackChartView::findXIndexByPosition(
|
||||||
|
@ -122,10 +123,8 @@ int StackChartView::findXIndexByPosition(
|
||||||
const Limits &xPercentageLimits,
|
const Limits &xPercentageLimits,
|
||||||
const QRect &rect,
|
const QRect &rect,
|
||||||
float64 xPos) {
|
float64 xPos) {
|
||||||
if (xPos < rect.x()) {
|
if ((xPos < rect.x()) || (xPos > (rect.x() + rect.width()))) {
|
||||||
return 0;
|
return _lastSelectedXIndex = -1;
|
||||||
} else if (xPos > (rect.x() + rect.width())) {
|
|
||||||
return chartData.xPercentage.size() - 1;
|
|
||||||
}
|
}
|
||||||
const auto &[localStart, localEnd] = _lastPaintedXIndices;
|
const auto &[localStart, localEnd] = _lastPaintedXIndices;
|
||||||
const auto &[leftStart, w] = ComputeLeftStartAndStep(
|
const auto &[leftStart, w] = ComputeLeftStartAndStep(
|
||||||
|
@ -135,7 +134,6 @@ int StackChartView::findXIndexByPosition(
|
||||||
localStart);
|
localStart);
|
||||||
|
|
||||||
for (auto i = 0; i < chartData.lines.size(); i++) {
|
for (auto i = 0; i < chartData.lines.size(); i++) {
|
||||||
const auto &line = chartData.lines[i];
|
|
||||||
for (auto x = localStart; x <= localEnd; x++) {
|
for (auto x = localStart; x <= localEnd; x++) {
|
||||||
const auto left = leftStart + (x - localStart) * w;
|
const auto left = leftStart + (x - localStart) * w;
|
||||||
if ((xPos >= left) && (xPos < (left + w))) {
|
if ((xPos >= left) && (xPos < (left + w))) {
|
||||||
|
@ -143,7 +141,7 @@ int StackChartView::findXIndexByPosition(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _lastSelectedXIndex = 0;
|
return _lastSelectedXIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractChartView::HeightLimits StackChartView::heightLimits(
|
AbstractChartView::HeightLimits StackChartView::heightLimits(
|
||||||
|
|
Loading…
Add table
Reference in a new issue