Browse Source

Fixed resize scene

flabbet 1 year ago
parent
commit
29f4331801

+ 3 - 1
src/PixiEditor.AvaloniaUI/Views/Main/ViewportControls/Viewport.axaml.cs

@@ -437,7 +437,9 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
     private void OnMainImageSizeChanged(object? sender, SizeChangedEventArgs e)
     private void OnMainImageSizeChanged(object? sender, SizeChangedEventArgs e)
     {
     {
         if (scene.Dimensions is { X: 0, Y: 0 }) return;
         if (scene.Dimensions is { X: 0, Y: 0 }) return;
-        scene.CenterContent(new VecD(e.NewSize.Width, e.NewSize.Height));
+        scene.CenterContent();
+        scene.ZoomIntoCenter(-1);
+        scene.ZoomIntoCenter(1); // a bit hacky, but it resets brush overlay properly
     }
     }
     
     
     private void ResetViewportClicked(object sender, RoutedEventArgs e)
     private void ResetViewportClicked(object sender, RoutedEventArgs e)

+ 0 - 1
src/PixiEditor.AvaloniaUI/Views/Rendering/Scene.cs

@@ -142,7 +142,6 @@ internal class Scene : Zoombox.Zoombox, ICustomHitTest
 
 
         RectD dirtyBounds = new RectD(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
         RectD dirtyBounds = new RectD(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
         Rect dirtyRect = new Rect(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
         Rect dirtyRect = new Rect(0, 0, Document.Width / resolutionScale, Document.Height / resolutionScale);
-        
 
 
         using var operation = new DrawSceneOperation(Surface, Document, CanvasPos, Scale * resolutionScale, angle, FlipX, FlipY,
         using var operation = new DrawSceneOperation(Surface, Document, CanvasPos, Scale * resolutionScale, angle, FlipX, FlipY,
             dirtyRect,
             dirtyRect,