Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/gallery/widgets-data-and-signals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/gallery/widgets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/gallery/widgets/datatable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions tools/WidgetGallery/Catalog/DataAndSignals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,24 @@ public static IEnumerable<GalleryEntry> Build()
[
new ImGuiWidgets.DataTableColumn<GalleryPart, string> { Label = "Name", Value = part => part.Name },
new ImGuiWidgets.DataTableColumn<GalleryPart, int> { Label = "Quantity", Value = part => part.Quantity },
new ImGuiWidgets.DataTableColumn<GalleryPart, bool> { Label = "In stock", Value = part => part.InStock },

// Editable, so the column draws as checkboxes. The gallery never edits it.
new ImGuiWidgets.DataTableColumn<GalleryPart, bool> { Label = "In stock", Value = part => part.InStock, OnEdit = _ => { } },
]);
ImGuiWidgets.DataTableOptions partsOptions = new() { RowHeight = 20f, OuterSize = new Vector2(270f, 150f) };
bool isPartsSelectionSet = false;
yield return new("DataTable", Category, [nameof(ImGuiWidgets.DataTable), typeof(ImGuiWidgets.DataTableState<>).Name, typeof(ImGuiWidgets.DataTableColumn<>).Name, typeof(ImGuiWidgets.DataTableColumn<,>).Name], _ =>
ImGuiWidgets.DataTable("##parts", parts, partsTable));
{
ImGuiWidgets.DataTable("##parts", parts, partsTable, partsOptions);

// The table learns its rows on its first draw, so the selection can only be set after it.
if (!isPartsSelectionSet)
{
partsTable.SelectRows([2]);
partsTable.ActivateCell(new ImGuiWidgets.DataTableCell(2, 1));
isPartsSelectionSet = true;
}
});
}

/// <summary>A row of the data table tile.</summary>
Expand Down
11 changes: 10 additions & 1 deletion tools/WidgetGallery/SampleFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,18 @@ private static void Create()
File.WriteAllText(Path.Join(root, file), "sample");
}

// Directories go through Directory: Windows refuses to open a directory as a file, so
// File.SetLastWriteTime on one throws there while Linux and macOS allow it.
foreach (string entry in Directory.EnumerateFileSystemEntries(root, "*", SearchOption.AllDirectories))
{
File.SetLastWriteTime(entry, Timestamp);
if (Directory.Exists(entry))
{
Directory.SetLastWriteTime(entry, Timestamp);
}
else
{
File.SetLastWriteTime(entry, Timestamp);
}
}
}
}
Loading