mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-22 21:30:05 +01:00
Demo: Assets Browser: added a way to disable sorting and hide sorting options.
This is mostly designed to showcase that on very large sets (e.g. 1 million) most of the time is likely spent on sorting.
This commit is contained in:
parent
c07864f64a
commit
f472f17054
@ -9676,6 +9676,7 @@ struct ExampleAssetsBrowser
|
|||||||
{
|
{
|
||||||
// Options
|
// Options
|
||||||
bool ShowTypeOverlay = true;
|
bool ShowTypeOverlay = true;
|
||||||
|
bool AllowSorting = true;
|
||||||
bool AllowDragUnselected = false;
|
bool AllowDragUnselected = false;
|
||||||
bool AllowBoxSelect = true;
|
bool AllowBoxSelect = true;
|
||||||
float IconSize = 32.0f;
|
float IconSize = 32.0f;
|
||||||
@ -9778,6 +9779,7 @@ struct ExampleAssetsBrowser
|
|||||||
|
|
||||||
ImGui::SeparatorText("Contents");
|
ImGui::SeparatorText("Contents");
|
||||||
ImGui::Checkbox("Show Type Overlay", &ShowTypeOverlay);
|
ImGui::Checkbox("Show Type Overlay", &ShowTypeOverlay);
|
||||||
|
ImGui::Checkbox("Allow Sorting", &AllowSorting);
|
||||||
|
|
||||||
ImGui::SeparatorText("Selection Behavior");
|
ImGui::SeparatorText("Selection Behavior");
|
||||||
ImGui::Checkbox("Allow dragging unselected item", &AllowDragUnselected);
|
ImGui::Checkbox("Allow dragging unselected item", &AllowDragUnselected);
|
||||||
@ -9796,22 +9798,25 @@ struct ExampleAssetsBrowser
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show a table with ONLY one header row to showcase the idea/possibility of using this to provide a sorting UI
|
// Show a table with ONLY one header row to showcase the idea/possibility of using this to provide a sorting UI
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
if (AllowSorting)
|
||||||
ImGuiTableFlags table_flags_for_sort_specs = ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Borders;
|
|
||||||
if (ImGui::BeginTable("for_sort_specs_only", 2, table_flags_for_sort_specs, ImVec2(0.0f, ImGui::GetFrameHeight())))
|
|
||||||
{
|
{
|
||||||
ImGui::TableSetupColumn("Index");
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||||
ImGui::TableSetupColumn("Type");
|
ImGuiTableFlags table_flags_for_sort_specs = ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Borders;
|
||||||
ImGui::TableHeadersRow();
|
if (ImGui::BeginTable("for_sort_specs_only", 2, table_flags_for_sort_specs, ImVec2(0.0f, ImGui::GetFrameHeight())))
|
||||||
if (ImGuiTableSortSpecs* sort_specs = ImGui::TableGetSortSpecs())
|
{
|
||||||
if (sort_specs->SpecsDirty || RequestSort)
|
ImGui::TableSetupColumn("Index");
|
||||||
{
|
ImGui::TableSetupColumn("Type");
|
||||||
ExampleAsset::SortWithSortSpecs(sort_specs, Items.Data, Items.Size);
|
ImGui::TableHeadersRow();
|
||||||
sort_specs->SpecsDirty = RequestSort = false;
|
if (ImGuiTableSortSpecs* sort_specs = ImGui::TableGetSortSpecs())
|
||||||
}
|
if (sort_specs->SpecsDirty || RequestSort)
|
||||||
ImGui::EndTable();
|
{
|
||||||
|
ExampleAsset::SortWithSortSpecs(sort_specs, Items.Data, Items.Size);
|
||||||
|
sort_specs->SpecsDirty = RequestSort = false;
|
||||||
|
}
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
ImGui::PopStyleVar();
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui::SetNextWindowContentSize(ImVec2(0.0f, LayoutOuterPadding + LayoutLineCount * (LayoutItemSize.x + LayoutItemSpacing)));
|
ImGui::SetNextWindowContentSize(ImVec2(0.0f, LayoutOuterPadding + LayoutLineCount * (LayoutItemSize.x + LayoutItemSpacing)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user