mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-27 16:17:12 +03:00
Improved Editor Interface
- Moved Add component button - Removed rounding on collapsed component header - Added indention in component panels - Changed frame background color
This commit is contained in:
@@ -14,14 +14,19 @@
|
||||
else if (ImGui::MenuItem(label)) \
|
||||
entity.AddComponent<Component>();
|
||||
|
||||
#define CompononentPropertyName(name) \
|
||||
ImGui::AlignTextToFramePadding(); \
|
||||
ImGui::Text(##name);
|
||||
|
||||
#define BeginComponentTable(name, component) \
|
||||
UIFont* boldFont = new UIFont(Fonts::Bold); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, 0.f)); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.f, 8.f)); \
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f); \
|
||||
bool removed = false; \
|
||||
bool headerOpened = ImGui::CollapsingHeader(#name, ImGuiTreeNodeFlags_DefaultOpen); \
|
||||
if (#name != "TRANSFORM" && ImGui::BeginPopupContextItem()) \
|
||||
ImGui::PopStyleVar(); \
|
||||
if (#name != "TRANSFORM" && ImGui::BeginPopupContextItem()) \
|
||||
{ \
|
||||
if (ImGui::Selectable("Remove")) { removed = true; } \
|
||||
ImGui::EndPopup(); \
|
||||
@@ -37,10 +42,11 @@
|
||||
{ \
|
||||
delete boldFont; \
|
||||
ImGui::PopStyleVar(); \
|
||||
if (ImGui::BeginTable(#name, 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) \
|
||||
ImGui::Indent(); \
|
||||
if (ImGui::BeginTable(#name, 3, ImGuiTableFlags_SizingStretchProp)) \
|
||||
{ \
|
||||
ImGui::TableSetupColumn("name", 0, 0.25f); \
|
||||
ImGui::TableSetupColumn("set", 0, 0.65f); \
|
||||
ImGui::TableSetupColumn("name", 0, 0.25f); \
|
||||
ImGui::TableSetupColumn("set", 0, 0.65f); \
|
||||
ImGui::TableSetupColumn("reset", 0, 0.1f); \
|
||||
\
|
||||
ImGui::TableNextColumn();
|
||||
@@ -49,13 +55,14 @@
|
||||
#define EndComponentTable() \
|
||||
ImGui::EndTable(); \
|
||||
} \
|
||||
ImGui::Unindent(); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ImGui::PopStyleVar(); \
|
||||
delete boldFont; \
|
||||
} \
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar(); \
|
||||
|
||||
|
||||
#define ComponentTableReset(setting, value) \
|
||||
|
||||
@@ -12,73 +12,84 @@ public:
|
||||
{
|
||||
using namespace Nuake;
|
||||
Nuake::TransformComponent& component = entity.GetComponent<Nuake::TransformComponent>();
|
||||
BeginComponentTable(TRANSFORM, Nuake::TransformComponent);
|
||||
{
|
||||
{
|
||||
ImGui::Text("Translation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 position = component.GetLocalPosition();
|
||||
ImGuiHelper::DrawVec3("Translation", &position);
|
||||
if (position != component.GetLocalPosition())
|
||||
component.SetLocalPosition(position);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetTranslation";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
component.SetLocalPosition(Vector3(0, 0, 0));
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::Indent();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, 0.f));
|
||||
if (ImGui::BeginTable("#transform", 3, ImGuiTableFlags_SizingStretchProp))
|
||||
{
|
||||
ImGui::TableSetupColumn("name", 0, 0.25f);
|
||||
ImGui::TableSetupColumn("set", 0, 0.65f);
|
||||
ImGui::TableSetupColumn("reset", 0, 0.1f);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Rotation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 eulerAngles = glm::eulerAngles(component.GetLocalRotation());
|
||||
Vector3 eulerDegrees = Vector3(glm::degrees(eulerAngles.x), glm::degrees(eulerAngles.y), glm::degrees(eulerAngles.z));
|
||||
ImGuiHelper::DrawVec3("Rotation", &eulerDegrees);
|
||||
Vector3 eulerAnglesDelta = Vector3(glm::radians(eulerDegrees.x), glm::radians(eulerDegrees.y), glm::radians(eulerDegrees.z));
|
||||
|
||||
float delta = glm::length(eulerAngles - eulerAnglesDelta);
|
||||
if (delta > 0.f)
|
||||
{
|
||||
Quat rotation = QuatFromEuler(eulerAnglesDelta.x, eulerAnglesDelta.y, eulerAnglesDelta.z);
|
||||
//component.SetLocalRotation(rotation);
|
||||
CompononentPropertyName("Translation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 position = component.GetLocalPosition();
|
||||
ImGuiHelper::DrawVec3("Translation", &position);
|
||||
if (position != component.GetLocalPosition())
|
||||
component.SetLocalPosition(position);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetTranslation";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
component.SetLocalPosition(Vector3(0, 0, 0));
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetRotation";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
{
|
||||
component.SetLocalRotation(Quat(1, 0, 0, 0));
|
||||
CompononentPropertyName("Rotation");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 eulerAngles = glm::eulerAngles(component.GetLocalRotation());
|
||||
Vector3 eulerDegrees = Vector3(glm::degrees(eulerAngles.x), glm::degrees(eulerAngles.y), glm::degrees(eulerAngles.z));
|
||||
ImGuiHelper::DrawVec3("Rotation", &eulerDegrees);
|
||||
Vector3 eulerAnglesDelta = Vector3(glm::radians(eulerDegrees.x), glm::radians(eulerDegrees.y), glm::radians(eulerDegrees.z));
|
||||
|
||||
float delta = glm::length(eulerAngles - eulerAnglesDelta);
|
||||
if (delta > 0.f)
|
||||
{
|
||||
Quat rotation = QuatFromEuler(eulerAnglesDelta.x, eulerAnglesDelta.y, eulerAnglesDelta.z);
|
||||
//component.SetLocalRotation(rotation);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetRotation";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
{
|
||||
component.SetLocalRotation(Quat(1, 0, 0, 0));
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Scale");
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
CompononentPropertyName("Scale");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
Vector3 localScale = component.GetLocalScale();
|
||||
ImGuiHelper::DrawVec3("Scale", &localScale);
|
||||
Vector3 localScale = component.GetLocalScale();
|
||||
ImGuiHelper::DrawVec3("Scale", &localScale);
|
||||
|
||||
if (localScale != component.GetLocalScale())
|
||||
component.SetLocalScale(localScale);
|
||||
if (localScale != component.GetLocalScale())
|
||||
component.SetLocalScale(localScale);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetScale";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
component.SetLocalScale(Vector3(1, 1, 1));
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
|
||||
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetScale";
|
||||
if (ImGui::Button(resetLabel.c_str()))
|
||||
component.SetLocalScale(Vector3(1, 1, 1));
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
EndComponentTable();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::Unindent();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user