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

Method m_renderContent

libs/misc/ImFileDialog.cpp:1088–1200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

FileIconFunction · 0.85
CreateTextureMethod · 0.80
stbi_image_freeFunction · 0.70
countFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected