new file on startup; styling; bug fixes

pull/1/head
Clyne 3 years ago
parent 41ae9b3b1b
commit 12440b673f

1
.gitignore vendored

@ -1,3 +1,4 @@
build/
imgui.ini
stmdspgui
stmdspgui.exe

@ -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

@ -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()) {

@ -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;
}
}

@ -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)

@ -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() +

Loading…
Cancel
Save