Browse Source

Fixed fill type not updating, enum translations

flabbet 8 months ago
parent
commit
c362e63c99

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

@@ -783,5 +783,9 @@
   "PREVIOUS_TOOL_SET": "Previous tool set",
   "FILL_MODE": "Fill mode",
   "USE_LINEAR_SRGB_PROCESSING": "Use linear sRGB for processing colors",
-  "USE_LINEAR_SRGB_PROCESSING_DESC": "Convert document using legacy blending mode to linear sRGB for processing colors. This will affect the colors of the document, but will make blending more accurate."
+  "USE_LINEAR_SRGB_PROCESSING_DESC": "Convert document using legacy blending mode to linear sRGB for processing colors. This will affect the colors of the document, but will make blending more accurate.",
+  "FILL_TYPE_WINDING": "Winding",
+  "FILL_TYPE_EVEN_ODD": "Even Odd",
+  "FILL_TYPE_INVERSE_WINDING": "Inverse Winding",
+  "FILL_TYPE_INVERSE_EVEN_ODD": "Inverse Even Odd"
 }

+ 4 - 3
src/PixiEditor/Models/DocumentModels/UpdateableChangeExecutors/VectorPathToolExecutor.cs

@@ -17,6 +17,7 @@ using PixiEditor.Models.DocumentModels.UpdateableChangeExecutors.Features;
 using PixiEditor.Models.Handlers.Toolbars;
 using PixiEditor.Models.Tools;
 using PixiEditor.ViewModels.Tools.Tools;
+using PixiEditor.ViewModels.Tools.ToolSettings.Settings;
 using PixiEditor.Views.Overlays.PathOverlay;
 using Color = Drawie.Backend.Core.ColorsImpl.Color;
 using Colors = Drawie.Backend.Core.ColorsImpl.Colors;
@@ -193,7 +194,7 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
     {
         if(startingPath == null)
         {
-            return new PathVectorData(new VectorPath() { FillType = vectorPathToolHandler.FillMode })
+            return new PathVectorData(new VectorPath() { FillType = (PathFillType)vectorPathToolHandler.FillMode })
             {
                 StrokeWidth = (float)toolbar.ToolSize,
                 StrokeColor = toolbar.StrokeColor.ToColor(),
@@ -201,7 +202,7 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
             };
         }
         
-        return new PathVectorData(new VectorPath(startingPath) { FillType = vectorPathToolHandler.FillMode })
+        return new PathVectorData(new VectorPath(startingPath) { FillType = (PathFillType)vectorPathToolHandler.FillMode })
         {
             StrokeWidth = (float)toolbar.ToolSize,
             StrokeColor = toolbar.StrokeColor.ToColor(),
@@ -264,6 +265,6 @@ internal class VectorPathToolExecutor : UpdateableChangeExecutor, IPathExecutorF
         toolbar.ToolSize = pathData.StrokeWidth;
         toolbar.Fill = pathData.Fill;
         toolbar.FillColor = pathData.FillColor.ToColor();
-        toolbar.GetSetting(nameof(VectorPathToolViewModel.FillMode)).Value = pathData.Path.FillType;
+        toolbar.GetSetting<EnumSettingViewModel<VectorPathFillType>>(nameof(VectorPathToolViewModel.FillMode)).Value = (VectorPathFillType)pathData.Path.FillType;
     }
 }

+ 1 - 0
src/PixiEditor/Models/Handlers/Toolbars/IToolbar.cs

@@ -8,6 +8,7 @@ internal interface IToolbar : IHandler
 {
     public void AddSetting(Setting setting);
     public Setting GetSetting(string name);
+    public T GetSetting<T>(string name) where T : Setting;
     public IReadOnlyList<Setting> Settings { get; }
     public void SaveToolbarSettings();
     public void LoadSharedSettings();

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

@@ -1,8 +1,9 @@
 using Drawie.Backend.Core.Vector;
+using PixiEditor.ViewModels.Tools.Tools;
 
 namespace PixiEditor.Models.Handlers.Tools;
 
 internal interface IVectorPathToolHandler : IToolHandler
 {
-    public PathFillType FillMode { get; }
+    public VectorPathFillType FillMode { get; }
 }

+ 20 - 4
src/PixiEditor/ViewModels/Tools/Tools/VectorPathToolViewModel.cs

@@ -1,4 +1,5 @@
-using Avalonia.Input;
+using System.ComponentModel;
+using Avalonia.Input;
 using Drawie.Backend.Core.Vector;
 using Drawie.Numerics;
 using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
@@ -33,10 +34,10 @@ internal class VectorPathToolViewModel : ShapeTool, IVectorPathToolHandler
     private LocalizedString actionDisplayShift;
     private LocalizedString actionDisplayCtrlShift;
 
-    [Settings.Enum("FILL_MODE", PathFillType.Winding)]
-    public PathFillType FillMode
+    [Settings.Enum("FILL_MODE", VectorPathFillType.Winding)]
+    public VectorPathFillType FillMode
     {
-        get => GetValue<PathFillType>();
+        get => GetValue<VectorPathFillType>();
     }
 
     public VectorPathToolViewModel()
@@ -119,3 +120,18 @@ internal class VectorPathToolViewModel : ShapeTool, IVectorPathToolHandler
         OnSelected(false);
     }
 }
+
+enum VectorPathFillType
+{
+    [Description("FILL_TYPE_WINDING")]
+    
+    Winding,
+    [Description("FILL_TYPE_EVEN_ODD")]
+    EvenOdd,
+    
+    [Description("FILL_TYPE_INVERSE_WINDING")]
+    InverseWinding,
+    
+    [Description("FILL_TYPE_INVERSE_EVEN_ODD")]
+    InverseEvenOdd
+}

+ 5 - 0
src/PixiEditor/Views/Tools/ToolSettings/Settings/EnumSettingView.axaml

@@ -22,5 +22,10 @@
                 <Setter Property="(ui:Translator.Key)" Value="{Binding ., Converter={helpers:EnumDescriptionConverter}}"/>
             </ControlTheme>
         </ComboBox.ItemContainerTheme>
+       <ComboBox.ItemTemplate>
+           <DataTemplate>
+               <TextBlock ui:Translator.Key="{Binding ., Converter={helpers:EnumDescriptionConverter}}"/>
+           </DataTemplate>
+       </ComboBox.ItemTemplate>
     </ComboBox>
 </UserControl>