Menu is ready !

This commit is contained in:
Pcornat 2022-01-14 19:21:42 +01:00
parent 7eb1b22b9d
commit 27c571a6b9
Signed by: Pcornat
GPG Key ID: 2F3932FF46D9ECA0
4 changed files with 17 additions and 5 deletions

View File

@ -2,6 +2,7 @@
#define BILLYSHEET_GUI_HPP
#include <filesystem>
#include "menu.hpp"
namespace fs = std::filesystem;
@ -13,6 +14,8 @@ namespace gui {
private:
GuiData &data;
Menu menu;
fs::path font;
bool initialized{ false };

View File

@ -1,6 +1,7 @@
#ifndef BILLYSHEET_MENU_HPP
#define BILLYSHEET_MENU_HPP
#include <spdlog/spdlog.h>
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;

View File

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

View File

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