diff --git a/src/Ursa.Themes.Semi/Controls/Dialog.axaml b/src/Ursa.Themes.Semi/Controls/Dialog.axaml
index 1dcf7cb..0e3f58f 100644
--- a/src/Ursa.Themes.Semi/Controls/Dialog.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Dialog.axaml
@@ -1,16 +1,16 @@
+ xmlns:helpers="clr-namespace:Irihi.Avalonia.Shared.Helpers;assembly=Irihi.Avalonia.Shared"
+ xmlns:u="https://irihi.tech/ursa">
-
-
+
+
@@ -26,20 +26,22 @@
Padding="0"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
+ Background="{DynamicResource SemiColorBackground2}"
Classes="Shadow"
ClipToBounds="False"
- Background="{DynamicResource SemiColorBackground2}"
CornerRadius="{TemplateBinding CornerRadius}"
Focusable="True"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
-
+ HorizontalScrollBarVisibility="Auto"
+ VerticalScrollBarVisibility="Auto">
+
+
-
+
@@ -75,9 +77,7 @@
@@ -91,9 +91,7 @@
CommandParameter="{x:Static u:DialogLayerChangeType.BringForward}"
Header="{DynamicResource STRING_MENU_BRING_FORWARD}">
-
+
@@ -139,8 +129,8 @@
-
-
+
+
@@ -155,9 +145,9 @@
Padding="0"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
+ Background="{DynamicResource SemiColorBackground2}"
BoxShadow="0 0 8 0 #1A000000"
Classes="Shadow"
- Background="{DynamicResource SemiColorBackground2}"
ClipToBounds="False"
CornerRadius="{TemplateBinding CornerRadius}"
Focusable="True"
@@ -165,7 +155,10 @@
Theme="{DynamicResource CardBorder}">
-
+
+ VerticalAlignment="Center"
+ Classes="ExtraLarge"
+ Theme="{StaticResource InnerPathIcon}" />
-
-
-
-
+
+
+
+
-
+
-
+
@@ -240,27 +225,27 @@
@@ -112,10 +114,10 @@
Name="PART_Root"
Margin="{TemplateBinding Padding,
Converter={x:Static c:ThicknessTakeConverter.Left}}"
- Background="{DynamicResource SemiColorBackground2}"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
+ Background="{DynamicResource SemiColorBackground2}"
BorderThickness="{TemplateBinding BorderThickness,
Converter={x:Static c:ThicknessTakeConverter.Left}}"
Classes="Shadow"
@@ -127,7 +129,10 @@
Theme="{DynamicResource CardBorder}">
-
+
-
-
-
-
+
+
+
+
@@ -179,27 +176,27 @@
diff --git a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
index 17ec24a..e796aa3 100644
--- a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
+++ b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Drawer.cs
@@ -26,6 +26,8 @@ public partial class OverlayDialogHost
_layers.Add(new DialogPair(mask, control));
ResetZIndices();
+ control.MaxWidth = Math.Min(control.MaxWidth, this.Bounds.Width);
+ control.MaxHeight = Math.Min(control.MaxHeight, this.Bounds.Height);
if (mask is not null) this.Children.Add(mask);
this.Children.Add(control);
control.Measure(this.Bounds.Size);
@@ -53,6 +55,8 @@ public partial class OverlayDialogHost
internal async void AddModalDrawer(DrawerControlBase control)
{
PureRectangle mask = CreateOverlayMask(true, control.CanLightDismiss);
+ control.MaxWidth = Math.Min(control.MaxWidth, this.Bounds.Width);
+ control.MaxHeight = Math.Min(control.MaxHeight, this.Bounds.Height);
_layers.Add(new DialogPair(mask, control));
this.Children.Add(mask);
this.Children.Add(control);
diff --git a/tests/HeadlessTest.Ursa/Controls/DrawerTests/MeasureTest/DrawerMeasureTest.cs b/tests/HeadlessTest.Ursa/Controls/DrawerTests/MeasureTest/DrawerMeasureTest.cs
new file mode 100644
index 0000000..1a1b409
--- /dev/null
+++ b/tests/HeadlessTest.Ursa/Controls/DrawerTests/MeasureTest/DrawerMeasureTest.cs
@@ -0,0 +1,69 @@
+using Avalonia.Controls;
+using Avalonia.Headless.XUnit;
+using Avalonia.Threading;
+using Avalonia.VisualTree;
+using Ursa.Common;
+using Ursa.Controls;
+using Ursa.Controls.Options;
+
+namespace HeadlessTest.Ursa.Controls.DrawerTests.MeasureTest;
+
+public class DrawerMeasureTest
+{
+ [AvaloniaTheory]
+ [InlineData(Position.Left)]
+ [InlineData(Position.Right)]
+ [InlineData(Position.Top)]
+ [InlineData(Position.Bottom)]
+ public async void Default_Drawer_Is_Constrained_When_Content_Is_Large(Position position)
+ {
+ var window = new UrsaWindow
+ {
+ Height = 600,
+ Width = 800
+ };
+ var textBlock = new TextBlock
+ {
+ Width = 1000,
+ Height = 1000
+ };
+ window.Show();
+ Dispatcher.UIThread.RunJobs();
+ Drawer.ShowModal(textBlock, "hello world", null,
+ new DrawerOptions { Position = position, TopLevelHashCode = window.GetHashCode() });
+ await Task.Delay(TimeSpan.FromSeconds(0.1));
+ var dialogControl = window.GetVisualDescendants().OfType().SingleOrDefault();
+ Assert.NotNull(dialogControl);
+ Assert.True(dialogControl.Bounds.Width <= window.Bounds.Width);
+ Assert.True(dialogControl.Bounds.Height <= window.Bounds.Height);
+ }
+
+ [AvaloniaTheory]
+ [InlineData(Position.Left)]
+ [InlineData(Position.Right)]
+ [InlineData(Position.Top)]
+ [InlineData(Position.Bottom)]
+ public async void Custom_Drawer_Is_Constrained_When_Content_Is_Large(Position position)
+ {
+ var window = new UrsaWindow
+ {
+ Height = 600,
+ Width = 800
+ };
+ var textBlock = new TextBlock
+ {
+ Width = 1000,
+ Height = 1000
+ };
+ window.Show();
+ Dispatcher.UIThread.RunJobs();
+ var d = window.GetVisualDescendants().ToList();
+ Drawer.ShowCustom(textBlock, "hello world", null,
+ new DrawerOptions { Position = position, TopLevelHashCode = window.GetHashCode() });
+ await Task.Delay(TimeSpan.FromSeconds(0.1));
+ var dialogControl = window.GetVisualDescendants().OfType().SingleOrDefault();
+ Assert.NotNull(dialogControl);
+ Assert.True(dialogControl.Bounds.Width <= window.Bounds.Width);
+ Assert.True(dialogControl.Bounds.Height <= window.Bounds.Height);
+ }
+}
\ No newline at end of file