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

Method m_renderFileDialog

ImFileDialog.cpp:1281–1413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1279 }
1280 }
1281 void FileDialog::m_renderFileDialog()
1282 {
1283 /***** TOP BAR *****/
1284 bool noBackHistory = m_backHistory.empty(), noForwardHistory = m_forwardHistory.empty();
1285
1286 ImGui::PushStyleColor(ImGuiCol_Button, 0);
1287 if (noBackHistory) ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
1288 if (ImGui::ArrowButtonEx("##back", ImGuiDir_Left, ImVec2(GUI_ELEMENT_SIZE, GUI_ELEMENT_SIZE), m_backHistory.empty() * ImGuiItemFlags_Disabled)) {
1289 std::filesystem::path newPath = m_backHistory.top();
1290 m_backHistory.pop();
1291 m_forwardHistory.push(m_currentDirectory);
1292
1293 m_setDirectory(newPath, false);
1294 }
1295 if (noBackHistory) ImGui::PopStyleVar();
1296 ImGui::SameLine();
1297
1298 if (noForwardHistory) ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
1299 if (ImGui::ArrowButtonEx("##forward", ImGuiDir_Right, ImVec2(GUI_ELEMENT_SIZE, GUI_ELEMENT_SIZE), m_forwardHistory.empty() * ImGuiItemFlags_Disabled)) {
1300 std::filesystem::path newPath = m_forwardHistory.top();
1301 m_forwardHistory.pop();
1302 m_backHistory.push(m_currentDirectory);
1303
1304 m_setDirectory(newPath, false);
1305 }
1306 if (noForwardHistory) ImGui::PopStyleVar();
1307 ImGui::SameLine();
1308
1309 if (ImGui::ArrowButtonEx("##up", ImGuiDir_Up, ImVec2(GUI_ELEMENT_SIZE, GUI_ELEMENT_SIZE))) {
1310 if (m_currentDirectory.has_parent_path())
1311 m_setDirectory(m_currentDirectory.parent_path());
1312 }
1313
1314 std::filesystem::path curDirCopy = m_currentDirectory;
1315 if (PathBox("##pathbox", curDirCopy, m_pathBuffer, ImVec2(-250, GUI_ELEMENT_SIZE)))
1316 m_setDirectory(curDirCopy);
1317 ImGui::SameLine();
1318
1319 if (FavoriteButton("##dirfav", std::count(m_favorites.begin(), m_favorites.end(), m_currentDirectory.u8string()))) {
1320 if (std::count(m_favorites.begin(), m_favorites.end(), m_currentDirectory.u8string()))
1321 RemoveFavorite(m_currentDirectory.u8string());
1322 else
1323 AddFavorite(m_currentDirectory.u8string());
1324 }
1325 ImGui::SameLine();
1326 ImGui::PopStyleColor();
1327
1328 if (ImGui::InputTextEx("##searchTB", "Search", m_searchBuffer, 128, ImVec2(-FLT_MIN, GUI_ELEMENT_SIZE), 0)) // TODO: no hardcoded literals
1329 m_setDirectory(m_currentDirectory, false); // refresh
1330
1331
1332
1333 /***** CONTENT *****/
1334 float bottomBarHeight = (GImGui->FontSize + ImGui::GetStyle().FramePadding.y + ImGui::GetStyle().ItemSpacing.y * 2.0f) * 2;
1335 if (ImGui::BeginTable("##table", 2, ImGuiTableFlags_Resizable, ImVec2(0, -bottomBarHeight))) {
1336 ImGui::TableSetupColumn("##tree", ImGuiTableColumnFlags_WidthFixed, 125.0f);
1337 ImGui::TableSetupColumn("##content", ImGuiTableColumnFlags_WidthStretch);
1338 ImGui::TableNextRow();

Callers

nothing calls this directly

Calls 2

PathBoxFunction · 0.85
FavoriteButtonFunction · 0.85

Tested by

no test coverage detected