Some changes to make the hierarchy look a bit better lol.
Some checks failed
Build C++ Project with Fedora Container and Create Release / build (push) Has been cancelled
Some checks failed
Build C++ Project with Fedora Container and Create Release / build (push) Has been cancelled
This commit is contained in:
52
src/main.cpp
52
src/main.cpp
@@ -2556,34 +2556,60 @@ private:
|
|||||||
void renderHierarchyPanel() {
|
void renderHierarchyPanel() {
|
||||||
ImGui::Begin("Hierarchy", &showHierarchy);
|
ImGui::Begin("Hierarchy", &showHierarchy);
|
||||||
|
|
||||||
|
// -------------------------------
|
||||||
|
// TOP TOOLBAR (row with + button)
|
||||||
|
// -------------------------------
|
||||||
|
{
|
||||||
|
// Child helps align things more cleanly
|
||||||
|
ImGui::BeginChild("HierarchyToolbar", ImVec2(0, 28), false);
|
||||||
|
|
||||||
|
// "+" button top-left
|
||||||
|
if (ImGui::Button("+", ImVec2(24, 24))) {
|
||||||
|
ImGui::OpenPopup("CreateMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Popup create menu
|
||||||
|
if (ImGui::BeginPopup("CreateMenu")) {
|
||||||
|
if (ImGui::MenuItem("Cube")) addObject(ObjectType::Cube, "Cube");
|
||||||
|
if (ImGui::MenuItem("Sphere")) addObject(ObjectType::Sphere, "Sphere");
|
||||||
|
if (ImGui::MenuItem("Capsule")) addObject(ObjectType::Capsule, "Capsule");
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// -------------------------------
|
||||||
|
// SEARCH BAR
|
||||||
|
// -------------------------------
|
||||||
static char searchBuffer[128] = "";
|
static char searchBuffer[128] = "";
|
||||||
ImGui::SetNextItemWidth(-1);
|
ImGui::SetNextItemWidth(-1);
|
||||||
ImGui::InputTextWithHint("##search", "Search objects...", searchBuffer, sizeof(searchBuffer));
|
ImGui::InputTextWithHint("##search", "Search objects...", searchBuffer, sizeof(searchBuffer));
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::Button("+ Cube")) addObject(ObjectType::Cube, "Cube");
|
// -------------------------------
|
||||||
ImGui::SameLine();
|
// HIERARCHY TREE
|
||||||
if (ImGui::Button("+ Sphere")) addObject(ObjectType::Sphere, "Sphere");
|
// -------------------------------
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button("+ Capsule")) addObject(ObjectType::Capsule, "Capsule");
|
|
||||||
|
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
ImGui::BeginChild("SceneTree", ImVec2(0, 0), false);
|
ImGui::BeginChild("SceneTree", ImVec2(0, 0), false);
|
||||||
|
|
||||||
std::string filter = searchBuffer;
|
std::string filter = searchBuffer;
|
||||||
std::transform(filter.begin(), filter.end(), filter.begin(), ::tolower);
|
std::transform(filter.begin(), filter.end(), filter.begin(), ::tolower);
|
||||||
|
|
||||||
for (size_t i = 0; i < sceneObjects.size(); i++) {
|
for (size_t i = 0; i < sceneObjects.size(); i++) {
|
||||||
if (sceneObjects[i].parentId != -1) continue;
|
if (sceneObjects[i].parentId != -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
renderObjectNode(sceneObjects[i], filter);
|
renderObjectNode(sceneObjects[i], filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndChild();
|
// Right-click empty space
|
||||||
|
if (ImGui::BeginPopupContextWindow("HierarchyBackground",
|
||||||
if (ImGui::BeginPopupContextWindow("HierarchyContextMenu", ImGuiPopupFlags_NoOpenOverItems | ImGuiPopupFlags_MouseButtonRight)) {
|
ImGuiPopupFlags_MouseButtonRight |
|
||||||
|
ImGuiPopupFlags_NoOpenOverItems))
|
||||||
|
{
|
||||||
if (ImGui::BeginMenu("Create")) {
|
if (ImGui::BeginMenu("Create")) {
|
||||||
if (ImGui::MenuItem("Cube")) addObject(ObjectType::Cube, "Cube");
|
if (ImGui::MenuItem("Cube")) addObject(ObjectType::Cube, "Cube");
|
||||||
if (ImGui::MenuItem("Sphere")) addObject(ObjectType::Sphere, "Sphere");
|
if (ImGui::MenuItem("Sphere")) addObject(ObjectType::Sphere, "Sphere");
|
||||||
@@ -2593,6 +2619,8 @@ private:
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user