1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Profile editor - Ensure hotkeys work whenever working i nthe editor

This commit is contained in:
Robert 2022-06-08 21:19:08 +02:00
parent 0d3890e560
commit 38986b73ac
8 changed files with 59 additions and 21 deletions

View File

@ -32,6 +32,7 @@
<entry key="Artemis.UI/Screens/Plugins/PluginSettingsView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/DisplayCondition/ConditionTypes/StaticConditionView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/MenuBar/MenuBarView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Playback/PlaybackView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/AdaptionHints/CategoryAdaptionHintView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/AdaptionHints/DeviceAdaptionHintView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/AdaptionHints/KeyboardSectionAdaptionHintView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />

View File

@ -7,7 +7,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.ProfileEditor.MenuBar.MenuBarView"
x:DataType="menuBar:MenuBarViewModel">
<Menu VerticalAlignment="Top">
<Menu VerticalAlignment="Top" MenuClosed="MenuBase_OnMenuClosed">
<MenuItem Header="_File">
<MenuItem Header="New">
<MenuItem.Icon>
@ -63,7 +63,7 @@
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Header="_Edit" SubmenuOpened="MenuItem_OnSubmenuOpened">
<MenuItem Header="_Edit">
<MenuItem Header="_Undo" Command="{CompiledBinding History.Undo}" InputGesture="Ctrl+Z">
<MenuItem.Icon>
<avalonia:MaterialIcon Kind="Undo" />

View File

@ -1,6 +1,8 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using Avalonia.VisualTree;
namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
@ -16,7 +18,9 @@ public class MenuBarView : ReactiveUserControl<MenuBarViewModel>
AvaloniaXamlLoader.Load(this);
}
private void MenuItem_OnSubmenuOpened(object? sender, RoutedEventArgs e)
private void MenuBase_OnMenuClosed(object? sender, RoutedEventArgs e)
{
ProfileEditorView? profileEditorView = this.FindAncestorOfType<Window>().FindDescendantOfType<ProfileEditorView>();
profileEditorView?.Focus();
}
}

View File

@ -10,33 +10,33 @@
<DockPanel Margin="8 0">
<StackPanel Orientation="Horizontal" Spacing="5">
<Button Classes="icon-button icon-button-large"
ToolTip.Tip="Play from start (Shift+Space)" Command="{Binding PlayFromStart}"
ToolTip.Tip="Play from start (Shift+Space)" Command="{CompiledBinding PlayFromStart}"
Focusable="False">
<avalonia:MaterialIcon Kind="StepForward" />
</Button>
<Button Classes="icon-button icon-button-large"
ToolTip.Tip="Toggle play/pause (Space)" Command="{Binding TogglePlay}" Focusable="False">
ToolTip.Tip="Toggle play/pause (Space)" Command="{CompiledBinding TogglePlay}" Focusable="False">
<StackPanel>
<avalonia:MaterialIcon Kind="Play" IsVisible="{CompiledBinding !Playing}" />
<avalonia:MaterialIcon Kind="Pause" IsVisible="{CompiledBinding Playing}" />
</StackPanel>
</Button>
<Button Classes="icon-button icon-button-large" ToolTip.Tip="Go to start" Command="{Binding GoToStart}" Focusable="False">
<Button Classes="icon-button icon-button-large" ToolTip.Tip="Go to start" Command="{CompiledBinding GoToStart}" Focusable="False">
<avalonia:MaterialIcon Kind="SkipBackward" />
</Button>
<Button Classes="icon-button icon-button-large" ToolTip.Tip="Go to end" Command="{Binding GoToEnd}" Focusable="False">
<Button Classes="icon-button icon-button-large" ToolTip.Tip="Go to end" Command="{CompiledBinding GoToEnd}" Focusable="False">
<avalonia:MaterialIcon Kind="SkipForward" />
</Button>
<Button Classes="icon-button icon-button-large" ToolTip.Tip="Previous frame" Command="{Binding GoToPreviousFrame}" Focusable="False">
<Button Classes="icon-button icon-button-large" ToolTip.Tip="Previous frame" Command="{CompiledBinding GoToPreviousFrame}" Focusable="False">
<avalonia:MaterialIcon Kind="SkipPrevious" />
</Button>
<Button Classes="icon-button icon-button-large" ToolTip.Tip="Next frame" Command="{Binding GoToNextFrame}" Focusable="False">
<Button Classes="icon-button icon-button-large" ToolTip.Tip="Next frame" Command="{CompiledBinding GoToNextFrame}" Focusable="False">
<avalonia:MaterialIcon Kind="SkipNext" />
</Button>
<ToggleButton Classes="icon-button icon-button-large"
IsChecked="{CompiledBinding Repeating}"
Focusable="False"
Command="{Binding CycleRepeating}">
Command="{CompiledBinding CycleRepeating}">
<ToolTip.Tip>
<StackPanel>
<StackPanel IsVisible="{CompiledBinding Repeating}">

View File

@ -1,4 +1,5 @@
using System;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Artemis.Core;
@ -40,8 +41,15 @@ public class PlaybackViewModel : ActivatableViewModelBase
updateTimer.Start();
Disposable.Create(() => updateTimer.Stop());
});
}
PlayFromStart = ReactiveCommand.Create(ExecutePlayFromStart);
TogglePlay = ReactiveCommand.Create(ExecuteTogglePlay);
GoToStart = ReactiveCommand.Create(ExecuteGoToStart);
GoToEnd = ReactiveCommand.Create(ExecuteGoToEnd);
GoToPreviousFrame = ReactiveCommand.Create(ExecuteGoToPreviousFrame);
GoToNextFrame = ReactiveCommand.Create(ExecuteGoToNextFrame);
CycleRepeating = ReactiveCommand.Create(ExecuteCycleRepeating);
}
public TimeSpan CurrentTime => _currentTime?.Value ?? TimeSpan.Zero;
public string? FormattedCurrentTime => _formattedCurrentTime?.Value;
@ -64,15 +72,23 @@ public class PlaybackViewModel : ActivatableViewModelBase
get => _repeatSegment;
set => RaiseAndSetIfChanged(ref _repeatSegment, value);
}
public ReactiveCommand<Unit,Unit> PlayFromStart { get; }
public ReactiveCommand<Unit,Unit> TogglePlay { get; }
public ReactiveCommand<Unit,Unit> GoToStart { get; }
public ReactiveCommand<Unit,Unit> GoToEnd { get; }
public ReactiveCommand<Unit,Unit> GoToPreviousFrame { get; }
public ReactiveCommand<Unit,Unit> GoToNextFrame { get; }
public ReactiveCommand<Unit,Unit> CycleRepeating { get; }
public void PlayFromStart()
private void ExecutePlayFromStart()
{
GoToStart();
ExecuteGoToStart();
if (!Playing)
_profileEditorService.Play();
}
public void TogglePlay()
private void ExecuteTogglePlay()
{
if (!Playing)
_profileEditorService.Play();
@ -80,12 +96,12 @@ public class PlaybackViewModel : ActivatableViewModelBase
_profileEditorService.Pause();
}
public void GoToStart()
private void ExecuteGoToStart()
{
_profileEditorService.ChangeTime(TimeSpan.Zero);
}
public void GoToEnd()
private void ExecuteGoToEnd()
{
if (_profileElement == null)
return;
@ -93,7 +109,7 @@ public class PlaybackViewModel : ActivatableViewModelBase
_profileEditorService.ChangeTime(_profileElement.Timeline.EndSegmentEndPosition);
}
public void GoToPreviousFrame()
private void ExecuteGoToPreviousFrame()
{
if (_profileElement == null)
return;
@ -103,7 +119,7 @@ public class PlaybackViewModel : ActivatableViewModelBase
_profileEditorService.ChangeTime(TimeSpan.FromMilliseconds(newTime));
}
public void GoToNextFrame()
private void ExecuteGoToNextFrame()
{
if (_profileElement == null)
return;
@ -114,7 +130,7 @@ public class PlaybackViewModel : ActivatableViewModelBase
_profileEditorService.ChangeTime(TimeSpan.FromMilliseconds(newTime));
}
public void CycleRepeating()
private void ExecuteCycleRepeating()
{
if (!Repeating)
{

View File

@ -8,7 +8,8 @@
xmlns:shared="clr-namespace:Artemis.UI.Shared.Services.ProfileEditor;assembly=Artemis.UI.Shared"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView"
x:DataType="profileEditor:ProfileEditorViewModel">
x:DataType="profileEditor:ProfileEditorViewModel"
Name="ProfileEditorView">
<UserControl.Resources>
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" />
</UserControl.Resources>
@ -25,6 +26,8 @@
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y" />
<KeyBinding Command="{CompiledBinding ToggleSuspend}" Gesture="F5" />
<KeyBinding Command="{CompiledBinding ToggleAutoSuspend}" Gesture="Shift+F5" />
<KeyBinding Command="{CompiledBinding PropertiesViewModel.PlaybackViewModel.TogglePlay}" Gesture="Space" />
<KeyBinding Command="{CompiledBinding PropertiesViewModel.PlaybackViewModel.PlayFromStart}" Gesture="Shift+Space" />
</UserControl.KeyBindings>
<UserControl.Styles>
<Style Selector="GridSplitter.editor-grid-splitter-vertical">

View File

@ -1,3 +1,4 @@
using Avalonia;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
@ -11,6 +12,17 @@ public class ProfileEditorView : ReactiveUserControl<ProfileEditorViewModel>
InitializeComponent();
}
#region Overrides of Visual
/// <inheritdoc />
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
Focus();
}
#endregion
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);

View File

@ -98,6 +98,8 @@ public class ProfileEditorViewModel : MainScreenViewModel
private void ExecuteToggleAutoSuspend()
{
// TODO
PluginSetting<bool> setting = _settingsService.GetSetting("ProfileEditor.AutoSuspend", true);
setting.Value = !setting.Value;
setting.Save();
}
}