diff --git a/src/gui.cpp b/src/gui/gui.cpp similarity index 60% rename from src/gui.cpp rename to src/gui/gui.cpp index 872e38c..6226b66 100644 --- a/src/gui.cpp +++ b/src/gui/gui.cpp @@ -3,34 +3,44 @@ #include #include #include "gui.h" -#include "project.h" +#include "../project.h" void Gui::render() { - if (imgui_demo_open) ImGui::ShowTestWindow(&imgui_demo_open); - if (project_overlay_open) this->render_project_overlay(); - this->render_menubar(); + if (present_mode) + return; + + if (imgui_demo_open) + ImGui::ShowTestWindow(&imgui_demo_open); + + if (project_overlay_open) + this->render_project_overlay(); + + if (node_editor_open) + this->node_editor.draw_window("Node Editor", &node_editor_open); + + this->render_menubar(); } void Gui::render_project_overlay() { ImGui::SetNextWindowPos(ImVec2(20, 30)); - if (ImGui::Begin("", &this->project_overlay_open, ImVec2(200,0), 0.3f, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings)) { - ImGui::Text("[project]"); - ImGui::Separator(); - if (state->current_project != nullptr) { - ImGui::Text("name: %s", state->current_project->name.c_str()); - ImGui::Text("n_scenes: %i", state->current_project->scenes.size()); - if (!state->current_project->scene_loaded) { - ImGui::Text("no scene loaded"); - } else { - ImGui::Text("current scene: %s", - state->current_project->current_scene->name.c_str()); - } - } else { - ImGui::Text("no project loaded."); - } - ImGui::End(); - } + if (ImGui::Begin("", &this->project_overlay_open, ImVec2(200,0), 0.3f, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings)) { + ImGui::Text("[project]"); + ImGui::Separator(); + if (state->current_project != nullptr) { + ImGui::Text("name: %s", state->current_project->name.c_str()); + ImGui::Text("n_scenes: %d", static_cast(state->current_project->scenes.size())); + if (!state->current_project->scene_loaded) { + ImGui::Text("no scene loaded"); + } else { + ImGui::Text("current scene: %s", + state->current_project->current_scene->name.c_str()); + } + } else { + ImGui::Text("no project loaded."); + } + ImGui::End(); + } } void Gui::render_menubar() { @@ -54,7 +64,7 @@ void Gui::render_mmb_file() { nfdresult_t result = NFD_OpenDialog(NULL, NULL, &out_path); if (result == NFD_OKAY) { // Load project - auto new_project = Project::fromFile(std::string(out_path)); + auto new_project = Project::from_file(std::string(out_path)); state->current_project = std::move(new_project); free(out_path); @@ -71,7 +81,8 @@ void Gui::render_mmb_file() { } void Gui::render_mmb_view() { - ImGui::MenuItem("Show project meta overlay", NULL, &this->project_overlay_open); + ImGui::MenuItem("Node Editor", NULL, &this->node_editor_open); + ImGui::MenuItem("Meta overlay", NULL, &this->project_overlay_open); ImGui::Separator(); @@ -126,12 +137,12 @@ void Gui::load_style(std::shared_ptr conf) { ImGuiStyle &style = ImGui::GetStyle(); auto defaultstyle = ImGuiStyle(); - st_lds_d(Alpha, "alpha"); - st_lds_v2(WindowPadding, "window.padding"); - st_lds_v2(WindowMinSize, "window.min_size"); - st_lds_d(WindowRounding, "window.rounding"); - st_lds_v2(WindowTitleAlign, "window.title_align"); - st_lds_d(ChildWindowRounding, "window.child_rounding"); - st_lds_v2(FramePadding, "frame.padding"); - st_lds_d(FrameRounding, "frame.rounding"); + st_lds_d(Alpha, "imgui.alpha"); + st_lds_v2(WindowPadding, "imgui.window.padding"); + st_lds_v2(WindowMinSize, "imgui.window.min_size"); + st_lds_d(WindowRounding, "imgui.window.rounding"); + st_lds_v2(WindowTitleAlign, "imgui.window.title_align"); + st_lds_d(ChildWindowRounding, "imgui.window.child_rounding"); + st_lds_v2(FramePadding, "imgui.frame.padding"); + st_lds_d(FrameRounding, "imgui.frame.rounding"); } diff --git a/src/gui.h b/src/gui/gui.h similarity index 56% rename from src/gui.h rename to src/gui/gui.h index aeb9f8f..7b34a22 100644 --- a/src/gui.h +++ b/src/gui/gui.h @@ -1,24 +1,28 @@ #pragma once -#include "state.h" #include #include +#include "../state.h" +#include "node_editor.h" class Gui { public: - Gui(DemoState *state) : - perf_open(false), - state(state) - { - this->load_style(cpptoml::parse_file(state->config->stylepath)); - } + Gui(DemoState *state) : state(state), node_editor{} + { + this->load_style(cpptoml::parse_file(state->config->stylepath)); + } void render(); bool perf_open = false; bool project_overlay_open = true; - bool imgui_demo_open = false; + bool node_editor_open = true; + + /// Skip rendering the GUI, for presenting stuff. + bool present_mode = false; + + NodeEditor node_editor; private: DemoState *state; @@ -32,4 +36,3 @@ private: void load_style(std::shared_ptr style); }; - diff --git a/src/main.cpp b/src/main.cpp index 4b2bb2e..da3d1d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,8 +7,8 @@ #include #include -#include "gui.h" #include "geom.h" +#include "gui/gui.h" #include "state.h" #include "notify.h"