diff options
author | kleines Filmröllchen <filmroellchen@serenityos.org> | 2022-03-25 21:40:54 +0100 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-03-25 18:34:30 -0700 |
commit | 9cca9f520442036bc8cc4f3ef89c5b30584baf48 (patch) | |
tree | 394a8b968f656b20061b868ac024b295ecdba8c9 /Userland/Applications | |
parent | 925c34cf436c13f1244f86d28286e08a7393b09e (diff) | |
download | serenity-9cca9f520442036bc8cc4f3ef89c5b30584baf48.zip |
SoundPlayer: Fix jump to slider behavior for playback slider
This was regressed at some point though I never saw it working.
Basically, while jump to slider works correctly it doesn't even get
actioned. While the user is clicking the slider it's very likely that a
buffer finishes playing and the callback for that changes the slider
value. This means that the user click just gets lost. There's some
additional weird behavior where values are lost in even more cases, so
an additional fix that is needed is to store the slider value in the
AutoSlider while we're dragging and apply it on mouse up.
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/SoundPlayer/Common.h | 4 | ||||
-rw-r--r-- | Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Userland/Applications/SoundPlayer/Common.h b/Userland/Applications/SoundPlayer/Common.h index 353fd29bd1..203aecf56b 100644 --- a/Userland/Applications/SoundPlayer/Common.h +++ b/Userland/Applications/SoundPlayer/Common.h @@ -15,6 +15,7 @@ public: Function<void(int)> on_knob_released; virtual void set_value(int value, GUI::AllowCallback allow_callback = GUI::AllowCallback::Yes) override { + m_in_drag_value = value; if (!knob_dragging() && !mouse_is_down()) GUI::Slider::set_value(value, allow_callback); } @@ -36,6 +37,7 @@ private: virtual void mouseup_event(GUI::MouseEvent& event) override { m_mouse_is_down = false; + set_value(m_in_drag_value); if (on_knob_released && is_enabled()) on_knob_released(value()); @@ -43,4 +45,6 @@ private: } bool m_mouse_is_down { false }; + // Keeps track of the value while we're dragging + int m_in_drag_value { 0 }; }; diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp index 0add1963f4..0eabca66bd 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp @@ -220,7 +220,9 @@ void SoundPlayerWidgetAdvancedView::sound_buffer_played(RefPtr<Audio::Buffer> bu { m_visualization->set_buffer(buffer); m_visualization->set_samplerate(sample_rate); - m_playback_progress_slider->set_value(samples_played); + // If the user is currently dragging the slider, don't interfere. + if (!m_playback_progress_slider->mouse_is_down()) + m_playback_progress_slider->set_value(samples_played); } void SoundPlayerWidgetAdvancedView::volume_changed(double volume) |