proper checkbox disable; basic themeing

pull/1/head
Clyne 3 years ago
parent 79032a73d5
commit 4306970fd3

@ -17,6 +17,7 @@
#include "stmdsp.hpp"
#include "imgui.h"
#include "imgui_internal.h"
#include "ImGuiFileDialog.h"
#include "wav.hpp"
@ -106,7 +107,7 @@ static void drawSamplesTask(std::shared_ptr<stmdsp::device> device)
std::vector<stmdsp::dacsample_t> chunk;
if (lockDevice.try_lock_until(next)) {
if (lockDevice.try_lock_until(next)) {
chunk = m_device->continuous_read();
int tries = -1;
while (chunk.empty() && m_device->is_running()) {
@ -115,16 +116,16 @@ static void drawSamplesTask(std::shared_ptr<stmdsp::device> device)
std::this_thread::sleep_for(std::chrono::microseconds(20));
chunk = m_device->continuous_read();
}
lockDevice.unlock();
} else {
lockDevice.unlock();
} else {
// Cooldown.
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
}
if (drawSamplesInput && popupRequestDraw) {
std::vector<stmdsp::dacsample_t> chunk2;
if (lockDevice.try_lock_for(std::chrono::milliseconds(1))) {
if (lockDevice.try_lock_for(std::chrono::milliseconds(1))) {
chunk2 = m_device->continuous_read_input();
int tries = -1;
while (chunk2.empty() && m_device->is_running()) {
@ -133,28 +134,28 @@ static void drawSamplesTask(std::shared_ptr<stmdsp::device> device)
std::this_thread::sleep_for(std::chrono::microseconds(20));
chunk2 = m_device->continuous_read_input();
}
lockDevice.unlock();
lockDevice.unlock();
}
lockDraw.lock();
lockDraw.lock();
auto i = chunk2.cbegin();
for (const auto& s : chunk) {
drawSamplesQueue.push_back(s);
drawSamplesInputQueue.push_back(*i++);
}
lockDraw.unlock();
lockDraw.unlock();
} else if (!doLogger) {
lockDraw.lock();
lockDraw.lock();
for (const auto& s : chunk)
drawSamplesQueue.push_back(s);
lockDraw.unlock();
lockDraw.unlock();
} else {
lockDraw.lock();
lockDraw.lock();
for (const auto& s : chunk) {
drawSamplesQueue.push_back(s);
logSamplesFile << s << '\n';
}
lockDraw.unlock();
lockDraw.unlock();
}
std::this_thread::sleep_until(next);
@ -193,7 +194,7 @@ static void feedSigGenTask(std::shared_ptr<stmdsp::device> device)
if (lockDevice.try_lock_until(next)) {
m_device->siggen_upload(wavBuf.data(), wavBuf.size());
lockDevice.unlock();
lockDevice.unlock();
std::this_thread::sleep_until(next);
}
}
@ -485,29 +486,24 @@ void deviceRenderMenu()
deviceAlgorithmUpload();
if (ImGui::MenuItem("Unload algorithm", nullptr, false, isConnected && !isRunning))
deviceAlgorithmUnload();
ImGui::Separator();
if (ImGui::Checkbox("Measure Code Time", &measureCodeTime)) {
if (!isConnected)
measureCodeTime = false;
}
if (!isConnected || isRunning)
ImGui::PushDisabled();
ImGui::Checkbox("Measure Code Time", &measureCodeTime);
if (ImGui::Checkbox("Draw samples", &drawSamples)) {
if (isConnected) {
if (drawSamples)
popupRequestDraw = true;
} else {
drawSamples = false;
}
if (drawSamples)
popupRequestDraw = true;
}
if (ImGui::Checkbox("Log results...", &logResults)) {
if (isConnected) {
if (logResults)
popupRequestLog = true;
else if (logSamplesFile.is_open())
logSamplesFile.close();
} else {
logResults = false;
}
if (logResults)
popupRequestLog = true;
else if (logSamplesFile.is_open())
logSamplesFile.close();
}
if (!isConnected || isRunning)
ImGui::PopDisabled();
if (ImGui::MenuItem("Set buffer size...", nullptr, false, isConnected && !isRunning)) {
popupRequestBuffer = true;
}
@ -575,7 +571,7 @@ void deviceConnect()
m_device.reset(new stmdsp::device(devices.front()));
} catch (...) {
log("Failed to connect (check permissions?).");
m_device.reset();
m_device.reset();
}
if (m_device) {

@ -10,6 +10,7 @@
*/
#include "imgui.h"
#include "imgui_internal.h"
#include "backends/imgui_impl_sdl.h"
#include "backends/imgui_impl_opengl2.h"
@ -49,19 +50,52 @@ bool guiInitialize()
IMGUI_CHECKVERSION();
ImGui::CreateContext();
io = &ImGui::GetIO();
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
//io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
fontSans = io->Fonts->AddFontFromFileTTF("fonts/Roboto-Regular.ttf", 20);
fontMono = io->Fonts->AddFontFromFileTTF("fonts/RobotoMono-Regular.ttf", 20);
ImGui::StyleColorsLight();
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
ImGui_ImplOpenGL2_Init();
ImGui::StyleColorsLight();
ImGuiStyle& style = ImGui::GetStyle();
style.WindowRounding = 5;
style.FrameRounding = 3;
style.ScrollbarRounding = 1;
//#define ACCENT1 0.26f, 0.59f, 0.98f
#define ACCENT1 0.6f, 0.6f, 0.6f
#define ACCENT2 0.4f, 0.4f, 0.4f
style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(ACCENT1, 0.40f);
style.Colors[ImGuiCol_FrameBgActive] = ImVec4(ACCENT1, 0.67f);
style.Colors[ImGuiCol_CheckMark] = ImVec4(ACCENT1, 1.00f);
style.Colors[ImGuiCol_SliderGrab] = ImVec4(ACCENT1, 0.78f);
style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.46f, 0.54f, 0.80f, 0.60f);
style.Colors[ImGuiCol_Button] = ImVec4(ACCENT1, 0.40f);
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(ACCENT1, 1.00f);
style.Colors[ImGuiCol_ButtonActive] = ImVec4(ACCENT2, 1.00f);
style.Colors[ImGuiCol_Header] = ImVec4(ACCENT1, 0.31f);
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(ACCENT1, 0.80f);
style.Colors[ImGuiCol_HeaderActive] = ImVec4(ACCENT1, 1.00f);
style.Colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 0.62f);
style.Colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f);
style.Colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f);
style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(ACCENT1, 0.67f);
style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(ACCENT1, 0.95f);
style.Colors[ImGuiCol_TableHeaderBg] = ImVec4(0.78f, 0.87f, 0.98f, 1.00f);
style.Colors[ImGuiCol_TableBorderStrong] = ImVec4(0.57f, 0.57f, 0.64f, 1.00f);
style.Colors[ImGuiCol_TableBorderLight] = ImVec4(0.68f, 0.68f, 0.74f, 1.00f);
style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(ACCENT1, 0.35f);
style.Colors[ImGuiCol_DragDropTarget] = ImVec4(ACCENT1, 0.95f);
style.Colors[ImGuiCol_Tab] = ImLerp(style.Colors[ImGuiCol_Header], style.Colors[ImGuiCol_TitleBgActive], 0.90f);
style.Colors[ImGuiCol_TabHovered] = style.Colors[ImGuiCol_HeaderHovered];
style.Colors[ImGuiCol_TabActive] = ImLerp(style.Colors[ImGuiCol_HeaderActive], style.Colors[ImGuiCol_TitleBgActive], 0.60f);
style.Colors[ImGuiCol_TabUnfocused] = ImLerp(style.Colors[ImGuiCol_Tab], style.Colors[ImGuiCol_TitleBg], 0.80f);
style.Colors[ImGuiCol_TabUnfocusedActive] = ImLerp(style.Colors[ImGuiCol_TabActive], style.Colors[ImGuiCol_TitleBg], 0.40f);
style.Colors[ImGuiCol_NavHighlight] = style.Colors[ImGuiCol_HeaderHovered];
return true;
}

Loading…
Cancel
Save