mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Profile editor - Added focusing
This commit is contained in:
1 parent
3f52279305
commit
1f311d2295
8 files changed
+154
-33
No files matched your search
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:menuBar="clr-namespace:Artemis.UI.Screens.ProfileEditor.MenuBar"
|
||||
xmlns:profileEditor="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.MenuBar.MenuBarView"
|
||||
x:DataType="menuBar:MenuBarViewModel">
|
||||
@@ -97,8 +98,8 @@
|
||||
<avalonia:MaterialIcon Kind="SwapHorizontal" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Switch Run Mode on Focus Loss"
|
||||
ToolTip.Tip="If enabled, run mode is set to normal on focus loss"
|
||||
<MenuItem Header="Switch Run Mode on Focus Loss"
|
||||
ToolTip.Tip="If enabled, run mode is set to normal on focus loss"
|
||||
InputGesture="Shift+F5"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding AutoSuspend}">
|
||||
@@ -108,12 +109,28 @@
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Options">
|
||||
<MenuItem Header="Focus Selected Layer" ToolTip.Tip="If enabled, displays only the layer you currently have selected"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding FocusSelectedLayer}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding FocusSelectedLayer.Value}" />
|
||||
</MenuItem.Icon>
|
||||
<MenuItem Header="Focus Mode" InputGesture="F">
|
||||
<MenuItem Header="None"
|
||||
Command="{CompiledBinding ChangeFocusMode}"
|
||||
CommandParameter="{x:Static profileEditor:ProfileEditorFocusMode.None}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding FocusNone}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Current Folder"
|
||||
Command="{CompiledBinding ChangeFocusMode}"
|
||||
CommandParameter="{x:Static profileEditor:ProfileEditorFocusMode.Folder}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding FocusFolder}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Current Selection"
|
||||
Command="{CompiledBinding ChangeFocusMode}"
|
||||
CommandParameter="{x:Static profileEditor:ProfileEditorFocusMode.Selection}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding FocusSelection}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Display Data Model Values"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
|
||||
@@ -31,6 +31,9 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
||||
private ObservableAsPropertyHelper<RenderProfileElement?>? _profileElement;
|
||||
private ObservableAsPropertyHelper<bool>? _suspendedEditing;
|
||||
private ObservableAsPropertyHelper<bool>? _focusNone;
|
||||
private ObservableAsPropertyHelper<bool>? _focusFolder;
|
||||
private ObservableAsPropertyHelper<bool>? _focusSelection;
|
||||
|
||||
public MenuBarViewModel(ILogger logger, IProfileEditorService profileEditorService, IProfileService profileService, ISettingsService settingsService, IWindowService windowService)
|
||||
{
|
||||
@@ -50,6 +53,10 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
.Switch()
|
||||
.ToProperty(this, vm => vm.IsSuspended)
|
||||
.DisposeWith(d);
|
||||
|
||||
_focusNone = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.None).ToProperty(this, vm => vm.FocusNone).DisposeWith(d);
|
||||
_focusFolder = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Folder).ToProperty(this, vm => vm.FocusFolder).DisposeWith(d);
|
||||
_focusSelection = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Selection).ToProperty(this, vm => vm.FocusSelection).DisposeWith(d);
|
||||
});
|
||||
|
||||
AddFolder = ReactiveCommand.Create(ExecuteAddFolder);
|
||||
@@ -62,8 +69,10 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
ExportProfile = ReactiveCommand.CreateFromTask(ExecuteExportProfile, this.WhenAnyValue(vm => vm.ProfileConfiguration).Select(c => c != null));
|
||||
DuplicateProfile = ReactiveCommand.Create(ExecuteDuplicateProfile, this.WhenAnyValue(vm => vm.ProfileConfiguration).Select(c => c != null));
|
||||
ToggleSuspendedEditing = ReactiveCommand.Create(ExecuteToggleSuspendedEditing);
|
||||
ToggleBooleanSetting = ReactiveCommand.Create<PluginSetting<bool>>(ExecuteToggleBooleanSetting);
|
||||
OpenUri = ReactiveCommand.Create<string>(s => Process.Start(new ProcessStartInfo(s) {UseShellExecute = true, Verb = "open"}));
|
||||
ToggleBooleanSetting = ReactiveCommand.Create<PluginSetting<bool>>(ExecuteToggleBooleanSetting);
|
||||
CycleFocusMode = ReactiveCommand.Create(ExecuteCycleFocusMode);
|
||||
ChangeFocusMode = ReactiveCommand.Create<ProfileEditorFocusMode>(ExecuteChangeFocusMode);
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> AddFolder { get; }
|
||||
@@ -78,18 +87,23 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
public ReactiveCommand<PluginSetting<bool>, Unit> ToggleBooleanSetting { get; }
|
||||
public ReactiveCommand<string, Unit> OpenUri { get; }
|
||||
public ReactiveCommand<Unit, Unit> ToggleSuspendedEditing { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> CycleFocusMode { get; }
|
||||
public ReactiveCommand<ProfileEditorFocusMode, Unit> ChangeFocusMode { get; }
|
||||
|
||||
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
||||
public RenderProfileElement? ProfileElement => _profileElement?.Value;
|
||||
public bool IsSuspended => _isSuspended?.Value ?? false;
|
||||
public bool SuspendedEditing => _suspendedEditing?.Value ?? false;
|
||||
public bool FocusNone => _focusNone?.Value ?? false;
|
||||
public bool FocusFolder => _focusFolder?.Value ?? false;
|
||||
public bool FocusSelection => _focusSelection?.Value ?? false;
|
||||
|
||||
public PluginSetting<bool> AutoSuspend => _settingsService.GetSetting("ProfileEditor.AutoSuspend", true);
|
||||
public PluginSetting<bool> FocusSelectedLayer => _settingsService.GetSetting("ProfileEditor.FocusSelectedLayer", false);
|
||||
public PluginSetting<bool> ShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||
public PluginSetting<bool> ShowFullPaths => _settingsService.GetSetting("ProfileEditor.ShowFullPaths", false);
|
||||
public PluginSetting<bool> AlwaysShowValues => _settingsService.GetSetting("ProfileEditor.AlwaysShowValues", true);
|
||||
public PluginSetting<bool> AlwaysApplyDataBindings => _settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", false);
|
||||
public PluginSetting<ProfileEditorFocusMode> FocusMode => _settingsService.GetSetting("ProfileEditor.FocusMode", ProfileEditorFocusMode.Folder);
|
||||
|
||||
public ProfileEditorHistory? History
|
||||
{
|
||||
@@ -125,7 +139,7 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
("profileConfiguration", ProfileConfiguration)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private async Task ExecuteViewScripts()
|
||||
{
|
||||
if (ProfileConfiguration?.Profile == null)
|
||||
@@ -218,4 +232,24 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
setting.Value = !setting.Value;
|
||||
setting.Save();
|
||||
}
|
||||
|
||||
private void ExecuteCycleFocusMode()
|
||||
{
|
||||
if (FocusMode.Value == ProfileEditorFocusMode.None)
|
||||
FocusMode.Value = ProfileEditorFocusMode.Folder;
|
||||
else if (FocusMode.Value == ProfileEditorFocusMode.Folder)
|
||||
FocusMode.Value = ProfileEditorFocusMode.Selection;
|
||||
else if (FocusMode.Value == ProfileEditorFocusMode.Selection)
|
||||
FocusMode.Value = ProfileEditorFocusMode.None;
|
||||
|
||||
FocusMode.Save();
|
||||
_profileEditorService.ChangeFocusMode(FocusMode.Value);
|
||||
}
|
||||
|
||||
private void ExecuteChangeFocusMode(ProfileEditorFocusMode focusMode)
|
||||
{
|
||||
FocusMode.Value = focusMode;
|
||||
FocusMode.Save();
|
||||
_profileEditorService.ChangeFocusMode(FocusMode.Value);
|
||||
}
|
||||
}
|
||||
@@ -90,8 +90,8 @@
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<Grid RowDefinitions="*,Auto">
|
||||
<TreeView Name="ProfileTreeView" Classes="no-right-margin draggable"
|
||||
Items="{CompiledBinding Children}"
|
||||
<TreeView Name="ProfileTreeView" Classes="no-right-margin draggable"
|
||||
Items="{CompiledBinding Children}"
|
||||
SelectedItem="{CompiledBinding SelectedChild}"
|
||||
SelectionChanged="ProfileTreeView_OnSelectionChanged">
|
||||
<TreeView.Styles>
|
||||
@@ -152,14 +152,25 @@
|
||||
</TreeDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Classes="icon-button" ToolTip.Tip="Add new folder to root" Command="{CompiledBinding AddFolder}">
|
||||
<avalonia:MaterialIcon Kind="FolderAdd" />
|
||||
</Button>
|
||||
<Button Classes="icon-button" ToolTip.Tip="Add new layer to root" Command="{CompiledBinding AddLayer}" Margin="2 0 0 0">
|
||||
<avalonia:MaterialIcon Kind="LayersPlus" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Spacing="5" ToolTip.Tip="Focus Mode - Use to disable parts of the profile you're not working on (F to change)">
|
||||
<avalonia:MaterialIcon Kind="ImageFilterCenterFocusStrong" />
|
||||
<TextBlock Text="{CompiledBinding FocusMode.Value}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
|
||||
<Button Classes="icon-button" ToolTip.Tip="Add new folder to root" Command="{CompiledBinding AddFolder}">
|
||||
<avalonia:MaterialIcon Kind="FolderAdd" />
|
||||
</Button>
|
||||
<Button Classes="icon-button" ToolTip.Tip="Add new layer to root" Command="{CompiledBinding AddLayer}" Margin="2 0 0 0">
|
||||
<avalonia:MaterialIcon Kind="LayersPlus" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
@@ -17,7 +18,7 @@ public class ProfileTreeViewModel : TreeItemViewModel
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private TreeItemViewModel? _selectedChild;
|
||||
|
||||
public ProfileTreeViewModel(IWindowService windowService, IProfileEditorService profileEditorService, IProfileEditorVmFactory profileEditorVmFactory)
|
||||
public ProfileTreeViewModel(IWindowService windowService, IProfileEditorService profileEditorService, IProfileEditorVmFactory profileEditorVmFactory, ISettingsService settingsService)
|
||||
: base(null, null, windowService, profileEditorService, profileEditorVmFactory)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
@@ -44,8 +45,11 @@ public class ProfileTreeViewModel : TreeItemViewModel
|
||||
if (model?.ProfileElement is RenderProfileElement renderProfileElement)
|
||||
profileEditorService.ChangeCurrentProfileElement(renderProfileElement);
|
||||
});
|
||||
|
||||
FocusMode = settingsService.GetSetting("ProfileEditor.FocusMode", ProfileEditorFocusMode.Folder);
|
||||
}
|
||||
|
||||
public PluginSetting<ProfileEditorFocusMode> FocusMode { get; }
|
||||
public TreeItemViewModel? SelectedChild
|
||||
{
|
||||
get => _selectedChild;
|
||||
|
||||
Reference in new issue
Block a user