Skip to content

Commit

Permalink
feat: Implement new focus-related types
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Apr 15, 2024
1 parent 49b637f commit ed17993
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Input
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class FocusChangedEventArgs
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
internal FocusChangedEventArgs()
{
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool Handled
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Input
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class FocusNavigationRequest
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
internal FocusNavigationRequest()
{
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Guid CorrelationId
{
Expand All @@ -23,7 +23,7 @@ internal FocusNavigationRequest()
}
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.Foundation.Rect? HintRect
{
Expand All @@ -33,7 +33,7 @@ internal FocusNavigationRequest()
}
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.UI.Input.FocusNavigationReason Reason
{
Expand All @@ -46,21 +46,21 @@ internal FocusNavigationRequest()
// Forced skipping of method Microsoft.UI.Input.FocusNavigationRequest.Reason.get
// Forced skipping of method Microsoft.UI.Input.FocusNavigationRequest.HintRect.get
// Forced skipping of method Microsoft.UI.Input.FocusNavigationRequest.CorrelationId.get
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Input.FocusNavigationRequest Create(global::Microsoft.UI.Input.FocusNavigationReason reason)
{
throw new global::System.NotImplementedException("The member FocusNavigationRequest FocusNavigationRequest.Create(FocusNavigationReason reason) is not implemented. For more information, visit https://aka.platform.uno/notimplemented#m=FocusNavigationRequest%20FocusNavigationRequest.Create%28FocusNavigationReason%20reason%29");
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Input.FocusNavigationRequest Create(global::Microsoft.UI.Input.FocusNavigationReason reason, global::Windows.Foundation.Rect hintRect)
{
throw new global::System.NotImplementedException("The member FocusNavigationRequest FocusNavigationRequest.Create(FocusNavigationReason reason, Rect hintRect) is not implemented. For more information, visit https://aka.platform.uno/notimplemented#m=FocusNavigationRequest%20FocusNavigationRequest.Create%28FocusNavigationReason%20reason%2C%20Rect%20hintRect%29");
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Input.FocusNavigationRequest Create(global::Microsoft.UI.Input.FocusNavigationReason reason, global::Windows.Foundation.Rect hintRect, global::System.Guid correlationId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Input
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class FocusNavigationRequestEventArgs
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
internal FocusNavigationRequestEventArgs()
{
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.UI.Input.FocusNavigationResult Result
{
Expand All @@ -27,7 +27,7 @@ internal FocusNavigationRequestEventArgs()
}
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.UI.Input.FocusNavigationRequest Request
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Input
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
public enum FocusNavigationResult
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
NotMoved = 0,
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
Moved = 1,
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
NoFocusableElements = 2,
#endif
}
Expand Down
16 changes: 16 additions & 0 deletions src/Uno.UI/Microsoft/UI/Input/FocusChangedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Microsoft.UI.Input;

/// <summary>
/// Contains event data for the InputFocusController.GotFocus and InputFocusController.LostFocus events.
/// </summary>
public partial class FocusChangedEventArgs
{
internal FocusChangedEventArgs()
{
}

/// <summary>
/// Gets or sets whether the InputFocusController.GotFocus and InputFocusController.LostFocus events were handled.
/// </summary>
public bool Handled { get; set; }
}
49 changes: 49 additions & 0 deletions src/Uno.UI/Microsoft/UI/Input/FocusNavigationReason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// <auto-generated>
#pragma warning disable 108 // new keyword hiding
namespace Microsoft.UI.Input;

/// <summary>
/// Specifies the possible reasons for a focus navigation event.
/// </summary>
public enum FocusNavigationReason
{
/// <summary>
/// Programmatically perform focus navigation.
/// </summary>
Programmatic = 0,

/// <summary>
/// Restore focus to a previous state.
/// </summary>
Restore = 1,

/// <summary>
/// Navigate to the first element in the focus recipient.
/// </summary>
First = 2,

/// <summary>
/// Navigate to the last element in the focus recipient.
/// </summary>
Last = 3,

/// <summary>
/// Navigate focus left.
/// </summary>
Left = 4,

/// <summary>
/// Navigate focus up.
/// </summary>
Up = 5,

/// <summary>
/// Navigate focus right.
/// </summary>
Right = 6,

/// <summary>
/// Navigate focus down.
/// </summary>
Down = 7,
}
61 changes: 61 additions & 0 deletions src/Uno.UI/Microsoft/UI/Input/FocusNavigationRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using Windows.Foundation;

namespace Microsoft.UI.Input;

/// <summary>
/// Provides details for focus navigation events.
/// </summary>
public partial class FocusNavigationRequest
{
internal FocusNavigationRequest(FocusNavigationReason reason)
{
Reason = reason;
}

/// <summary>
/// Gets the unique ID generated when a focus movement event is initiated.
/// </summary>
public Guid CorrelationId { get; init; }

/// <summary>
/// Gets the reason for a focus navigation event.
/// </summary>
public FocusNavigationReason Reason { get; }

/// <summary>
/// Gets the bounding rectangle used to identify the focus candidates most likely to receive navigation focus.
/// </summary>
public Rect? HintRect { get; init; }

/// <summary>
/// Creates an instance of FocusNavigationRequest using the specified FocusNavigationReason.
/// </summary>
/// <param name="reason">The reason for a focus navigation event.</param>
/// <returns>A FocusNavigationRequest object.</returns>
public static FocusNavigationRequest Create(FocusNavigationReason reason) => new(reason);

/// <summary>
/// Creates an instance of FocusNavigationRequest using the specified FocusNavigationReason and hint Rect.
/// </summary>
/// <param name="reason">The reason for a focus navigation event.</param>
/// <param name="hintRect">The bounding rectangle used to identify the focus candidates most likely to receive navigation focus.</param>
/// <returns>A FocusNavigationRequest object.</returns>
public static FocusNavigationRequest Create(FocusNavigationReason reason, Rect hintRect) => new(reason)
{
HintRect = hintRect
};

/// <summary>
/// Creates an instance of FocusNavigationRequest using the specified FocusNavigationReason, hint Rect, and unique identifier.
/// </summary>
/// <param name="reason">The reason for a focus navigation event.</param>
/// <param name="hintRect">The bounding rectangle used to identify the focus candidates most likely to receive navigation focus.</param>
/// <param name="correlationId">The unique ID generated when a focus movement event is initiated.</param>
/// <returns>A FocusNavigationRequest object.</returns>
public static FocusNavigationRequest Create(FocusNavigationReason reason, Rect hintRect, Guid correlationId) => new(reason)
{
HintRect = hintRect,
CorrelationId = correlationId
};
}
24 changes: 24 additions & 0 deletions src/Uno.UI/Microsoft/UI/Input/FocusNavigationRequestEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace Microsoft.UI.Input;

/// <summary>
/// Contains event data for the InputFocusController.NavigateFocusRequested and InputFocusNavigationHost.DepartFocusRequested events.
/// </summary>
public partial class FocusNavigationRequestEventArgs
{
internal FocusNavigationRequestEventArgs(FocusNavigationRequest request)
{
Request = request ?? throw new ArgumentNullException(nameof(request));
}

/// <summary>
/// Gets the details for focus navigation event.
/// </summary>
public FocusNavigationRequest Request { get; }

/// <summary>
/// Gets or sets the result of a focus navigation event.
/// </summary>
public FocusNavigationResult Result { get; set; }
}
22 changes: 22 additions & 0 deletions src/Uno.UI/Microsoft/UI/Input/FocusNavigationResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Microsoft.UI.Input;

/// <summary>
/// Specifies the possible results of a focus navigation event.
/// </summary>
public enum FocusNavigationResult
{
/// <summary>
/// Event was not subscribed or the event ran into an error. This is the default value.
/// </summary>
NotMoved = 0,

/// <summary>
/// Focus successfully moved to another component.
/// </summary>
Moved = 1,

/// <summary>
/// No focusable element was found.
/// </summary>
NoFocusableElements = 2,
}

0 comments on commit ed17993

Please sign in to comment.