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

Merge branch 'master' into development

flabbet 8 сар өмнө
parent
commit
bee69c0c5f

+ 3 - 3
src/PixiEditor.SVG/Enums/SvgStrokeLineJoin.cs

@@ -2,9 +2,9 @@
 
 
 public enum SvgStrokeLineJoin
 public enum SvgStrokeLineJoin
 {
 {
-    Arcs,
-    Bevel,
     Miter,
     Miter,
+    Round,
+    Bevel,
+    Arcs,
     MiterClip,
     MiterClip,
-    Round
 }
 }

+ 3 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -787,5 +787,7 @@
   "FILL_TYPE_WINDING": "Winding",
   "FILL_TYPE_WINDING": "Winding",
   "FILL_TYPE_EVEN_ODD": "Even Odd",
   "FILL_TYPE_EVEN_ODD": "Even Odd",
   "FILL_TYPE_INVERSE_WINDING": "Inverse Winding",
   "FILL_TYPE_INVERSE_WINDING": "Inverse Winding",
-  "FILL_TYPE_INVERSE_EVEN_ODD": "Inverse Even Odd"
+  "FILL_TYPE_INVERSE_EVEN_ODD": "Inverse Even Odd",
+  "STROKE_CAP": "Stroke Cap",
+  "STROKE_JOIN": "Stroke Join"
 }
 }

+ 12 - 15
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/VectorPathToolExecutor.cs

@@ -1,6 +1,7 @@
 using Avalonia.Input;
 using Avalonia.Input;
 using Avalonia.Media;
 using Avalonia.Media;
 using ChunkyImageLib.DataHolders;
 using ChunkyImageLib.DataHolders;
+using Drawie.Backend.Core.Surfaces.PaintImpl;
 using Drawie.Backend.Core.Vector;
 using Drawie.Backend.Core.Vector;
 using Drawie.Numerics;
 using Drawie.Numerics;
 using PixiEditor.ChangeableDocument;
 using PixiEditor.ChangeableDocument;
@@ -25,7 +26,7 @@ using Colors = Drawie.Backend.Core.ColorsImpl.Colors;
 
 
 namespace PixiEditor.Models.DocumentModels.UpdateableChangeExecutors;
 namespace PixiEditor.Models.DocumentModels.UpdateableChangeExecutors;
 
 
-internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorFeature, IMidChangeUndoableExecutor
+internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorFeature
 {
 {
     private IStructureMemberHandler member;
     private IStructureMemberHandler member;
     private VectorPath startingPath;
     private VectorPath startingPath;
@@ -36,8 +37,6 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
 
 
     public override ExecutorType Type => ExecutorType.ToolLinked;
     public override ExecutorType Type => ExecutorType.ToolLinked;
 
 
-    public bool CanUndo => document.PathOverlayHandler.HasUndo;
-    public bool CanRedo => document.PathOverlayHandler.HasRedo;
     public bool StopExecutionOnNormalUndo => false;
     public bool StopExecutionOnNormalUndo => false;
 
 
     public override bool BlocksOtherActions => false;
     public override bool BlocksOtherActions => false;
@@ -102,9 +101,9 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
                 }
                 }
 
 
                 //below forces undo before starting new path
                 //below forces undo before starting new path
-                //internals.ActionAccumulator.AddFinishedActions(new EndSetShapeGeometry_Action());
+               // internals.ActionAccumulator.AddFinishedActions(new EndSetShapeGeometry_Action());
 
 
-                //internals.ActionAccumulator.AddActions(new SetShapeGeometry_Action(member.Id, ConstructShapeData()));
+               // internals.ActionAccumulator.AddActions(new SetShapeGeometry_Action(member.Id, ConstructShapeData(startingPath)));
             }
             }
         }
         }
         else
         else
@@ -207,6 +206,9 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
                 StrokeWidth = (float)toolbar.ToolSize,
                 StrokeWidth = (float)toolbar.ToolSize,
                 StrokeColor = toolbar.StrokeColor.ToColor(),
                 StrokeColor = toolbar.StrokeColor.ToColor(),
                 FillColor = toolbar.Fill ? toolbar.FillColor.ToColor() : Colors.Transparent,
                 FillColor = toolbar.Fill ? toolbar.FillColor.ToColor() : Colors.Transparent,
+                Fill = toolbar.Fill,
+                StrokeLineCap = vectorPathToolHandler.StrokeLineCap,
+                StrokeLineJoin = vectorPathToolHandler.StrokeLineJoin
             };
             };
         }
         }
         
         
