From e1a66f8a7eec5c246a529c55389f7cf604ca0923 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 15 Jun 2022 21:57:10 +0200 Subject: [PATCH] Layer properties - Tweaked step sizes for draggable float UI - Tweak selection rectangle design --- src/.idea/.idea.Artemis/.idea/avalonia.xml | 3 ++ .../Profile/LayerTransformProperties.cs | 4 +- .../Plugins/LayerBrushes/PerLedLayerBrush.cs | 2 +- .../Controls/DraggableNumberBox.axaml.cs | 27 +++++++++--- .../FloatPropertyInputView.axaml | 28 ++++++------- .../PropertyInput/IntPropertyInputView.axaml | 4 +- .../SKPointPropertyInputView.axaml | 9 ++-- .../SKSizePropertyInputView.axaml | 42 +++++++++---------- .../Properties/Timeline/TimelineView.axaml | 11 ++++- .../Tools/SelectionAddToolView.axaml | 2 +- .../Tools/SelectionRemoveToolView.axaml | 2 +- .../VisualEditor/VisualEditorView.axaml | 3 +- .../SurfaceEditor/SurfaceEditorView.axaml | 4 +- .../SurfaceEditor/SurfaceEditorView.axaml.cs | 1 - 14 files changed, 85 insertions(+), 57 deletions(-) diff --git a/src/.idea/.idea.Artemis/.idea/avalonia.xml b/src/.idea/.idea.Artemis/.idea/avalonia.xml index d598a0111..a58199850 100644 --- a/src/.idea/.idea.Artemis/.idea/avalonia.xml +++ b/src/.idea/.idea.Artemis/.idea/avalonia.xml @@ -32,6 +32,7 @@ + @@ -62,6 +63,8 @@ + + diff --git a/src/Artemis.Core/Models/Profile/LayerTransformProperties.cs b/src/Artemis.Core/Models/Profile/LayerTransformProperties.cs index 518df4953..5e2447c2e 100644 --- a/src/Artemis.Core/Models/Profile/LayerTransformProperties.cs +++ b/src/Artemis.Core/Models/Profile/LayerTransformProperties.cs @@ -30,13 +30,13 @@ namespace Artemis.Core /// /// The rotation of the shape in degree /// - [PropertyDescription(Description = "The rotation of the shape in degrees", InputAffix = "°")] + [PropertyDescription(Description = "The rotation of the shape in degrees", InputAffix = "°", InputStepSize = 0.5f)] public FloatLayerProperty Rotation { get; set; } /// /// The opacity of the shape /// - [PropertyDescription(Description = "The opacity of the shape", InputAffix = "%", MinInputValue = 0f, MaxInputValue = 100f)] + [PropertyDescription(Description = "The opacity of the shape", InputAffix = "%", MinInputValue = 0f, MaxInputValue = 100f, InputStepSize = 0.1f)] public FloatLayerProperty Opacity { get; set; } /// diff --git a/src/Artemis.Core/Plugins/LayerBrushes/PerLedLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrushes/PerLedLayerBrush.cs index a4296b7aa..5133d119b 100644 --- a/src/Artemis.Core/Plugins/LayerBrushes/PerLedLayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrushes/PerLedLayerBrush.cs @@ -60,7 +60,7 @@ namespace Artemis.Core.LayerBrushes continue; // Let the brush determine the color - paint.Color = GetColor(artemisLed, renderPoint); + paint.Color = GetColor(artemisLed, renderPoint).WithAlpha(paint.Color.Alpha); SKRect ledRectangle = SKRect.Create( artemisLed.AbsoluteRectangle.Left - Layer.Bounds.Left, diff --git a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs index ad0d00513..653b829f9 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs @@ -134,13 +134,17 @@ public partial class DraggableNumberBox : UserControl _inputTextBox = _numberBox.FindDescendantOfType(); _moved = false; _startX = point.Position.X; + _lastX = point.Position.X; e.Handled = true; } private void OnPointerMoved(object? sender, PointerEventArgs e) { PointerPoint point = e.GetCurrentPoint(this); - if (!_moved && Math.Abs(point.Position.X - _startX) < 2 || !point.Properties.IsLeftButtonPressed || _inputTextBox == null || _inputTextBox.IsFocused) + if (!point.Properties.IsLeftButtonPressed || _inputTextBox == null || _inputTextBox.IsFocused) + return; + + if (!_moved && Math.Abs(point.Position.X - _startX) < 2) { _lastX = point.Position.X; return; @@ -155,11 +159,24 @@ public partial class DraggableNumberBox : UserControl DragStarted?.Invoke(this, EventArgs.Empty); } - double smallChange = SmallChange != 0 ? SmallChange : 0.1; - double largeChange = LargeChange != 0 ? LargeChange : smallChange * 10; - double changeMultiplier = e.KeyModifiers.HasFlag(KeyModifiers.Shift) ? smallChange : largeChange; + double smallChange; + if (SmallChange != 0) + smallChange = SmallChange; + else if (LargeChange != 0) + smallChange = LargeChange / 10; + else + smallChange = 0.1; - Value += (point.Position.X - _lastX) * changeMultiplier; + double largeChange; + if (LargeChange != 0) + largeChange = LargeChange; + else if (LargeChange != 0) + largeChange = LargeChange * 10; + else + largeChange = 1; + + double changeMultiplier = e.KeyModifiers.HasFlag(KeyModifiers.Shift) ? smallChange : largeChange; + Value = Math.Clamp(Value + (point.Position.X - _lastX) * changeMultiplier, Minimum, Maximum); _lastX = point.Position.X; e.Handled = true; } diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml index d58bce685..19521c951 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml @@ -7,19 +7,19 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.DefaultTypes.PropertyInput.FloatPropertyInputView" x:DataType="propertyInput:FloatPropertyInputViewModel"> - - - + + + + MinWidth="80" + Value="{CompiledBinding InputValue}" + Prefix="{CompiledBinding Prefix}" + Suffix="{CompiledBinding Affix}" + Minimum="{CompiledBinding MinInputValue}" + Maximum="{CompiledBinding MaxInputValue}" + LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}" + SimpleNumberFormat="F3" + VerticalAlignment="Center" + DragStarted="DraggableNumberBox_OnDragStarted" + DragFinished="DraggableNumberBox_OnDragFinished" /> \ No newline at end of file diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml b/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml index 089870508..2ddce477f 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml @@ -17,9 +17,9 @@ Suffix="{CompiledBinding Affix}" Minimum="{CompiledBinding MinInputValue}" Maximum="{CompiledBinding MaxInputValue}" - SmallChange="{Binding LayerProperty.PropertyDescription.InputStepSize}" + LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}" SimpleNumberFormat="F1" VerticalAlignment="Center" DragStarted="DraggableNumberBox_OnDragStarted" - DragFinished="DraggableNumberBox_OnDragFinished"/> + DragFinished="DraggableNumberBox_OnDragFinished" /> \ No newline at end of file diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.axaml b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.axaml index 21ac7f4b7..7b63f8414 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.axaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.axaml @@ -7,30 +7,29 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.DefaultTypes.PropertyInput.SKPointPropertyInputView" x:DataType="propertyInput:SKPointPropertyInputViewModel"> - + DragFinished="DraggableNumberBox_OnDragFinished" /> , + DragFinished="DraggableNumberBox_OnDragFinished" /> \ No newline at end of file diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml b/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml index af00074a6..a89fe697a 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml @@ -9,27 +9,27 @@ x:DataType="propertyInput:SKSizePropertyInputViewModel"> + MinWidth="80" + Value="{CompiledBinding Height}" + Prefix="{CompiledBinding Prefix}" + Suffix="{CompiledBinding Affix}" + LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}" + SimpleNumberFormat="F3" + VerticalAlignment="Center" + ToolTip.Tip="Height" + DragStarted="DraggableNumberBox_OnDragStarted" + DragFinished="DraggableNumberBox_OnDragFinished" /> , + MinWidth="80" + Value="{CompiledBinding Width}" + Prefix="{CompiledBinding Prefix}" + Suffix="{CompiledBinding Affix}" + LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}" + SimpleNumberFormat="F3" + VerticalAlignment="Center" + ToolTip.Tip="Width" + DragStarted="DraggableNumberBox_OnDragStarted" + DragFinished="DraggableNumberBox_OnDragFinished" /> - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/TimelineView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/TimelineView.axaml index 25bb54012..5b3669d16 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/TimelineView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/TimelineView.axaml @@ -24,7 +24,16 @@ - + + + + + diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/SelectionAddToolView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/SelectionAddToolView.axaml index c53ce42aa..5a5634690 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/SelectionAddToolView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/SelectionAddToolView.axaml @@ -9,7 +9,7 @@ diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/SelectionRemoveToolView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/SelectionRemoveToolView.axaml index 056a8f896..16e6a5aba 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/SelectionRemoveToolView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/SelectionRemoveToolView.axaml @@ -11,7 +11,7 @@ diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml index 29ae07f2a..13f951a51 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml @@ -30,8 +30,7 @@ HorizontalAlignment="Stretch" Background="{StaticResource LargeCheckerboardBrush}" ZoomChanged="ZoomBorder_OnZoomChanged"> - + diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml index fabfe1b86..055f5602f 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml @@ -103,7 +103,9 @@ InputElement="{Binding #ZoomBorder}" SelectionUpdated="SelectionRectangle_OnSelectionUpdated" BorderBrush="{DynamicResource SystemAccentColor}" - BorderRadius="8"> + BorderRadius="8" + BorderThickness="1" + ZoomRatio="{Binding $parent[ZoomBorder].ZoomX}"> diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml.cs b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml.cs index 4e3343626..e7f12f075 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml.cs @@ -47,7 +47,6 @@ public class SurfaceEditorView : ReactiveUserControl private void ZoomBorder_OnZoomChanged(object sender, ZoomChangedEventArgs e) { UpdateZoomBorderBackground(); - _selectionRectangle.BorderThickness = 1 / _zoomBorder.ZoomX; _surfaceBounds.BorderThickness = new Thickness(2 / _zoomBorder.ZoomX); }