-
Notifications
You must be signed in to change notification settings - Fork 79
Add basic support for automation #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wieslawsoltes
wants to merge
11
commits into
AvaloniaUI:master
Choose a base branch
from
wieslawsoltes:AutomatioPeers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ec30c1f
Add TreeDataGridAutomationPeer
wieslawsoltes 405ccfd
Add TreeDataGridRowAutomationPeer
wieslawsoltes 46b2a73
Add TreeDataGridCellAutomationPeer
wieslawsoltes 4f385ef
Add TreeDataGridColumnHeaderAutomationPeer
wieslawsoltes ab017b3
Add TreeDataGridColumnHeadersPresenterAutomationPeer
wieslawsoltes aeb36a9
Merge branch 'master' into AutomatioPeers
wieslawsoltes 5f63dc9
Merge branch 'master' into AutomatioPeers
wieslawsoltes fff0f0c
Merge remote-tracking branch 'upstream/master' into AutomatioPeers
wieslawsoltes fd5be11
Use TreeItem for TreeDataGridRowAutomationPeer
wieslawsoltes cccc806
Implement IToggleProvider and IValueProvider for TreeDataGridRowAutom…
wieslawsoltes b02607e
Override GetNameCore() for TreeDataGridCellAutomationPeer
wieslawsoltes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/Avalonia.Controls.TreeDataGrid/Automation/Peers/TreeDataGridAutomationPeer.cs
This file contains hidden or 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,18 @@ | ||
using Avalonia.Automation.Peers; | ||
|
||
namespace Avalonia.Controls.Automation.Peers; | ||
|
||
public class TreeDataGridAutomationPeer : ControlAutomationPeer | ||
{ | ||
public TreeDataGridAutomationPeer(TreeDataGrid owner) | ||
: base(owner) | ||
{ | ||
} | ||
|
||
public new TreeDataGrid Owner => (TreeDataGrid)base.Owner; | ||
|
||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
{ | ||
return AutomationControlType.DataGrid; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Avalonia.Controls.TreeDataGrid/Automation/Peers/TreeDataGridCellAutomationPeer.cs
This file contains hidden or 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,39 @@ | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Controls.Primitives; | ||
|
||
namespace Avalonia.Controls.Automation.Peers; | ||
|
||
public class TreeDataGridCellAutomationPeer : ControlAutomationPeer | ||
{ | ||
public TreeDataGridCellAutomationPeer(TreeDataGridCell owner) | ||
: base(owner) | ||
{ | ||
} | ||
|
||
public new TreeDataGridCell Owner => (TreeDataGridCell)base.Owner; | ||
|
||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
{ | ||
return AutomationControlType.Custom; | ||
} | ||
|
||
protected override bool IsContentElementCore() => true; | ||
|
||
protected override bool IsControlElementCore() => true; | ||
|
||
protected override string? GetNameCore() | ||
{ | ||
var name = base.GetNameCore(); | ||
if (!string.IsNullOrEmpty(name)) | ||
{ | ||
return name; | ||
} | ||
|
||
return Owner switch | ||
{ | ||
TreeDataGridTextCell textCell => textCell.Value, | ||
TreeDataGridTemplateCell templateCell => templateCell.Content?.ToString(), | ||
_ => Owner.Model?.ToString() | ||
}; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...Avalonia.Controls.TreeDataGrid/Automation/Peers/TreeDataGridColumnHeaderAutomationPeer.cs
This file contains hidden or 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,23 @@ | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Controls.Primitives; | ||
|
||
namespace Avalonia.Controls.Automation.Peers; | ||
|
||
public class TreeDataGridColumnHeaderAutomationPeer : ContentControlAutomationPeer | ||
{ | ||
public TreeDataGridColumnHeaderAutomationPeer(TreeDataGridColumnHeader owner) | ||
: base(owner) | ||
{ | ||
} | ||
|
||
public new TreeDataGridColumnHeader Owner => (TreeDataGridColumnHeader)base.Owner; | ||
|
||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
{ | ||
return AutomationControlType.HeaderItem; | ||
} | ||
|
||
protected override bool IsContentElementCore() => false; | ||
|
||
protected override bool IsControlElementCore() => true; | ||
} |
23 changes: 23 additions & 0 deletions
23
...ontrols.TreeDataGrid/Automation/Peers/TreeDataGridColumnHeadersPresenterAutomationPeer.cs
This file contains hidden or 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,23 @@ | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Controls.Primitives; | ||
|
||
namespace Avalonia.Controls.Automation.Peers; | ||
|
||
public class TreeDataGridColumnHeadersPresenterAutomationPeer : ControlAutomationPeer | ||
{ | ||
public TreeDataGridColumnHeadersPresenterAutomationPeer(TreeDataGridColumnHeadersPresenter owner) | ||
: base(owner) | ||
{ | ||
} | ||
|
||
public new TreeDataGridColumnHeadersPresenter Owner => (TreeDataGridColumnHeadersPresenter)base.Owner; | ||
|
||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
{ | ||
return AutomationControlType.Header; | ||
} | ||
|
||
protected override bool IsContentElementCore() => false; | ||
|
||
protected override bool IsControlElementCore() => true; | ||
} |
61 changes: 61 additions & 0 deletions
61
src/Avalonia.Controls.TreeDataGrid/Automation/Peers/TreeDataGridRowAutomationPeer.cs
This file contains hidden or 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,61 @@ | ||
using System; | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Automation.Provider; | ||
using Avalonia.Controls.Models.TreeDataGrid; | ||
using Avalonia.Controls.Primitives; | ||
|
||
namespace Avalonia.Controls.Automation.Peers; | ||
|
||
public class TreeDataGridRowAutomationPeer : ControlAutomationPeer, IToggleProvider, IValueProvider | ||
{ | ||
public TreeDataGridRowAutomationPeer(TreeDataGridRow owner) | ||
: base(owner) | ||
{ | ||
} | ||
|
||
public new TreeDataGridRow Owner => (TreeDataGridRow)base.Owner; | ||
|
||
public ToggleState ToggleState | ||
{ | ||
get | ||
{ | ||
if (Owner.DataContext is IExpander expander) | ||
{ | ||
return expander.IsExpanded ? ToggleState.On : ToggleState.Off; | ||
} | ||
return ToggleState.Indeterminate; | ||
} | ||
} | ||
|
||
public bool IsReadOnly => true; | ||
|
||
public string? Value | ||
{ | ||
get | ||
{ | ||
return Owner.Model?.ToString(); | ||
} | ||
} | ||
|
||
protected override AutomationControlType GetAutomationControlTypeCore() | ||
{ | ||
return AutomationControlType.TreeItem; | ||
} | ||
|
||
protected override bool IsContentElementCore() => true; | ||
|
||
protected override bool IsControlElementCore() => true; | ||
|
||
public void Toggle() | ||
{ | ||
if (Owner.DataContext is IExpander expander) | ||
{ | ||
expander.IsExpanded = !expander.IsExpanded; | ||
} | ||
} | ||
|
||
public void SetValue(string? value) | ||
{ | ||
throw new InvalidOperationException("TreeDataGrid rows are read-only."); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't cell be a content control automation peer? Or just override GetNameCore
https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Automation/Peers/ContentControlAutomationPeer.cs#L16-L31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b02607e