[apps/shared] CurveView: fix confusion between after/before relative

position in drawLabel
This commit is contained in:
Émilie Feral
2020-01-08 17:18:47 +01:00
committed by Léa Saviot
parent 8c69314fea
commit c6e54f90c3
2 changed files with 5 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ void TrigonometryGraphView::drawRect(KDContext * ctx, KDRect rect) const {
drawLabelsAndGraduations(ctx, rect, Axis::Horizontal, false, true);
// Draw labels
drawLabel(ctx, rect, 0.0f, s, "sin(θ)", Palette::Red, c >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None);
drawLabel(ctx, rect, c, 0.0f, "cos(θ)", Palette::Red, CurveView::RelativePosition::None, s >= 0.0f ? CurveView::RelativePosition::After : CurveView::RelativePosition::Before);
drawLabel(ctx, rect, c, 0.0f, "cos(θ)", Palette::Red, CurveView::RelativePosition::None, s >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After);
}
}

View File

@@ -236,10 +236,10 @@ KDPoint CurveView::positionLabel(KDCoordinate xPosition, KDCoordinate yPosition,
xPosition -= labelSize.width()/2;
}
switch (verticalPosition) {
case RelativePosition::Before: // Above
case RelativePosition::After: // Above
yPosition -= labelSize.height() + k_labelMargin;
break;
case RelativePosition::After: // Below
case RelativePosition::Before: // Below
yPosition += k_labelMargin;
break;
default:
@@ -358,11 +358,11 @@ void CurveView::drawLabelsAndGraduations(KDContext * ctx, KDRect rect, Axis axis
continue;
}
if (shiftOrigin && floatingLabels == FloatingPosition::None) {
position = positionLabel(horizontalCoordinate, verticalCoordinate, textSize, RelativePosition::Before, RelativePosition::After);
position = positionLabel(horizontalCoordinate, verticalCoordinate, textSize, RelativePosition::Before, RelativePosition::Before);
}
} else {
if (axis == Axis::Horizontal) {
position = positionLabel(labelPosition, verticalCoordinate, textSize, RelativePosition::None, RelativePosition::After);
position = positionLabel(labelPosition, verticalCoordinate, textSize, RelativePosition::None, RelativePosition::Before);
if (floatingLabels == FloatingPosition::Min) {
position = KDPoint(position.x(), k_labelMargin);
} else if (floatingLabels == FloatingPosition::Max) {