Trying to make the properties view look nice. Using the ImGuiDrawList API.

master
Joey Pollack 3 years ago
parent ce3dd3f984
commit 0da94313d2

@ -15,11 +15,23 @@
namespace lunarium { namespace editor 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) void CompGui::RenderTagComp(TagComponent& comp)
{ {
ImGuiExt::TextCentered("Tag Component"); DrawTitle("Tag Component");
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(3.0f, ImGui::GetStyle().ItemSpacing.y));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(3.0f, ImGui::GetStyle().ItemSpacing.y));
const int BUFFER_SIZE = 256; const int BUFFER_SIZE = 256;
static char buffer[BUFFER_SIZE] = ""; static char buffer[BUFFER_SIZE] = "";
ImGui::Text("Tag Info"); ImGui::Text("Tag Info");
@ -35,6 +47,8 @@ namespace lunarium { namespace editor
/// https://github.com/TheCherno/Hazel/blob/master/Hazelnut/src/Panels/SceneHierarchyPanel.cpp /// https://github.com/TheCherno/Hazel/blob/master/Hazelnut/src/Panels/SceneHierarchyPanel.cpp
void CompGui::RenderTransformComp(TransformComponent& comp) void CompGui::RenderTransformComp(TransformComponent& comp)
{ {
DrawTitle("Tag Component");
ImGuiExt::Vec3Control("Translation", comp.Position, 0.0f, 85.0f); ImGuiExt::Vec3Control("Translation", comp.Position, 0.0f, 85.0f);
glm::vec3 rotation = glm::degrees(comp.Rotation); glm::vec3 rotation = glm::degrees(comp.Rotation);
ImGuiExt::Vec3Control("Rotation", rotation, 0.0f, 85.0f); ImGuiExt::Vec3Control("Rotation", rotation, 0.0f, 85.0f);

Loading…
Cancel
Save