diff --git a/src/Ursa.Themes.Semi/Controls/Resizer.axaml b/src/Ursa.Themes.Semi/Controls/Resizer.axaml new file mode 100644 index 0000000..59e5ced --- /dev/null +++ b/src/Ursa.Themes.Semi/Controls/Resizer.axaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Ursa.Themes.Semi/Controls/UrsaWindow.axaml b/src/Ursa.Themes.Semi/Controls/UrsaWindow.axaml index aafb7f0..1f1fe30 100644 --- a/src/Ursa.Themes.Semi/Controls/UrsaWindow.axaml +++ b/src/Ursa.Themes.Semi/Controls/UrsaWindow.axaml @@ -71,7 +71,13 @@ LeftContent="{Binding $parent[u:UrsaWindow].LeftContent}" RightContent="{Binding $parent[u:UrsaWindow].RightContent}" /> - + + + + @@ -82,6 +88,7 @@ VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" /> + diff --git a/src/Ursa.Themes.Semi/Controls/_index.axaml b/src/Ursa.Themes.Semi/Controls/_index.axaml index f8947d3..4ad1527 100644 --- a/src/Ursa.Themes.Semi/Controls/_index.axaml +++ b/src/Ursa.Themes.Semi/Controls/_index.axaml @@ -37,6 +37,7 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Shared/Resizer.axaml b/src/Ursa.Themes.Semi/Themes/Shared/Resizer.axaml new file mode 100644 index 0000000..68866f1 --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Shared/Resizer.axaml @@ -0,0 +1,6 @@ + + + 6 + 6 + diff --git a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml index 638a5bf..a47bb98 100644 --- a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml @@ -1,29 +1,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa/Controls/Resizers/ResizeDirection.cs b/src/Ursa/Controls/Resizers/ResizeDirection.cs new file mode 100644 index 0000000..f6b5899 --- /dev/null +++ b/src/Ursa/Controls/Resizers/ResizeDirection.cs @@ -0,0 +1,13 @@ +namespace Ursa.Controls; + +public enum ResizeDirection +{ + Top, + Bottom, + Left, + Right, + TopLeft, + TopRight, + BottomLeft, + BottomRight, +} \ No newline at end of file diff --git a/src/Ursa/Controls/Resizers/WindowResizer.cs b/src/Ursa/Controls/Resizers/WindowResizer.cs new file mode 100644 index 0000000..940fcc6 --- /dev/null +++ b/src/Ursa/Controls/Resizers/WindowResizer.cs @@ -0,0 +1,8 @@ +using Avalonia.Controls.Primitives; + +namespace Ursa.Controls; + +public class WindowResizer : TemplatedControl +{ + +} \ No newline at end of file diff --git a/src/Ursa/Controls/Resizers/WindowResizerThumb.cs b/src/Ursa/Controls/Resizers/WindowResizerThumb.cs new file mode 100644 index 0000000..480da62 --- /dev/null +++ b/src/Ursa/Controls/Resizers/WindowResizerThumb.cs @@ -0,0 +1,45 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Input; + +namespace Ursa.Controls; + +public class WindowResizerThumb: Thumb +{ + private Window? _window; + + public static readonly StyledProperty ResizeDirectionProperty = AvaloniaProperty.Register( + nameof(ResizeDirection)); + + public ResizeDirection ResizeDirection + { + get => GetValue(ResizeDirectionProperty); + set => SetValue(ResizeDirectionProperty, value); + } + + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) + { + base.OnApplyTemplate(e); + _window = TopLevel.GetTopLevel(this) as Window; + } + + protected override void OnPointerPressed(PointerPressedEventArgs e) + { + base.OnPointerPressed(e); + if (_window is null || !_window.CanResize) return; + var windowEdge = ResizeDirection switch + { + ResizeDirection.Top => WindowEdge.North, + ResizeDirection.TopRight => WindowEdge.NorthEast, + ResizeDirection.Right => WindowEdge.East, + ResizeDirection.BottomRight => WindowEdge.SouthEast, + ResizeDirection.Bottom => WindowEdge.South, + ResizeDirection.BottomLeft => WindowEdge.SouthWest, + ResizeDirection.Left => WindowEdge.West, + ResizeDirection.TopLeft => WindowEdge.NorthWest, + _ => throw new ArgumentOutOfRangeException() + }; + _window.BeginResizeDrag(windowEdge, e); + } +} \ No newline at end of file diff --git a/src/Ursa/Windows/UrsaWindow.cs b/src/Ursa/Windows/UrsaWindow.cs index 73ebd67..a6be365 100644 --- a/src/Ursa/Windows/UrsaWindow.cs +++ b/src/Ursa/Windows/UrsaWindow.cs @@ -54,6 +54,15 @@ public class UrsaWindow: Window get => GetValue(IsTitleBarVisibleProperty); set => SetValue(IsTitleBarVisibleProperty, value); } + + public static readonly StyledProperty IsManagedResizerVisibleProperty = AvaloniaProperty.Register( + nameof(IsManagedResizerVisible)); + + public bool IsManagedResizerVisible + { + get => GetValue(IsManagedResizerVisibleProperty); + set => SetValue(IsManagedResizerVisibleProperty, value); + } public static readonly StyledProperty TitleBarContentProperty = AvaloniaProperty.Register( nameof(TitleBarContent));