61 lines
1.8 KiB
C++
Executable File
61 lines
1.8 KiB
C++
Executable File
#include "monitor/gui/components/audio/audio.hpp"
|
|
#include "monitor/utils/event_type.hpp"
|
|
|
|
namespace monitor::components
|
|
{
|
|
void audio::render()
|
|
{
|
|
if (m_status != utils::var::STATUS::ACTIVE) return;
|
|
|
|
ImGui::SameLine( ImGui::GetWindowSize().x / 2.2f );
|
|
|
|
bool is_play = m_player.is_playing();
|
|
if (is_play)
|
|
{
|
|
ImGui::PushStyleColor(ImGuiCol_Button, VE_COLOR("#298FD4", 180));
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, VE_COLOR("#298FD4", 255));
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, VE_COLOR("#298FD4", 200));
|
|
}
|
|
else
|
|
{
|
|
ImGui::PushStyleColor(ImGuiCol_Button, VE_COLOR("#125C25", 180));
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, VE_COLOR("#125C25", 255));
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, VE_COLOR("#125C25", 200));
|
|
}
|
|
|
|
if (ImGui::Button(is_play ? "pause" : "play", ImVec2{70.f, 26.f} ))
|
|
{
|
|
auto f = [this]() { m_player.toggle_play(); };
|
|
std::thread t(f);
|
|
t.detach();
|
|
}
|
|
ImGui::PopStyleColor(3);
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("<<<"))
|
|
{
|
|
m_player.stop();
|
|
VE::event e { utils::event_type::AUDIO_STOP, nullptr };
|
|
EMIT(e);
|
|
}
|
|
|
|
// HERE
|
|
// выбор устройства воспроизведения
|
|
auto ctx = ImGui::GetCurrentContext();
|
|
ImGui::SameLine(0.f, ctx->Style.FramePadding.x);
|
|
ImGui::SetNextItemWidth(120.f);
|
|
static std::size_t domain_id = 0;
|
|
if (ImGui::BeginCombo(VE_NO_NAME("select_domain"), m_domains[domain_id].c_str()))
|
|
{
|
|
for (std::size_t i = 0; i < m_domains.size(); ++i)
|
|
{
|
|
const bool is_selected = (domain_id == i);
|
|
if (ImGui::Selectable(m_domains[i].c_str(), is_selected)) domain_id = i;
|
|
if (is_selected) ImGui::SetItemDefaultFocus();
|
|
}
|
|
ImGui::EndCombo();
|
|
}
|
|
}
|
|
}
|