diff options
author | Cesar Torres <shortanemoia@protonmail.com> | 2021-03-21 13:01:33 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-27 10:20:55 +0100 |
commit | 7aa52978359c721cb283bab786a36943dc5b3e20 (patch) | |
tree | f5ef8cc2ae35d0957bea660d15c96c893bf20a45 /Userland/Applications/SoundPlayer/SoundPlayerWidget.h | |
parent | 45e928bfb294e43cd54bb75567c8ce3bf0645662 (diff) | |
download | serenity-7aa52978359c721cb283bab786a36943dc5b3e20.zip |
SoundPlayer: Update the SoundPlayer interface
Also fix rebase conflict
Diffstat (limited to 'Userland/Applications/SoundPlayer/SoundPlayerWidget.h')
-rw-r--r-- | Userland/Applications/SoundPlayer/SoundPlayerWidget.h | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidget.h b/Userland/Applications/SoundPlayer/SoundPlayerWidget.h index ab7bc60aea..9f01a552ee 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidget.h +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidget.h @@ -26,24 +26,28 @@ #pragma once +#include "Common.h" #include "PlaybackManager.h" +#include "Player.h" #include "SampleWidget.h" +#include <AK/NonnullRefPtr.h> #include <LibGUI/Button.h> #include <LibGUI/Label.h> -#include <LibGUI/Slider.h> #include <LibGUI/Widget.h> #include <LibGUI/Window.h> -class SoundPlayerWidget final : public GUI::Widget { +class SoundPlayerWidget final : public GUI::Widget + , public Player { C_OBJECT(SoundPlayerWidget) public: virtual ~SoundPlayerWidget() override; - void open_file(String path); + void open_file(StringView path) override; void hide_scope(bool); - PlaybackManager& manager() { return m_manager; } + Audio::ClientConnection& client_connection() override { return m_connection; } + PlaybackManager& playback_manager() override { return m_manager; } private: - explicit SoundPlayerWidget(GUI::Window&, NonnullRefPtr<Audio::ClientConnection>); + explicit SoundPlayerWidget(GUI::Window& window, Audio::ClientConnection& connection, PlaybackManager& manager); virtual void drop_event(GUI::DropEvent&) override; @@ -52,35 +56,10 @@ private: int normalize_rate(int) const; int denormalize_rate(int) const; - class Slider final : public GUI::Slider { - C_OBJECT(Slider) - public: - virtual ~Slider() override; - Function<void(int)> on_knob_released; - void set_value(int value) - { - if (!knob_dragging()) - GUI::Slider::set_value(value); - } - - protected: - Slider(Orientation orientation) - : GUI::Slider(orientation) - { - } - - virtual void mouseup_event(GUI::MouseEvent& event) override - { - if (on_knob_released && is_enabled()) - on_knob_released(value()); - - GUI::Slider::mouseup_event(event); - } - }; - GUI::Window& m_window; - NonnullRefPtr<Audio::ClientConnection> m_connection; - PlaybackManager m_manager; + Audio::ClientConnection& m_connection; + PlaybackManager& m_manager; + float m_sample_ratio { 1.0 }; RefPtr<GUI::Label> m_status; RefPtr<GUI::Label> m_elapsed; |