Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/Dock.Avalonia/Internal/WindowDragHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Dock.Avalonia.Internal;
/// <summary>
/// Helper that enables starting window drag operations from custom controls.
/// </summary>
internal class WindowDragHelper
public class WindowDragHelper
{
private readonly Control _owner;
private readonly Func<bool> _isEnabled;
Expand All @@ -33,6 +33,9 @@ internal class WindowDragHelper
private IDisposable[]? _disposables;
private IDisposable? _releasedEventDisposable;

/// <summary>
/// Initializes a helper that starts tracked window move drags from a custom control.
/// </summary>
public WindowDragHelper(
Control owner,
Func<bool> isEnabled,
Expand All @@ -47,6 +50,9 @@ public WindowDragHelper(
_getDockScope = getDockScope ?? (_ => WindowDragDockScope.FullWindow);
}

/// <summary>
/// Attaches pointer handlers to the owner control.
/// </summary>
public void Attach()
{
Detach();
Expand All @@ -58,6 +64,9 @@ public void Attach()
];
}

/// <summary>
/// Detaches pointer handlers and clears any in-progress drag state.
/// </summary>
public void Detach()
{
if (_disposables != null)
Expand Down Expand Up @@ -262,7 +271,11 @@ private IDisposable SubscribeToPointerReleased(Window window)
return window.AddDisposableHandler(InputElement.PointerReleasedEvent, OnPointerReleased, RoutingStrategies.Tunnel);
}

internal static bool IsChildOfType<T>(Control owner, Control control) where T : Control
/// <summary>
/// Determines whether <paramref name="control"/> has an ancestor of type <typeparamref name="T"/>
/// before reaching <paramref name="owner"/>.
/// </summary>
public static bool IsChildOfType<T>(Control owner, Control control) where T : Control
{
var parent = control;
while (parent != null && parent != owner)
Expand Down
Loading