mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
SoundPlayer: Make 'volume_slider' a member variable
This change will allow us to modify the volume slider from any event inside the widget.
This commit is contained in:
parent
11a4fa6067
commit
ccced92ac2
2 changed files with 7 additions and 6 deletions
|
@ -102,13 +102,13 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window
|
||||||
m_volume_label = &menubar.add<GUI::Label>();
|
m_volume_label = &menubar.add<GUI::Label>();
|
||||||
m_volume_label->set_fixed_width(30);
|
m_volume_label->set_fixed_width(30);
|
||||||
|
|
||||||
auto& volume_slider = menubar.add<GUI::HorizontalSlider>();
|
m_volume_slider = &menubar.add<GUI::HorizontalSlider>();
|
||||||
volume_slider.set_fixed_width(95);
|
m_volume_slider->set_fixed_width(95);
|
||||||
volume_slider.set_min(0);
|
m_volume_slider->set_min(0);
|
||||||
volume_slider.set_max(150);
|
m_volume_slider->set_max(150);
|
||||||
volume_slider.set_value(100);
|
m_volume_slider->set_value(100);
|
||||||
|
|
||||||
volume_slider.on_change = [&](int value) {
|
m_volume_slider->on_change = [&](int value) {
|
||||||
double volume = m_nonlinear_volume_slider ? (double)(value * value) / (100 * 100) : value / 100.;
|
double volume = m_nonlinear_volume_slider ? (double)(value * value) / (100 * 100) : value / 100.;
|
||||||
set_volume(volume);
|
set_volume(volume);
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,6 +73,7 @@ private:
|
||||||
RefPtr<GUI::Button> m_next_button;
|
RefPtr<GUI::Button> m_next_button;
|
||||||
RefPtr<AutoSlider> m_playback_progress_slider;
|
RefPtr<AutoSlider> m_playback_progress_slider;
|
||||||
RefPtr<GUI::Label> m_volume_label;
|
RefPtr<GUI::Label> m_volume_label;
|
||||||
|
RefPtr<GUI::HorizontalSlider> m_volume_slider;
|
||||||
RefPtr<GUI::Label> m_timestamp_label;
|
RefPtr<GUI::Label> m_timestamp_label;
|
||||||
|
|
||||||
bool m_nonlinear_volume_slider;
|
bool m_nonlinear_volume_slider;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue