From 2a66878148842f06a2d88ffecfcea863596c14d5 Mon Sep 17 00:00:00 2001 From: William McPherson Date: Sun, 9 Feb 2020 21:18:23 +1100 Subject: [PATCH] Piano: Ensure WaveWidget paints in-bounds Letting GUI::Frame::paint_event() cover up your mistakes is tacky :P --- Applications/Piano/WaveWidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Applications/Piano/WaveWidget.cpp b/Applications/Piano/WaveWidget.cpp index bd2430099e..41659ce0e2 100644 --- a/Applications/Piano/WaveWidget.cpp +++ b/Applications/Piano/WaveWidget.cpp @@ -47,8 +47,8 @@ int WaveWidget::sample_to_y(int sample) const { constexpr double sample_max = std::numeric_limits::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; }