feat: support full screen.
This commit is contained in:
@@ -14,12 +14,13 @@ namespace Ursa.Controls;
|
||||
|
||||
[TemplatePart(PART_CloseButton, typeof(Button))]
|
||||
[TemplatePart(PART_TitleArea, typeof(Panel))]
|
||||
[PseudoClasses(PC_Modal)]
|
||||
[PseudoClasses(PC_Modal, PC_FullScreen)]
|
||||
public abstract class DialogControlBase : OverlayFeedbackElement
|
||||
{
|
||||
public const string PART_CloseButton = "PART_CloseButton";
|
||||
public const string PART_TitleArea = "PART_TitleArea";
|
||||
public const string PC_Modal = ":modal";
|
||||
public const string PC_FullScreen = ":full-screen";
|
||||
|
||||
internal HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
||||
internal VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
||||
@@ -31,6 +32,17 @@ public abstract class DialogControlBase : OverlayFeedbackElement
|
||||
internal double? VerticalOffsetRatio { get; set; }
|
||||
internal bool CanLightDismiss { get; set; }
|
||||
|
||||
private bool _isFullScreen;
|
||||
|
||||
public static readonly DirectProperty<DialogControlBase, bool> IsFullScreenProperty = AvaloniaProperty.RegisterDirect<DialogControlBase, bool>(
|
||||
nameof(IsFullScreen), o => o.IsFullScreen, (o, v) => o.IsFullScreen = v);
|
||||
|
||||
public bool IsFullScreen
|
||||
{
|
||||
get => _isFullScreen;
|
||||
set => SetAndRaise(IsFullScreenProperty, ref _isFullScreen, value);
|
||||
}
|
||||
|
||||
protected internal Button? _closeButton;
|
||||
private Panel? _titleArea;
|
||||
|
||||
@@ -133,6 +145,7 @@ public abstract class DialogControlBase : OverlayFeedbackElement
|
||||
{
|
||||
CanDragMoveProperty.Changed.AddClassHandler<InputElement, bool>(OnCanDragMoveChanged);
|
||||
CanCloseProperty.Changed.AddClassHandler<InputElement, bool>(OnCanCloseChanged);
|
||||
IsFullScreenProperty.AffectsPseudoClass<DialogControlBase>(PC_FullScreen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ public enum VerticalPosition
|
||||
public class OverlayDialogOptions
|
||||
{
|
||||
internal static OverlayDialogOptions Default { get; } = new OverlayDialogOptions();
|
||||
public bool FullScreen { get; set; }
|
||||
public HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
||||
public VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using Ursa.Common;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
@@ -181,6 +182,12 @@ public static class OverlayDialog
|
||||
private static void ConfigureCustomDialogControl(CustomDialogControl control, OverlayDialogOptions? options)
|
||||
{
|
||||
options ??= OverlayDialogOptions.Default;
|
||||
control.IsFullScreen = options.FullScreen;
|
||||
if (options.FullScreen)
|
||||
{
|
||||
control.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
control.VerticalAlignment = VerticalAlignment.Stretch;
|
||||
}
|
||||
control.HorizontalAnchor = options.HorizontalAnchor;
|
||||
control.VerticalAnchor = options.VerticalAnchor;
|
||||
control.ActualHorizontalAnchor = options.HorizontalAnchor;
|
||||
@@ -197,6 +204,12 @@ public static class OverlayDialog
|
||||
private static void ConfigureDefaultDialogControl(DefaultDialogControl control, OverlayDialogOptions? options)
|
||||
{
|
||||
if (options is null) options = new OverlayDialogOptions();
|
||||
control.IsFullScreen = options.FullScreen;
|
||||
if (options.FullScreen)
|
||||
{
|
||||
control.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
control.VerticalAlignment = VerticalAlignment.Stretch;
|
||||
}
|
||||
control.HorizontalAnchor = options.HorizontalAnchor;
|
||||
control.VerticalAnchor = options.VerticalAnchor;
|
||||
control.ActualHorizontalAnchor = options.HorizontalAnchor;
|
||||
|
||||
@@ -133,6 +133,11 @@ public partial class OverlayDialogHost
|
||||
ResetZIndices();
|
||||
this.Children.Add(mask);
|
||||
this.Children.Add(control);
|
||||
if (control.IsFullScreen)
|
||||
{
|
||||
control.Width = Bounds.Width;
|
||||
control.Height = Bounds.Height;
|
||||
}
|
||||
control.Measure(this.Bounds.Size);
|
||||
control.Arrange(new Rect(control.DesiredSize));
|
||||
SetToPosition(control);
|
||||
|
||||
Reference in New Issue
Block a user