]> code.bitgloo.com Git - clyne/stmdspgui.git/commitdiff
new file on startup; styling; bug fixes
authorClyne Sullivan <clyne@bitgloo.com>
Sat, 30 Oct 2021 14:08:11 +0000 (10:08 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Sat, 30 Oct 2021 14:08:11 +0000 (10:08 -0400)
.gitignore
CMakeLists.txt
source/device.cpp
source/file.cpp
source/gui.cpp
source/main.cpp

index debda6d01570c2dc78fb26a0bb8257c1e197633d..d7ed0eb94bec6c79ec5f8375efdee97d7b464e7b 100644 (file)
@@ -1,3 +1,4 @@
+build/
 imgui.ini
 stmdspgui
 stmdspgui.exe
index d042f12c0dfb6fb37130b6741f5404034251943f..54f70860a0dbcbad568f23ad5ffee78fee0b8cf2 100644 (file)
@@ -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
index 333fd819eccf59661b759984f3b0722334d8babc..6f052d78636300251c7c2ff56aaa135a83d0c9e7 100644 (file)
@@ -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()) {
index 96dac0a7447510afabeda8edb75fa040f457ce28..0f0015c63c7974b06d2cbc8ee8132981123b8c6c 100644 (file)
@@ -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;
             }
         }
         
index 47291c60b43511bc2ae599cae7ba2adc76c826bf..2ecf8eee043f44da65561a3bb437a239789feb47 100644 (file)
@@ -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)
index bea1a2169c3f18658561b8fe3ff70af6937642fb..e11211890aab7b1af8998d60467e69134aaaaf94 100644 (file)
@@ -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() +