Browse Source
Convert ExpandCollapseState to its UIA wire value in the Win32 automation layer; Avalonia declares PartiallyExpanded and LeafNode in the opposite order from UIA. (#21693 )
pull/21695/head
Jumar Macato
3 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
16 additions and
6 deletions
src/Windows/Avalonia.Win32.Automation/AutomationNode.ExpandCollapse.cs
src/Windows/Avalonia.Win32.Automation/AutomationNode.cs
src/Windows/Avalonia.Win32.Automation/Interop/IExpandCollapseProvider.cs
@ -6,11 +6,22 @@ namespace Avalonia.Win32.Automation
{
internal partial class AutomationNode : UIA . IExpandCollapseProvider
{
ExpandCollapseState UIA . IExpandCollapseProvider . GetExpandCollapseState ( )
int UIA . IExpandCollapseProvider . GetExpandCollapseState ( )
{
return InvokeSync < IExpandCollapseProvider , ExpandCollapseState > ( x = > x . ExpandCollapseState ) ;
return ToUiaExpandCollapseState ( InvokeSync < IExpandCollapseProvider , ExpandCollapseState > ( x = > x . ExpandCollapseState ) ) ;
}
// Avalonia declares PartiallyExpanded and LeafNode in the opposite order
// from the UIA wire values.
internal static int ToUiaExpandCollapseState ( ExpandCollapseState state ) = > state switch
{
ExpandCollapseState . Collapsed = > 0 ,
ExpandCollapseState . Expanded = > 1 ,
ExpandCollapseState . PartiallyExpanded = > 2 ,
ExpandCollapseState . LeafNode = > 3 ,
_ = > 0 ,
} ;
void UIA . IExpandCollapseProvider . Expand ( ) = > InvokeSync < IExpandCollapseProvider > ( x = > x . Expand ( ) ) ;
void UIA . IExpandCollapseProvider . Collapse ( ) = > InvokeSync < IExpandCollapseProvider > ( x = > x . Collapse ( ) ) ;
}
@ -301,8 +301,8 @@ namespace Avalonia.Win32.Automation
UiaCoreProviderApi . UiaRaiseAutomationPropertyChangedEvent (
this ,
( int ) id ,
e . OldValue as IConvertible ,
e . NewValue as IConvertible ) ;
e . OldValue is ExpandCollapseState o ? ToUiaExpandCollapseState ( o ) : e . OldValue as IConvertible ,
e . NewValue is ExpandCollapseState n ? ToUiaExpandCollapseState ( n ) : e . NewValue as IConvertible ) ;
}
if ( id = = UiaPropertyId . Name & & Peer . GetLiveSetting ( ) ! = AutomationLiveSetting . Off )
@ -1,6 +1,5 @@
using System.Runtime.InteropServices ;
using System.Runtime.InteropServices.Marshalling ;
using Avalonia.Automation ;
namespace Avalonia.Win32.Automation.Interop ;
@ -10,5 +9,5 @@ internal partial interface IExpandCollapseProvider
{
void Expand ( ) ;
void Collapse ( ) ;
ExpandCollapseState GetExpandCollapseState ( ) ;
int GetExpandCollapseState ( ) ;
}