A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Made scrollviewer working automatically following minimum height of child grid.
Etienne Baudouxa9397d2e2935
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGridCell.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGridCell.csindex 517f21724..60813399f 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGridCell.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGridCell.cs@@ -20,11 +20,13 @@ public interface IUIGridCell/// <summary>/// Gets a value that indicates the total number of rows that the cell content spans within the parent grid.+ /// Default is 1./// </summary>int RowSpan { get; }/// <summary>/// Gets a value that indicates the total number of columns that the cell content spans within the parent grid.+ /// Default is 1./// </summary>int ColumnSpan { get; }@@ -64,8 +66,8 @@ internal sealed class UIGridCell : IUIGridCell, INotifyPropertyChanged{private int _row;private int _column;- private int _rowSpan;- private int _columnSpan;+ private int _rowSpan = 1;+ private int _columnSpan = 1;private IUIElement? _child;public int Row@@ -83,13 +85,21 @@ internal sealed class UIGridCell : IUIGridCell, INotifyPropertyChangedpublic int RowSpan{get => _rowSpan;- internal set => SetPropertyValue(ref _rowSpan, value, RowSpanChanged);+ internal set+ {+ Guard.IsGreaterThanOrEqualTo(value, 1);+ SetPropertyValue(ref _rowSpan, value, RowSpanChanged);+ }}public int ColumnSpan{get => _columnSpan;- internal set => SetPropertyValue(ref _columnSpan, value, ColumnSpanChanged);+ internal set+ {+ Guard.IsGreaterThanOrEqualTo(value, 1);+ SetPropertyValue(ref _columnSpan, value, ColumnSpanChanged);+ }}public IUIElement? Childdiff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.csindex cd967c5db..1936e7677 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.cs@@ -5,32 +5,19 @@ namespace DevToys.Api;/// <summary>/// Represents the root ui definition of a <see cref="IGuiTool"/>./// </summary>-[DebuggerDisplay($"IsScrollable = {{{nameof(IsScrollable)}}}")]+[DebuggerDisplay($"RootElement = {{{nameof(RootElement)}}}")]public class UIToolView : INotifyPropertyChanged{- private bool _isScrollable;-/// <summary>/// Creates a new instance of the <see cref="UIToolView"/> class./// </summary>- /// <param name="isScrollable">Indicates whether the UI of the tool is scrollable or should fits to the window boundaries.</param>/// <param name="rootElement">The root element of the tool's UI.</param>- public UIToolView(bool isScrollable, IUIElement rootElement)+ public UIToolView(IUIElement rootElement){Guard.IsNotNull(rootElement);- IsScrollable = isScrollable;RootElement = rootElement;}- /// <summary>- /// Gets whether the UI of the tool is scrollable or should fits to the window boundaries.- /// </summary>- public bool IsScrollable- {- get => _isScrollable;- internal set => SetPropertyValue(ref _isScrollable, value, IsScrollableChanged);- }-/// <summary>/// Gets the root element of the tool's UI./// </summary>diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.csindex 214f9fda8..20749b90c 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs@@ -68,8 +68,10 @@ public partial class Container : StyledComponentBasestyleBuilder.AddImportantStyle("align-items", "stretch");styleBuilder.AddImportantStyle("height", "100%", !Height.HasValue);styleBuilder.AddImportantStyle("max-height", "100%", !Height.HasValue);+ styleBuilder.AddImportantStyle("min-height", "min-content", !Height.HasValue);innerStyleBuilder.AddImportantStyle("max-height", "inherit", !Height.HasValue);innerStyleBuilder.AddImportantStyle("height", "100%", !Height.HasValue);+ innerStyleBuilder.AddImportantStyle("min-height", "min-content", !Height.HasValue);break;case UIVerticalAlignment.Top:diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor.csindex 9f62d503a..1e0a42d0d 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor.cs@@ -51,7 +51,7 @@ public partial class Grid : StyledComponentBase{if (collection is null || !collection.Any()){- return "1fr";+ return "minmax(min-content, 1fr)";}var builder = new StringBuilder();@@ -59,7 +59,7 @@ public partial class Grid : StyledComponentBase{if (item.IsFraction){- builder.Append($" {item.Value}fr");+ builder.Append($" minmax(min-content, {item.Value}fr)");}else if (item.IsAbsolute){@@ -67,7 +67,7 @@ public partial class Grid : StyledComponentBase}else if (item.IsAuto){- builder.Append($" auto");+ builder.Append($" minmax(min-content, auto)");}else{diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/GridCell.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/GridCell.razor.csindex dfcc0ec26..30233e7df 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/GridCell.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/GridCell.razor.cs@@ -5,8 +5,8 @@ namespace DevToys.Blazor.Components;public partial class GridCell : ComponentBase{protected string? GridCellStyleValue => new StyleBuilder()- .AddStyle("grid-column", $"{Column + 1}", ColumnSpan == 1)- .AddStyle("grid-row", $"{Row + 1}", RowSpan == 1)+ .AddStyle("grid-column", $"{Column + 1}", ColumnSpan <= 1)+ .AddStyle("grid-row", $"{Row + 1}", RowSpan <= 1).AddStyle("grid-column", $"{Column + 1} / span {ColumnSpan}", ColumnSpan > 1).AddStyle("grid-row", $"{Row + 1} / span {RowSpan}", RowSpan > 1).Build();diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razorindex 9b068dbe9..301798f69 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor+++ b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor@@ -21,7 +21,9 @@style="@(Style)"@ref=Element@attributes="AdditionalAttributes">- @ChildContent+ <div style="grid-row: 1;">+ @ChildContent+ </div></div></Container></CascadingValue>\ No newline at end of filediff --git a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.scss b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.scssindex 279e1c12a..ebf9ee36f 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.scss+++ b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.scss@@ -325,6 +325,8 @@-ms-overflow-style: none;}-[data-simplebar-not-scrollable] .simplebar-content{- height: 100% !important;+.simplebar-content {+ display: grid;+ grid-template-rows: minmax(min-content, 1fr);+ height: 100%;}diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razorindex e395e0787..6d2748d2b 100644--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor@@ -2,19 +2,10 @@@using DevToys.Blazor.Components.UIElements@inherits MefComponentBase-@if (ViewModel.ToolView.IsScrollable)-{- <ScrollViewer Class="entrance-theme-transition tool-page-content"- IsScrollable="@(!IsInFullScreenMode)">- @RenderToolWithHeader(true)- </ScrollViewer>-}-else-{- <div class="entrance-theme-transition tool-page-content">- @RenderToolWithHeader(false)- </div>-}+<ScrollViewer Class="entrance-theme-transition tool-page-content"+ IsScrollable="@(!IsInFullScreenMode)">+ @RenderToolWithHeader(true)+</ScrollViewer>@code {private RenderFragment<bool> RenderToolWithHeader { get; set; } = default!;diff --git a/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs b/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.csindex 001fc1e0f..07a527f68 100644--- a/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs+++ b/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs@@ -83,7 +83,6 @@ internal sealed class SampleGuiTool : IGuiToolpublic UIToolView View =>new(- isScrollable: false,_mainStack.Vertical().WithChildren(diff --git a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.csindex d98ab4799..f245800ad 100644--- a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs@@ -47,7 +47,6 @@ internal sealed class SettingsGuiTool : IGuiToolpublic UIToolView View=> new(- isScrollable: true,Stack().Vertical().WithChildren(diff --git a/src/app/dev/DevToys.Tools/Tools/Test/TestGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Test/TestGuiTool.csindex 12a1b2b7c..8c6cf019f 100644--- a/src/app/dev/DevToys.Tools/Tools/Test/TestGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Test/TestGuiTool.cs@@ -51,8 +51,6 @@ internal sealed class TestGuiTool : IGuiToolpublic UIToolView View=> new(- isScrollable: false, // This tool is non-scrollable.-Grid().ColumnLargeSpacing().RowLargeSpacing()