@@ -215,6 +217,9 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
             StrokeWidth = (float)toolbar.ToolSize,
             StrokeWidth = (float)toolbar.ToolSize,
             StrokeColor = toolbar.StrokeColor.ToColor(),
             StrokeColor = toolbar.StrokeColor.ToColor(),
             FillColor = toolbar.Fill ? toolbar.FillColor.ToColor() : Colors.Transparent,
             FillColor = toolbar.Fill ? toolbar.FillColor.ToColor() : Colors.Transparent,
+            Fill = toolbar.Fill,
+            StrokeLineCap = vectorPathToolHandler.StrokeLineCap,
+            StrokeLineJoin = vectorPathToolHandler.StrokeLineJoin
         };
         };
     }
     }
 
 
@@ -238,16 +243,6 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
         };
         };
     }
     }
 
 
-    public void OnMidChangeUndo()
-    {
-        document.PathOverlayHandler.Undo();
-    }
-
-    public void OnMidChangeRedo()
-    {
-        document.PathOverlayHandler.Redo();
-    }
-
     protected void HighlightSnapping(string? snapX, string? snapY)
     protected void HighlightSnapping(string? snapX, string? snapY)
     {
     {
         document!.SnappingHandler.SnappingController.HighlightedXAxis = snapX;
         document!.SnappingHandler.SnappingController.HighlightedXAxis = snapX;
@@ -274,5 +269,7 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
         toolbar.Fill = pathData.Fill;
         toolbar.Fill = pathData.Fill;
         toolbar.FillColor = pathData.FillColor.ToColor();
         toolbar.FillColor = pathData.FillColor.ToColor();
         toolbar.GetSetting<EnumSettingViewModel<VectorPathFillType>>(nameof(VectorPathToolViewModel.FillMode)).Value = (VectorPathFillType)pathData.Path.FillType;
         toolbar.GetSetting<EnumSettingViewModel<VectorPathFillType>>(nameof(VectorPathToolViewModel.FillMode)).Value = (VectorPathFillType)pathData.Path.FillType;
+        toolbar.GetSetting<EnumSettingViewModel<StrokeCap>>(nameof(VectorPathToolViewModel.StrokeLineCap)).Value = pathData.StrokeLineCap;
+        toolbar.GetSetting<EnumSettingViewModel<StrokeJoin>>(nameof(VectorPathToolViewModel.StrokeLineJoin)).Value = pathData.StrokeLineJoin;
     }
     }
 }
 }

+ 0 - 4
src/PixiEditor/Models/Handlers/IPathOverlayHandler.cs

@@ -8,8 +8,4 @@ public interface IPathOverlayHandler : IHandler
     public void Hide();
     public void Hide();
     public event Action<VectorPath> PathChanged;
     public event Action<VectorPath> PathChanged;
     public bool IsActive { get; }
     public bool IsActive { get; }
-    public bool HasUndo { get; }
-    public bool HasRedo { get; }
-    public void Undo();
-    public void Redo();
 }
 }

+ 2 - 0
src/PixiEditor/Models/Handlers/Toolbars/IFillableShapeToolbar.cs

@@ -1,4 +1,6 @@
 using Avalonia.Media;
 using Avalonia.Media;
+using Drawie.Backend.Core.Surfaces.PaintImpl;
+using Drawie.Backend.Core.Vector;
 
 
 namespace PixiEditor.Models.Handlers.Toolbars;
 namespace PixiEditor.Models.Handlers.Toolbars;
 
 

+ 4 - 1
src/PixiEditor/Models/Handlers/Tools/IVectorPathToolHandler.cs

@@ -1,4 +1,5 @@
-using Drawie.Backend.Core.Vector;
+using Drawie.Backend.Core.Surfaces.PaintImpl;
+using Drawie.Backend.Core.Vector;
 using PixiEditor.ViewModels.Tools.Tools;
 using PixiEditor.ViewModels.Tools.Tools;
 
 
 namespace PixiEditor.Models.Handlers.Tools;
 namespace PixiEditor.Models.Handlers.Tools;
@@ -6,4 +7,6 @@ namespace PixiEditor.Models.Handlers.Tools;
 internal interface IVectorPathToolHandler : IToolHandler
 internal interface IVectorPathToolHandler : IToolHandler
 {
 {
     public VectorPathFillType FillMode { get; }
     public VectorPathFillType FillMode { get; }
+    public StrokeCap StrokeLineCap { get; }
+    public StrokeJoin StrokeLineJoin { get; }
 }
 }

+ 2 - 39
src/PixiEditor/ViewModels/Document/TransformOverlays/PathOverlayViewModel.cs

