mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 01:42:02 +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
|
public class ProfileLayerViewModel : CanvasViewModel
|
||||||
{
|
{
|
||||||
private readonly ILayerEditorService _layerEditorService;
|
private readonly ILayerEditorService _layerEditorService;
|
||||||
private readonly IProfileEditorService _profileEditorService;
|
|
||||||
private readonly PanZoomViewModel _panZoomViewModel;
|
private readonly PanZoomViewModel _panZoomViewModel;
|
||||||
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private bool _isSelected;
|
private bool _isSelected;
|
||||||
private Geometry _shapeGeometry;
|
private Geometry _shapeGeometry;
|
||||||
private Rect _viewportRectangle;
|
private Rect _viewportRectangle;
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
d:DesignHeight="510.9" d:DesignWidth="800"
|
d:DesignHeight="510.9" d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileViewModel}}">
|
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileViewModel}}">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
@ -23,16 +24,16 @@
|
|||||||
<StackPanel Orientation="Vertical" />
|
<StackPanel Orientation="Vertical" />
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ListBox.ItemsPanel>
|
</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" />
|
<materialDesign:PackIcon Kind="HandLeft" />
|
||||||
</ListBoxItem>
|
</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" />
|
<materialDesign:PackIcon Kind="TransitConnectionVariant" />
|
||||||
</ListBoxItem>
|
</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" />
|
<materialDesign:PackIcon Kind="SelectionDrag" />
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
<ListBoxItem ToolTip="Remove from layer selection">
|
<ListBoxItem ToolTip="Remove from layer selection - Ctrl+W">
|
||||||
<materialDesign:PackIcon Kind="SelectOff" />
|
<materialDesign:PackIcon Kind="SelectOff" />
|
||||||
</ListBoxItem>
|
</ListBoxItem>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
@ -133,9 +134,9 @@
|
|||||||
<materialDesign:Card Padding="8">
|
<materialDesign:Card Padding="8">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
<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">
|
ToolTip="If selected, dims all LEDs that are not part of the selected layer">
|
||||||
Highlight LEDs of selected layer
|
Focus selected layer
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||||
Margin="10 0 0 0"
|
Margin="10 0 0 0"
|
||||||
|
|||||||
@ -15,7 +15,7 @@ using Stylet;
|
|||||||
|
|
||||||
namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
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 ICoreService _coreService;
|
||||||
private readonly IProfileEditorService _profileEditorService;
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
@ -31,7 +31,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
private bool _canSelectEditTool;
|
private bool _canSelectEditTool;
|
||||||
private BindableCollection<ArtemisDevice> _devices;
|
private BindableCollection<ArtemisDevice> _devices;
|
||||||
private BindableCollection<ArtemisLed> _highlightedLeds;
|
private BindableCollection<ArtemisLed> _highlightedLeds;
|
||||||
private PluginSetting<bool> _highlightSelectedLayer;
|
private PluginSetting<bool> _focusSelectedLayer;
|
||||||
private DateTime _lastUpdate;
|
private DateTime _lastUpdate;
|
||||||
private PanZoomViewModel _panZoomViewModel;
|
private PanZoomViewModel _panZoomViewModel;
|
||||||
private Layer _previousSelectedLayer;
|
private Layer _previousSelectedLayer;
|
||||||
@ -55,7 +55,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
eventAggregator.Subscribe(this);
|
eventAggregator.Subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool CanSelectEditTool
|
public bool CanSelectEditTool
|
||||||
{
|
{
|
||||||
get => _canSelectEditTool;
|
get => _canSelectEditTool;
|
||||||
@ -86,10 +85,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
set => SetAndNotify(ref _alwaysApplyDataBindings, value);
|
set => SetAndNotify(ref _alwaysApplyDataBindings, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginSetting<bool> HighlightSelectedLayer
|
public PluginSetting<bool> FocusSelectedLayer
|
||||||
{
|
{
|
||||||
get => _highlightSelectedLayer;
|
get => _focusSelectedLayer;
|
||||||
set => SetAndNotify(ref _highlightSelectedLayer, value);
|
set => SetAndNotify(ref _focusSelectedLayer, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VisualizationToolViewModel ActiveToolViewModel
|
public VisualizationToolViewModel ActiveToolViewModel
|
||||||
@ -146,12 +145,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
ApplyActiveProfile();
|
ApplyActiveProfile();
|
||||||
|
|
||||||
AlwaysApplyDataBindings = _settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", true);
|
AlwaysApplyDataBindings = _settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", true);
|
||||||
HighlightSelectedLayer = _settingsService.GetSetting("ProfileEditor.HighlightSelectedLayer", true);
|
FocusSelectedLayer = _settingsService.GetSetting("ProfileEditor.FocusSelectedLayer", true);
|
||||||
|
|
||||||
_lastUpdate = DateTime.Now;
|
_lastUpdate = DateTime.Now;
|
||||||
_coreService.FrameRendered += OnFrameRendered;
|
_coreService.FrameRendered += OnFrameRendered;
|
||||||
|
|
||||||
HighlightSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
|
FocusSelectedLayer.SettingChanged += HighlightSelectedLayerOnSettingChanged;
|
||||||
_rgbService.DeviceAdded += RgbServiceOnDevicesModified;
|
_rgbService.DeviceAdded += RgbServiceOnDevicesModified;
|
||||||
_rgbService.DeviceRemoved += RgbServiceOnDevicesModified;
|
_rgbService.DeviceRemoved += RgbServiceOnDevicesModified;
|
||||||
_profileEditorService.ProfileSelected += OnProfileSelected;
|
_profileEditorService.ProfileSelected += OnProfileSelected;
|
||||||
@ -164,7 +163,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
{
|
{
|
||||||
_coreService.FrameRendered -= OnFrameRendered;
|
_coreService.FrameRendered -= OnFrameRendered;
|
||||||
HighlightSelectedLayer.SettingChanged -= HighlightSelectedLayerOnSettingChanged;
|
FocusSelectedLayer.SettingChanged -= HighlightSelectedLayerOnSettingChanged;
|
||||||
_rgbService.DeviceAdded -= RgbServiceOnDevicesModified;
|
_rgbService.DeviceAdded -= RgbServiceOnDevicesModified;
|
||||||
_rgbService.DeviceRemoved -= RgbServiceOnDevicesModified;
|
_rgbService.DeviceRemoved -= RgbServiceOnDevicesModified;
|
||||||
_profileEditorService.ProfileSelected -= OnProfileSelected;
|
_profileEditorService.ProfileSelected -= OnProfileSelected;
|
||||||
@ -174,7 +173,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
_previousSelectedLayer.LayerBrushUpdated -= SelectedLayerOnLayerBrushUpdated;
|
_previousSelectedLayer.LayerBrushUpdated -= SelectedLayerOnLayerBrushUpdated;
|
||||||
|
|
||||||
AlwaysApplyDataBindings.Save();
|
AlwaysApplyDataBindings.Save();
|
||||||
HighlightSelectedLayer.Save();
|
FocusSelectedLayer.Save();
|
||||||
|
|
||||||
base.OnClose();
|
base.OnClose();
|
||||||
}
|
}
|
||||||
@ -191,8 +190,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
|
|
||||||
// Add new layers missing a VM
|
// Add new layers missing a VM
|
||||||
foreach (Layer layer in layers)
|
foreach (Layer layer in layers)
|
||||||
|
{
|
||||||
if (layerViewModels.All(vm => vm.Layer != layer))
|
if (layerViewModels.All(vm => vm.Layer != layer))
|
||||||
Items.Add(_profileLayerVmFactory.Create(layer, PanZoomViewModel));
|
Items.Add(_profileLayerVmFactory.Create(layer, PanZoomViewModel));
|
||||||
|
}
|
||||||
|
|
||||||
// Remove layers that no longer exist
|
// Remove layers that no longer exist
|
||||||
IEnumerable<ProfileLayerViewModel> toRemove = layerViewModels.Where(vm => !layers.Contains(vm.Layer));
|
IEnumerable<ProfileLayerViewModel> toRemove = layerViewModels.Where(vm => !layers.Contains(vm.Layer));
|
||||||
@ -209,7 +210,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
private void UpdateLedsDimStatus()
|
private void UpdateLedsDimStatus()
|
||||||
{
|
{
|
||||||
HighlightedLeds.Clear();
|
HighlightedLeds.Clear();
|
||||||
if (HighlightSelectedLayer.Value && _profileEditorService.SelectedProfileElement is Layer layer)
|
if (FocusSelectedLayer.Value && _profileEditorService.SelectedProfileElement is Layer layer)
|
||||||
HighlightedLeds.AddRange(layer.Leds);
|
HighlightedLeds.AddRange(layer.Leds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +235,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
|
|
||||||
private void ActivateToolByIndex(int value)
|
private void ActivateToolByIndex(int value)
|
||||||
{
|
{
|
||||||
|
if (value == 1 && !CanSelectEditTool)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -262,7 +266,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
Devices.Max(d => d.Rectangle.Right),
|
Devices.Max(d => d.Rectangle.Right),
|
||||||
Devices.Max(d => d.Rectangle.Bottom)
|
Devices.Max(d => d.Rectangle.Bottom)
|
||||||
);
|
);
|
||||||
|
|
||||||
PanZoomViewModel.Reset(rect);
|
PanZoomViewModel.Reset(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,12 +278,14 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
{
|
{
|
||||||
((IInputElement) sender).CaptureMouse();
|
((IInputElement) sender).CaptureMouse();
|
||||||
ActiveToolViewModel?.MouseDown(sender, e);
|
ActiveToolViewModel?.MouseDown(sender, e);
|
||||||
|
e.Handled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CanvasMouseUp(object sender, MouseButtonEventArgs e)
|
public void CanvasMouseUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
((IInputElement) sender).ReleaseMouseCapture();
|
((IInputElement) sender).ReleaseMouseCapture();
|
||||||
ActiveToolViewModel?.MouseUp(sender, e);
|
ActiveToolViewModel?.MouseUp(sender, e);
|
||||||
|
e.Handled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CanvasMouseMove(object sender, MouseEventArgs e)
|
public void CanvasMouseMove(object sender, MouseEventArgs e)
|
||||||
@ -382,24 +388,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
ActivateToolByIndex(2);
|
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)
|
public void Handle(MainWindowKeyEvent message)
|
||||||
{
|
{
|
||||||
if (message.KeyDown)
|
if (message.KeyDown)
|
||||||
@ -412,6 +400,17 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActiveToolViewModel?.KeyDown(message.EventArgs);
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user