Feature & Fix: Feature Docking layout, Fix ImGUI & glfw submodule
This commit is contained in:
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,3 +1,7 @@
|
|||||||
[submodule "external/gtest"]
|
[submodule "external/gtest"]
|
||||||
path = external/gtest
|
path = external/gtest
|
||||||
url = https://github.com/google/googletest.git
|
url = https://github.com/google/googletest.git
|
||||||
|
[submodule "external/imgui"]
|
||||||
|
path = external/imgui
|
||||||
|
url = https://github.com/ocornut/imgui.git
|
||||||
|
branch = docking
|
||||||
|
|||||||
@@ -24,7 +24,14 @@ file(GLOB_RECURSE SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
|||||||
file(GLOB IMGUI_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/*.cpp")
|
file(GLOB IMGUI_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/*.cpp")
|
||||||
|
|
||||||
add_executable(emulator ${SRC_FILES}
|
add_executable(emulator ${SRC_FILES}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/external/glad/src/glad.c ${IMGUI_SRC_FILES})
|
${CMAKE_CURRENT_SOURCE_DIR}/external/glad/src/glad.c
|
||||||
|
${IMGUI_SRC_FILES}
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.h"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends/imgui_impl_opengl3.cpp"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends/imgui_impl_opengl3.h"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/external/imgui/backends/imgui_impl_opengl3_loader.h"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(emulator PRIVATE glfw OpenGL::GL)
|
target_link_libraries(emulator PRIVATE glfw OpenGL::GL)
|
||||||
target_include_directories(emulator PRIVATE external/glfw/include
|
target_include_directories(emulator PRIVATE external/glfw/include
|
||||||
|
|||||||
1
external/glfw
vendored
Submodule
1
external/glfw
vendored
Submodule
Submodule external/glfw added at 232164f62b
1
external/imgui
vendored
Submodule
1
external/imgui
vendored
Submodule
Submodule external/imgui added at 913a3c6056
1
external/imgui_club
vendored
Submodule
1
external/imgui_club
vendored
Submodule
Submodule external/imgui_club added at 1e7facddfd
37
src/GUI.cpp
37
src/GUI.cpp
@@ -1,8 +1,9 @@
|
|||||||
#include "GUI.h"
|
#include "GUI.h"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_impl_glfw.h>
|
#include <imgui_internal.h>
|
||||||
#include <imgui_impl_opengl3.h>
|
#include <backends/imgui_impl_glfw.h>
|
||||||
|
#include <backends/imgui_impl_opengl3.h>
|
||||||
#include <imgui_memory_editor.h>
|
#include <imgui_memory_editor.h>
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
@@ -48,18 +49,20 @@ void GUI::CreateWindow() {
|
|||||||
ImGui_ImplOpenGL3_Init("#version 460");
|
ImGui_ImplOpenGL3_Init("#version 460");
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.FontGlobalScale = 2.0f;
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
|
io.FontGlobalScale = 1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::Run() {
|
void GUI::Run() {
|
||||||
while (!glfwWindowShouldClose(m_Window))
|
while (!glfwWindowShouldClose(m_Window)) {
|
||||||
{
|
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
DockingSetup();
|
||||||
|
|
||||||
ControlGUI();
|
ControlGUI();
|
||||||
DebugInfoGUI();
|
DebugInfoGUI();
|
||||||
|
|
||||||
@@ -85,6 +88,30 @@ void GUI::Terminate() {
|
|||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::DockingSetup() {
|
||||||
|
ImGuiID dockspace_id = ImGui::GetID("Dockspace");
|
||||||
|
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||||
|
|
||||||
|
if (ImGui::DockBuilderGetNode(dockspace_id) == nullptr) {
|
||||||
|
ImGui::DockBuilderAddNode(dockspace_id, ImGuiDockNodeFlags_DockSpace);
|
||||||
|
ImGui::DockBuilderSetNodeSize(dockspace_id, viewport->Size);
|
||||||
|
ImGuiID dock_id_left = 0;
|
||||||
|
ImGuiID dock_id_main = dockspace_id;
|
||||||
|
ImGui::DockBuilderSplitNode(dock_id_main, ImGuiDir_Left, 0.40f, &dock_id_left, &dock_id_main);
|
||||||
|
ImGuiID dock_id_right = 0;
|
||||||
|
ImGui::DockBuilderSplitNode(dock_id_main, ImGuiDir_Right, 0.40f, &dock_id_right, &dock_id_main);
|
||||||
|
// ImGuiID dock_id_left_top = 0;
|
||||||
|
// ImGuiID dock_id_left_bottom = 0;
|
||||||
|
// ImGui::DockBuilderSplitNode(dock_id_left, ImGuiDir_Up, 0.50f, &dock_id_left_top, &dock_id_left_bottom);
|
||||||
|
ImGui::DockBuilderDockWindow("Process Memory", dock_id_main);
|
||||||
|
ImGui::DockBuilderDockWindow("Debug Information", dock_id_left);
|
||||||
|
ImGui::DockBuilderDockWindow("Emulator Control", dock_id_right);
|
||||||
|
ImGui::DockBuilderFinish(dockspace_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::DockSpaceOverViewport(dockspace_id, viewport, ImGuiDockNodeFlags_PassthruCentralNode);
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::ControlGUI() {
|
void GUI::ControlGUI() {
|
||||||
ImGui::Begin("Emulator Control");
|
ImGui::Begin("Emulator Control");
|
||||||
ImGui::Text("Current State: %s", m_Userspace.IsRunning() ? "Running" : "Stopped");
|
ImGui::Text("Current State: %s", m_Userspace.IsRunning() ? "Running" : "Stopped");
|
||||||
|
|||||||
Reference in New Issue
Block a user