volume slider
This commit is contained in:
@@ -254,18 +254,33 @@ ImVec2 audioDeviceWindow(ApplicationData& appData, std::vector<AudioDevice>& dev
|
||||
ImGui::TableNextColumn();
|
||||
if (dev.state == DEVICE_STATE_ACTIVE)
|
||||
{
|
||||
|
||||
|
||||
float volume = log10f(getMeterValue(dev.meterInterface) * 9. + 1.);
|
||||
// Log scale because it looks better (no actual reason for these exact numbers)
|
||||
float meterValue = log10f(getMeterValue(dev.meterInterface) * 9. + 1.);
|
||||
|
||||
auto drawList = ImGui::GetWindowDrawList();
|
||||
ImVec2 windowPos = ImGui::GetWindowPos();
|
||||
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
|
||||
ImVec2 space = ImGui::GetContentRegionAvail();
|
||||
float lineY = cursorPos.y + ImGui::GetTextLineHeight() / 2.;
|
||||
float lineY = cursorPos.y + ImGui::GetTextLineHeight() / 2. + 2.;
|
||||
|
||||
const float linePaddingX = 3.;
|
||||
cursorPos.x += linePaddingX;
|
||||
|
||||
drawList->AddLine(ImVec2(cursorPos.x, lineY), ImVec2(cursorPos.x + space.x, lineY), IM_COL32(120, 120, 120, 255), 2.);
|
||||
drawList->AddLine(ImVec2(cursorPos.x, lineY), ImVec2(cursorPos.x + space.x * volume, lineY), IM_COL32(200, 200, 255, 255), 3.);
|
||||
drawList->AddLine(ImVec2(cursorPos.x, lineY), ImVec2(cursorPos.x + (space.x - 2. * linePaddingX) , lineY), IM_COL32(120, 120, 120, 255), 2.);
|
||||
drawList->AddLine(ImVec2(cursorPos.x, lineY), ImVec2(cursorPos.x + (space.x - 2. * linePaddingX) * meterValue, lineY), IM_COL32(200, 200, 255, 255), 3.);
|
||||
|
||||
float volume = getVolume(dev.volumeInterface);
|
||||
float prevVolume = volume;
|
||||
ImGui::SetNextItemWidth(space.x);
|
||||
ImGui::PushID(dev.device);
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0, 0, 0, 0));
|
||||
ImGui::SliderFloat("", &volume, 0., 1., "", ImGuiSliderFlags_NoRoundToFormat | ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopID();
|
||||
if (prevVolume != volume)
|
||||
{
|
||||
setVolume(dev.volumeInterface, volume);
|
||||
}
|
||||
}
|
||||
|
||||
// Defaults
|
||||
|
||||
Reference in New Issue
Block a user