[apps/shared] Add display margin on top of / below constant curve

This commit is contained in:
Léa Saviot
2019-09-02 15:45:21 +02:00
parent 18a458bae5
commit b05041dbd0
2 changed files with 7 additions and 1 deletions

View File

@@ -22,6 +22,12 @@ bool InteractiveCurveViewRangeDelegate::didChangeRange(InteractiveCurveViewRange
if (interactiveCurveViewRange->yMin() == addMargin(min, range, true) && interactiveCurveViewRange->yMax() == addMargin(max, range, false)) {
return false;
}
if (min == max) {
// Add same margin on top of / below the curve, to center it on the screen
float step = max != 0.0f ? 2.0f * interactiveCurveViewRange->defaultRangeLengthFor(max) : 1.0f;
min = min - step;
max = max + step;
}
if (min == FLT_MAX && max == -FLT_MAX) {
min = -1.0f;
max = 1.0f;

View File

@@ -19,9 +19,9 @@ public:
virtual void setXMax(float f);
virtual void setYMin(float f);
virtual void setYMax(float f);
float defaultRangeLengthFor(float position) const;
protected:
float defaultRangeLengthFor(float position) const;
// Window bounds of the data
float m_xMin;
float m_xMax;