1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:37:35 +00:00

Piano: Ensure WaveWidget paints in-bounds

Letting GUI::Frame::paint_event() cover up your mistakes is tacky :P
This commit is contained in:
William McPherson 2020-02-09 21:18:23 +11:00 committed by Andreas Kling
parent 60fdc6c9ab
commit 2a66878148

View file

@ -47,8 +47,8 @@ int WaveWidget::sample_to_y(int sample) const
{
constexpr double sample_max = std::numeric_limits<i16>::max();
double percentage = sample / sample_max;
double portion_of_height = percentage * frame_inner_rect().height();
int y = (frame_inner_rect().height() / 2) + portion_of_height;
double portion_of_half_height = percentage * ((frame_inner_rect().height() - 1) / 2.0);
double y = (frame_inner_rect().height() / 2.0) + portion_of_half_height;
return y;
}