forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement
ScrollViewerAutomationPeer
- Loading branch information
1 parent
2b3ab69
commit c1707ef
Showing
2 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
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
86 changes: 86 additions & 0 deletions
86
src/Uno.UI/UI/Xaml/Automation/Peers/ScrollBarAutomationPeer.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,86 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
// MUX Reference ScrollBarAutomationPeer_Partial.cpp, tag winui3/release/1.4.2 | ||
using DirectUI; | ||
using Windows.Foundation; | ||
|
||
namespace Microsoft.UI.Xaml.Automation.Peers; | ||
|
||
/// <summary> | ||
/// Exposes ScrollBar types to UI Automation. | ||
/// </summary> | ||
public partial class ScrollBarAutomationPeer : RangeBaseAutomationPeer | ||
{ | ||
private const string UIA_SCROLLBAR_HORIZONTAL = nameof(UIA_SCROLLBAR_HORIZONTAL); | ||
private const string UIA_SCROLLBAR_VERTICAL = nameof(UIA_SCROLLBAR_VERTICAL); | ||
|
||
public ScrollBarAutomationPeer(Controls.Primitives.ScrollBar owner) : base(owner) | ||
{ | ||
} | ||
|
||
protected override string GetClassNameCore() => nameof(Controls.Primitives.ScrollBar); | ||
|
||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
=> AutomationControlType.ScrollBar; | ||
|
||
protected override Point GetClickablePointCore() | ||
=> new(DoubleUtil.NaN, DoubleUtil.NaN); | ||
|
||
protected override AutomationOrientation GetOrientationCore() | ||
{ | ||
var owner = Owner as Controls.Primitives.ScrollBar; | ||
|
||
if (owner.Orientation == Controls.Orientation.Horizontal) | ||
{ | ||
return AutomationOrientation.Horizontal; | ||
} | ||
else | ||
{ | ||
return AutomationOrientation.Vertical; | ||
} | ||
} | ||
|
||
protected override bool IsContentElementCore() => false; | ||
|
||
private protected override bool ChildIsAcceptable(UIElement element) | ||
{ | ||
var childIsAcceptable = base.ChildIsAcceptable(element); | ||
|
||
if (childIsAcceptable) | ||
{ | ||
var owner = Owner as Controls.Primitives.ScrollBar; | ||
|
||
//UNO TODO: ElementHorizontalTemplate and ElementVerticalTemplate on ScrollBar | ||
var elementHorizontalTemplate = owner.ElementHorizontalTemplate; | ||
var elementVerticalTemplate = owner.ElementVerticalTemplate; | ||
|
||
if (element == elementHorizontalTemplate || element == elementVerticalTemplate) | ||
{ | ||
return element.Visibility == Visibility.Visible; | ||
} | ||
} | ||
|
||
return childIsAcceptable; | ||
} | ||
|
||
protected override string GetNameCore() | ||
{ | ||
var returnValue = base.GetNameCore(); | ||
|
||
if (string.IsNullOrEmpty(returnValue)) | ||
{ | ||
var owner = Owner as Controls.Primitives.ScrollBar; | ||
|
||
if (owner.Orientation == Controls.Orientation.Horizontal) | ||
{ | ||
return DXamlCore.Current.GetLocalizedResourceString(UIA_SCROLLBAR_HORIZONTAL); | ||
} | ||
else | ||
{ | ||
return DXamlCore.Current.GetLocalizedResourceString(UIA_SCROLLBAR_VERTICAL); | ||
} | ||
} | ||
|
||
return returnValue; | ||
} | ||
} |