Browse Source

Scroll Zoom

flabbet 1 year ago
parent
commit
18cb76f99a

+ 0 - 2
src/PixiEditor.AvaloniaUI/Styles/Templates/Timeline.axaml

@@ -36,8 +36,6 @@
                                 Command="{TemplateBinding DeleteKeyFrameCommand}" 
                                 IsEnabled="{Binding !!SelectedKeyFrame, RelativeSource={RelativeSource TemplatedParent}}"
                                 CommandParameter="{Binding SelectedKeyFrame.Id, RelativeSource={RelativeSource TemplatedParent}}"/>
-                        <TextBlock DockPanel.Dock="Left" Text="Scale:" />
-                        <Slider Minimum="1" Maximum="100" Value="{TemplateBinding Scale, Mode=TwoWay}" Width="100" />
                         <TextBlock Text="{Binding Scale, RelativeSource={RelativeSource TemplatedParent}}" />
                         <input:NumberInput Min="1"
                                            Value="{Binding Fps, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />

+ 28 - 6
src/PixiEditor.AvaloniaUI/Views/Animations/Timeline.cs

@@ -5,6 +5,7 @@ using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Controls.Metadata;
 using Avalonia.Controls.Primitives;
+using Avalonia.Input;
 using Avalonia.Interactivity;
 using Avalonia.Threading;
 using CommunityToolkit.Mvvm.Input;
@@ -120,6 +121,16 @@ internal class Timeline : TemplatedControl
         });
     }
 
+    public void Play()
+    {
+        IsPlaying = true;
+    }
+
+    public void Pause()
+    {
+        IsPlaying = false;
+    }
+    
     protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
     {
         base.OnApplyTemplate(e);
@@ -160,14 +171,25 @@ internal class Timeline : TemplatedControl
         }
     }
 
-    public void Play()
+    protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
     {
-        IsPlaying = true;
-    }
+        base.OnPointerWheelChanged(e);
+        
+        double newScale = Scale;
+        
+        int ticks = e.KeyModifiers.HasFlag(KeyModifiers.Control) ? 1 : 10;
 
-    public void Pause()
-    {
-        IsPlaying = false;
+        if (e.Delta.Y > 0)
+        {
+            newScale += ticks;
+        }
+        else
+        {
+            newScale -= ticks;
+        }
+        
+        newScale = Math.Clamp(newScale, 1, 900);
+        Scale = newScale;
     }
 
     private static void IsPlayingChanged(AvaloniaPropertyChangedEventArgs e)