#ifndef __AUDIO_WIDGET_H__
#define __AUDIO_WIDGET_H__

#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
#include <QSlider>
#include <QSpinBox>
#include "audio_render.h"

class AudioWidget : public QWidget
{
    Q_OBJECT
public:
    AudioWidget(QWidget* parent = nullptr);
    void ShowVolume(float volume)
    {
        _render->setLevel(volume);
        _render->update();
    }
    void SetName(const std::string& name) { _nameLabel->setText(name.c_str()); }
    double GetVolume() { return _mutebox->isChecked() ? 0 : _volumeBox->value(); }

private:
    void _CreateUi();
    void _CreateConnect();
    QLabel* _nameLabel = nullptr;
    AudioRender* _render = nullptr;
    QCheckBox* _mutebox = nullptr;
    QDoubleSpinBox* _volumeBox = nullptr;
    float _lastShowVal = 0;

signals:
    void SetVolumeScale(float scale);
};

#endif
