From 530d0bf8e31e19a171203bd6a1e4c3c229cf6200 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Mon, 10 Jan 2022 17:31:55 -0500 Subject: [PATCH] Beginning development of UI --- Navigator/src/Navigator/Application.cpp | 3 +- .../src/Navigator/Editor/EditorLayer.cpp | 53 +++++++++++++++++++ Navigator/src/Navigator/Editor/EditorLayer.h | 28 ++++++++++ Navigator/src/Navigator/ImGui/ImGuiLayer.cpp | 6 +-- 4 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 Navigator/src/Navigator/Editor/EditorLayer.cpp create mode 100644 Navigator/src/Navigator/Editor/EditorLayer.h diff --git a/Navigator/src/Navigator/Application.cpp b/Navigator/src/Navigator/Application.cpp index e32ffea..a4be472 100644 --- a/Navigator/src/Navigator/Application.cpp +++ b/Navigator/src/Navigator/Application.cpp @@ -1,6 +1,7 @@ #include "Application.h" #include "Renderer/Renderer.h" #include "Renderer/RenderCommand.h" +#include "Editor/EditorLayer.h" namespace Navigator { @@ -14,7 +15,7 @@ namespace Navigator { m_window = std::unique_ptr(Window::Create()); m_window->SetEventCallback(BIND_EVENT_FUNCTION(Application::OnEvent)); - PushLayer(new Layer()); + PushLayer(new EditorLayer(&m_histMap)); m_histMap.AddHistogram("myHisto", "joseph", 100, 0, 10); diff --git a/Navigator/src/Navigator/Editor/EditorLayer.cpp b/Navigator/src/Navigator/Editor/EditorLayer.cpp new file mode 100644 index 0000000..7f0cf45 --- /dev/null +++ b/Navigator/src/Navigator/Editor/EditorLayer.cpp @@ -0,0 +1,53 @@ +#include "EditorLayer.h" +#include "imgui.h" + +namespace Navigator { + + EditorLayer::EditorLayer(HistogramMap* hmap) : + Layer("EditorLayer"), m_histMap(hmap) + { + } + + EditorLayer::~EditorLayer() {} + + void EditorLayer::OnAttach() + { + } + + void EditorLayer::OnDetach() + { + } + + void EditorLayer::OnUpdate() + { + } + + void EditorLayer::OnEvent(Event& e) + { + } + + void EditorLayer::OnImGuiRender() + { + ImGui::Begin("MyTestSpace"); + if(ImGui::BeginMenuBar()) + { + if(ImGui::BeginMenu("File")) + { + if(ImGui::MenuItem("Open")) + { + } + if(ImGui::MenuItem("Exit")) + { + } + if(ImGui::MenuItem("Save")) + { + } + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } + + ImGui::End(); + + } +} diff --git a/Navigator/src/Navigator/Editor/EditorLayer.h b/Navigator/src/Navigator/Editor/EditorLayer.h new file mode 100644 index 0000000..e9f9c39 --- /dev/null +++ b/Navigator/src/Navigator/Editor/EditorLayer.h @@ -0,0 +1,28 @@ +#ifndef EDITOR_LAYER_H +#define EDITOR_LAYER_H + +#include "Navigator/Layer.h" +#include "Navigator/Events/Event.h" +#include "Navigator/HistogramMap.h" + +namespace Navigator { + + class EditorLayer : public Layer + { + public: + EditorLayer(HistogramMap* hmap); + ~EditorLayer(); + + virtual void OnAttach() override; + virtual void OnDetach() override; + virtual void OnImGuiRender() override; + virtual void OnUpdate() override; + virtual void OnEvent(Event& event) override; + + private: + HistogramMap* m_histMap; //Not owned by the EditorLayer!! + }; + +} + +#endif diff --git a/Navigator/src/Navigator/ImGui/ImGuiLayer.cpp b/Navigator/src/Navigator/ImGui/ImGuiLayer.cpp index 0940b53..c2cae29 100644 --- a/Navigator/src/Navigator/ImGui/ImGuiLayer.cpp +++ b/Navigator/src/Navigator/ImGui/ImGuiLayer.cpp @@ -92,8 +92,8 @@ namespace Navigator { void ImGuiLayer::OnImGuiRender() { - static bool show = true; - ImGui::ShowDemoWindow(&show); - ImPlot::ShowDemoWindow(); + //static bool show = true; + //ImGui::ShowDemoWindow(&show); + //ImPlot::ShowDemoWindow(); } }