2
0
Эх сурвалжийг харах

Made navigator update each frame and renamed navigator to preview

flabbet 9 сар өмнө
parent
commit
8998919188

+ 2 - 2
src/PixiEditor/Data/Localization/Languages/en.json

@@ -260,7 +260,7 @@
   "OPEN_STARTUP_WINDOW": "Open startup window",
   "OPEN_STARTUP_WINDOW": "Open startup window",
   "OPEN_SHORTCUT_WINDOW": "Open shortcuts window",
   "OPEN_SHORTCUT_WINDOW": "Open shortcuts window",
   "OPEN_ABOUT_WINDOW": "Open about window",
   "OPEN_ABOUT_WINDOW": "Open about window",
-  "OPEN_NAVIGATION_WINDOW": "Open navigation window",
+  "OPEN_PREVIEW_WINDOW": "Open preview window",
   "ERROR": "Error",
   "ERROR": "Error",
   "INTERNAL_ERROR": "Internal error",
   "INTERNAL_ERROR": "Internal error",
   "ERROR_SAVE_LOCATION": "Couldn't save the file to the specified location",
   "ERROR_SAVE_LOCATION": "Couldn't save the file to the specified location",
@@ -381,7 +381,7 @@
   "PALETTE_TITLE": "Palette",
   "PALETTE_TITLE": "Palette",
   "SWATCHES_TITLE": "Swatches",
   "SWATCHES_TITLE": "Swatches",
   "LAYERS_TITLE": "Layers",
   "LAYERS_TITLE": "Layers",
-  "NAVIGATION_TITLE": "Navigation",
+  "PREVIEW_TITLE": "Preview",
   "NORMAL_BLEND_MODE": "Normal",
   "NORMAL_BLEND_MODE": "Normal",
   "ERASE_BLEND_MODE": "Erase",
   "ERASE_BLEND_MODE": "Erase",
   "DARKEN_BLEND_MODE": "Darken",
   "DARKEN_BLEND_MODE": "Darken",

+ 1 - 1
src/PixiEditor/Data/ShortcutActionMaps/AsepriteShortcutMap.json

