diff --git a/code/addons/dynui/imguicontext.cc b/code/addons/dynui/imguicontext.cc index 011ab1355..d93d89e4f 100644 --- a/code/addons/dynui/imguicontext.cc +++ b/code/addons/dynui/imguicontext.cc @@ -452,28 +452,28 @@ ImguiContext::Create() ImGuiStyle& style = ImGui::GetStyle(); - style.FrameRounding = 2.0f; + style.FrameRounding = 0.0f; style.GrabRounding = 0.0f; style.ChildRounding = 0.0f; - style.WindowRounding = 2.0f; + style.WindowRounding = 0.0f; style.PopupRounding = 0.0f; - style.ScrollbarRounding = 2.0f; - style.TabRounding = 3.0f; + style.ScrollbarRounding = 0.0f; + style.TabRounding = 0.0f; style.TabMinWidthForCloseButton = FLT_MAX; - style.WindowTitleAlign = { 0.5f, 0.38f }; + style.WindowTitleAlign = { 0.0f, 0.52f }; style.WindowMenuButtonPosition = ImGuiDir_Right; - style.WindowPadding = { 8.0f, 8.0f }; + style.WindowPadding = { 10.0f, 10.0f }; // FIXME: ImGui seems to have problems with the "X" (close window) button when setting framepadding to anything higher than ~4. Could be the docking branch which is currently in beta. - style.FramePadding = { 4, 3 };//{ 16, 3 }; - style.ItemInnerSpacing = { 4, 2 }; - style.ItemSpacing = { 4, 5 }; - style.IndentSpacing = 8.0f; + style.FramePadding = { 8, 3 };//{ 16, 3 }; + style.ItemInnerSpacing = { 2, 2 }; + style.ItemSpacing = { 2, 2 }; + style.IndentSpacing = 10.0f; style.GrabMinSize = 8.0f; - style.FrameBorderSize = 0.0f; + style.FrameBorderSize = 1.0f; style.WindowBorderSize = 1.0f; - style.PopupBorderSize = 0.0f; + style.PopupBorderSize = 1.0f; style.ChildBorderSize = 0.0f; style.ScaleAllSizes(scaleFactor); @@ -526,10 +526,10 @@ ImguiContext::Create() colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.20f, 1.00f); - colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f); - colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f); + colors[ImGuiCol_TableBorderStrong] = ImVec4(0.039f, 0.039f, 0.039f, 1.00f); + colors[ImGuiCol_TableBorderLight] = ImVec4(0.174f, 0.174f, 0.174f, 1.00f); colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f); + colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.022f); colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); diff --git a/code/addons/graphicsfeature/managers/graphicsmanager.cc b/code/addons/graphicsfeature/managers/graphicsmanager.cc index 02a1f85d7..79d1ee917 100644 --- a/code/addons/graphicsfeature/managers/graphicsmanager.cc +++ b/code/addons/graphicsfeature/managers/graphicsmanager.cc @@ -469,9 +469,7 @@ template <> void Game::ComponentDrawFuncT(Game::ComponentId component, void* data, bool* commit) { - ImGui::SameLine(); ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); - static const char* items[] {"Disk", "Rectangle", "Tube"}; static_assert(sizeof(items) / sizeof(const char*) == (int)GraphicsFeature::AreaLightShape::NumAreaLightShape); GraphicsFeature::AreaLightShape* selectedItem = (GraphicsFeature::AreaLightShape*)data; diff --git a/code/application/game/componentinspection.cc b/code/application/game/componentinspection.cc index 760fd673e..86d9dd4ee 100644 --- a/code/application/game/componentinspection.cc +++ b/code/application/game/componentinspection.cc @@ -121,7 +121,6 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); if (ImGui::Checkbox("##input_data", (bool*)data)) *commit = true; @@ -135,8 +134,19 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); + ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); + if (ImGui::InputInt("##input_data", (int*)data)) + *commit = true; + ImGui::PopID(); +} +//------------------------------------------------------------------------------ +/** +*/ +template <> +void +ComponentDrawFuncT(ComponentId component, void* data, bool* commit) +{ ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); if (ImGui::InputInt("##input_data", (int*)data)) *commit = true; @@ -150,8 +160,19 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); + ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); + if (ImGui::InputInt("##input_data", (int*)data)) + *commit = true; + ImGui::PopID(); +} +//------------------------------------------------------------------------------ +/** +*/ +template <> +void +ComponentDrawFuncT(ComponentId component, void* data, bool* commit) +{ ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); if (ImGui::InputInt("##input_data", (int*)data)) *commit = true; @@ -165,8 +186,6 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); - ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); if (ImGui::InputFloat("##float_input", (float*)data)) *commit = true; @@ -180,7 +199,6 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); ImGui::Text(((Util::StringAtom*)data)->Value()); if (ImGui::BeginDragDropTarget()) @@ -204,8 +222,6 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); - ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); if (ImGui::InputFloat4("##row0", (float*)data)) *commit = true; @@ -225,10 +241,34 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); + ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); + if (ImGui::InputFloat3("##vec3", (float*)data)) + *commit = true; + ImGui::PopID(); +} +//------------------------------------------------------------------------------ +/** +*/ +template <> +void +ComponentDrawFuncT(ComponentId component, void* data, bool* commit) +{ ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); - if (ImGui::InputFloat3("##vec", (float*)data)) + if (ImGui::InputFloat4("##vec4", (float*)data)) + *commit = true; + ImGui::PopID(); +} + +//------------------------------------------------------------------------------ +/** +*/ +template <> +void +ComponentDrawFuncT(ComponentId component, void* data, bool* commit) +{ + ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); + if (ImGui::InputFloat4("##quat", (float*)data)) *commit = true; ImGui::PopID(); } @@ -240,9 +280,10 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); - - ImGui::SameLine(); + ImGui::TableSetColumnIndex(0); + ImGui::AlignTextToFramePadding(); + ImGui::Text("Position"); + ImGui::TableSetColumnIndex(1); ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); if (ImGui::InputFloat3("##pos", (float*)data)) *commit = true; @@ -256,9 +297,10 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); - - ImGui::SameLine(); + ImGui::TableSetColumnIndex(0); + ImGui::AlignTextToFramePadding(); + ImGui::Text("Orientation"); + ImGui::TableSetColumnIndex(1); ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); if (ImGui::InputFloat4("##orient", (float*)data)) *commit = true; @@ -272,9 +314,10 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); - - ImGui::SameLine(); + ImGui::TableSetColumnIndex(0); + ImGui::AlignTextToFramePadding(); + ImGui::Text("Scale"); + ImGui::TableSetColumnIndex(1); ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); if (ImGui::InputFloat3("##scl", (float*)data)) *commit = true; @@ -288,11 +331,8 @@ template<> void ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { - MemDb::Attribute* desc = MemDb::AttributeRegistry::GetAttribute(component); - - ImGui::SameLine(); ImGui::PushID(component.id + 0x125233 + reinterpret_cast(data)); - if (ImGui::ColorEdit4("##scl", (float*)data)) + if (ImGui::ColorEdit4("##color", (float*)data)) *commit = true; ImGui::PopID(); } diff --git a/code/application/game/componentinspection.h b/code/application/game/componentinspection.h index b76c23aa8..2d8ea78a1 100644 --- a/code/application/game/componentinspection.h +++ b/code/application/game/componentinspection.h @@ -61,10 +61,16 @@ InspectorDrawField(ComponentId component, void* data, bool* commit) Util::String fieldName = TYPE::Traits::field_names[i]; fieldName.CamelCaseToWords(); fieldName.Capitalize(); + ImGui::TableSetColumnIndex(0); ImGui::Text(fieldName.AsCharPtr()); - ImGui::SameLine(); + ImGui::TableSetColumnIndex(1); ComponentDrawFuncT(component, (byte*)data + TYPE::Traits::field_byte_offsets[i], commit); - InspectorDrawField(component, data, commit); + + if constexpr (i < TYPE::Traits::num_fields - 1) + { + ImGui::TableNextRow(); + InspectorDrawField(component, data, commit); + } } } @@ -79,7 +85,6 @@ ComponentDrawFuncT(ComponentId component, void* data, bool* commit) { if constexpr (TYPE::Traits::num_fields > 0 && !std::is_enum()) { - //UnrollTypesAndInspect(std::make_index_sequence(), component, data, commit); InspectorDrawField(component, data, commit); } } @@ -89,11 +94,15 @@ ComponentDrawFuncT(ComponentId component, void* data, bool* commit) template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); +template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); +template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); +template<> void ComponentDrawFuncT(ComponentId, void*, bool*); +template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); template<> void ComponentDrawFuncT(ComponentId, void*, bool*); diff --git a/toolkit/editor/editor/ui/windows/inspector.cc b/toolkit/editor/editor/ui/windows/inspector.cc index 78fd68e7c..a905c01cd 100644 --- a/toolkit/editor/editor/ui/windows/inspector.cc +++ b/toolkit/editor/editor/ui/windows/inspector.cc @@ -110,23 +110,32 @@ Inspector::Run(SaveMode save) { continue; } + + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::PushID(0xA3FC + (int)component.id); // offset the ids with some magic number - Util::String componentName = MemDb::AttributeRegistry::GetAttribute(component)->name.AsString(); - componentName.CamelCaseToWords(); - componentName.Capitalize(); - ImGui::Text(componentName.AsCharPtr()); - ImGui::SameLine(); - - if (component != Game::GetComponentId() && - component != Game::GetComponentId() && + if (component != Game::GetComponentId() && component != Game::GetComponentId() && component != Game::GetComponentId()) { + Util::String componentName = MemDb::AttributeRegistry::GetAttribute(component)->name.AsString(); + componentName.CamelCaseToWords(); + componentName.Capitalize(); + + ImGui::AlignTextToFramePadding(); + ImGui::Text(componentName.AsCharPtr()); + ImGui::SameLine(); + + ImGuiStyle const& style = ImGui::GetStyle(); + float widthNeeded = ImGui::CalcTextSize("Remove").x + style.FramePadding.x * 2.f + style.ItemSpacing.x; + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - widthNeeded); if (ImGui::Button("Remove")) { Edit::RemoveComponent(entity, component); ImGui::PopID(); return; // return, otherwise we're reading stale data. } + ImGui::Spacing(); } auto& tempComponent = this->tempComponents[i]; @@ -163,7 +172,22 @@ Inspector::Run(SaveMode save) } bool commitChange = false; - Game::ComponentInspection::DrawInspector(component, tempComponent.buffer, &commitChange); + + const ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | + ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; + if (ImGui::BeginTable("table1", 2, flags)) + { + ImGui::TableSetupColumn("FieldName", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("FieldValue", ImGuiTableColumnFlags_WidthStretch); + + //ImGui::TableHeadersRow(); + ImGui::TableNextRow(); + Game::ComponentInspection::DrawInspector(component, tempComponent.buffer, &commitChange); + ImGui::EndTable(); + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Spacing(); + } if (commitChange) { @@ -232,8 +256,7 @@ Inspector::ShowAddComponentMenu() Game::Position::Traits::name, Game::Orientation::Traits::name, Game::Scale::Traits::name, - Game::IsActive::Traits::name - }; + Game::IsActive::Traits::name}; for (SizeT i = 0; i < numComponents; i++) {