diff options
Diffstat (limited to 'src/bookmouse.cpp')
-rw-r--r-- | src/bookmouse.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/bookmouse.cpp b/src/bookmouse.cpp index 77c2304..4899453 100644 --- a/src/bookmouse.cpp +++ b/src/bookmouse.cpp @@ -8,6 +8,8 @@ namespace bookmouse { +constexpr const char* OpenDialogHandle = "Open File"; + Bookmouse::Bookmouse() : m_sdlContext{}, m_mainWindow{m_sdlContext}, m_glContext{m_mainWindow}, m_imgui{m_glContext, m_sdlContext, m_mainWindow} @@ -106,10 +108,16 @@ void Bookmouse::updateState() &m_running, // Is this right? ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_MenuBar); IM_ASSERT(stateResult); - if (ImGui::BeginMenuBar()) { - menuBar(); + if (ImguiMenuBar menuBar{}) { + menuing(); + } + if (m_openDialog) { + m_openDialog = false; + ImGui::OpenPopup(OpenDialogHandle); } + openDialog(); + // Edit a color stored as 4 floats fud::Array<float, 4> my_color{}; ImGui::ColorEdit4("Color", my_color.data()); @@ -129,21 +137,16 @@ void Bookmouse::updateState() ImGui::End(); } -constexpr const char* OpenDialogHandle = "Open File"; -void Bookmouse::menuBar() +void Bookmouse::menuing() { - bool clickOpen = false; if (ImguiMenu menu{"File"}) { IM_ASSERT(menu); - spdlog::debug("HERE {}", menu); - if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ - spdlog::debug("Open - m_openDialog was {}", m_openDialog); - clickOpen = true; + if (ImGui::MenuItem("Open Archive", "Ctrl+O")) { /* Do stuff */ + m_openDialog = true; } if (ImGui::MenuItem("Close", "Ctrl+Q")) { m_running = false; } - spdlog::debug("THERE"); } if (ImguiMenu menu{"Help"}) { @@ -153,18 +156,9 @@ void Bookmouse::menuBar() } ImGui::EndMenu(); } - ImGui::EndMenuBar(); - - if (clickOpen) { - clickOpen = false; - ImGui::OpenPopup(OpenDialogHandle); - } - - openDialog(); } void Bookmouse::openDialog() { - // if (ImGui::Begin("Another Window", &m_openDialog, 0)) { if (ImGui::BeginPopupModal(OpenDialogHandle)) { ImGui::Text("Hello from another window!"); if (ImGui::Button("Close Me")) { @@ -172,7 +166,6 @@ void Bookmouse::openDialog() { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); - // ImGui::End(); } } |