mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Profiles - Finished moving and improving timeline logic
This commit is contained in:
1 parent
4ede3876d4
commit
458fd2a704
20 files changed
+351
-245
No files matched your search
@@ -200,7 +200,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<RadioButton Grid.Column="0"
|
||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||
IsChecked="{Binding Path=RenderProfileElement.EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Restart}}">
|
||||
IsChecked="{Binding Path=RenderProfileElement.Timeline.EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Restart}}">
|
||||
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||
<materialDesign:PackIcon Kind="Repeat" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||
RESTART
|
||||
@@ -215,7 +215,7 @@
|
||||
</RadioButton>
|
||||
<RadioButton Grid.Column="1"
|
||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||
IsChecked="{Binding Path=RenderProfileElement.EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Ignore}}">
|
||||
IsChecked="{Binding Path=RenderProfileElement.Timeline.EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Ignore}}">
|
||||
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||
<materialDesign:PackIcon Kind="EarHearingOff" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||
IGNORE
|
||||
@@ -230,7 +230,7 @@
|
||||
</RadioButton>
|
||||
<RadioButton Grid.Column="2"
|
||||
Style="{StaticResource MaterialDesignTabRadioButton}"
|
||||
IsChecked="{Binding Path=RenderProfileElement.EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Copy}}">
|
||||
IsChecked="{Binding Path=RenderProfileElement.Timeline.EventOverlapMode, Converter={StaticResource ComparisonConverter}, ConverterParameter={x:Static core:TimeLineEventOverlapMode.Copy}}">
|
||||
<TextBlock VerticalAlignment="Center" FontSize="12">
|
||||
<materialDesign:PackIcon Kind="ContentCopy" VerticalAlignment="Center" Margin="-3 0 0 -3" />
|
||||
COPY
|
||||
|
||||
+6
-6
@@ -43,24 +43,24 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
||||
|
||||
public bool DisplayContinuously
|
||||
{
|
||||
get => RenderProfileElement?.PlayMode == TimelinePlayMode.Repeat;
|
||||
get => RenderProfileElement?.Timeline.PlayMode == TimelinePlayMode.Repeat;
|
||||
set
|
||||
{
|
||||
TimelinePlayMode playMode = value ? TimelinePlayMode.Repeat : TimelinePlayMode.Once;
|
||||
if (RenderProfileElement == null || RenderProfileElement?.PlayMode == playMode) return;
|
||||
RenderProfileElement.PlayMode = playMode;
|
||||
if (RenderProfileElement == null || RenderProfileElement?.Timeline.PlayMode == playMode) return;
|
||||
RenderProfileElement.Timeline.PlayMode = playMode;
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
}
|
||||
|
||||
public bool AlwaysFinishTimeline
|
||||
{
|
||||
get => RenderProfileElement?.StopMode == TimelineStopMode.Finish;
|
||||
get => RenderProfileElement?.Timeline.StopMode == TimelineStopMode.Finish;
|
||||
set
|
||||
{
|
||||
TimelineStopMode stopMode = value ? TimelineStopMode.Finish : TimelineStopMode.SkipToEnd;
|
||||
if (RenderProfileElement == null || RenderProfileElement?.StopMode == stopMode) return;
|
||||
RenderProfileElement.StopMode = stopMode;
|
||||
if (RenderProfileElement == null || RenderProfileElement?.Timeline.StopMode == stopMode) return;
|
||||
RenderProfileElement.Timeline.StopMode = stopMode;
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -237,7 +237,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
}
|
||||
|
||||
// While playing in preview data bindings aren't updated
|
||||
Registration.DataBinding.Update(0.04);
|
||||
Registration.DataBinding.Update(Registration.LayerProperty.ProfileElement.Timeline);
|
||||
|
||||
if (ActiveItem.SupportsTestValue)
|
||||
{
|
||||
|
||||
@@ -567,7 +567,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
{
|
||||
if (Repeating && RepeatTimeline)
|
||||
{
|
||||
if (newTime > SelectedProfileElement.TimelineLength)
|
||||
if (newTime > SelectedProfileElement.Timeline.Length)
|
||||
newTime = TimeSpan.Zero;
|
||||
}
|
||||
else if (Repeating && RepeatSegment)
|
||||
@@ -575,9 +575,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
if (newTime > GetCurrentSegmentEnd())
|
||||
newTime = GetCurrentSegmentStart();
|
||||
}
|
||||
else if (newTime > SelectedProfileElement.TimelineLength)
|
||||
else if (newTime > SelectedProfileElement.Timeline.Length)
|
||||
{
|
||||
newTime = SelectedProfileElement.TimelineLength;
|
||||
newTime = SelectedProfileElement.Timeline.Length;
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -148,8 +148,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
if (position < TimeSpan.Zero)
|
||||
LayerPropertyKeyframe.Position = TimeSpan.Zero;
|
||||
else if (position > _profileEditorService.SelectedProfileElement.TimelineLength)
|
||||
LayerPropertyKeyframe.Position = _profileEditorService.SelectedProfileElement.TimelineLength;
|
||||
else if (position > _profileEditorService.SelectedProfileElement.Timeline.Length)
|
||||
LayerPropertyKeyframe.Position = _profileEditorService.SelectedProfileElement.Timeline.Length;
|
||||
else
|
||||
LayerPropertyKeyframe.Position = position;
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
);
|
||||
// If possible, shift the keyframe to the right by 11 pixels
|
||||
TimeSpan desiredPosition = newKeyframe.Position + TimeSpan.FromMilliseconds(1000f / _profileEditorService.PixelsPerSecond * 11);
|
||||
if (desiredPosition <= newKeyframe.LayerProperty.ProfileElement.TimelineLength)
|
||||
if (desiredPosition <= newKeyframe.LayerProperty.ProfileElement.Timeline.Length)
|
||||
newKeyframe.Position = desiredPosition;
|
||||
// Otherwise if possible shift it to the left by 11 pixels
|
||||
else
|
||||
|
||||
+2
-2
@@ -56,10 +56,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
start ??= TimeSpan.Zero;
|
||||
end ??= TimeSpan.MaxValue;
|
||||
|
||||
List<LayerPropertyKeyframe<T>> toShift = LayerProperty.Keyframes.Where(k => k.Position >= start && k.Position < end).ToList();
|
||||
List<LayerPropertyKeyframe<T>> toShift = LayerProperty.Keyframes.Where(k => k.Position > start && k.Position < end).ToList();
|
||||
foreach (LayerPropertyKeyframe<T> keyframe in toShift)
|
||||
keyframe.Position += amount;
|
||||
|
||||
|
||||
UpdateKeyframes();
|
||||
}
|
||||
|
||||
|
||||
+48
-54
@@ -48,7 +48,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
ProfileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
ProfileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
|
||||
if (ProfileEditorService.SelectedProfileElement != null)
|
||||
ProfileEditorService.SelectedProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
|
||||
ProfileEditorService.SelectedProfileElement.Timeline.PropertyChanged += TimelineOnPropertyChanged;
|
||||
|
||||
Update();
|
||||
}
|
||||
@@ -104,13 +104,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
if (Segment != SegmentViewModelType.Main)
|
||||
return false;
|
||||
return SelectedProfileElement?.PlayMode == TimelinePlayMode.Repeat;
|
||||
return SelectedProfileElement?.Timeline.PlayMode == TimelinePlayMode.Repeat;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Segment != SegmentViewModelType.Main)
|
||||
if (Segment != SegmentViewModelType.Main || SelectedProfileElement == null)
|
||||
return;
|
||||
SelectedProfileElement.PlayMode = value ? TimelinePlayMode.Repeat : TimelinePlayMode.Once;
|
||||
SelectedProfileElement.Timeline.PlayMode = value ? TimelinePlayMode.Repeat : TimelinePlayMode.Once;
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
NotifyOfPropertyChange(nameof(RepeatSegment));
|
||||
}
|
||||
@@ -156,32 +156,35 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
if (SelectedProfileElement == null)
|
||||
{
|
||||
SegmentLength = TimeSpan.Zero;
|
||||
SegmentStart = TimeSpan.Zero;
|
||||
SegmentEnd = TimeSpan.Zero;
|
||||
SegmentLength = TimeSpan.Zero;
|
||||
SegmentStartPosition = 0;
|
||||
SegmentWidth = 0;
|
||||
SegmentEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// It would be nice to do this differently if this patterns end up appearing in more places
|
||||
if (Segment == SegmentViewModelType.Start)
|
||||
{
|
||||
SegmentLength = SelectedProfileElement.StartSegmentLength;
|
||||
SegmentStart = TimeSpan.Zero;
|
||||
SegmentEnd = SelectedProfileElement.Timeline.StartSegmentEndPosition;
|
||||
SegmentLength = SelectedProfileElement.Timeline.StartSegmentLength;
|
||||
}
|
||||
else if (Segment == SegmentViewModelType.Main)
|
||||
{
|
||||
SegmentLength = SelectedProfileElement.MainSegmentLength;
|
||||
SegmentStart = SelectedProfileElement.StartSegmentLength;
|
||||
SegmentStart = SelectedProfileElement.Timeline.MainSegmentStartPosition;
|
||||
SegmentEnd = SelectedProfileElement.Timeline.MainSegmentEndPosition;
|
||||
SegmentLength = SelectedProfileElement.Timeline.MainSegmentLength;
|
||||
}
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
{
|
||||
SegmentLength = SelectedProfileElement.EndSegmentLength;
|
||||
SegmentStart = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength;
|
||||
SegmentStart = SelectedProfileElement.Timeline.EndSegmentStartPosition;
|
||||
SegmentEnd = SelectedProfileElement.Timeline.EndSegmentEndPosition;
|
||||
SegmentLength = SelectedProfileElement.Timeline.EndSegmentLength;
|
||||
}
|
||||
|
||||
SegmentEnd = SegmentStart + SegmentLength;
|
||||
SegmentStartPosition = SegmentStart.TotalSeconds * ProfileEditorService.PixelsPerSecond;
|
||||
SegmentWidth = SegmentLength.TotalSeconds * ProfileEditorService.PixelsPerSecond;
|
||||
SegmentEnabled = SegmentLength != TimeSpan.Zero;
|
||||
@@ -195,28 +198,25 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
public void DisableSegment()
|
||||
{
|
||||
TimeSpan startSegmentEnd = SelectedProfileElement.StartSegmentLength;
|
||||
TimeSpan mainSegmentEnd = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength;
|
||||
|
||||
TimeSpan oldSegmentLength = SegmentLength;
|
||||
|
||||
if (Segment == SegmentViewModelType.Start)
|
||||
{
|
||||
// Remove keyframes that fall in this segment
|
||||
WipeKeyframes(null, startSegmentEnd);
|
||||
SelectedProfileElement.StartSegmentLength = TimeSpan.Zero;
|
||||
WipeKeyframes(null, SelectedProfileElement.Timeline.StartSegmentEndPosition);
|
||||
SelectedProfileElement.Timeline.StartSegmentLength = TimeSpan.Zero;
|
||||
}
|
||||
else if (Segment == SegmentViewModelType.Main)
|
||||
{
|
||||
// Remove keyframes that fall in this segment
|
||||
WipeKeyframes(startSegmentEnd, startSegmentEnd);
|
||||
SelectedProfileElement.MainSegmentLength = TimeSpan.Zero;
|
||||
WipeKeyframes(SelectedProfileElement.Timeline.MainSegmentStartPosition, SelectedProfileElement.Timeline.MainSegmentEndPosition);
|
||||
SelectedProfileElement.Timeline.MainSegmentLength = TimeSpan.Zero;
|
||||
}
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
{
|
||||
// Remove keyframes that fall in this segment
|
||||
WipeKeyframes(mainSegmentEnd, null);
|
||||
SelectedProfileElement.EndSegmentLength = TimeSpan.Zero;
|
||||
WipeKeyframes(SelectedProfileElement.Timeline.EndSegmentStartPosition, SelectedProfileElement.Timeline.EndSegmentEndPosition);
|
||||
SelectedProfileElement.Timeline.EndSegmentLength = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
ShiftNextSegment(SegmentLength - oldSegmentLength);
|
||||
@@ -228,11 +228,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
ShiftNextSegment(TimeSpan.FromSeconds(1));
|
||||
if (Segment == SegmentViewModelType.Start)
|
||||
SelectedProfileElement.StartSegmentLength = TimeSpan.FromSeconds(1);
|
||||
SelectedProfileElement.Timeline.StartSegmentLength = TimeSpan.FromSeconds(1);
|
||||
else if (Segment == SegmentViewModelType.Main)
|
||||
SelectedProfileElement.MainSegmentLength = TimeSpan.FromSeconds(1);
|
||||
SelectedProfileElement.Timeline.MainSegmentLength = TimeSpan.FromSeconds(1);
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
SelectedProfileElement.EndSegmentLength = TimeSpan.FromSeconds(1);
|
||||
SelectedProfileElement.Timeline.EndSegmentLength = TimeSpan.FromSeconds(1);
|
||||
|
||||
ProfileEditorService.UpdateSelectedProfileElement();
|
||||
Update();
|
||||
@@ -290,27 +290,24 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
public void UpdateLength(TimeSpan newTime)
|
||||
{
|
||||
TimeSpan oldSegmentLength = SegmentLength;
|
||||
if (newTime < TimeSpan.FromMilliseconds(100))
|
||||
newTime = TimeSpan.FromMilliseconds(100);
|
||||
|
||||
TimeSpan difference = newTime - SegmentEnd;
|
||||
|
||||
if (difference > TimeSpan.Zero)
|
||||
ShiftNextSegment(difference);
|
||||
|
||||
if (Segment == SegmentViewModelType.Start)
|
||||
{
|
||||
if (newTime < TimeSpan.FromMilliseconds(100))
|
||||
newTime = TimeSpan.FromMilliseconds(100);
|
||||
SelectedProfileElement.StartSegmentLength = newTime;
|
||||
}
|
||||
SelectedProfileElement.Timeline.StartSegmentEndPosition = newTime;
|
||||
else if (Segment == SegmentViewModelType.Main)
|
||||
{
|
||||
if (newTime < SelectedProfileElement.StartSegmentLength + TimeSpan.FromMilliseconds(100))
|
||||
newTime = SelectedProfileElement.StartSegmentLength + TimeSpan.FromMilliseconds(100);
|
||||
SelectedProfileElement.MainSegmentLength = newTime - SelectedProfileElement.StartSegmentLength;
|
||||
}
|
||||
SelectedProfileElement.Timeline.MainSegmentEndPosition = newTime;
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
{
|
||||
if (newTime < SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength + TimeSpan.FromMilliseconds(100))
|
||||
newTime = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength + TimeSpan.FromMilliseconds(100);
|
||||
SelectedProfileElement.EndSegmentLength = newTime - SelectedProfileElement.StartSegmentLength - SelectedProfileElement.MainSegmentLength;
|
||||
}
|
||||
SelectedProfileElement.Timeline.EndSegmentEndPosition = newTime;
|
||||
|
||||
if (difference < TimeSpan.Zero)
|
||||
ShiftNextSegment(difference);
|
||||
|
||||
ShiftNextSegment(SegmentLength - oldSegmentLength);
|
||||
Update();
|
||||
}
|
||||
|
||||
@@ -323,7 +320,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
ProfileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
ProfileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
|
||||
if (SelectedProfileElement != null)
|
||||
SelectedProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
|
||||
SelectedProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -333,20 +330,20 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
private void ProfileEditorServiceOnProfileElementSelected(object? sender, RenderProfileElementEventArgs e)
|
||||
{
|
||||
if (e.PreviousRenderProfileElement != null)
|
||||
e.PreviousRenderProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
|
||||
e.PreviousRenderProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
if (e.RenderProfileElement != null)
|
||||
e.RenderProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
|
||||
e.RenderProfileElement.Timeline.PropertyChanged += TimelineOnPropertyChanged;
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
private void SelectedProfileElementOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
private void TimelineOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(RenderProfileElement.StartSegmentLength) ||
|
||||
e.PropertyName == nameof(RenderProfileElement.MainSegmentLength) ||
|
||||
e.PropertyName == nameof(RenderProfileElement.EndSegmentLength))
|
||||
if (e.PropertyName == nameof(Core.Timeline.StartSegmentLength) ||
|
||||
e.PropertyName == nameof(Core.Timeline.MainSegmentLength) ||
|
||||
e.PropertyName == nameof(Core.Timeline.EndSegmentLength))
|
||||
Update();
|
||||
else if (e.PropertyName == nameof(RenderProfileElement.PlayMode))
|
||||
else if (e.PropertyName == nameof(Core.Timeline.PlayMode))
|
||||
NotifyOfPropertyChange(nameof(RepeatSegment));
|
||||
}
|
||||
|
||||
@@ -359,15 +356,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
public void ShiftNextSegment(TimeSpan amount)
|
||||
{
|
||||
TimeSpan segmentEnd = TimeSpan.Zero;
|
||||
if (Segment == SegmentViewModelType.Start)
|
||||
segmentEnd = SelectedProfileElement.StartSegmentLength;
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.StartSegmentEndPosition, null, amount);
|
||||
else if (Segment == SegmentViewModelType.Main)
|
||||
segmentEnd = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength;
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.MainSegmentEndPosition, null, amount);
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
segmentEnd = SelectedProfileElement.TimelineLength;
|
||||
|
||||
ShiftKeyframes(segmentEnd, null, amount);
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.EndSegmentEndPosition, null, amount);
|
||||
}
|
||||
|
||||
private void WipeKeyframes(TimeSpan? start, TimeSpan? end)
|
||||
|
||||
+10
-13
@@ -29,7 +29,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
_profileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
_profileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
|
||||
if (_profileEditorService.SelectedProfileElement != null)
|
||||
_profileEditorService.SelectedProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
|
||||
_profileEditorService.SelectedProfileElement.Timeline.PropertyChanged += TimelineOnPropertyChanged;
|
||||
Update();
|
||||
}
|
||||
|
||||
@@ -75,9 +75,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
TotalTimelineWidth = EndSegmentEndPosition;
|
||||
}
|
||||
|
||||
private void SelectedProfileElementOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
private void TimelineOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
Update();
|
||||
if (e.PropertyName == nameof(Core.Timeline.StartSegmentLength) ||
|
||||
e.PropertyName == nameof(Core.Timeline.MainSegmentLength) ||
|
||||
e.PropertyName == nameof(Core.Timeline.EndSegmentLength))
|
||||
Update();
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
|
||||
@@ -88,9 +91,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
private void ProfileEditorServiceOnProfileElementSelected(object? sender, RenderProfileElementEventArgs e)
|
||||
{
|
||||
if (e.PreviousRenderProfileElement != null)
|
||||
e.PreviousRenderProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
|
||||
e.PreviousRenderProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
if (e.RenderProfileElement != null)
|
||||
e.RenderProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
|
||||
e.RenderProfileElement.Timeline.PropertyChanged += TimelineOnPropertyChanged;
|
||||
|
||||
Update();
|
||||
}
|
||||
@@ -184,13 +187,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
// If shift is held, snap to the current time
|
||||
// Take a tolerance of 5 pixels (half a keyframe width)
|
||||
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
||||
{
|
||||
float tolerance = 1000f / _profileEditorService.PixelsPerSecond * 5;
|
||||
if (Math.Abs(_profileEditorService.CurrentTime.TotalMilliseconds - time.TotalMilliseconds) < tolerance)
|
||||
time = _profileEditorService.CurrentTime;
|
||||
else if (Math.Abs(_profileEditorService.SelectedProfileElement.StartSegmentLength.TotalMilliseconds - time.TotalMilliseconds) < tolerance)
|
||||
time = _profileEditorService.SelectedProfileElement.StartSegmentLength;
|
||||
}
|
||||
time = _profileEditorService.SnapToTimeline(time, TimeSpan.FromMilliseconds(1000f / _profileEditorService.PixelsPerSecond * 5), false, true);
|
||||
|
||||
return time;
|
||||
}
|
||||
@@ -351,7 +348,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
_profileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
_profileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
|
||||
if (_profileEditorService.SelectedProfileElement != null)
|
||||
_profileEditorService.SelectedProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
|
||||
_profileEditorService.SelectedProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user