summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam McPherson <willmcpherson2@gmail.com>2020-02-09 21:18:23 +1100
committerAndreas Kling <kling@serenityos.org>2020-02-10 14:04:27 +0100
commit2a66878148842f06a2d88ffecfcea863596c14d5 (patch)
tree76bfd2509cff638bcbc30a50d6d8ea14b1473f0c
parent60fdc6c9ab587f8af16253be0a9a39dd217c66fd (diff)
downloadserenity-2a66878148842f06a2d88ffecfcea863596c14d5.zip
Piano: Ensure WaveWidget paints in-bounds
Letting GUI::Frame::paint_event() cover up your mistakes is tacky :P
-rw-r--r--Applications/Piano/WaveWidget.cpp4
1 files 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<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;
}