summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/SoundPlayer/Common.h12
-rw-r--r--Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp13
2 files changed, 22 insertions, 3 deletions
diff --git a/Userland/Applications/SoundPlayer/Common.h b/Userland/Applications/SoundPlayer/Common.h
index 3a5a2c9816..901a7d17bb 100644
--- a/Userland/Applications/SoundPlayer/Common.h
+++ b/Userland/Applications/SoundPlayer/Common.h
@@ -19,17 +19,29 @@ public:
GUI::Slider::set_value(value);
}
+ bool mouse_is_down() const { return m_mouse_is_down; }
+
protected:
AutoSlider(Orientation orientation)
: GUI::Slider(orientation)
{
}
+ virtual void mousedown_event(GUI::MouseEvent& event) override
+ {
+ m_mouse_is_down = true;
+ GUI::Slider::mousedown_event(event);
+ }
+
virtual void mouseup_event(GUI::MouseEvent& event) override
{
+ m_mouse_is_down = false;
if (on_knob_released && is_enabled())
on_knob_released(value());
GUI::Slider::mouseup_event(event);
}
+
+private:
+ bool m_mouse_is_down { false };
};
diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
index ffc7fb3511..477278d8e7 100644
--- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
+++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp
@@ -47,10 +47,15 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window
m_visualization = m_player_view->add<BarsVisualizationWidget>();
+ // Set a temporary value for total samples.
+ // This value will be set properly when we load a new file.
+ const int total_samples = this->manager().total_length() * 44100;
+
m_playback_progress_slider = m_player_view->add<AutoSlider>(Orientation::Horizontal);
m_playback_progress_slider->set_fixed_height(20);
m_playback_progress_slider->set_min(0);
- m_playback_progress_slider->set_max(this->manager().total_length() * 44100); //this value should be set when we load a new file
+ m_playback_progress_slider->set_max(total_samples);
+ m_playback_progress_slider->set_page_step(total_samples / 10);
m_playback_progress_slider->on_knob_released = [&](int value) {
this->manager().seek(value);
};
@@ -139,7 +144,9 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window
int samples_played = client_connection().get_played_samples() + this->manager().last_seek();
int current_second = samples_played / 44100;
timestamp_label.set_text(String::formatted("Elapsed: {:02}:{:02}:{:02}", current_second / 3600, current_second / 60, current_second % 60));
- m_playback_progress_slider->set_value(samples_played);
+ if (!m_playback_progress_slider->mouse_is_down()) {
+ m_playback_progress_slider->set_value(samples_played);
+ }
dynamic_cast<Visualization*>(m_visualization.ptr())->set_buffer(this->manager().current_buffer());
dynamic_cast<Visualization*>(m_visualization.ptr())->set_samplerate(loaded_file_samplerate());
@@ -191,11 +198,11 @@ void SoundPlayerWidgetAdvancedView::open_file(StringView path)
}
m_window.set_title(String::formatted("{} - Sound Player", loader->file()->filename()));
m_playback_progress_slider->set_max(loader->total_samples());
+ m_playback_progress_slider->set_page_step(loader->total_samples() / 10);
m_playback_progress_slider->set_enabled(true);
m_play_button->set_enabled(true);
m_play_button->set_icon(*m_pause_icon);
m_stop_button->set_enabled(true);
- m_playback_progress_slider->set_max(loader->total_samples());
manager().set_loader(move(loader));
set_has_loaded_file(true);
set_loaded_file_samplerate(loader->sample_rate());