[color] clip trim value displayed based on range set.

Resolves #443
This commit is contained in:
Raphael Coeffic
2021-07-15 10:46:44 +02:00
parent c1486c8780
commit cdbc62c559
+5 -1
View File
@@ -44,13 +44,17 @@ void MainViewHorizontalTrim::paint(BitmapBuffer * dc)
trimMax = TRIM_MAX; trimMax = TRIM_MAX;
} }
int16_t dispVal = value;
if (dispVal < trimMin) dispVal = trimMin;
if (dispVal > trimMax) dispVal = trimMax;
// Trim line // Trim line
dc->drawSolidFilledRect( dc->drawSolidFilledRect(
TRIM_SQUARE_SIZE / 2, (height() - TRIM_LINE_WIDTH - 1) / 2, TRIM_SQUARE_SIZE / 2, (height() - TRIM_LINE_WIDTH - 1) / 2,
width() - TRIM_SQUARE_SIZE + 1, TRIM_LINE_WIDTH, DEFAULT_COLOR); width() - TRIM_SQUARE_SIZE + 1, TRIM_LINE_WIDTH, DEFAULT_COLOR);
// Trim square // Trim square
coord_t x = divRoundClosest((width() - TRIM_SQUARE_SIZE) * (value - trimMin), coord_t x = divRoundClosest((width() - TRIM_SQUARE_SIZE) * (dispVal - trimMin),
trimMax - trimMin); trimMax - trimMin);
drawTrimSquare(dc, x, 0, drawTrimSquare(dc, x, 0,
(value < TRIM_MIN || value > TRIM_MAX) (value < TRIM_MIN || value > TRIM_MAX)