mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Layer properties - Added drag-editing for number-based properties
Layer properties - Added min and max values Nuget - Updated Stylet to 1.3.1
This commit is contained in:
1 parent
ed26a9a5e5
commit
05cf1f0b53
37 files changed
+522
-235
No files matched your search
-5
@@ -59,11 +59,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
NotifyOfPropertyChange(() => BrushInputValue);
|
||||
}
|
||||
|
||||
public override void ApplyInputDrag(object startValue, double dragDistance)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
UpdateEnumValues();
|
||||
|
||||
-5
@@ -27,11 +27,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
NotifyOfPropertyChange(() => EnumInputValue);
|
||||
}
|
||||
|
||||
public override void ApplyInputDrag(object startValue, double dragDistance)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
EnumValues = EnumUtilities.GetAllValuesAndDescriptions(LayerPropertyViewModel.LayerProperty.Type);
|
||||
|
||||
+2
-35
@@ -4,47 +4,14 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:FloatPropertyInputViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="0 0 5 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
|
||||
<!-- Drag handle -->
|
||||
<Border BorderThickness="0,0,0,1" Margin="0 2">
|
||||
<Border.BorderBrush>
|
||||
<VisualBrush>
|
||||
<VisualBrush.Visual>
|
||||
<Rectangle StrokeDashArray="2 2" Stroke="{DynamicResource SecondaryAccentBrush}" StrokeThickness="1"
|
||||
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"/>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Border.BorderBrush>
|
||||
<TextBlock Width="60"
|
||||
Padding="2 0"
|
||||
Margin="0 2 0 0"
|
||||
Text="{Binding FloatInputValue}"
|
||||
Cursor="/Resources/aero_drag_ew.cur"
|
||||
Foreground="{DynamicResource SecondaryAccentBrush}"
|
||||
Visibility="{Binding InputFieldEnabled, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}"
|
||||
MouseDown="{s:Action InputMouseDown}"
|
||||
MouseUp="{s:Action InputMouseUp}"
|
||||
MouseMove="{s:Action InputMouseMove}" />
|
||||
</Border>
|
||||
|
||||
<!-- Input -->
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding FloatInputValue}"
|
||||
Visibility="{Binding InputFieldEnabled, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
|
||||
LostFocus="{s:Action InputLostFocus}"
|
||||
KeyDown="{s:Action InputKeyDown}"
|
||||
IsVisibleChanged="{s:Action InputIsVisibleChanged}" />
|
||||
<shared:DraggableFloat Value="{Binding FloatInputValue}" StepSize="{Binding LayerPropertyViewModel.LayerProperty.InputStepSize}" />
|
||||
<TextBlock Margin="5 0 0 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
+10
-4
@@ -16,7 +16,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
public float FloatInputValue
|
||||
{
|
||||
get => (float?) InputValue ?? 0f;
|
||||
set => InputValue = value;
|
||||
set => InputValue = ApplyInputValue(value);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
@@ -24,10 +24,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
NotifyOfPropertyChange(() => FloatInputValue);
|
||||
}
|
||||
|
||||
public override void ApplyInputDrag(object startValue, double dragDistance)
|
||||
private float ApplyInputValue(float value)
|
||||
{
|
||||
var floatStartValue = (float) startValue;
|
||||
FloatInputValue = (float) (floatStartValue + dragDistance);
|
||||
if (LayerPropertyViewModel.LayerProperty.MaxInputValue != null &&
|
||||
LayerPropertyViewModel.LayerProperty.MaxInputValue is float maxFloat)
|
||||
value = Math.Min(value, maxFloat);
|
||||
if (LayerPropertyViewModel.LayerProperty.MinInputValue != null &&
|
||||
LayerPropertyViewModel.LayerProperty.MinInputValue is float minFloat)
|
||||
value = Math.Max(value, minFloat);
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -6,17 +6,13 @@
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:IntPropertyInputViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="0 0 5 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{Binding IntInputValue}" />
|
||||
<shared:DraggableFloat Value="{Binding IntInputValue}" StepSize="{Binding LayerPropertyViewModel.LayerProperty.InputStepSize}" />
|
||||
<TextBlock Margin="5 0 0 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
+10
-3
@@ -15,7 +15,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
public int IntInputValue
|
||||
{
|
||||
get => (int?) InputValue ?? 0;
|
||||
set => InputValue = value;
|
||||
set => InputValue = ApplyInputValue(value);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
@@ -23,9 +23,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
NotifyOfPropertyChange(() => IntInputValue);
|
||||
}
|
||||
|
||||
public override void ApplyInputDrag(object startValue, double dragDistance)
|
||||
private int ApplyInputValue(int value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (LayerPropertyViewModel.LayerProperty.MaxInputValue != null &&
|
||||
LayerPropertyViewModel.LayerProperty.MaxInputValue is int maxInt)
|
||||
value = Math.Min(value, maxInt);
|
||||
if (LayerPropertyViewModel.LayerProperty.MinInputValue != null &&
|
||||
LayerPropertyViewModel.LayerProperty.MinInputValue is int minInt)
|
||||
value = Math.Max(value, minInt);
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
-71
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Artemis.UI.Exceptions;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Stylet;
|
||||
@@ -21,7 +18,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
|
||||
public bool Initialized { get; private set; }
|
||||
public LayerPropertyViewModel LayerPropertyViewModel { get; private set; }
|
||||
public bool InputFieldEnabled { get; set; }
|
||||
|
||||
protected object InputValue
|
||||
{
|
||||
@@ -50,8 +46,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
|
||||
public abstract void Update();
|
||||
|
||||
public abstract void ApplyInputDrag(object startValue, double dragDistance);
|
||||
|
||||
protected virtual void OnInitialized()
|
||||
{
|
||||
}
|
||||
@@ -64,70 +58,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
#region Mouse-based mutations
|
||||
|
||||
private Point _mouseDragStartPoint;
|
||||
private object _startValue;
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void InputMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
_startValue = InputValue;
|
||||
((IInputElement) sender).CaptureMouse();
|
||||
_mouseDragStartPoint = e.GetPosition((IInputElement) sender);
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void InputMouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
if (position == _mouseDragStartPoint)
|
||||
InputFieldEnabled = true;
|
||||
|
||||
((IInputElement) sender).ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void InputMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
ApplyInputDrag(_startValue, position.X - _mouseDragStartPoint.X);
|
||||
}
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void InputIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (InputFieldEnabled)
|
||||
{
|
||||
((UIElement) sender).Focus();
|
||||
if (sender is TextBox textBox)
|
||||
textBox.SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void InputLostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InputFieldEnabled = false;
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void InputKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
InputFieldEnabled = false;
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
if (sender is TextBox textBox)
|
||||
textBox.Text = _startValue.ToString();
|
||||
InputFieldEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
-5
@@ -23,10 +23,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
{
|
||||
NotifyOfPropertyChange(() => SKColorInputValue);
|
||||
}
|
||||
|
||||
public override void ApplyInputDrag(object startValue, double dragDistance)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-14
@@ -6,26 +6,19 @@
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="25" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:SKPointPropertyInputViewModel}">
|
||||
<StackPanel Orientation="Horizontal" KeyboardNavigation.IsTabStop="True">
|
||||
<TextBlock Margin="0 0 5 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="X-coordinate (horizontal)"
|
||||
Text="{Binding X}" />
|
||||
<shared:DraggableFloat ToolTip="X-coordinate (horizontal)"
|
||||
Value="{Binding X}"
|
||||
StepSize="{Binding LayerPropertyViewModel.LayerProperty.InputStepSize}" />
|
||||
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Y-coordinate (vertical)"
|
||||
Text="{Binding Y}" />
|
||||
<shared:DraggableFloat ToolTip="Y-coordinate (vertical)"
|
||||
Value="{Binding Y}"
|
||||
StepSize="{Binding LayerPropertyViewModel.LayerProperty.InputStepSize}" />
|
||||
<TextBlock Margin="5 0 0 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
+11
-4
@@ -19,14 +19,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
public float X
|
||||
{
|
||||
get => ((SKPoint?) InputValue)?.X ?? 0;
|
||||
set => InputValue = new SKPoint(value, Y);
|
||||
set => InputValue = new SKPoint(ApplyInputValue(value), Y);
|
||||
}
|
||||
|
||||
[DependsOn(nameof(InputValue))]
|
||||
public float Y
|
||||
{
|
||||
get => ((SKPoint?) InputValue)?.Y ?? 0;
|
||||
set => InputValue = new SKPoint(X, value);
|
||||
set => InputValue = new SKPoint(X, ApplyInputValue(value));
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
@@ -35,9 +35,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
NotifyOfPropertyChange(() => Y);
|
||||
}
|
||||
|
||||
public override void ApplyInputDrag(object startValue, double dragDistance)
|
||||
private float ApplyInputValue(float value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (LayerPropertyViewModel.LayerProperty.MaxInputValue != null &&
|
||||
LayerPropertyViewModel.LayerProperty.MaxInputValue is float maxFloat)
|
||||
value = Math.Min(value, maxFloat);
|
||||
if (LayerPropertyViewModel.LayerProperty.MinInputValue != null &&
|
||||
LayerPropertyViewModel.LayerProperty.MinInputValue is float minFloat)
|
||||
value = Math.Max(value, minFloat);
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-14
@@ -6,26 +6,15 @@
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:SKSizePropertyInputViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="0 0 5 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputPrefix}" />
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Height"
|
||||
Text="{Binding Height}" />
|
||||
<shared:DraggableFloat ToolTip="Height" Value="{Binding Height}" StepSize="{Binding LayerPropertyViewModel.LayerProperty.InputStepSize}" />
|
||||
<TextBlock Margin="5 0" VerticalAlignment="Bottom">,</TextBlock>
|
||||
<TextBox Width="60"
|
||||
Margin="0 2"
|
||||
Padding="0 -1"
|
||||
materialDesign:ValidationAssist.UsePopup="True"
|
||||
HorizontalAlignment="Left"
|
||||
ToolTip="Width"
|
||||
Text="{Binding Width}" />
|
||||
<shared:DraggableFloat ToolTip="Width" Value="{Binding Width}" StepSize="{Binding LayerPropertyViewModel.LayerProperty.InputStepSize}" />
|
||||
<TextBlock Margin="5 0 0 4" Width="10" VerticalAlignment="Bottom" Text="{Binding LayerPropertyViewModel.LayerProperty.InputAffix}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
+11
-4
@@ -19,14 +19,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
public float Width
|
||||
{
|
||||
get => ((SKSize?) InputValue)?.Width ?? 0;
|
||||
set => InputValue = new SKSize(value, Height);
|
||||
set => InputValue = new SKSize(ApplyInputValue(value), Height);
|
||||
}
|
||||
|
||||
[DependsOn(nameof(InputValue))]
|
||||
public float Height
|
||||
{
|
||||
get => ((SKSize?) InputValue)?.Height ?? 0;
|
||||
set => InputValue = new SKSize(Width, value);
|
||||
set => InputValue = new SKSize(Width, ApplyInputValue(value));
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
@@ -35,9 +35,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.P
|
||||
NotifyOfPropertyChange(() => Height);
|
||||
}
|
||||
|
||||
public override void ApplyInputDrag(object startValue, double dragDistance)
|
||||
private float ApplyInputValue(float value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (LayerPropertyViewModel.LayerProperty.MaxInputValue != null &&
|
||||
LayerPropertyViewModel.LayerProperty.MaxInputValue is float maxFloat)
|
||||
value = Math.Min(value, maxFloat);
|
||||
if (LayerPropertyViewModel.LayerProperty.MinInputValue != null &&
|
||||
LayerPropertyViewModel.LayerProperty.MinInputValue is float minFloat)
|
||||
value = Math.Max(value, minFloat);
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
-34
@@ -2,14 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.SurfaceEditor;
|
||||
using Artemis.UI.Screens.SurfaceEditor.Visualization;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Stylet;
|
||||
|
||||
@@ -99,9 +95,37 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
UpdateEndTime();
|
||||
}
|
||||
|
||||
#region Keyframe movement
|
||||
|
||||
public void MoveSelectedKeyframes(TimeSpan offset)
|
||||
{
|
||||
var keyframeViewModels = PropertyTrackViewModels.SelectMany(t => t.KeyframeViewModels.OrderBy(k => k.Keyframe.Position)).ToList();
|
||||
foreach (var keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected))
|
||||
{
|
||||
// TODO: Not ideal as this stacks them all if they get to 0, oh well
|
||||
if (keyframeViewModel.Keyframe.Position + offset > TimeSpan.Zero)
|
||||
{
|
||||
keyframeViewModel.Keyframe.Position += offset;
|
||||
keyframeViewModel.Update(LayerPropertiesViewModel.PixelsPerSecond);
|
||||
}
|
||||
}
|
||||
|
||||
_profileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void CreateViewModels(LayerPropertyViewModel property)
|
||||
{
|
||||
PropertyTrackViewModels.Add(_propertyTrackVmFactory.Create(this, property));
|
||||
foreach (var child in property.Children)
|
||||
CreateViewModels(child);
|
||||
}
|
||||
|
||||
#region Keyframe selection
|
||||
|
||||
private Point _mouseDragStartPoint;
|
||||
private bool _mouseDragging;
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void TimelineCanvasMouseDown(object sender, MouseButtonEventArgs e)
|
||||
@@ -110,12 +134,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
SelectionRectangle.Rect = new Rect();
|
||||
_mouseDragStartPoint = e.GetPosition((IInputElement) sender);
|
||||
_mouseDragging = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void TimelineCanvasMouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
var position = e.GetPosition((IInputElement)sender);
|
||||
if (!_mouseDragging)
|
||||
return;
|
||||
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||
SelectionRectangle.Rect = selectedRect;
|
||||
|
||||
@@ -130,21 +159,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
return HitTestFilterBehavior.Continue;
|
||||
});
|
||||
VisualTreeHelper.HitTest((Visual) sender, filterCallback, resultCallback, hitTestParams);
|
||||
|
||||
|
||||
var keyframeViewModels = PropertyTrackViewModels.SelectMany(t => t.KeyframeViewModels.OrderBy(k => k.Keyframe.Position)).ToList();
|
||||
foreach (var keyframeViewModel in keyframeViewModels)
|
||||
keyframeViewModel.IsSelected = selectedKeyframes.Contains(keyframeViewModel);
|
||||
|
||||
_mouseDragging = false;
|
||||
e.Handled = true;
|
||||
((IInputElement) sender).ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
public void TimelineCanvasMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
if (_mouseDragging && e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||
SelectionRectangle.Rect = selectedRect;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,32 +223,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Keyframe movement
|
||||
|
||||
public void MoveSelectedKeyframes(TimeSpan offset)
|
||||
{
|
||||
var keyframeViewModels = PropertyTrackViewModels.SelectMany(t => t.KeyframeViewModels.OrderBy(k => k.Keyframe.Position)).ToList();
|
||||
foreach (var keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected))
|
||||
{
|
||||
// TODO: Not ideal as this stacks them all if they get to 0, oh well
|
||||
if (keyframeViewModel.Keyframe.Position + offset > TimeSpan.Zero)
|
||||
{
|
||||
keyframeViewModel.Keyframe.Position += offset;
|
||||
keyframeViewModel.Update(LayerPropertiesViewModel.PixelsPerSecond);
|
||||
}
|
||||
}
|
||||
|
||||
_profileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void CreateViewModels(LayerPropertyViewModel property)
|
||||
{
|
||||
PropertyTrackViewModels.Add(_propertyTrackVmFactory.Create(this, property));
|
||||
foreach (var child in property.Children)
|
||||
CreateViewModels(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -48,6 +48,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Released)
|
||||
return;
|
||||
|
||||
((IInputElement)sender).CaptureMouse();
|
||||
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift) && !IsSelected)
|
||||
PropertyTrackViewModel.PropertyTimelineViewModel.SelectKeyframe(this, true, false);
|
||||
else if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
|
||||
@@ -55,16 +57,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
else if (!IsSelected)
|
||||
PropertyTrackViewModel.PropertyTimelineViewModel.SelectKeyframe(this, false, false);
|
||||
|
||||
((IInputElement) sender).CaptureMouse();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
public void KeyframeMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Released)
|
||||
return;
|
||||
((IInputElement) sender).ReleaseMouseCapture();
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
|
||||
((IInputElement)sender).ReleaseMouseCapture();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
PropertyTrackViewModel.PropertyTimelineViewModel.MoveSelectedKeyframes(newTime - Keyframe.Position);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -46,14 +46,14 @@
|
||||
<DataTrigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="StrokeThickness" To="1" Duration="0:0:0.25"></DoubleAnimation>
|
||||
<DoubleAnimation Storyboard.TargetProperty="StrokeThickness" To="1" Duration="0:0:0.25" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.EnterActions>
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="StrokeThickness" To="0" Duration="0:0:0.25"></DoubleAnimation>
|
||||
<DoubleAnimation Storyboard.TargetProperty="StrokeThickness" To="0" Duration="0:0:0.25" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
|
||||
Reference in new issue
Block a user