Improved casting of limits for std::distance in stack linear chart view.

This commit is contained in:
23rd 2023-09-29 15:46:10 +03:00 committed by John Preston
parent be82df72e6
commit ded3f135bb
2 changed files with 5 additions and 3 deletions

View file

@ -401,7 +401,9 @@ void ChartWidget::Footer::moveCenter(
void ChartWidget::Footer::moveSide(bool left, float64 x) {
const auto w = float64(st::statisticsChartFooterSideWidth);
const auto mid = float64(st::statisticsChartFooterBetweenSide);
if (left) {
if (_width < (2 * w + mid)) {
return;
} else if (left) {
const auto min = std::clamp(x, 0., _rightSide.min - w - mid);
_leftSide = Limits{ .min = min, .max = min + w };
} else if (!left) {

View file

@ -905,8 +905,8 @@ int StackLinearChartView::findXIndexByPosition(
const auto nearestXPercentageIt = ((right) > (left)) ? (it - 1) : it;
return std::clamp(
std::distance(begin(chartData.xPercentage), nearestXPercentageIt),
long(localStart),
long(localEnd));
std::ptrdiff_t(localStart),
std::ptrdiff_t(localEnd));
}
AbstractChartView::HeightLimits StackLinearChartView::heightLimits(