@@ -14,8 +14,6 @@ internal class PathOverlayViewModel : ObservableObject, IPathOverlayHandler
     private DocumentViewModel documentViewModel;
     private DocumentViewModel documentViewModel;
     private DocumentInternalParts internals;
     private DocumentInternalParts internals;
 
 
-    private PathOverlayUndoStack<VectorPath>? undoStack = null;
-
     private VectorPath path;
     private VectorPath path;
 
 
     public VectorPath Path
     public VectorPath Path
@@ -43,8 +41,6 @@ internal class PathOverlayViewModel : ObservableObject, IPathOverlayHandler
 
 
     public event Action<VectorPath>? PathChanged;
     public event Action<VectorPath>? PathChanged;
     public bool IsActive { get; set; }
     public bool IsActive { get; set; }
-    public bool HasUndo => undoStack.UndoCount > 0;
-    public bool HasRedo => undoStack.RedoCount > 0;
 
 
     private RelayCommand<VectorPath> addToUndoCommand;
     private RelayCommand<VectorPath> addToUndoCommand;
 
 
@@ -63,33 +59,24 @@ internal class PathOverlayViewModel : ObservableObject, IPathOverlayHandler
     }
     }
 
 
     private bool suppressUndo = false;
     private bool suppressUndo = false;
-    private RelayCommand<VectorPath> embeddedAddToUndo;
 
 
     public PathOverlayViewModel(DocumentViewModel documentViewModel, DocumentInternalParts internals)
     public PathOverlayViewModel(DocumentViewModel documentViewModel, DocumentInternalParts internals)
     {
     {
         this.documentViewModel = documentViewModel;
         this.documentViewModel = documentViewModel;
         this.internals = internals;
         this.internals = internals;
-
-        embeddedAddToUndo = new RelayCommand<VectorPath>(AddToUndo);
-
-        AddToUndoCommand = embeddedAddToUndo;
-        undoStack = new PathOverlayUndoStack<VectorPath>();
     }
     }
 
 
-    public void Show(VectorPath newPath, bool showApplyButton, Action<VectorPath>? customAddToUndo = null)
+    public void Show(VectorPath newPath, bool showApplyButton, Action<VectorPath>? customAddToUndo)
     {
     {
         if (IsActive)
         if (IsActive)
         {
         {
             return;
             return;
         }
         }
 
 
-        undoStack?.Dispose();
-        undoStack = new PathOverlayUndoStack<VectorPath>();
-        undoStack.AddState(new VectorPath(newPath));
         Path = newPath;
         Path = newPath;
         IsActive = true;
         IsActive = true;
         ShowApplyButton = showApplyButton;
         ShowApplyButton = showApplyButton;
-        AddToUndoCommand = customAddToUndo != null ? new RelayCommand<VectorPath>(customAddToUndo) : embeddedAddToUndo;
+        AddToUndoCommand = new RelayCommand<VectorPath>(customAddToUndo);
     }
     }
 
 
     public void Hide()
     public void Hide()
@@ -99,30 +86,6 @@ internal class PathOverlayViewModel : ObservableObject, IPathOverlayHandler
         ShowApplyButton = false;
         ShowApplyButton = false;
     }
     }
 
 
-    public void Undo()
-    {
-        suppressUndo = true;
-        Path = new VectorPath(undoStack?.Undo());
-        suppressUndo = false;
-    }
-
-    public void Redo()
-    {
-        suppressUndo = true;
-        Path = new VectorPath(undoStack?.Redo());
-        suppressUndo = false;
-    }
-
-    private void AddToUndo(VectorPath toAdd)
-    {
-        if (suppressUndo)
-        {
-            return;
-        }
-
-        undoStack?.AddState(new VectorPath(path));
-    }
-
     private void PathDataChanged(VectorPath path)
     private void PathDataChanged(VectorPath path)
     {
     {
         AddToUndoCommand.Execute(path);
         AddToUndoCommand.Execute(path);

+ 13 - 0
src/PixiEditor/ViewModels/Tools/Tools/VectorPathToolViewModel.cs

@@ -1,5 +1,6 @@
 using System.ComponentModel;
 using System.ComponentModel;
 using Avalonia.Input;
 using Avalonia.Input;
+using Drawie.Backend.Core.Surfaces.PaintImpl;
 using Drawie.Backend.Core.Vector;
 using Drawie.Backend.Core.Vector;
 using Drawie.Numerics;
 using Drawie.Numerics;
 using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
 using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
@@ -41,6 +42,18 @@ internal class VectorPathToolViewModel : ShapeTool, IVectorPathToolHandler
         get => GetValue<VectorPathFillType>();
         get => GetValue<VectorPathFillType>();
     }
     }
 
 
