diff --git a/.gitignore b/.gitignore index debda6d..d7ed0eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build/ imgui.ini stmdspgui stmdspgui.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index d042f12..54f7086 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,13 +5,15 @@ project(stmdspgui VERSION 0.5) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) -add_compile_options(-O0 -ggdb -g3 -Wall -Wextra -pedantic) +add_compile_options(-O0 -ggdb -g3) file(GLOB SRC_IMGUI_BACKENDS "${CMAKE_SOURCE_DIR}/source/imgui/backends/*.cpp") file(GLOB SRC_IMGUI "${CMAKE_SOURCE_DIR}/source/imgui/*.cpp") file(GLOB SRC_STMDSP "${CMAKE_SOURCE_DIR}/source/stmdsp/*.cpp") file(GLOB SRC_STMDSPGUI "${CMAKE_SOURCE_DIR}/source/*.cpp") +set_property(SOURCE ${SRC_STMDSPGUI} PROPERTY COMPILE_FLAGS "-Wall -Wextra -Wpedantic") + add_executable(stmdspgui source/serial/src/serial.cc source/serial/src/impl/unix.cc diff --git a/source/device.cpp b/source/device.cpp index 333fd81..6f052d7 100644 --- a/source/device.cpp +++ b/source/device.cpp @@ -519,7 +519,7 @@ void deviceRenderToolbar() ImGui::SameLine(); ImGui::SetNextItemWidth(100); if (ImGui::BeginCombo("", sampleRatePreview)) { - for (int i = 0; i < sampleRateList.size(); ++i) { + for (unsigned int i = 0; i < sampleRateList.size(); ++i) { if (ImGui::Selectable(sampleRateList[i])) { sampleRatePreview = sampleRateList[i]; if (m_device != nullptr && !m_device->is_running()) { diff --git a/source/file.cpp b/source/file.cpp index 96dac0a..0f0015c 100644 --- a/source/file.cpp +++ b/source/file.cpp @@ -56,6 +56,12 @@ static void openCurrentFile() } } +void openNewFile() +{ + fileCurrentPath.clear(); + editor.SetText(stmdsp::file_content); +} + void fileScanTemplates() { auto path = std::filesystem::current_path() / "templates"; @@ -68,8 +74,7 @@ void fileRenderMenu() if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("New")) { // TODO modified? - fileCurrentPath.clear(); - editor.SetText(stmdsp::file_content); + openNewFile(); log("Ready."); } @@ -129,18 +134,13 @@ void fileRenderDialog() if (ImGuiFileDialog::Instance()->IsOk()) { std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName(); - switch (fileAction) { - case FileAction::None: - break; - case FileAction::Open: + if (fileAction == FileAction::Open) { fileCurrentPath = filePathName; openCurrentFile(); log("Ready."); - break; - case FileAction::SaveAs: + } else if (fileAction == FileAction::SaveAs) { fileCurrentPath = filePathName; saveCurrentFile(); - break; } } diff --git a/source/gui.cpp b/source/gui.cpp index 47291c6..2ecf8ee 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -57,6 +57,11 @@ bool guiInitialize() ImGui_ImplSDL2_InitForOpenGL(window, gl_context); ImGui_ImplOpenGL2_Init(); + ImGuiStyle& style = ImGui::GetStyle(); + style.WindowRounding = 5; + style.FrameRounding = 3; + style.ScrollbarRounding = 1; + return true; } @@ -71,7 +76,6 @@ void guiRender(void (*func)()) void guiHandleEvents(bool& done) { - SDL_Event event; for (SDL_Event event; SDL_PollEvent(&event);) { ImGui_ImplSDL2_ProcessEvent(&event); if (event.type == SDL_QUIT) diff --git a/source/main.cpp b/source/main.cpp index bea1a21..e112118 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -33,6 +33,7 @@ extern void guiRender(void (*func)()); extern void fileRenderMenu(); extern void fileRenderDialog(); extern void fileScanTemplates(); +extern void openNewFile(); extern void codeEditorInit(); extern void codeRenderMenu(); @@ -62,6 +63,7 @@ int main(int, char **) fileScanTemplates(); codeEditorInit(); + openNewFile(); while (!done) { auto endTime = std::chrono::steady_clock::now() +