@@ -436,7 +436,7 @@
       "Parameters": []
       "Parameters": []
     },
     },
     "TogglePreview": {
     "TogglePreview": {
-      "Command": "PixiEditor.Window.OpenNavigationWindow",
+      "Command": "PixiEditor.Window.OpenPreviewWindow",
       "DefaultShortcut": {
       "DefaultShortcut": {
         "key": "F7",
         "key": "F7",
         "modifiers": null
         "modifiers": null

+ 3 - 10
src/PixiEditor/Models/Rendering/CanvasUpdater.cs

@@ -22,13 +22,6 @@ internal class CanvasUpdater
     private int lastOnionKeyFrames = -1;
     private int lastOnionKeyFrames = -1;
     private double lastOnionOpacity = -1;
     private double lastOnionOpacity = -1;
 
 
-    private static readonly Paint ReplacingPaint = new() { BlendMode = BlendMode.Src };
-
-    private static readonly Paint ClearPaint = new()
-    {
-        BlendMode = BlendMode.Src, Color = Colors.Transparent
-    };
-
     /// <summary>
     /// <summary>
     /// Affected chunks that have not been rerendered yet.
     /// Affected chunks that have not been rerendered yet.
     /// </summary>
     /// </summary>
@@ -65,7 +58,7 @@ internal class CanvasUpdater
     /// </summary>
     /// </summary>
     public async Task UpdateGatheredChunks
     public async Task UpdateGatheredChunks
         (AffectedAreasGatherer chunkGatherer, bool rerenderDelayed)
         (AffectedAreasGatherer chunkGatherer, bool rerenderDelayed)
-    { 
+    {
         await Task.Run(() => Render(chunkGatherer, rerenderDelayed)).ConfigureAwait(true);
         await Task.Run(() => Render(chunkGatherer, rerenderDelayed)).ConfigureAwait(true);
     }
     }
 
 
@@ -157,7 +150,7 @@ internal class CanvasUpdater
     {
     {
         Dictionary<ChunkResolution, HashSet<VecI>> chunksToRerender =
         Dictionary<ChunkResolution, HashSet<VecI>> chunksToRerender =
             FindGlobalChunksToRerender(chunkGatherer, rerenderDelayed);
             FindGlobalChunksToRerender(chunkGatherer, rerenderDelayed);
-        
+
         ChunkResolution onionSkinResolution = chunksToRerender.Min(x => x.Key);
         ChunkResolution onionSkinResolution = chunksToRerender.Min(x => x.Key);
 
 
         bool updatingStoredChunks = false;
         bool updatingStoredChunks = false;
@@ -199,7 +192,7 @@ internal class CanvasUpdater
             if (globalClippingRectangle is not null)
             if (globalClippingRectangle is not null)
                 globalScaledClippingRectangle =
                 globalScaledClippingRectangle =
                     (RectI?)((RectI)globalClippingRectangle).Scale(resolution.Multiplier()).RoundOutwards();
                     (RectI?)((RectI)globalClippingRectangle).Scale(resolution.Multiplier()).RoundOutwards();
-            
+
             foreach (var chunkPos in chunks)
             foreach (var chunkPos in chunks)
             {
             {
                 RenderChunk(chunkPos, resolution);
                 RenderChunk(chunkPos, resolution);

+ 7 - 2
src/PixiEditor/Models/Rendering/MemberPreviewUpdater.cs

@@ -52,7 +52,9 @@ internal class MemberPreviewUpdater
         Guid[] nodesGuids = nodesToUpdate as Guid[] ?? nodesToUpdate.ToArray();
         Guid[] nodesGuids = nodesToUpdate as Guid[] ?? nodesToUpdate.ToArray();
         Guid[] keyFramesGuids = keyFramesToUpdate as Guid[] ?? keyFramesToUpdate.ToArray();
         Guid[] keyFramesGuids = keyFramesToUpdate as Guid[] ?? keyFramesToUpdate.ToArray();
 
 
-        if (undoBoundaryPassed)
+        //TODO: It probably is a good idea to add this check for insignificant previews, like document tab icon
+        // But navigation uses the same preview painter so it must be separated before this check is added
+        //if (undoBoundaryPassed)
         {
         {
             RenderWholeCanvasPreview();
             RenderWholeCanvasPreview();
         }
         }
@@ -70,7 +72,7 @@ internal class MemberPreviewUpdater
     private void RenderWholeCanvasPreview()
     private void RenderWholeCanvasPreview()
     {
     {
         var previewSize = StructureHelpers.CalculatePreviewSize(internals.Tracker.Document.Size);
         var previewSize = StructureHelpers.CalculatePreviewSize(internals.Tracker.Document.Size);
-        float scaling = (float)previewSize.X / doc.SizeBindable.X;
+        //float scaling = (float)previewSize.X / doc.SizeBindable.X;
 
 
         if (doc.PreviewPainter == null)
         if (doc.PreviewPainter == null)
         {
         {
@@ -78,6 +80,9 @@ internal class MemberPreviewUpdater
                 doc.SizeBindable, internals.Tracker.Document.ProcessingColorSpace);
                 doc.SizeBindable, internals.Tracker.Document.ProcessingColorSpace);
         }
         }
 
 
+        doc.PreviewPainter.DocumentSize = doc.SizeBindable;
+        doc.PreviewPainter.ProcessingColorSpace = internals.Tracker.Document.ProcessingColorSpace;
+        doc.PreviewPainter.FrameTime = doc.AnimationHandler.ActiveFrameTime;
         doc.PreviewPainter.Repaint();
         doc.PreviewPainter.Repaint();
     }
     }
 
 

+ 4 - 4
src/PixiEditor/ViewModels/Dock/NavigationDockViewModel.cs → src/PixiEditor/ViewModels/Dock/DocumentPreviewDockViewModel.cs

@@ -7,12 +7,12 @@ using PixiEditor.ViewModels.SubViewModels;
 
 
 namespace PixiEditor.ViewModels.Dock;
 namespace PixiEditor.ViewModels.Dock;
 
 
-internal class NavigationDockViewModel : DockableViewModel
+internal class DocumentPreviewDockViewModel : DockableViewModel
 {
 {
-    public const string TabId = "Navigator";
+    public const string TabId = "DocumentPreview";
 
 
     public override string Id => TabId;
     public override string Id => TabId;
-    public override string Title => new LocalizedString("NAVIGATION_TITLE");
+    public override string Title => new LocalizedString("PREVIEW_TITLE");
     public override bool CanFloat => true;
     public override bool CanFloat => true;
     public override bool CanClose => true;
     public override bool CanClose => true;
 
 
@@ -32,7 +32,7 @@ internal class NavigationDockViewModel : DockableViewModel
         set => SetProperty(ref documentManagerSubViewModel, value);
         set => SetProperty(ref documentManagerSubViewModel, value);
     }
     }
 
 
-    public NavigationDockViewModel(ColorsViewModel colorsSubViewModel, DocumentManagerViewModel documentManagerViewModel)
+    public DocumentPreviewDockViewModel(ColorsViewModel colorsSubViewModel, DocumentManagerViewModel documentManagerViewModel)
     {
     {
         ColorsSubViewModel = colorsSubViewModel;
         ColorsSubViewModel = colorsSubViewModel;
         DocumentManagerSubViewModel = documentManagerViewModel;
         DocumentManagerSubViewModel = documentManagerViewModel;

+ 3 - 3
src/PixiEditor/ViewModels/Dock/LayoutManager.cs

@@ -33,7 +33,7 @@ internal class LayoutManager
         LayersDockViewModel layersDockViewModel = new(mainViewModel.DocumentManagerSubViewModel);
         LayersDockViewModel layersDockViewModel = new(mainViewModel.DocumentManagerSubViewModel);
         ColorPickerDockViewModel colorPickerDockViewModel = new(mainViewModel.ColorsSubViewModel);
         ColorPickerDockViewModel colorPickerDockViewModel = new(mainViewModel.ColorsSubViewModel);
         ColorSlidersDockViewModel colorSldersDockViewModel = new(mainViewModel.ColorsSubViewModel);
         ColorSlidersDockViewModel colorSldersDockViewModel = new(mainViewModel.ColorsSubViewModel);
-        NavigationDockViewModel navigationDockViewModel =
+        DocumentPreviewDockViewModel documentPreviewDockViewModel =
             new(mainViewModel.ColorsSubViewModel, mainViewModel.DocumentManagerSubViewModel);
             new(mainViewModel.ColorsSubViewModel, mainViewModel.DocumentManagerSubViewModel);
         SwatchesDockViewModel swatchesDockViewModel = new(mainViewModel.DocumentManagerSubViewModel);
         SwatchesDockViewModel swatchesDockViewModel = new(mainViewModel.DocumentManagerSubViewModel);
         PaletteViewerDockViewModel paletteViewerDockViewModel =
         PaletteViewerDockViewModel paletteViewerDockViewModel =
@@ -48,7 +48,7 @@ internal class LayoutManager
         RegisterDockable(layersDockViewModel);
         RegisterDockable(layersDockViewModel);
         RegisterDockable(colorPickerDockViewModel);
         RegisterDockable(colorPickerDockViewModel);
         RegisterDockable(colorSldersDockViewModel);
         RegisterDockable(colorSldersDockViewModel);
-        RegisterDockable(navigationDockViewModel);
+        RegisterDockable(documentPreviewDockViewModel);
         RegisterDockable(swatchesDockViewModel);
         RegisterDockable(swatchesDockViewModel);
         RegisterDockable(paletteViewerDockViewModel);
         RegisterDockable(paletteViewerDockViewModel);
         RegisterDockable(timelineDockViewModel);
         RegisterDockable(timelineDockViewModel);
@@ -101,7 +101,7 @@ internal class LayoutManager
                     SplitDirection = DockingDirection.Bottom,
                     SplitDirection = DockingDirection.Bottom,
                     Second = new DockableArea
                     Second = new DockableArea
                     {
                     {
-                        Id = "NavigatorArea", ActiveDockable = DockContext.CreateDockable(navigationDockViewModel)
+                        Id = "DocumentPreviewArea", ActiveDockable = DockContext.CreateDockable(documentPreviewDockViewModel)
                     }
                     }
                 }
                 }
             }
             }

+ 2 - 2
src/PixiEditor/ViewModels/SubViewModels/WindowViewModel.cs

@@ -210,8 +210,8 @@ internal class WindowViewModel : SubViewModel<ViewModelMain>
     }
     }
 
 
     [Commands_Command.Internal("PixiEditor.Window.ShowDockWindow")]
     [Commands_Command.Internal("PixiEditor.Window.ShowDockWindow")]
-    [Commands_Command.Basic("PixiEditor.Window.OpenNavigationWindow", "Navigator", "OPEN_NAVIGATION_WINDOW",
-        "OPEN_NAVIGATION_WINDOW")]
+    [Commands_Command.Basic("PixiEditor.Window.OpenPreviewWindow", "DocumentPreview", "OPEN_PREVIEW_WINDOW",
+        "OPEN_PREVIEW_WINDOW")]
     public void ShowDockWindow(string id)
     public void ShowDockWindow(string id)
     {
     {
         Owner.LayoutSubViewModel.LayoutManager.ShowDockable(id);
         Owner.LayoutSubViewModel.LayoutManager.ShowDockable(id);

+ 4 - 4
src/PixiEditor/Views/Dock/NavigationDockView.axaml → src/PixiEditor/Views/Dock/DocumentPreviewDockView.axaml

@@ -6,11 +6,11 @@
              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
              xmlns:dock="clr-namespace:PixiEditor.ViewModels.Dock"
              xmlns:dock="clr-namespace:PixiEditor.ViewModels.Dock"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
-             x:DataType="dock:NavigationDockViewModel"
-             x:Class="PixiEditor.Views.Dock.NavigationDockView">
+             x:DataType="dock:DocumentPreviewDockViewModel"
+             x:Class="PixiEditor.Views.Dock.DocumentPreviewDockView">
     <Design.DataContext>
     <Design.DataContext>
-        <dock:NavigationDockViewModel/>
+        <dock:DocumentPreviewDockViewModel/>
     </Design.DataContext>
     </Design.DataContext>
-    <main:Navigation Document="{Binding DocumentManagerSubViewModel.ActiveDocument}"
+    <main:DocumentPreview Document="{Binding DocumentManagerSubViewModel.ActiveDocument}"
                      PrimaryColor="{Binding ColorsSubViewModel.PrimaryColor, Mode=TwoWay, Converter={converters:GenericColorToMediaColorConverter}}"/>
                      PrimaryColor="{Binding ColorsSubViewModel.PrimaryColor, Mode=TwoWay, Converter={converters:GenericColorToMediaColorConverter}}"/>
 </UserControl>
 </UserControl>

+ 2 - 2
src/PixiEditor/Views/Dock/NavigationDockView.axaml.cs → src/PixiEditor/Views/Dock/DocumentPreviewDockView.axaml.cs

@@ -2,9 +2,9 @@
 
 
 namespace PixiEditor.Views.Dock;
 namespace PixiEditor.Views.Dock;
 
 
-public partial class NavigationDockView : UserControl
+public partial class DocumentPreviewDockView : UserControl
 {
 {
-    public NavigationDockView()
+    public DocumentPreviewDockView()
     {
     {
         InitializeComponent();
         InitializeComponent();
     }
     }

+ 1 - 1
src/PixiEditor/Views/Main/Navigation.axaml → src/PixiEditor/Views/Main/DocumentPreview.axaml

@@ -9,7 +9,7 @@
              xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
              xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              Name="uc"
              Name="uc"
-             x:Class="PixiEditor.Views.Main.Navigation">
+             x:Class="PixiEditor.Views.Main.DocumentPreview">
      <Grid>
      <Grid>
         <Grid.RowDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition Height="*"/>
             <RowDefinition Height="*"/>

+ 9 - 11
src/PixiEditor/Views/Main/Navigation.axaml.cs → src/PixiEditor/Views/Main/DocumentPreview.axaml.cs

@@ -1,11 +1,9 @@
-using System.Threading.Tasks;
-using Avalonia;
+using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Controls;
 using Avalonia.Input;
 using Avalonia.Input;
 using Avalonia.Interactivity;
 using Avalonia.Interactivity;
 using Avalonia.Media;
 using Avalonia.Media;
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
-using Drawie.Backend.Core.Numerics;
 using PixiEditor.Models.Controllers.InputDevice;
 using PixiEditor.Models.Controllers.InputDevice;
 using PixiEditor.Models.Tools;
 using PixiEditor.Models.Tools;
 using Drawie.Numerics;
 using Drawie.Numerics;
@@ -15,19 +13,19 @@ using Point = Avalonia.Point;
 
 
 namespace PixiEditor.Views.Main;
 namespace PixiEditor.Views.Main;
 
 
-internal partial class Navigation : UserControl
+internal partial class DocumentPreview : UserControl
 {
 {
     public static readonly StyledProperty<DocumentViewModel> DocumentProperty =
     public static readonly StyledProperty<DocumentViewModel> DocumentProperty =
-        AvaloniaProperty.Register<Navigation, DocumentViewModel>(nameof(Document));
+        AvaloniaProperty.Register<DocumentPreview, DocumentViewModel>(nameof(Document));
 
 
     public static readonly StyledProperty<Thickness> ColorCursorPositionProperty =
     public static readonly StyledProperty<Thickness> ColorCursorPositionProperty =
-        AvaloniaProperty.Register<Navigation, Thickness>(nameof(ColorCursorPosition));
+        AvaloniaProperty.Register<DocumentPreview, Thickness>(nameof(ColorCursorPosition));
 
 
     public static readonly StyledProperty<Color> ColorCursorColorProperty =
     public static readonly StyledProperty<Color> ColorCursorColorProperty =
-        AvaloniaProperty.Register<Navigation, Color>(nameof(ColorCursorColor));
+        AvaloniaProperty.Register<DocumentPreview, Color>(nameof(ColorCursorColor));
 
 
     public static readonly StyledProperty<Color> PrimaryColorProperty =
     public static readonly StyledProperty<Color> PrimaryColorProperty =
-        AvaloniaProperty.Register<Navigation, Color>(nameof(PrimaryColor));
+        AvaloniaProperty.Register<DocumentPreview, Color>(nameof(PrimaryColor));
 
 
     public DocumentViewModel Document
     public DocumentViewModel Document
     {
     {
@@ -55,7 +53,7 @@ internal partial class Navigation : UserControl
     
     
     private MouseUpdateController mouseUpdateController;
     private MouseUpdateController mouseUpdateController;
 
 
-    public Navigation()
+    public DocumentPreview()
     {
     {
         InitializeComponent();
         InitializeComponent();
         
         
@@ -81,7 +79,7 @@ internal partial class Navigation : UserControl
     {
     {
         if (ViewModelMain.Current != null)
         if (ViewModelMain.Current != null)
         {
         {
-            ViewModelMain.Current.ActionDisplays[nameof(Navigation)] = null;
+            ViewModelMain.Current.ActionDisplays[nameof(DocumentPreview)] = null;
         }
         }
     }
     }
 
 
@@ -89,7 +87,7 @@ internal partial class Navigation : UserControl
     {
     {
         if (ViewModelMain.Current != null)
         if (ViewModelMain.Current != null)
         {
         {
-            ViewModelMain.Current.ActionDisplays[nameof(Navigation)] = "NAVIGATOR_PICK_ACTION_DISPLAY";
+            ViewModelMain.Current.ActionDisplays[nameof(DocumentPreview)] = "NAVIGATOR_PICK_ACTION_DISPLAY";
         }
         }
     }
     }