| 1807 | |
| 1808 | |
| 1809 | void FileDialog::DoFileTypesDropdown(bool supportMultipleTypes) |
| 1810 | { |
| 1811 | const ImGuiStyle& style = ImGui::GetStyle(); |
| 1812 | float dropdownWidth = Gutil::GetUIParamScaled(140.0f, 2.5f); |
| 1813 | dropdownWidth += style.ItemSpacing.x; |
| 1814 | |
| 1815 | ImGui::SetNextItemWidth(dropdownWidth); |
| 1816 | |
| 1817 | // The GetWindowContentRegionMax is OK here since width was fixed to a specific size before the Begin call. |
| 1818 | ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - dropdownWidth); |
| 1819 | |
| 1820 | // Nothing selected means all types used. |
| 1821 | bool anySelected = FileTypes.AnySelected(); |
| 1822 | bool allTypes = supportMultipleTypes && !anySelected; |
| 1823 | tString currChosen; |
| 1824 | if (supportMultipleTypes) |
| 1825 | { |
| 1826 | currChosen = allTypes ? "All Types" : FileTypes.GetSelectedString(tSystem::tFileTypes::Separator::CommaSpace, 4); |
| 1827 | } |
| 1828 | else |
| 1829 | { |
| 1830 | if (!anySelected) |
| 1831 | { |
| 1832 | FileTypes.First()->Selected = true; |
| 1833 | InvalidateAllNodeContent(); |
| 1834 | } |
| 1835 | currChosen = FileTypes.GetSelectedString(tSystem::tFileTypes::Separator::CommaSpace, 4); |
| 1836 | } |
| 1837 | |
| 1838 | if (ImGui::BeginCombo("##TypeFilter", currChosen.Chr(), ImGuiComboFlags_HeightLarge)) |
| 1839 | { |
| 1840 | if (supportMultipleTypes && ImGui::Selectable("All Types", allTypes)) |
| 1841 | { |
| 1842 | FileTypes.ClearSelected(); |
| 1843 | InvalidateAllNodeContent(); |
| 1844 | } |
| 1845 | |
| 1846 | for (tFileTypes::tFileTypeItem* typeItem = FileTypes.First(); typeItem; typeItem = typeItem->Next()) |
| 1847 | { |
| 1848 | tFileType fileType = typeItem->FileType; |
| 1849 | tString fileTypeName = tSystem::tGetFileTypeName(fileType); |
| 1850 | if (fileTypeName.IsEmpty()) |
| 1851 | continue; |
| 1852 | |
| 1853 | if (ImGui::Selectable(fileTypeName.Chr(), typeItem->Selected)) |
| 1854 | { |
| 1855 | if (!supportMultipleTypes) |
| 1856 | { |
| 1857 | FileTypes.ClearSelected(); |
| 1858 | typeItem->Selected = true; |
| 1859 | } |
| 1860 | else |
| 1861 | typeItem->Selected = !typeItem->Selected; |
| 1862 | InvalidateAllNodeContent(); |
| 1863 | } |
| 1864 | |
| 1865 | if (typeItem->Selected) |
| 1866 | ImGui::SetItemDefaultFocus(); |
nothing calls this directly
no outgoing calls
no test coverage detected