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. 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); + } } } }