UI CONTROLS */
| 35 | |
| 36 | /* UI CONTROLS */ |
| 37 | bool FolderNode(const char* label, ImTextureID icon, bool& clicked) |
| 38 | { |
| 39 | ImGuiContext& g = *GImGui; |
| 40 | ImGuiWindow* window = g.CurrentWindow; |
| 41 | |
| 42 | clicked = false; |
| 43 | |
| 44 | ImU32 id = window->GetID(label); |
| 45 | int opened = window->StateStorage.GetInt(id, 0); |
| 46 | ImVec2 pos = window->DC.CursorPos; |
| 47 | const bool is_mouse_x_over_arrow = (g.IO.MousePos.x >= pos.x && g.IO.MousePos.x < pos.x + g.FontSize); |
| 48 | if (ImGui::InvisibleButton(label, ImVec2(-FLT_MIN, g.FontSize + g.Style.FramePadding.y * 2))) |
| 49 | { |
| 50 | if (is_mouse_x_over_arrow) { |
| 51 | int* p_opened = window->StateStorage.GetIntRef(id, 0); |
| 52 | opened = *p_opened = !*p_opened; |
| 53 | } else { |
| 54 | clicked = true; |
| 55 | } |
| 56 | } |
| 57 | bool hovered = ImGui::IsItemHovered(); |
| 58 | bool active = ImGui::IsItemActive(); |
| 59 | bool doubleClick = ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left); |
| 60 | if (doubleClick && hovered) { |
| 61 | int* p_opened = window->StateStorage.GetIntRef(id, 0); |
| 62 | opened = *p_opened = !*p_opened; |
| 63 | clicked = false; |
| 64 | } |
| 65 | if (hovered || active) |
| 66 | window->DrawList->AddRectFilled(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, ImGui::ColorConvertFloat4ToU32(ImGui::GetStyle().Colors[active ? ImGuiCol_HeaderActive : ImGuiCol_HeaderHovered])); |
| 67 | |
| 68 | // Icon, text |
| 69 | float icon_posX = pos.x + g.FontSize + g.Style.FramePadding.y; |
| 70 | float text_posX = icon_posX + g.Style.FramePadding.y + ICON_SIZE; |
| 71 | ImGui::RenderArrow(window->DrawList, ImVec2(pos.x, pos.y+g.Style.FramePadding.y), ImGui::ColorConvertFloat4ToU32(ImGui::GetStyle().Colors[((hovered && is_mouse_x_over_arrow) || opened) ? ImGuiCol_Text : ImGuiCol_TextDisabled]), opened ? ImGuiDir_Down : ImGuiDir_Right); |
| 72 | window->DrawList->AddImage(icon, ImVec2(icon_posX, pos.y), ImVec2(icon_posX + ICON_SIZE, pos.y + ICON_SIZE)); |
| 73 | ImGui::RenderText(ImVec2(text_posX, pos.y + g.Style.FramePadding.y), label); |
| 74 | if (opened) |
| 75 | ImGui::TreePush(label); |
| 76 | return opened != 0; |
| 77 | } |
| 78 | bool FileNode(const char* label, ImTextureID icon) { |
| 79 | ImGuiContext& g = *GImGui; |
| 80 | ImGuiWindow* window = g.CurrentWindow; |