+    [Settings.Enum("STROKE_CAP", StrokeCap.Round)]
+    public StrokeCap StrokeLineCap
+    {
+        get => GetValue<StrokeCap>();
+    }
+
+    [Settings.Enum("STROKE_JOIN", StrokeJoin.Round)]
+    public StrokeJoin StrokeLineJoin
+    {
+        get => GetValue<StrokeJoin>();
+    }
+
     public VectorPathToolViewModel()
     public VectorPathToolViewModel()
     {
     {
         Toolbar = ToolbarFactory.Create<VectorPathToolViewModel, FillableShapeToolbar>(this);
         Toolbar = ToolbarFactory.Create<VectorPathToolViewModel, FillableShapeToolbar>(this);

+ 55 - 41
src/PixiEditor/Views/Main/Tools/Toolbar.axaml

@@ -13,62 +13,76 @@
             BorderThickness="{DynamicResource ThemeBorderThickness}"
             BorderThickness="{DynamicResource ThemeBorderThickness}"
             Cursor="Arrow"
             Cursor="Arrow"
             IsHitTestVisible="True"
             IsHitTestVisible="True"
-            Padding="5"
-            Height="40"
+            Padding="2.5"
             HorizontalAlignment="Left"
             HorizontalAlignment="Left"
             Background="{DynamicResource ThemeBackgroundBrush1}">
             Background="{DynamicResource ThemeBackgroundBrush1}">
-        <StackPanel Orientation="Horizontal">
-            <Button
-                Width="36" Height="36"
-                Classes="pixi-icon"
-                Command="{cmds:Command PixiEditor.Undo.Undo}"
-                ui:Translator.TooltipKey="UNDO">
-                <TextBlock Text="{DynamicResource icon-undo}" FontSize="20" />
-            </Button>
-            <Button
-                Command="{cmds:Command PixiEditor.Undo.Redo}"
-                Width="36" Height="36"
-                Classes="pixi-icon"
-                Margin="0, 0, 5, 0"
-                ui:Translator.TooltipKey="REDO">
-                <TextBlock Text="{DynamicResource icon-redo}" FontSize="20" />
-            </Button>
-            <ToggleButton
-                Width="30"
-                BorderThickness="0"
-                ui:Translator.TooltipKey="PEN_MODE"
-                Focusable="False"
-                Classes="pixi-icon"
-                Content="{DynamicResource icon-edit}"
-                FontSize="20"
-                IsChecked="{Binding StylusSubViewModel.IsPenModeEnabled}">
-            </ToggleButton>
-            <Grid Margin="5,5,10,5" Background="{DynamicResource ThemeBackgroundBrush2}" Width="5"
-                  IsVisible="{Binding ElementName=CollapseButton, Path=!IsChecked}" />
-            <Label CornerRadius="5" Background="{DynamicResource ThemeBackgroundBrush2}" Padding="5" FontSize="12"
-                   VerticalAlignment="Center" IsVisible="{Binding ElementName=CollapseButton, Path=!IsChecked}"
-                   ui:Translator.Key="{Binding ToolsSubViewModel.ActiveTool.DisplayName.Key}"
-                   ui:Translator.TooltipLocalizedString="{Binding ToolsSubViewModel.ActiveTool.ActionDisplay}" />
-            <ItemsControl IsVisible="{Binding ElementName=CollapseButton, Path=!IsChecked}"
+        <Grid>
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="Auto" />
+                <ColumnDefinition Width="*" />
+                <ColumnDefinition Width="Auto" />
+            </Grid.ColumnDefinitions>
+            <StackPanel Orientation="Horizontal">
+                <Button
+                    Width="36" Height="36"
+                    Classes="pixi-icon"
+                    Command="{cmds:Command PixiEditor.Undo.Undo}"
+                    ui:Translator.TooltipKey="UNDO">
+                    <TextBlock Text="{DynamicResource icon-undo}" FontSize="20" />
+                </Button>
+                <Button
+                    Command="{cmds:Command PixiEditor.Undo.Redo}"
+                    Width="36" Height="36"
+                    Classes="pixi-icon"
+                    Margin="0, 0, 5, 0"
+                    ui:Translator.TooltipKey="REDO">
+                    <TextBlock Text="{DynamicResource icon-redo}" FontSize="20" />
+                </Button>
+                <ToggleButton
+                    Width="30"
+                    BorderThickness="0"
+                    ui:Translator.TooltipKey="PEN_MODE"
+                    Focusable="False"
+                    Classes="pixi-icon"
+                    Content="{DynamicResource icon-edit}"
+                    FontSize="20"
+                    IsChecked="{Binding StylusSubViewModel.IsPenModeEnabled}">
+                </ToggleButton>
+                <Grid Margin="5,5,10,5" Background="{DynamicResource ThemeBackgroundBrush2}" Width="5"
+                      IsVisible="{Binding ElementName=CollapseButton, Path=!IsChecked}" />
+                <Label CornerRadius="5" Background="{DynamicResource ThemeBackgroundBrush2}" Padding="5" FontSize="12"
+                       VerticalAlignment="Center" IsVisible="{Binding ElementName=CollapseButton, Path=!IsChecked}"
+                       ui:Translator.Key="{Binding ToolsSubViewModel.ActiveTool.DisplayName.Key}"
+                       ui:Translator.TooltipLocalizedString="{Binding ToolsSubViewModel.ActiveTool.ActionDisplay}" />
+            </StackPanel>
+            <ItemsControl VerticalAlignment="Center" Grid.Column="1" IsVisible="{Binding ElementName=CollapseButton, Path=!IsChecked}"
                           ItemsSource="{Binding ToolsSubViewModel.ActiveTool.Toolbar.Settings}">
                           ItemsSource="{Binding ToolsSubViewModel.ActiveTool.Toolbar.Settings}">
                 <ItemsControl.ItemsPanel>
                 <ItemsControl.ItemsPanel>
                     <ItemsPanelTemplate>
                     <ItemsPanelTemplate>
-                        <StackPanel Orientation="Horizontal" Margin="0, 0, 0, 0" />
+                        <WrapPanel Orientation="Horizontal" Margin="0, 0, 0, 0" />
                     </ItemsPanelTemplate>
                     </ItemsPanelTemplate>
                 </ItemsControl.ItemsPanel>
                 </ItemsControl.ItemsPanel>
                 <ItemsControl.ItemTemplate>
                 <ItemsControl.ItemTemplate>
                     <DataTemplate x:DataType="settings:Setting">
                     <DataTemplate x:DataType="settings:Setting">
-                        <StackPanel IsVisible="{Binding IsExposed}" Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0,5,0">
+                        <StackPanel IsVisible="{Binding IsExposed}" Orientation="Horizontal"
+                                    VerticalAlignment="Center" Margin="5,0,5,0">
                             <Label
                             <Label
                                 IsVisible="{Binding HasLabel}" VerticalAlignment="Center"
                                 IsVisible="{Binding HasLabel}" VerticalAlignment="Center"
-                                Foreground="{DynamicResource ThemeForegroundBrush}" ui:Translator.Key="{Binding Label.Key}" />
+                                Foreground="{DynamicResource ThemeForegroundBrush}"
+                                ui:Translator.Key="{Binding Label.Key}" />
                             <ContentControl VerticalAlignment="Center" Content="{Binding }" />
                             <ContentControl VerticalAlignment="Center" Content="{Binding }" />
                         </StackPanel>
                         </StackPanel>
                     </DataTemplate>
                     </DataTemplate>
                 </ItemsControl.ItemTemplate>
                 </ItemsControl.ItemTemplate>
             </ItemsControl>
             </ItemsControl>
-            <Border Margin="5 -5 5 -5" Width="1" Background="{DynamicResource ThemeBackgroundBrush2}"/>
-            <ToggleButton Name="CollapseButton" Classes="ExpandCollapseToggleStyle Right" VerticalAlignment="Center" />
-        </StackPanel>
+
+            <StackPanel Grid.Column="2" Orientation="Horizontal">
+                <Border Margin="5 -5 5 -5" Width="1"
+                        Background="{DynamicResource ThemeBackgroundBrush2}" />
+                <ToggleButton Name="CollapseButton" Classes="ExpandCollapseToggleStyle Right"
+                              Background="Transparent"
+                              VerticalAlignment="Center" />
+            </StackPanel>
+        </Grid>
     </Border>
     </Border>
 </UserControl>
 </UserControl>

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

@@ -143,7 +143,7 @@
         </overlays:TogglableFlyout>
         </overlays:TogglableFlyout>
         <Grid ZIndex="100" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10">
         <Grid ZIndex="100" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10">
             <Grid.RowDefinitions>
             <Grid.RowDefinitions>
-                <RowDefinition Height="45" />
+                <RowDefinition MinHeight="40" MaxHeight="120"/>
                 <RowDefinition Height="35" />
                 <RowDefinition Height="35" />
                 <RowDefinition Height="*" />
                 <RowDefinition Height="*" />
             </Grid.RowDefinitions>
             </Grid.RowDefinitions>