From 0da94313d2d182dfcccaa9122d41f6dce55aa5b8 Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Thu, 7 Jul 2022 16:52:15 -0400 Subject: [PATCH] Trying to make the properties view look nice. Using the ImGuiDrawList API. --- src/run_modes/editor/component_guis.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/run_modes/editor/component_guis.cpp b/src/run_modes/editor/component_guis.cpp index 8894d02..2516d31 100644 --- a/src/run_modes/editor/component_guis.cpp +++ b/src/run_modes/editor/component_guis.cpp @@ -15,11 +15,23 @@ namespace lunarium { namespace editor { + ///////////////////////////////////////////////////////////////////// + // COMMON SECTIONS + ///////////////////////////////////////////////////////////////////// + static void DrawTitle(std::string title) + { + ImVec2 top_left(ImGui::GetWindowPos().x, ImGui::GetCursorScreenPos().y - ImGui::GetStyle().FramePadding.y); + ImVec2 bot_right(top_left.x + ImGui::GetWindowSize().x, ImGui::GetCursorScreenPos().y + ImGui::GetFrameHeight()); + ImU32 color = ImGui::ColorConvertFloat4ToU32(ImVec4(0.1f, 0.3f, 0.8f, 1.0f)); + ImGui::GetWindowDrawList()->AddRectFilled(top_left, bot_right, color); + ImGuiExt::TextCentered(title.c_str()); + } + void CompGui::RenderTagComp(TagComponent& comp) { - ImGuiExt::TextCentered("Tag Component"); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(3.0f, ImGui::GetStyle().ItemSpacing.y)); + DrawTitle("Tag Component"); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(3.0f, ImGui::GetStyle().ItemSpacing.y)); const int BUFFER_SIZE = 256; static char buffer[BUFFER_SIZE] = ""; ImGui::Text("Tag Info"); @@ -35,6 +47,8 @@ namespace lunarium { namespace editor /// https://github.com/TheCherno/Hazel/blob/master/Hazelnut/src/Panels/SceneHierarchyPanel.cpp void CompGui::RenderTransformComp(TransformComponent& comp) { + DrawTitle("Tag Component"); + ImGuiExt::Vec3Control("Translation", comp.Position, 0.0f, 85.0f); glm::vec3 rotation = glm::degrees(comp.Rotation); ImGuiExt::Vec3Control("Rotation", rotation, 0.0f, 85.0f);