From ecee78141d52138cd050b4cc953a0aa2dd0b2648 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Thu, 9 Jan 2020 22:01:41 +0100 Subject: [PATCH] Re-enabled timeline scrolling and fixed the issues with it --- .../Profile/LayerProperties/LayerProperty.cs | 2 +- .../LayerProperties/LayerPropertiesView.xaml | 49 ++++++++++++------- .../LayerPropertiesView.xaml.cs | 11 +++++ .../LayerPropertiesViewModel.cs | 6 +-- .../Timeline/PropertyTimelineHeader.cs | 1 - .../Timeline/PropertyTimelineViewModel.cs | 2 + 6 files changed, 47 insertions(+), 24 deletions(-) diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs index 59fe67272..62858b53e 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs @@ -21,7 +21,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties /// /// The value of the property with keyframes applied /// - public T CurrentValue => (T) KeyframeEngine.GetCurrentValue(); + public T CurrentValue => KeyframeEngine != null ? (T) KeyframeEngine.GetCurrentValue() : Value; /// /// A list of keyframes defining different values of the property in time, this list contains the strongly typed diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml index 70a77f0e9..0b27a31cf 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml @@ -41,40 +41,51 @@ - + - - - - - - - - + + + + + + + - + VisibleWidth="{Binding ActualWidth, ElementName=TimelineHeaderScrollViewer}" + Width="{Binding ActualWidth, ElementName=PropertyTimeLine}" /> + - - + + + + + + + + diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml.cs index 4bc4ca79e..859b751f3 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml.cs @@ -13,5 +13,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties } // Keeping the scroll viewers in sync is up to the view, not a viewmodel concern + private void TimelineScrollChanged(object sender, ScrollChangedEventArgs e) + { + if (sender == TimelineHeaderScrollViewer) + { + TimelineRailsScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset); + } + else if (sender == TimelineRailsScrollViewer) + { + TimelineHeaderScrollViewer.ScrollToHorizontalOffset(e.HorizontalOffset); + } + } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs index 3f9535ed2..742b7e63a 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs @@ -96,7 +96,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties private bool _mouseOverCaret; private int _pixelsPerSecond; - public void RightGridMouseDown(object sender, MouseButtonEventArgs e) + public void TimelineMouseDown(object sender, MouseButtonEventArgs e) { // TODO Preserve mouse offset _caretStartMouseStartOffset = e.GetPosition((IInputElement) sender).X - TimeCaretPosition.Left; @@ -113,10 +113,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties _mouseOverCaret = false; } - public void RightGridMouseMove(object sender, MouseEventArgs e) + public void TimelineMouseMove(object sender, MouseEventArgs e) { if (_mouseOverCaret && e.LeftButton == MouseButtonState.Pressed) - TimeCaretPosition = new Thickness(Math.Max(0, e.GetPosition((IInputElement) sender).X), 0, 0, 0); + TimeCaretPosition = new Thickness(Math.Max(0, e.GetPosition((IInputElement) sender).X + _caretStartMouseStartOffset), 0, 0, 0); } #endregion diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/PropertyTimelineHeader.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/PropertyTimelineHeader.cs index be55f7b43..4cee1446d 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/PropertyTimelineHeader.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/PropertyTimelineHeader.cs @@ -60,7 +60,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline protected override void OnRender(DrawingContext drawingContext) { - SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased); base.OnRender(drawingContext); UpdateTimeScale(); diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/PropertyTimelineViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/PropertyTimelineViewModel.cs index 08a208eab..574d7586f 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/PropertyTimelineViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/PropertyTimelineViewModel.cs @@ -64,6 +64,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline { foreach (var viewModel in PropertyTrackViewModels) viewModel.UpdateKeyframes(LayerPropertiesViewModel.PixelsPerSecond); + + UpdateEndTime(); } ///