#pragma once #include "PlaybackManager.h" #include "SampleWidget.h" #include #include #include #include #include class SoundPlayerWidget final : public GWidget { C_OBJECT(SoundPlayerWidget) public: virtual ~SoundPlayerWidget() override; void open_file(String path); PlaybackManager& manager() { return m_manager; } private: explicit SoundPlayerWidget(GWindow&, NonnullRefPtr); void update_position(const int position); void update_ui(); int normalize_rate(int) const; int denormalize_rate(int) const; class Slider final : public GSlider { C_OBJECT(Slider) public: virtual ~Slider() override; Function on_knob_released; void set_value(int value) { if (!knob_dragging()) GSlider::set_value(value); } protected: Slider(Orientation orientation, GWidget* parent) : GSlider(orientation, parent) { } virtual void mouseup_event(GMouseEvent& event) override { if (on_knob_released && is_enabled()) on_knob_released(value()); GSlider::mouseup_event(event); } }; GWindow& m_window; NonnullRefPtr m_connection; PlaybackManager m_manager; float m_sample_ratio; RefPtr m_status; RefPtr m_elapsed; RefPtr m_remaining; RefPtr m_slider; RefPtr m_sample_widget; RefPtr m_play_icon { GraphicsBitmap::load_from_file("/res/icons/16x16/play.png") }; RefPtr m_pause_icon { GraphicsBitmap::load_from_file("/res/icons/16x16/pause.png") }; RefPtr m_play; RefPtr m_stop; };