[color] Fix vertical trims as well

This commit is contained in:
Raphael Coeffic
2021-07-15 11:32:07 +02:00
parent cdbc62c559
commit 000836a018
+8 -3
View File
@@ -89,15 +89,20 @@ void MainViewVerticalTrim::paint(BitmapBuffer * dc)
trimMax = TRIM_MAX;
}
int16_t dispVal = value;
if (dispVal < trimMin) dispVal = trimMin;
if (dispVal > trimMax) dispVal = trimMax;
// Trim line
dc->drawSolidFilledRect((width() - TRIM_LINE_WIDTH) / 2, TRIM_SQUARE_SIZE / 2,
TRIM_LINE_WIDTH, height() - TRIM_SQUARE_SIZE + 1,
DEFAULT_COLOR);
// Trim square
coord_t y = height() - TRIM_SQUARE_SIZE -
divRoundClosest((height() - TRIM_SQUARE_SIZE) * (value - trimMin),
trimMax - trimMin);
coord_t y =
height() - TRIM_SQUARE_SIZE -
divRoundClosest((height() - TRIM_SQUARE_SIZE) * (dispVal - trimMin),
trimMax - trimMin);
drawTrimSquare(dc, 0, y,
(value < TRIM_MIN || value > TRIM_MAX)
? HIGHLIGHT_COLOR /* TODO add a color */