mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03:00
3126b78903
This is a first pass at refactoring SoundPlayer so that the View widget is decoupled from the player itself. In doing so, this fixed a couple of issues, including possibly inconsistent states (e.g. player could be paused and stopped at the same time). With the change, Player actually controls the show, and calls methods overriden by its subclasses to perform actions, such as update the Seek bar; the hard work of massaging the raw data is done by the Player class, so subclasses don't need to reimplement any of these things. This also removes some copies of playlist management code that happened to be copied+pasted inside callbacks of buttons -- it now lives inside a neatly packaged Playlist class, and the Player only asks for the next song to play. In addition, the menu bar has been slightly rearranged.
38 lines
985 B
C++
38 lines
985 B
C++
/*
|
|
* Copyright (c) 2021, Cesar Torres <shortanemoia@protonmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "VisualizationWidget.h"
|
|
#include <AK/Complex.h>
|
|
#include <LibAudio/Buffer.h>
|
|
#include <LibGUI/Frame.h>
|
|
|
|
class BarsVisualizationWidget final : public VisualizationWidget {
|
|
C_OBJECT(BarsVisualizationWidget)
|
|
|
|
public:
|
|
~BarsVisualizationWidget() override;
|
|
void set_buffer(RefPtr<Audio::Buffer> buffer) override;
|
|
void set_samplerate(int samplerate) override;
|
|
|
|
private:
|
|
BarsVisualizationWidget();
|
|
void set_buffer(RefPtr<Audio::Buffer> buffer, int samples_to_use);
|
|
|
|
void paint_event(GUI::PaintEvent&) override;
|
|
void context_menu_event(GUI::ContextMenuEvent& event) override;
|
|
|
|
Vector<Complex<double>> m_sample_buffer;
|
|
Vector<int> m_gfx_falling_bars;
|
|
int m_last_id;
|
|
int m_sample_count;
|
|
int m_samplerate;
|
|
bool m_is_using_last;
|
|
bool m_adjust_frequencies;
|
|
RefPtr<GUI::Menu> m_context_menu;
|
|
};
|