|
|
|
|
/******************************************************************************
|
|
|
|
|
* File - component_guis.cpp
|
|
|
|
|
* Author - Joey Pollack
|
|
|
|
|
* Date - 2022/06/01 (y/m/d)
|
|
|
|
|
* Mod Date - 2022/06/01 (y/m/d)
|
|
|
|
|
* Description - Functions to render component editing GUIs
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "component_guis.h"
|
|
|
|
|
#include <editor/editor.h>
|
|
|
|
|
#include <utils/logger.h>
|
|
|
|
|
#include <gui/imgui_ext.h>
|
|
|
|
|
#include <dearimgui/imgui.h>
|
|
|
|
|
#include <dearimgui/imgui_internal.h>
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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");
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
strcpy(buffer, comp.Info.c_str());
|
|
|
|
|
ImGui::InputText("##Tag", buffer, BUFFER_SIZE);
|
|
|
|
|
comp.Info = buffer;
|
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// This code taken from the Hazel engine
|
|
|
|
|
/// 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);
|
|
|
|
|
comp.Rotation = glm::radians(rotation);
|
|
|
|
|
ImGuiExt::Vec3Control("Scale", comp.Scale, 1.0f, 85.0f);
|
|
|
|
|
}
|
|
|
|
|
}}
|