1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 11:25:07 +00:00
serenity/Userland/Applications/SoundPlayer/BarsVisualizationWidget.h
Karol Kosek 9d36369c58 SoundPlayer: Show the context menu right under the cursor
The context menu used the mouse position by window,
which resulted in a pop-up menu in the upper left corner of the screen.
2021-07-11 21:15:56 +02:00

38 lines
1,001 B
C++

/*
* Copyright (c) 2021, Cesar Torres <shortanemoia@protonmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "VisualizationBase.h"
#include <AK/Complex.h>
#include <LibAudio/Buffer.h>
#include <LibGUI/Frame.h>
class BarsVisualizationWidget final : public GUI::Frame
, public Visualization {
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;
};