-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dragdrop): Import the core drag and drop classes
- Loading branch information
Showing
9 changed files
with
137 additions
and
19 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using Windows.Foundation; | ||
using Windows.System; | ||
using Windows.UI.Core; | ||
using Windows.UI.Input; | ||
|
||
namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core | ||
{ | ||
public partial class CoreDragInfo | ||
{ | ||
private readonly CoreWindow _window; | ||
private readonly Action<DataPackageOperation> _complete; | ||
|
||
internal CoreDragInfo( | ||
CoreWindow window, | ||
DataPackageView data, | ||
DataPackageOperation allowedOperations, | ||
Action<DataPackageOperation> complete) | ||
{ | ||
_window = window; | ||
_complete = complete; | ||
Data = data; | ||
AllowedOperations = allowedOperations; | ||
} | ||
|
||
public DataPackageView Data { get; } | ||
|
||
public DataPackageOperation AllowedOperations { get; } | ||
|
||
public DragDropModifiers Modifiers | ||
{ | ||
get | ||
{ | ||
var mods = DragDropModifiers.None; | ||
if (_window.LastPointerEvent is {} args) | ||
{ | ||
var props = args.GetLocation(null).Properties; | ||
if (props.IsLeftButtonPressed) | ||
{ | ||
mods |= DragDropModifiers.LeftButton; | ||
} | ||
if (props.IsMiddleButtonPressed) | ||
{ | ||
mods |= DragDropModifiers.MiddleButton; | ||
} | ||
if (props.IsRightButtonPressed) | ||
{ | ||
mods |= DragDropModifiers.RightButton; | ||
} | ||
} | ||
|
||
if (_window.GetAsyncKeyState(VirtualKey.Shift) == CoreVirtualKeyStates.Down) | ||
{ | ||
mods |= DragDropModifiers.Shift; | ||
} | ||
if (_window.GetAsyncKeyState(VirtualKey.Control) == CoreVirtualKeyStates.Down) | ||
{ | ||
mods |= DragDropModifiers.Control; | ||
} | ||
if (_window.GetAsyncKeyState(VirtualKey.Menu) == CoreVirtualKeyStates.Down) | ||
{ | ||
mods |= DragDropModifiers.Alt; | ||
} | ||
|
||
return mods; | ||
} | ||
} | ||
|
||
public Point Position => _window.PointerPosition; | ||
|
||
internal void Complete(DataPackageOperation result) | ||
=> _complete(result); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/CoreDragUIOverride.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#nullable enable | ||
|
||
namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core | ||
{ | ||
public partial class CoreDragUIOverride | ||
{ | ||
public bool IsGlyphVisible { get; set; } | ||
public bool IsContentVisible { get; set; } | ||
public bool IsCaptionVisible { get; set; } | ||
public string Caption { get; set; } = string.Empty; | ||
|
||
public void Clear() | ||
{ | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
.../ApplicationModel/DataTransfer/DragDrop/Core/CoreDropOperationTargetRequestedEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#nullable enable | ||
|
||
namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core | ||
{ | ||
public partial class CoreDropOperationTargetRequestedEventArgs | ||
{ | ||
internal ICoreDropOperationTarget? Target { get; private set; } | ||
|
||
public void SetTarget(ICoreDropOperationTarget target) | ||
=> Target = target; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Uno.UWP/ApplicationModel/DataTransfer/DragDrop/Core/ICoreDropOperationTarget.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#nullable enable | ||
|
||
using Windows.Foundation; | ||
|
||
namespace Windows.ApplicationModel.DataTransfer.DragDrop.Core | ||
{ | ||
public partial interface ICoreDropOperationTarget | ||
{ | ||
IAsyncOperation<DataPackageOperation> EnterAsync(CoreDragInfo dragInfo, CoreDragUIOverride dragUIOverride); | ||
IAsyncOperation<DataPackageOperation> OverAsync(CoreDragInfo dragInfo, CoreDragUIOverride dragUIOverride); | ||
IAsyncAction LeaveAsync( CoreDragInfo dragInfo); | ||
IAsyncOperation<DataPackageOperation> DropAsync(CoreDragInfo dragInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters