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:
parent
0d3890e560
commit
38986b73ac
1
src/.idea/.idea.Artemis/.idea/avalonia.xml
generated
1
src/.idea/.idea.Artemis/.idea/avalonia.xml
generated
@ -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/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/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/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/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/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" />
|
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/AdaptionHints/KeyboardSectionAdaptionHintView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Artemis.UI.Screens.ProfileEditor.MenuBar.MenuBarView"
|
x:Class="Artemis.UI.Screens.ProfileEditor.MenuBar.MenuBarView"
|
||||||
x:DataType="menuBar:MenuBarViewModel">
|
x:DataType="menuBar:MenuBarViewModel">
|
||||||
<Menu VerticalAlignment="Top">
|
<Menu VerticalAlignment="Top" MenuClosed="MenuBase_OnMenuClosed">
|
||||||
<MenuItem Header="_File">
|
<MenuItem Header="_File">
|
||||||
<MenuItem Header="New">
|
<MenuItem Header="New">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
@ -63,7 +63,7 @@
|
|||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem Header="_Edit" SubmenuOpened="MenuItem_OnSubmenuOpened">
|
<MenuItem Header="_Edit">
|
||||||
<MenuItem Header="_Undo" Command="{CompiledBinding History.Undo}" InputGesture="Ctrl+Z">
|
<MenuItem Header="_Undo" Command="{CompiledBinding History.Undo}" InputGesture="Ctrl+Z">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<avalonia:MaterialIcon Kind="Undo" />
|
<avalonia:MaterialIcon Kind="Undo" />
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
using Avalonia.VisualTree;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
|
namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
|
||||||
|
|
||||||
@ -16,7 +18,9 @@ public class MenuBarView : ReactiveUserControl<MenuBarViewModel>
|
|||||||
AvaloniaXamlLoader.Load(this);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,33 +10,33 @@
|
|||||||
<DockPanel Margin="8 0">
|
<DockPanel Margin="8 0">
|
||||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||||
<Button Classes="icon-button icon-button-large"
|
<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">
|
Focusable="False">
|
||||||
<avalonia:MaterialIcon Kind="StepForward" />
|
<avalonia:MaterialIcon Kind="StepForward" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button Classes="icon-button icon-button-large"
|
<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>
|
<StackPanel>
|
||||||
<avalonia:MaterialIcon Kind="Play" IsVisible="{CompiledBinding !Playing}" />
|
<avalonia:MaterialIcon Kind="Play" IsVisible="{CompiledBinding !Playing}" />
|
||||||
<avalonia:MaterialIcon Kind="Pause" IsVisible="{CompiledBinding Playing}" />
|
<avalonia:MaterialIcon Kind="Pause" IsVisible="{CompiledBinding Playing}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</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" />
|
<avalonia:MaterialIcon Kind="SkipBackward" />
|
||||||
</Button>
|
</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" />
|
<avalonia:MaterialIcon Kind="SkipForward" />
|
||||||
</Button>
|
</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" />
|
<avalonia:MaterialIcon Kind="SkipPrevious" />
|
||||||
</Button>
|
</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" />
|
<avalonia:MaterialIcon Kind="SkipNext" />
|
||||||
</Button>
|
</Button>
|
||||||
<ToggleButton Classes="icon-button icon-button-large"
|
<ToggleButton Classes="icon-button icon-button-large"
|
||||||
IsChecked="{CompiledBinding Repeating}"
|
IsChecked="{CompiledBinding Repeating}"
|
||||||
Focusable="False"
|
Focusable="False"
|
||||||
Command="{Binding CycleRepeating}">
|
Command="{CompiledBinding CycleRepeating}">
|
||||||
<ToolTip.Tip>
|
<ToolTip.Tip>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel IsVisible="{CompiledBinding Repeating}">
|
<StackPanel IsVisible="{CompiledBinding Repeating}">
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Reactive;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
@ -40,8 +41,15 @@ public class PlaybackViewModel : ActivatableViewModelBase
|
|||||||
updateTimer.Start();
|
updateTimer.Start();
|
||||||
Disposable.Create(() => updateTimer.Stop());
|
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 TimeSpan CurrentTime => _currentTime?.Value ?? TimeSpan.Zero;
|
||||||
public string? FormattedCurrentTime => _formattedCurrentTime?.Value;
|
public string? FormattedCurrentTime => _formattedCurrentTime?.Value;
|
||||||
@ -65,14 +73,22 @@ public class PlaybackViewModel : ActivatableViewModelBase
|
|||||||
set => RaiseAndSetIfChanged(ref _repeatSegment, value);
|
set => RaiseAndSetIfChanged(ref _repeatSegment, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayFromStart()
|
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; }
|
||||||
|
|
||||||
|
private void ExecutePlayFromStart()
|
||||||
{
|
{
|
||||||
GoToStart();
|
ExecuteGoToStart();
|
||||||
if (!Playing)
|
if (!Playing)
|
||||||
_profileEditorService.Play();
|
_profileEditorService.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TogglePlay()
|
private void ExecuteTogglePlay()
|
||||||
{
|
{
|
||||||
if (!Playing)
|
if (!Playing)
|
||||||
_profileEditorService.Play();
|
_profileEditorService.Play();
|
||||||
@ -80,12 +96,12 @@ public class PlaybackViewModel : ActivatableViewModelBase
|
|||||||
_profileEditorService.Pause();
|
_profileEditorService.Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToStart()
|
private void ExecuteGoToStart()
|
||||||
{
|
{
|
||||||
_profileEditorService.ChangeTime(TimeSpan.Zero);
|
_profileEditorService.ChangeTime(TimeSpan.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToEnd()
|
private void ExecuteGoToEnd()
|
||||||
{
|
{
|
||||||
if (_profileElement == null)
|
if (_profileElement == null)
|
||||||
return;
|
return;
|
||||||
@ -93,7 +109,7 @@ public class PlaybackViewModel : ActivatableViewModelBase
|
|||||||
_profileEditorService.ChangeTime(_profileElement.Timeline.EndSegmentEndPosition);
|
_profileEditorService.ChangeTime(_profileElement.Timeline.EndSegmentEndPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToPreviousFrame()
|
private void ExecuteGoToPreviousFrame()
|
||||||
{
|
{
|
||||||
if (_profileElement == null)
|
if (_profileElement == null)
|
||||||
return;
|
return;
|
||||||
@ -103,7 +119,7 @@ public class PlaybackViewModel : ActivatableViewModelBase
|
|||||||
_profileEditorService.ChangeTime(TimeSpan.FromMilliseconds(newTime));
|
_profileEditorService.ChangeTime(TimeSpan.FromMilliseconds(newTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoToNextFrame()
|
private void ExecuteGoToNextFrame()
|
||||||
{
|
{
|
||||||
if (_profileElement == null)
|
if (_profileElement == null)
|
||||||
return;
|
return;
|
||||||
@ -114,7 +130,7 @@ public class PlaybackViewModel : ActivatableViewModelBase
|
|||||||
_profileEditorService.ChangeTime(TimeSpan.FromMilliseconds(newTime));
|
_profileEditorService.ChangeTime(TimeSpan.FromMilliseconds(newTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CycleRepeating()
|
private void ExecuteCycleRepeating()
|
||||||
{
|
{
|
||||||
if (!Repeating)
|
if (!Repeating)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,7 +8,8 @@
|
|||||||
xmlns:shared="clr-namespace:Artemis.UI.Shared.Services.ProfileEditor;assembly=Artemis.UI.Shared"
|
xmlns:shared="clr-namespace:Artemis.UI.Shared.Services.ProfileEditor;assembly=Artemis.UI.Shared"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView"
|
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView"
|
||||||
x:DataType="profileEditor:ProfileEditorViewModel">
|
x:DataType="profileEditor:ProfileEditorViewModel"
|
||||||
|
Name="ProfileEditorView">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" />
|
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
@ -25,6 +26,8 @@
|
|||||||
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y" />
|
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y" />
|
||||||
<KeyBinding Command="{CompiledBinding ToggleSuspend}" Gesture="F5" />
|
<KeyBinding Command="{CompiledBinding ToggleSuspend}" Gesture="F5" />
|
||||||
<KeyBinding Command="{CompiledBinding ToggleAutoSuspend}" Gesture="Shift+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.KeyBindings>
|
||||||
<UserControl.Styles>
|
<UserControl.Styles>
|
||||||
<Style Selector="GridSplitter.editor-grid-splitter-vertical">
|
<Style Selector="GridSplitter.editor-grid-splitter-vertical">
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using Avalonia;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
@ -11,6 +12,17 @@ public class ProfileEditorView : ReactiveUserControl<ProfileEditorViewModel>
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Overrides of Visual
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnAttachedToVisualTree(e);
|
||||||
|
Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
|||||||
@ -98,6 +98,8 @@ public class ProfileEditorViewModel : MainScreenViewModel
|
|||||||
|
|
||||||
private void ExecuteToggleAutoSuspend()
|
private void ExecuteToggleAutoSuspend()
|
||||||
{
|
{
|
||||||
// TODO
|
PluginSetting<bool> setting = _settingsService.GetSetting("ProfileEditor.AutoSuspend", true);
|
||||||
|
setting.Value = !setting.Value;
|
||||||
|
setting.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user