-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add HotKeys Page to DevTools #15700
Merged
Merged
Add HotKeys Page to DevTools #15700
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
32 changes: 32 additions & 0 deletions
32
src/Avalonia.Diagnostics/Diagnostics/HotKeyConfiguration.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,32 @@ | ||
using Avalonia.Input; | ||
|
||
namespace Avalonia.Diagnostics | ||
{ | ||
internal class HotKeyConfiguration | ||
{ | ||
/// <summary> | ||
/// Freezes refreshing the Value Frames inspector for the selected Control | ||
/// </summary> | ||
public KeyGesture ValueFramesFreeze { get; init; } = new(Key.S, KeyModifiers.Alt); | ||
|
||
/// <summary> | ||
/// Resumes refreshing the Value Frames inspector for the selected Control | ||
/// </summary> | ||
public KeyGesture ValueFramesUnfreeze { get; init; } = new(Key.D, KeyModifiers.Alt); | ||
|
||
/// <summary> | ||
/// Inspects the hovered Control in the Logical or Visual Tree Page | ||
/// </summary> | ||
public KeyGesture InspectHoveredControl { get; init; } = new(Key.None, KeyModifiers.Shift | KeyModifiers.Control); | ||
|
||
/// <summary> | ||
/// Toggles the freezing of Popups which prevents visible Popups from closing so they can be inspected | ||
/// </summary> | ||
public KeyGesture TogglePopupFreeze { get; init; } = new(Key.F, KeyModifiers.Alt | KeyModifiers.Control); | ||
|
||
/// <summary> | ||
/// Saves a Screenshot of the Selected Control in the Logical or Visual Tree Page | ||
/// </summary> | ||
public KeyGesture ScreenshotSelectedControl { get; init; } = new(Key.F8); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Avalonia.Diagnostics/Diagnostics/ViewModels/HotKeyPageViewModel.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,40 @@ | ||
using System.Collections.ObjectModel; | ||
using Avalonia.Input; | ||
|
||
namespace Avalonia.Diagnostics.ViewModels | ||
{ | ||
internal record HotKeyDescription(string Gesture, string BriefDescription, string? DetailedDescription = null); | ||
|
||
internal class HotKeyPageViewModel : ViewModelBase | ||
{ | ||
private ObservableCollection<HotKeyDescription>? _hotKeyDescriptions; | ||
public ObservableCollection<HotKeyDescription>? HotKeyDescriptions | ||
{ | ||
get => _hotKeyDescriptions; | ||
private set => RaiseAndSetIfChanged(ref _hotKeyDescriptions, value); | ||
} | ||
|
||
public void SetOptions(DevToolsOptions options) | ||
{ | ||
var hotKeys = options.HotKeys; | ||
|
||
HotKeyDescriptions = new() | ||
{ | ||
new(CreateDescription(options.Gesture), "Launch DevTools", "Launches DevTools to inspect the TopLevel that received the hotkey input"), | ||
new(CreateDescription(hotKeys.ValueFramesFreeze), "Freeze Value Frames", "Pauses refreshing the Value Frames inspector for the selected Control"), | ||
new(CreateDescription(hotKeys.ValueFramesUnfreeze), "Unfreeze Value Frames", "Resumes refreshing the Value Frames inspector for the selected Control"), | ||
new(CreateDescription(hotKeys.InspectHoveredControl), "Inspect Control Under Pointer", "Inspects the hovered Control in the Logical or Visual Tree Page"), | ||
new(CreateDescription(hotKeys.TogglePopupFreeze), "Toggle Popup Freeze", "Prevents visible Popups from closing so they can be inspected"), | ||
new(CreateDescription(hotKeys.ScreenshotSelectedControl), "Screenshot Selected Control", "Saves a Screenshot of the Selected Control in the Logical or Visual Tree Page") | ||
}; | ||
} | ||
|
||
private string CreateDescription(KeyGesture gesture) | ||
{ | ||
if (gesture.Key == Key.None && gesture.KeyModifiers != KeyModifiers.None) | ||
return gesture.ToString().Replace("+None", ""); | ||
else | ||
return gesture.ToString(); | ||
} | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/Avalonia.Diagnostics/Diagnostics/Views/HotKeyPageView.axaml
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,36 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:vm="using:Avalonia.Diagnostics.ViewModels" | ||
Padding="4" | ||
x:Class="Avalonia.Diagnostics.Views.HotKeyPageView" | ||
x:DataType="vm:HotKeyPageViewModel"> | ||
<Grid RowDefinitions="auto,*" Grid.IsSharedSizeScope="True"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition SharedSizeGroup="A" Width="auto" /> | ||
<ColumnDefinition Width="8" /> | ||
<ColumnDefinition SharedSizeGroup="B" Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<TextBlock FontWeight="Bold" Text="Action" /> | ||
<TextBlock Grid.Column="2" FontWeight="Bold" Text="Gesture" /> | ||
</Grid> | ||
|
||
<ItemsControl Grid.Row="1" Grid.ColumnSpan="3" ItemsSource="{Binding HotKeyDescriptions}"> | ||
<ItemsControl.ItemTemplate> | ||
<DataTemplate> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition SharedSizeGroup="A" Width="auto" /> | ||
<ColumnDefinition Width="8" /> | ||
<ColumnDefinition SharedSizeGroup="B" Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<TextBlock Text="{Binding BriefDescription}" ToolTip.Tip="{Binding DetailedDescription}" /> | ||
<TextBlock Grid.Column="2" Text="{Binding Gesture}" /> | ||
</Grid> | ||
</DataTemplate> | ||
</ItemsControl.ItemTemplate> | ||
</ItemsControl> | ||
</Grid> | ||
</UserControl> |
18 changes: 18 additions & 0 deletions
18
src/Avalonia.Diagnostics/Diagnostics/Views/HotKeyPageView.axaml.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,18 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace Avalonia.Diagnostics.Views | ||
{ | ||
internal class HotKeyPageView : UserControl | ||
{ | ||
public HotKeyPageView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} | ||
} |
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
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
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
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.
A bit cludgy here, but changing
SelectedTab
is necessary so other tabs do not remain selected.