MCPcopy Create free account
hub / github.com/dfranx/ImFileDialog / m_renderContent

Method m_renderContent

ImFileDialog.cpp:1091–1202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1089 ImGui::PopID();
1090 }
1091 void FileDialog::m_renderContent()
1092 {
1093 if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
1094 m_selectedFileItem = -1;
1095
1096 // table view
1097 if (m_zoom == 1.0f) {
1098 if (ImGui::BeginTable("##contentTable", 3, /*ImGuiTableFlags_Resizable |*/ ImGuiTableFlags_Sortable, ImVec2(0, -FLT_MIN))) {
1099 // header
1100 ImGui::TableSetupColumn("Name##filename", ImGuiTableColumnFlags_WidthStretch, 0.0f -1.0f, 0);
1101 ImGui::TableSetupColumn("Date modified##filedate", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 0.0f, 1);
1102 ImGui::TableSetupColumn("Size##filesize", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, 0.0f, 2);
1103 ImGui::TableSetupScrollFreeze(0, 1);
1104 ImGui::TableHeadersRow();
1105
1106 // sort
1107 if (ImGuiTableSortSpecs* sortSpecs = ImGui::TableGetSortSpecs()) {
1108 if (sortSpecs->SpecsDirty) {
1109 sortSpecs->SpecsDirty = false;
1110 m_sortContent(sortSpecs->Specs->ColumnUserID, sortSpecs->Specs->SortDirection);
1111 }
1112 }
1113
1114 // content
1115 int fileId = 0;
1116 for (auto& entry : m_content) {
1117 std::string filename = entry.Path.filename().u8string();
1118 if (filename.size() == 0)
1119 filename = entry.Path.u8string(); // drive
1120
1121 bool isSelected = std::count(m_selections.begin(), m_selections.end(), entry.Path);
1122
1123 ImGui::TableNextRow();
1124
1125 // file name
1126 ImGui::TableSetColumnIndex(0);
1127 ImGui::Image((ImTextureID)m_getIcon(entry.Path), ImVec2(ICON_SIZE, ICON_SIZE));
1128 ImGui::SameLine();
1129 if (ImGui::Selectable(filename.c_str(), isSelected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowDoubleClick)) {
1130 std::error_code ec;
1131 bool isDir = std::filesystem::is_directory(entry.Path, ec);
1132
1133 if (ImGui::IsMouseDoubleClicked(0)) {
1134 if (isDir) {
1135 m_setDirectory(entry.Path);
1136 break;
1137 } else
1138 m_finalize(filename);
1139 } else {
1140 if ((isDir && m_type == IFD_DIALOG_DIRECTORY) || !isDir)
1141 m_select(entry.Path, ImGui::GetIO().KeyCtrl);
1142 }
1143 }
1144 if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
1145 m_selectedFileItem = fileId;
1146 fileId++;
1147
1148 // date

Callers

nothing calls this directly

Calls 1

FileIconFunction · 0.85

Tested by

no test coverage detected