diff --git a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs index 20ee1a0f6..d116bff6b 100644 --- a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs +++ b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.TokenResourceKeyGenerator/TokenResourceConst.g.cs @@ -392,6 +392,8 @@ namespace AtomUI.Controls.DesignTokens public static readonly TokenResourceKey FontSize = new TokenResourceKey("TextArea.FontSize"); public static readonly TokenResourceKey FontSizeLG = new TokenResourceKey("TextArea.FontSizeLG"); public static readonly TokenResourceKey FontSizeSM = new TokenResourceKey("TextArea.FontSizeSM"); + public static readonly TokenResourceKey ResizeHandleSize = new TokenResourceKey("TextArea.ResizeHandleSize"); + public static readonly TokenResourceKey ResizeIndicatorLineColor = new TokenResourceKey("TextArea.ResizeIndicatorLineColor"); } public static class ListTokenKey diff --git a/src/AtomUI.Controls/Input/ResizeHandle.cs b/src/AtomUI.Controls/Input/ResizeHandle.cs new file mode 100644 index 000000000..768bace7b --- /dev/null +++ b/src/AtomUI.Controls/Input/ResizeHandle.cs @@ -0,0 +1,52 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Input; + +namespace AtomUI.Controls; + +internal class ResizeHandle : TemplatedControl +{ + internal TextArea? Owner { get; set; } + + private Point? _lastPoint; + private bool _dragging; + + protected override void OnPointerPressed(PointerPressedEventArgs e) + { + base.OnPointerPressed(e); + e.Handled = true; + _lastPoint = e.GetPosition(TopLevel.GetTopLevel(this)); + } + + protected override void OnPointerReleased(PointerReleasedEventArgs e) + { + base.OnPointerReleased(e); + if (_lastPoint.HasValue) + { + Owner?.NotifyResizeCompleted(); + e.Handled = true; + _lastPoint = null; + _dragging = false; + } + } + + protected override void OnPointerMoved(PointerEventArgs e) + { + base.OnPointerMoved(e); + if (_lastPoint.HasValue && e.Properties.IsLeftButtonPressed) + { + var delta = e.GetPosition(TopLevel.GetTopLevel(this)) - _lastPoint.Value; + var manhattanDistance = Math.Abs(delta.X) + Math.Abs(delta.Y); + if (manhattanDistance > Constants.DragThreshold) + { + if (!_dragging) + { + Owner?.NotifyAboutToResize(); + _dragging = true; + } + Owner?.NotifyResizing(delta); + } + } + } +} \ No newline at end of file diff --git a/src/AtomUI.Controls/Input/TextArea.cs b/src/AtomUI.Controls/Input/TextArea.cs index ec11014a7..e72df3452 100644 --- a/src/AtomUI.Controls/Input/TextArea.cs +++ b/src/AtomUI.Controls/Input/TextArea.cs @@ -6,6 +6,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; +using Avalonia.Input; using Avalonia.Media; using Avalonia.Media.TextFormatting; @@ -25,7 +26,13 @@ public class TextArea : AvaloniaTextBox, public static readonly StyledProperty IsAutoSizeProperty = AvaloniaProperty.Register(nameof(IsAutoSize), false); + + public static readonly StyledProperty IsShowCountProperty = + AvaloniaProperty.Register(nameof(IsShowCount)); + public static readonly StyledProperty IsResizableProperty = + AvaloniaProperty.Register(nameof(IsResizable)); + public static readonly StyledProperty StyleVariantProperty = AddOnDecoratedBox.StyleVariantProperty.AddOwner