SoundPlayer: Fix logic bug in bars visualization
When calculating bar height, we clamp our values to the maximum vertical height of the widget minus a margin. When the window was resized such that the widget got smaller than this margin however, our maximum height became negative. This caused a crash in clamp().
This commit is contained in:
parent
c3abb1396c
commit
adb1c842c2
Notes:
sideshowbarker
2024-07-17 06:38:11 +09:00
Author: https://github.com/janso3 Commit: https://github.com/SerenityOS/serenity/commit/adb1c842c2 Pull-request: https://github.com/SerenityOS/serenity/pull/17384 Reviewed-by: https://github.com/kleinesfilmroellchen ✅
1 changed files with 1 additions and 1 deletions
|
@ -75,7 +75,7 @@ void BarsVisualizationWidget::render(GUI::PaintEvent& event, FixedArray<float> c
|
|||
int const top_vertical_margin = 15;
|
||||
int const pixels_inbetween_groups = frame_inner_rect().width() > 350 ? 5 : 2;
|
||||
int const pixel_per_group_width = (frame_inner_rect().width() - horizontal_margin * 2 - pixels_inbetween_groups * (bar_count - 1)) / bar_count;
|
||||
int const max_height = frame_inner_rect().height() - top_vertical_margin;
|
||||
int const max_height = AK::max(0, frame_inner_rect().height() - top_vertical_margin);
|
||||
int current_xpos = horizontal_margin;
|
||||
for (size_t g = 0; g < bar_count; g++) {
|
||||
m_gfx_falling_bars[g] = AK::min(clamp(max_height - static_cast<int>(groups[g] * static_cast<float>(max_height) * 0.8f), 0, max_height), m_gfx_falling_bars[g]);
|
||||
|
|
Loading…
Add table
Reference in a new issue