From 27c571a6b9e83570e97dcb0f3e8f5e93707e7f1d Mon Sep 17 00:00:00 2001 From: Pcornat Date: Fri, 14 Jan 2022 19:21:42 +0100 Subject: [PATCH] Menu is ready ! --- include/gui/gui.hpp | 3 +++ include/gui/menu.hpp | 3 ++- src/gui/gui.cpp | 6 ++++-- src/gui/menu.cpp | 10 ++++++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/gui/gui.hpp b/include/gui/gui.hpp index 9586dc9..0202b8f 100644 --- a/include/gui/gui.hpp +++ b/include/gui/gui.hpp @@ -2,6 +2,7 @@ #define BILLYSHEET_GUI_HPP #include +#include "menu.hpp" namespace fs = std::filesystem; @@ -13,6 +14,8 @@ namespace gui { private: GuiData &data; + Menu menu; + fs::path font; bool initialized{ false }; diff --git a/include/gui/menu.hpp b/include/gui/menu.hpp index 3575d8b..5c89c93 100644 --- a/include/gui/menu.hpp +++ b/include/gui/menu.hpp @@ -1,6 +1,7 @@ #ifndef BILLYSHEET_MENU_HPP #define BILLYSHEET_MENU_HPP +#include namespace gui { class GuiData; @@ -11,7 +12,7 @@ namespace gui { public: Menu() noexcept = delete; - explicit Menu(GuiData &data) noexcept: data(data) {} + explicit Menu(GuiData &data) noexcept: data(data) { SPDLOG_DEBUG("Creating Menu"); } ~Menu() noexcept = default; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 5f153e5..db02c4d 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -6,7 +6,7 @@ #include "imgui_impl_opengl3_loader.h" #include "gui/window.hpp" -gui::Gui::Gui(gui::GuiData &data) : data(data), font("font/DejaVuSans.ttf") { +gui::Gui::Gui(gui::GuiData &data) : data(data), menu(data), font("font/DejaVuSans.ttf") { SPDLOG_DEBUG("Creating GUI"); (void) ImGui::CreateContext(); ImGui::StyleColorsDark(); @@ -24,7 +24,8 @@ gui::Gui::~Gui() noexcept { void gui::Gui::render_gui() { if (initialized) { - constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_NoMove | + constexpr ImGuiWindowFlags flags = ImGuiWindowFlags_MenuBar | + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar; @@ -42,6 +43,7 @@ void gui::Gui::render_gui() { // Never collapsed. (void) ImGui::Begin("Billy", nullptr, flags); + menu.gui(); ImGui::Text("Hello world!"); ImGui::Text("Average framerate: %.3f ms/frame (%.1f FPS)", 1000.f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 0b2a620..68976fb 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -2,12 +2,18 @@ #include "imgui.h" void gui::Menu::gui() const noexcept { - if (ImGui::BeginMainMenuBar()) { + if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("File")) { + if (ImGui::MenuItem("Save")) { + } + + if (ImGui::MenuItem("Save as...")) { + + } ImGui::EndMenu(); } - ImGui::EndMainMenuBar(); + ImGui::EndMenuBar(); } }