From 997a9f0c37b58c164b1773406fa2b35d06f558b2 Mon Sep 17 00:00:00 2001 From: Matt Edmondson Date: Wed, 30 Sep 2026 07:08:03 +1000 Subject: [PATCH 1/2] [patch] Stamp the gallery's sample folders with Directory.SetLastWriteTime File.SetLastWriteTime on a directory throws UnauthorizedAccessException on Windows, which refuses to open a directory as a file. Linux and macOS allow it, so the gallery only failed to build its catalog on Windows. --- tools/WidgetGallery/SampleFolder.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/WidgetGallery/SampleFolder.cs b/tools/WidgetGallery/SampleFolder.cs index 34579609..f2cfd9c5 100644 --- a/tools/WidgetGallery/SampleFolder.cs +++ b/tools/WidgetGallery/SampleFolder.cs @@ -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); + } } } } From fe4e813d4638f8e4c184470e235d356a248605c7 Mon Sep 17 00:00:00 2001 From: Matt Edmondson Date: Wed, 30 Sep 2026 07:17:14 +1000 Subject: [PATCH 2/2] [patch] Add the data table to the widget gallery Renders the DataTable tile and adds it to the full gallery and the Data and Signals sheet. The tile is sized to its rows instead of filling the viewport, draws the stock column as checkboxes, and shows a selected row with an active cell. Only the new tile and the two sheets that contain it are committed. A full render on Windows re-encodes every PNG with different compression but identical pixels, so the other images are left as they were. --- docs/gallery/widgets-data-and-signals.png | 4 ++-- docs/gallery/widgets.png | 4 ++-- docs/gallery/widgets/datatable.png | 3 +++ tools/WidgetGallery/Catalog/DataAndSignals.cs | 18 ++++++++++++++++-- 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 docs/gallery/widgets/datatable.png diff --git a/docs/gallery/widgets-data-and-signals.png b/docs/gallery/widgets-data-and-signals.png index e0fbdd9b..8ff1bbc2 100644 --- a/docs/gallery/widgets-data-and-signals.png +++ b/docs/gallery/widgets-data-and-signals.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7f53190f5fd3ea89b05c79111f9aeb6b478be33619c54411caf7d2ca952acd63 -size 65112 +oid sha256:9be2a64e0d85d6b46aa801c2f4f686f002b9c91f0e4ddaa175e4c711f8ec017b +size 95146 diff --git a/docs/gallery/widgets.png b/docs/gallery/widgets.png index 1a7b9b5d..1dfb997b 100644 --- a/docs/gallery/widgets.png +++ b/docs/gallery/widgets.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c851afc79cd9326f27f30afb3b6c94128c931c362a3d29fb30a817c81b7d6a0 -size 586274 +oid sha256:3b56d0dc6a7f12f1518b469d61a3d2a466f8de5584a24cbbd447ac3d1dd3e9c6 +size 819272 diff --git a/docs/gallery/widgets/datatable.png b/docs/gallery/widgets/datatable.png new file mode 100644 index 00000000..c11e3343 --- /dev/null +++ b/docs/gallery/widgets/datatable.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e525c30ac721c523d035c8b9a7d14f524812033e986545fd534886d771253a22 +size 9966 diff --git a/tools/WidgetGallery/Catalog/DataAndSignals.cs b/tools/WidgetGallery/Catalog/DataAndSignals.cs index a2964434..71b76145 100644 --- a/tools/WidgetGallery/Catalog/DataAndSignals.cs +++ b/tools/WidgetGallery/Catalog/DataAndSignals.cs @@ -110,10 +110,24 @@ public static IEnumerable Build() [ new ImGuiWidgets.DataTableColumn { Label = "Name", Value = part => part.Name }, new ImGuiWidgets.DataTableColumn { Label = "Quantity", Value = part => part.Quantity }, - new ImGuiWidgets.DataTableColumn { Label = "In stock", Value = part => part.InStock }, + + // Editable, so the column draws as checkboxes. The gallery never edits it. + new ImGuiWidgets.DataTableColumn { 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; + } + }); } /// A row of the data table tile.