mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +00:00
Profile editor - Added hotkeys for each tool
This commit is contained in:
parent
f829743b6c
commit
b917f36978
@ -14,8 +14,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
public class ProfileLayerViewModel : CanvasViewModel
|
||||
{
|
||||
private readonly ILayerEditorService _layerEditorService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly PanZoomViewModel _panZoomViewModel;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private bool _isSelected;
|
||||
private Geometry _shapeGeometry;
|
||||
private Rect _viewportRectangle;
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
d:DesignHeight="510.9" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileViewModel}}">
|
||||
<Grid>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
@ -23,16 +24,16 @@
|
||||
<StackPanel Orientation="Vertical" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBoxItem ToolTip="Pan over different parts of the surface">
|
||||
<ListBoxItem ToolTip="Pan over different parts of the surface - Ctrl">
|
||||
<materialDesign:PackIcon Kind="HandLeft" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Transform layer shape (hold SHIFT for incremental changes and X/Y snapping)" IsEnabled="{Binding CanSelectEditTool}">
|
||||
<ListBoxItem ToolTip="Transform layer shape (hold SHIFT for incremental changes and X/Y snapping) - Ctrl+T" IsEnabled="{Binding CanSelectEditTool}">
|
||||
<materialDesign:PackIcon Kind="TransitConnectionVariant" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Change layer selection (hold SHIFT to add to existing selection)">
|
||||
<ListBoxItem ToolTip="Change layer selection (hold SHIFT to add to existing selection) - Ctrl+Q">
|
||||
<materialDesign:PackIcon Kind="SelectionDrag" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Remove from layer selection">
|
||||
<ListBoxItem ToolTip="Remove from layer selection - Ctrl+W">
|
||||
<materialDesign:PackIcon Kind="SelectOff" />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
@ -133,9 +134,9 @@
|
||||
<materialDesign:Card Padding="8">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
IsChecked="{Binding HighlightSelectedLayer.Value}"
|
||||
IsChecked="{Binding FocusSelectedLayer.Value}"
|
||||
ToolTip="If selected, dims all LEDs that are not part of the selected layer">
|
||||
Highlight LEDs of selected layer
|
||||
Focus selected layer
|
||||
</CheckBox>
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
Margin="10 0 0 0"
|
||||
|
||||
@ -15,7 +15,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
{
|
||||
public class ProfileViewModel : Conductor<CanvasViewModel>.Collection.AllActive, IProfileEditorPanelViewModel, IHandle<MainWindowFocusChangedEvent>, IHandle<MainWindowKeyEvent>
|
||||
public class ProfileViewModel : Conductor<CanvasViewModel>.Collection.AllActive, IProfileEditorPanelViewModel, IHandle<MainWindowKeyEvent>
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
@ -31,7 +31,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
private bool _canSelectEditTool;
|
||||
private BindableCollection<ArtemisDevice> _devices;
|
||||
private BindableCollection<ArtemisLed> _highlightedLeds;
|
||||
private PluginSetting<bool> _highlightSelectedLayer;
|
||||
private PluginSetting<bool> _focusSelectedLayer;
|
||||
private DateTime _lastUpdate;
|
||||
private PanZoomViewModel _panZoomViewModel;
|
||||
private Layer _previousSelectedLayer;
|
||||
@ -55,7 +55,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
eventAggregator.Subscribe(this);
|
||||
}
|
||||
|
||||
|
||||
public bool CanSelectEditTool
|
||||
{
|
||||
get => _canSelectEditTool;
|
||||
@ -86,10 +85,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
set => SetAndNotify(ref _alwaysApplyDataBindings, value);
|
||||
}
|
||||
|
||||
public PluginSetting<bool> HighlightSelectedLayer
|
||||
public PluginSetting<bool> FocusSelectedLayer
|
||||
{
|
||||
get => _highlightSelectedLayer;
|
||||
set => SetAndNotify(ref _highlightSelectedLayer, value);
|
||||
get => _focusSelectedLayer;
|
||||
set => SetAndNotify(ref _focusSelectedLayer, value);
|
||||
}
|
||||
|
||||
public VisualizationToolViewModel ActiveToolViewModel
|
||||
@ -146,12 +145,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
ApplyActiveProfile();
|
||||
|
||||
AlwaysApplyDataBindings = _settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", true);
|
||||
HighlightSelectedLayer = _settingsService.GetSetting("ProfileEditor.HighlightSelectedLayer", true);
|
||||
FocusSelectedLayer = _settingsService.GetSetting("ProfileEditor.FocusSelectedLayer", true);
|
||||
|
||||
_lastUpdate = DateTime.Now;
|
||||
_coreService.FrameRendered += OnFrameRendered;
|
||||
|
||||
HighlightSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
|
||||
FocusSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
|
||||
_rgbService.DeviceAdded += RgbServiceOnDevicesModified;
|
||||
_rgbService.DeviceRemoved += RgbServiceOnDevicesModified;
|
||||
_profileEditorService.ProfileSelected += OnProfileSelected;
|
||||
@ -164,7 +163,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
protected override void OnClose()
|
||||
{
|
||||
_coreService.FrameRendered -= OnFrameRendered;
|
||||
HighlightSelectedLayer.SettingChanged -= HighlightSelectedLayerOnSettingChanged;
|
||||
FocusSelectedLayer.SettingChanged -= HighlightSelectedLayerOnSettingChanged;
|
||||
_rgbService.DeviceAdded -= RgbServiceOnDevicesModified;
|
||||
_rgbService.DeviceRemoved -= RgbServiceOnDevicesModified;
|
||||
_profileEditorService.ProfileSelected -= OnProfileSelected;
|
||||
@ -174,7 +173,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
_previousSelectedLayer.LayerBrushUpdated -= SelectedLayerOnLayerBrushUpdated;
|
||||
|
||||
AlwaysApplyDataBindings.Save();
|
||||
HighlightSelectedLayer.Save();
|
||||
FocusSelectedLayer.Save();
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
@ -191,8 +190,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
|
||||
// Add new layers missing a VM
|
||||
foreach (Layer layer in layers)
|
||||
{
|
||||
if (layerViewModels.All(vm => vm.Layer != layer))
|
||||
Items.Add(_profileLayerVmFactory.Create(layer, PanZoomViewModel));
|
||||
}
|
||||
|
||||
// Remove layers that no longer exist
|
||||
IEnumerable<ProfileLayerViewModel> toRemove = layerViewModels.Where(vm => !layers.Contains(vm.Layer));
|
||||
@ -209,7 +210,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
private void UpdateLedsDimStatus()
|
||||
{
|
||||
HighlightedLeds.Clear();
|
||||
if (HighlightSelectedLayer.Value && _profileEditorService.SelectedProfileElement is Layer layer)
|
||||
if (FocusSelectedLayer.Value && _profileEditorService.SelectedProfileElement is Layer layer)
|
||||
HighlightedLeds.AddRange(layer.Leds);
|
||||
}
|
||||
|
||||
@ -234,6 +235,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
|
||||
private void ActivateToolByIndex(int value)
|
||||
{
|
||||
if (value == 1 && !CanSelectEditTool)
|
||||
return;
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
@ -274,12 +278,14 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
{
|
||||
((IInputElement) sender).CaptureMouse();
|
||||
ActiveToolViewModel?.MouseDown(sender, e);
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
public void CanvasMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
((IInputElement) sender).ReleaseMouseCapture();
|
||||
ActiveToolViewModel?.MouseUp(sender, e);
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
public void CanvasMouseMove(object sender, MouseEventArgs e)
|
||||
@ -382,24 +388,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
ActivateToolByIndex(2);
|
||||
}
|
||||
|
||||
public void Handle(MainWindowFocusChangedEvent message)
|
||||
{
|
||||
// if (PauseRenderingOnFocusLoss == null || ScreenState != ScreenState.Active)
|
||||
// return;
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// if (PauseRenderingOnFocusLoss.Value && !message.IsFocused)
|
||||
// _updateTrigger.Stop();
|
||||
// else if (PauseRenderingOnFocusLoss.Value && message.IsFocused)
|
||||
// _updateTrigger.Start();
|
||||
// }
|
||||
// catch (NullReferenceException)
|
||||
// {
|
||||
// // TODO: Remove when fixed in RGB.NET, or avoid double stopping
|
||||
// }
|
||||
}
|
||||
|
||||
public void Handle(MainWindowKeyEvent message)
|
||||
{
|
||||
if (message.KeyDown)
|
||||
@ -412,6 +400,17 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
||||
}
|
||||
|
||||
ActiveToolViewModel?.KeyDown(message.EventArgs);
|
||||
|
||||
// If T is pressed while Ctrl is down, that makes it Ctrl+T > swap to transformation tool on Ctrl release
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftCtrl))
|
||||
{
|
||||
if (message.EventArgs.Key == Key.T)
|
||||
_previousTool = 1;
|
||||
else if (message.EventArgs.Key == Key.Q)
|
||||
_previousTool = 2;
|
||||
else if (message.EventArgs.Key == Key.W)
|
||||
_previousTool = 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user