|
@@ -9,6 +9,8 @@ using Avalonia.Threading;
|
|
|
using Avalonia.Reactive;
|
|
using Avalonia.Reactive;
|
|
|
using Avalonia.Rendering;
|
|
using Avalonia.Rendering;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
|
+using Avalonia.Media;
|
|
|
|
|
+using Avalonia.Controls.Primitives;
|
|
|
|
|
|
|
|
namespace Avalonia.Diagnostics.ViewModels
|
|
namespace Avalonia.Diagnostics.ViewModels
|
|
|
{
|
|
{
|
|
@@ -31,7 +33,9 @@ namespace Avalonia.Diagnostics.ViewModels
|
|
|
private bool _showPropertyType;
|
|
private bool _showPropertyType;
|
|
|
private bool _showImplementedInterfaces;
|
|
private bool _showImplementedInterfaces;
|
|
|
private readonly HashSet<string> _pinnedProperties = new();
|
|
private readonly HashSet<string> _pinnedProperties = new();
|
|
|
-
|
|
|
|
|
|
|
+ private IBrush? _FocusHighlighter;
|
|
|
|
|
+ private IDisposable? _currentFocusHighlightAdorner = default;
|
|
|
|
|
+
|
|
|
public MainViewModel(AvaloniaObject root)
|
|
public MainViewModel(AvaloniaObject root)
|
|
|
{
|
|
{
|
|
|
_root = root;
|
|
_root = root;
|
|
@@ -210,10 +214,10 @@ namespace Avalonia.Diagnostics.ViewModels
|
|
|
private set { RaiseAndSetIfChanged(ref _focusedControl, value); }
|
|
private set { RaiseAndSetIfChanged(ref _focusedControl, value); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public IInputRoot? PointerOverRoot
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public IInputRoot? PointerOverRoot
|
|
|
|
|
+ {
|
|
|
get => _pointerOverRoot;
|
|
get => _pointerOverRoot;
|
|
|
- private set => RaiseAndSetIfChanged( ref _pointerOverRoot , value);
|
|
|
|
|
|
|
+ private set => RaiseAndSetIfChanged(ref _pointerOverRoot, value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public IInputElement? PointerOverElement
|
|
public IInputElement? PointerOverElement
|
|
@@ -264,7 +268,7 @@ namespace Avalonia.Diagnostics.ViewModels
|
|
|
_pointerOverSubscription.Dispose();
|
|
_pointerOverSubscription.Dispose();
|
|
|
_logicalTree.Dispose();
|
|
_logicalTree.Dispose();
|
|
|
_visualTree.Dispose();
|
|
_visualTree.Dispose();
|
|
|
-
|
|
|
|
|
|
|
+ _currentFocusHighlightAdorner?.Dispose();
|
|
|
if (TryGetRenderer() is { } renderer)
|
|
if (TryGetRenderer() is { } renderer)
|
|
|
{
|
|
{
|
|
|
renderer.Diagnostics.DebugOverlays = RendererDebugOverlays.None;
|
|
renderer.Diagnostics.DebugOverlays = RendererDebugOverlays.None;
|
|
@@ -273,7 +277,20 @@ namespace Avalonia.Diagnostics.ViewModels
|
|
|
|
|
|
|
|
private void UpdateFocusedControl()
|
|
private void UpdateFocusedControl()
|
|
|
{
|
|
{
|
|
|
- FocusedControl = KeyboardDevice.Instance?.FocusedElement?.GetType().Name;
|
|
|
|
|
|
|
+ var element = KeyboardDevice.Instance?.FocusedElement;
|
|
|
|
|
+ FocusedControl = element?.GetType().Name;
|
|
|
|
|
+ _currentFocusHighlightAdorner?.Dispose();
|
|
|
|
|
+ if (FocusHighlighter is IBrush brush
|
|
|
|
|
+ && element is InputElement input
|
|
|
|
|
+ && TopLevel.GetTopLevel(input) is { } topLevel
|
|
|
|
|
+ && (topLevel is not Views.MainWindow))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (topLevel is PopupRoot pr && pr.ParentTopLevel is Views.MainWindow)
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ _currentFocusHighlightAdorner = Controls.ControlHighlightAdorner.Add(input, brush);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void KeyboardPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
private void KeyboardPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
@@ -299,7 +316,7 @@ namespace Avalonia.Diagnostics.ViewModels
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public int? StartupScreenIndex { get; private set; } = default;
|
|
public int? StartupScreenIndex { get; private set; } = default;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
[DependsOn(nameof(TreePageViewModel.SelectedNode))]
|
|
[DependsOn(nameof(TreePageViewModel.SelectedNode))]
|
|
|
[DependsOn(nameof(Content))]
|
|
[DependsOn(nameof(Content))]
|
|
|
public bool CanShot(object? parameter)
|
|
public bool CanShot(object? parameter)
|
|
@@ -333,12 +350,13 @@ namespace Avalonia.Diagnostics.ViewModels
|
|
|
_screenshotHandler = options.ScreenshotHandler;
|
|
_screenshotHandler = options.ScreenshotHandler;
|
|
|
StartupScreenIndex = options.StartupScreenIndex;
|
|
StartupScreenIndex = options.StartupScreenIndex;
|
|
|
ShowImplementedInterfaces = options.ShowImplementedInterfaces;
|
|
ShowImplementedInterfaces = options.ShowImplementedInterfaces;
|
|
|
|
|
+ FocusHighlighter = options.FocusHighlighterBrush;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public bool ShowImplementedInterfaces
|
|
|
|
|
- {
|
|
|
|
|
- get => _showImplementedInterfaces;
|
|
|
|
|
- private set => RaiseAndSetIfChanged(ref _showImplementedInterfaces , value);
|
|
|
|
|
|
|
+ public bool ShowImplementedInterfaces
|
|
|
|
|
+ {
|
|
|
|
|
+ get => _showImplementedInterfaces;
|
|
|
|
|
+ private set => RaiseAndSetIfChanged(ref _showImplementedInterfaces, value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void ToggleShowImplementedInterfaces(object parameter)
|
|
public void ToggleShowImplementedInterfaces(object parameter)
|
|
@@ -351,14 +369,25 @@ namespace Avalonia.Diagnostics.ViewModels
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public bool ShowDetailsPropertyType
|
|
public bool ShowDetailsPropertyType
|
|
|
- {
|
|
|
|
|
- get => _showPropertyType;
|
|
|
|
|
- private set => RaiseAndSetIfChanged(ref _showPropertyType , value);
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ get => _showPropertyType;
|
|
|
|
|
+ private set => RaiseAndSetIfChanged(ref _showPropertyType, value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void ToggleShowDetailsPropertyType(object parameter)
|
|
public void ToggleShowDetailsPropertyType(object parameter)
|
|
|
{
|
|
{
|
|
|
ShowDetailsPropertyType = !ShowDetailsPropertyType;
|
|
ShowDetailsPropertyType = !ShowDetailsPropertyType;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public IBrush? FocusHighlighter
|
|
|
|
|
+ {
|
|
|
|
|
+ get => _FocusHighlighter;
|
|
|
|
|
+ private set => RaiseAndSetIfChanged(ref _FocusHighlighter, value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void SelectFocusHighlighter(object parameter)
|
|
|
|
|
+ {
|
|
|
|
|
+ FocusHighlighter = parameter as IBrush;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|