LibGUI: Fix OpacitySlider hairline disappearing towards the left

Whoops, we were scaling the alpha channel of the hairline color along
with the RGB channels.
This commit is contained in:
Andreas Kling 2021-01-15 23:22:10 +01:00
parent 71f50b6e94
commit 4839f36f5e
Notes: sideshowbarker 2024-07-18 23:47:57 +09:00

View File

@ -105,9 +105,9 @@ void OpacitySlider::paint_event(PaintEvent& event)
// We adjust the hairline's x position so it lines up with the shadow/highlight of the notches.
u8 h = ((float)value() / (float)max()) * 255.0f;
if (h < 128)
painter.draw_line({ notch_x, notch_y_top }, { notch_x, notch_y_bottom }, Color(h, h, h, h));
painter.draw_line({ notch_x, notch_y_top }, { notch_x, notch_y_bottom }, Color(h, h, h, 255));
else
painter.draw_line({ notch_x - 1, notch_y_top }, { notch_x - 1, notch_y_bottom }, Color(h, h, h, h));
painter.draw_line({ notch_x - 1, notch_y_top }, { notch_x - 1, notch_y_bottom }, Color(h, h, h, 255));
// Text label
auto percent_text = String::formatted("{}%", (int)((float)value() / (float)max() * 100.0f));