mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Re-enabled timeline scrolling and fixed the issues with it
This commit is contained in:
parent
0958c3af9f
commit
ecee78141d
@ -21,7 +21,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The value of the property with keyframes applied
|
/// The value of the property with keyframes applied
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public T CurrentValue => (T) KeyframeEngine.GetCurrentValue();
|
public T CurrentValue => KeyframeEngine != null ? (T) KeyframeEngine.GetCurrentValue() : Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of keyframes defining different values of the property in time, this list contains the strongly typed
|
/// A list of keyframes defining different values of the property in time, this list contains the strongly typed
|
||||||
|
|||||||
@ -41,40 +41,51 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Right side -->
|
<!-- Right side -->
|
||||||
<Grid Grid.Column="1"
|
<Grid Grid.Column="1">
|
||||||
MouseDown="{s:Action RightGridMouseDown}"
|
|
||||||
MouseMove="{s:Action RightGridMouseMove}">
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="56" />
|
<RowDefinition Height="56" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Caret -->
|
|
||||||
<Canvas ZIndex="1"
|
|
||||||
Margin="{Binding TimeCaretPosition}"
|
|
||||||
Cursor="SizeWE"
|
|
||||||
MouseEnter="{s:Action CaretMouseEnter}"
|
|
||||||
MouseLeave="{s:Action CaretMouseLeave}">
|
|
||||||
<Polygon Points="-10,0 0,20, 10,00" Fill="{StaticResource SecondaryAccentBrush}" />
|
|
||||||
<Line X1="0" X2="0" Y1="0" Y2="{Binding ActualHeight, ElementName=ContainerGrid}" StrokeThickness="2" Stroke="{StaticResource SecondaryAccentBrush}" />
|
|
||||||
</Canvas>
|
|
||||||
|
|
||||||
<!-- Timeline header -->
|
<!-- Timeline header -->
|
||||||
<ScrollViewer Grid.Row="0" x:Name="TimelineHeaderScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
|
<ScrollViewer Grid.Row="0" x:Name="TimelineHeaderScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" ScrollChanged="TimelineScrollChanged">
|
||||||
<StackPanel>
|
<Grid MouseDown="{s:Action TimelineMouseDown}"
|
||||||
|
MouseMove="{s:Action TimelineMouseMove}"
|
||||||
|
Background="{DynamicResource MaterialDesignCardBackground}">
|
||||||
|
<!-- Caret -->
|
||||||
|
<Canvas ZIndex="1"
|
||||||
|
Margin="{Binding TimeCaretPosition}"
|
||||||
|
Cursor="SizeWE"
|
||||||
|
MouseEnter="{s:Action CaretMouseEnter}"
|
||||||
|
MouseLeave="{s:Action CaretMouseLeave}">
|
||||||
|
<Polygon Points="-10,0 0,20, 10,00" Fill="{StaticResource SecondaryAccentBrush}" />
|
||||||
|
<Line X1="0" X2="0" Y1="0" Y2="{Binding ActualHeight, ElementName=ContainerGrid}" StrokeThickness="2" Stroke="{StaticResource SecondaryAccentBrush}" />
|
||||||
|
</Canvas>
|
||||||
<!-- Time -->
|
<!-- Time -->
|
||||||
<timeline:PropertyTimelineHeader Margin="0 25 0 0"
|
<timeline:PropertyTimelineHeader Margin="0 25 0 0"
|
||||||
Fill="{DynamicResource MaterialDesignBody}"
|
Fill="{DynamicResource MaterialDesignBody}"
|
||||||
PixelsPerSecond="{Binding PixelsPerSecond}"
|
PixelsPerSecond="{Binding PixelsPerSecond}"
|
||||||
HorizontalOffset="{Binding ContentHorizontalOffset, ElementName=TimelineHeaderScrollViewer}"
|
HorizontalOffset="{Binding ContentHorizontalOffset, ElementName=TimelineHeaderScrollViewer}"
|
||||||
VisibleWidth="{Binding ActualWidth, ElementName=TimelineHeaderScrollViewer}" />
|
VisibleWidth="{Binding ActualWidth, ElementName=TimelineHeaderScrollViewer}"
|
||||||
</StackPanel>
|
Width="{Binding ActualWidth, ElementName=PropertyTimeLine}" />
|
||||||
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
<!-- Timeline rails -->
|
<!-- Timeline rails -->
|
||||||
<ScrollViewer Grid.Row="1" x:Name="TimelineRailsScrollViewer" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Hidden">
|
<ScrollViewer Grid.Row="1" x:Name="TimelineRailsScrollViewer" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Hidden" ScrollChanged="TimelineScrollChanged">
|
||||||
<ContentControl s:View.Model="{Binding PropertyTimeline}" />
|
<Grid MouseDown="{s:Action TimelineMouseDown}"
|
||||||
|
MouseMove="{s:Action TimelineMouseMove}">
|
||||||
|
<Canvas ZIndex="1"
|
||||||
|
Margin="{Binding TimeCaretPosition}"
|
||||||
|
Cursor="SizeWE"
|
||||||
|
MouseEnter="{s:Action CaretMouseEnter}"
|
||||||
|
MouseLeave="{s:Action CaretMouseLeave}">
|
||||||
|
<Line X1="0" X2="0" Y1="0" Y2="{Binding ActualHeight, ElementName=ContainerGrid}" StrokeThickness="2" Stroke="{StaticResource SecondaryAccentBrush}" />
|
||||||
|
</Canvas>
|
||||||
|
<ContentControl x:Name="PropertyTimeLine" s:View.Model="{Binding PropertyTimeline}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|||||||
@ -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
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
private bool _mouseOverCaret;
|
private bool _mouseOverCaret;
|
||||||
private int _pixelsPerSecond;
|
private int _pixelsPerSecond;
|
||||||
|
|
||||||
public void RightGridMouseDown(object sender, MouseButtonEventArgs e)
|
public void TimelineMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
// TODO Preserve mouse offset
|
// TODO Preserve mouse offset
|
||||||
_caretStartMouseStartOffset = e.GetPosition((IInputElement) sender).X - TimeCaretPosition.Left;
|
_caretStartMouseStartOffset = e.GetPosition((IInputElement) sender).X - TimeCaretPosition.Left;
|
||||||
@ -113,10 +113,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
_mouseOverCaret = false;
|
_mouseOverCaret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RightGridMouseMove(object sender, MouseEventArgs e)
|
public void TimelineMouseMove(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (_mouseOverCaret && e.LeftButton == MouseButtonState.Pressed)
|
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
|
#endregion
|
||||||
|
|||||||
@ -60,7 +60,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
|||||||
|
|
||||||
protected override void OnRender(DrawingContext drawingContext)
|
protected override void OnRender(DrawingContext drawingContext)
|
||||||
{
|
{
|
||||||
SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
|
|
||||||
base.OnRender(drawingContext);
|
base.OnRender(drawingContext);
|
||||||
UpdateTimeScale();
|
UpdateTimeScale();
|
||||||
|
|
||||||
|
|||||||
@ -64,6 +64,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
|||||||
{
|
{
|
||||||
foreach (var viewModel in PropertyTrackViewModels)
|
foreach (var viewModel in PropertyTrackViewModels)
|
||||||
viewModel.UpdateKeyframes(LayerPropertiesViewModel.PixelsPerSecond);
|
viewModel.UpdateKeyframes(LayerPropertiesViewModel.PixelsPerSecond);
|
||||||
|
|
||||||
|
UpdateEndTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user