Browse Source

translations, colors and reenabled previews

Krzysztof Krysiński 5 months ago
parent
commit
86d81cc534

+ 25 - 12
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Effects/OutlineNode.cs

@@ -30,13 +30,16 @@ public class OutlineNode : RenderNode, IRenderInput, ICustomShaderNode
     private Paint paint;
     private Paint paint;
     private ImageFilter filter;
     private ImageFilter filter;
 
 
-    private OutlineType lastType;
+    private OutlineType? lastType = null;
+
+    protected override bool ExecuteOnlyOnCacheChange => true;
 
 
     public OutlineNode()
     public OutlineNode()
     {
     {
         Background = CreateRenderInput("Background", "BACKGROUND");
         Background = CreateRenderInput("Background", "BACKGROUND");
         Type = CreateInput("Type", "TYPE", OutlineType.Simple);
         Type = CreateInput("Type", "TYPE", OutlineType.Simple);
-        Thickness = CreateInput("Thickness", "THICKNESS", 1.0);
+        Thickness = CreateInput("Thickness", "THICKNESS", 1.0)
+            .WithRules(validator => validator.Min(0.0));
         Color = CreateInput("Color", "COLOR", Colors.Black);
         Color = CreateInput("Color", "COLOR", Colors.Black);
 
 
         paint = new Paint();
         paint = new Paint();
@@ -47,6 +50,11 @@ public class OutlineNode : RenderNode, IRenderInput, ICustomShaderNode
     protected override void OnExecute(RenderContext context)
     protected override void OnExecute(RenderContext context)
     {
     {
         base.OnExecute(context);
         base.OnExecute(context);
+        if(lastType == Type.Value)
+        {
+            return;
+        }
+
         Kernel finalKernel = Type.Value switch
         Kernel finalKernel = Type.Value switch
         {
         {
             OutlineType.Simple => simpleKernel,
             OutlineType.Simple => simpleKernel,
@@ -60,6 +68,8 @@ public class OutlineNode : RenderNode, IRenderInput, ICustomShaderNode
 
 
         filter?.Dispose();
         filter?.Dispose();
         filter = ImageFilter.CreateMatrixConvolution(finalKernel, (float)gain, 0, offset, TileMode.Clamp, true);
         filter = ImageFilter.CreateMatrixConvolution(finalKernel, (float)gain, 0, offset, TileMode.Clamp, true);
+
+        lastType = Type.Value;
     }
     }
 
 
     protected override void OnPaint(RenderContext context, DrawingSurface surface)
     protected override void OnPaint(RenderContext context, DrawingSurface surface)
@@ -69,22 +79,25 @@ public class OutlineNode : RenderNode, IRenderInput, ICustomShaderNode
             return;
             return;
         }
         }
 
 
-        paint.ImageFilter = filter;
-        paint.ColorFilter = ColorFilter.CreateBlendMode(Color.Value, BlendMode.SrcIn);
+        if (Thickness.Value > 0)
+        {
+            paint.ImageFilter = filter;
+            paint.ColorFilter = ColorFilter.CreateBlendMode(Color.Value, BlendMode.SrcIn);
 
 
-        int saved = surface.Canvas.SaveLayer(paint);
+            int saved = surface.Canvas.SaveLayer(paint);
 
 
-        Background.Value.Paint(context, surface);
+            Background.Value.Paint(context, surface);
 
 
-        surface.Canvas.RestoreToCount(saved);
+            surface.Canvas.RestoreToCount(saved);
 
 
-        for (int i = 1; i < (int)Thickness.Value; i++)
-        {
-            saved = surface.Canvas.SaveLayer(paint);
+            for (int i = 1; i < (int)Thickness.Value; i++)
+            {
+                saved = surface.Canvas.SaveLayer(paint);
 
 
-            surface.Canvas.DrawSurface(surface, 0, 0);
+                surface.Canvas.DrawSurface(surface, 0, 0);
 
 
-            surface.Canvas.RestoreToCount(saved);
+                surface.Canvas.RestoreToCount(saved);
+            }
         }
         }
 
 
         Background.Value.Paint(context, surface);
         Background.Value.Paint(context, surface);

+ 2 - 1
src/PixiEditor.ChangeableDocument/Changes/NodeGraph/UpdateProperty_Change.cs

@@ -43,7 +43,8 @@ internal class UpdatePropertyValue_Change : Change
             {
             {
                 ignoreInUndo = true;
                 ignoreInUndo = true;
             }
             }
-            
+
+            _value = SetValue(property, _value);
             ignoreInUndo = false;
             ignoreInUndo = false;
         }
         }
         else
         else

+ 2 - 0
src/PixiEditor.UI.Common/Accents/Base.axaml

@@ -85,6 +85,7 @@
             <Color x:Key="NumbersCategoryBackgroundColor">#666666</Color>
             <Color x:Key="NumbersCategoryBackgroundColor">#666666</Color>
             <Color x:Key="ColorCategoryBackgroundColor">#3B665D</Color>
             <Color x:Key="ColorCategoryBackgroundColor">#3B665D</Color>
             <Color x:Key="AnimationCategoryBackgroundColor">#4D4466</Color>
             <Color x:Key="AnimationCategoryBackgroundColor">#4D4466</Color>
+            <Color x:Key="EffectsCategoryBackgroundColor">#e36262</Color>
             
             
             <Color x:Key="HorizontalSnapAxisColor">#B00022</Color>
             <Color x:Key="HorizontalSnapAxisColor">#B00022</Color>
             <Color x:Key="VerticalSnapAxisColor">#5fad65</Color>
             <Color x:Key="VerticalSnapAxisColor">#5fad65</Color>
@@ -174,6 +175,7 @@
             <SolidColorBrush x:Key="NumbersCategoryBackgroundBrush" Color="{StaticResource NumbersCategoryBackgroundColor}" />
             <SolidColorBrush x:Key="NumbersCategoryBackgroundBrush" Color="{StaticResource NumbersCategoryBackgroundColor}" />
             <SolidColorBrush x:Key="ColorCategoryBackgroundBrush" Color="{StaticResource ColorCategoryBackgroundColor}" />
             <SolidColorBrush x:Key="ColorCategoryBackgroundBrush" Color="{StaticResource ColorCategoryBackgroundColor}" />
             <SolidColorBrush x:Key="AnimationCategoryBackgroundBrush" Color="{StaticResource AnimationCategoryBackgroundColor}" />
             <SolidColorBrush x:Key="AnimationCategoryBackgroundBrush" Color="{StaticResource AnimationCategoryBackgroundColor}" />
+            <SolidColorBrush x:Key="EffectsCategoryBackgroundBrush" Color="{StaticResource EffectsCategoryBackgroundColor}" />
 
 
             <SolidColorBrush x:Key="HorizontalSnapAxisBrush" Color="{StaticResource HorizontalSnapAxisColor}"/>
             <SolidColorBrush x:Key="HorizontalSnapAxisBrush" Color="{StaticResource HorizontalSnapAxisColor}"/>
             <SolidColorBrush x:Key="VerticalSnapAxisBrush" Color="{StaticResource VerticalSnapAxisColor}"/>
             <SolidColorBrush x:Key="VerticalSnapAxisBrush" Color="{StaticResource VerticalSnapAxisColor}"/>

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

@@ -857,5 +857,7 @@
   "TEXT_ON_PATH_NODE": "Text on Path",
   "TEXT_ON_PATH_NODE": "Text on Path",
   "HIGH_DPI_RENDERING": "High DPI Rendering",
   "HIGH_DPI_RENDERING": "High DPI Rendering",
   "THICKNESS": "Thickness",
   "THICKNESS": "Thickness",
-  "TYPE": "Type"
+  "TYPE": "Type",
+  "EFFECTS": "Effects",
+  "OUTLINE_NODE": "Outline"
 }
 }

+ 2 - 2
src/PixiEditor/Styles/Templates/NodeView.axaml

@@ -53,7 +53,7 @@
                                 </ItemsControl>
                                 </ItemsControl>
                             </StackPanel>
                             </StackPanel>
                         </Border>
                         </Border>
-                        <!--<Border IsVisible="{Binding !!ResultPreview, RelativeSource={RelativeSource TemplatedParent}}"
+                        <Border IsVisible="{Binding !!ResultPreview, RelativeSource={RelativeSource TemplatedParent}}"
                                 CornerRadius="0, 0, 4.5, 4.5" Grid.Row="2" ClipToBounds="True">
                                 CornerRadius="0, 0, 4.5, 4.5" Grid.Row="2" ClipToBounds="True">
                             <Panel RenderOptions.BitmapInterpolationMode="None" Width="200" Height="200">
                             <Panel RenderOptions.BitmapInterpolationMode="None" Width="200" Height="200">
                                 <Panel.Background>
                                 <Panel.Background>
@@ -66,7 +66,7 @@
                                                            RenderOptions.BitmapInterpolationMode="None">
                                                            RenderOptions.BitmapInterpolationMode="None">
                             </visuals:PreviewPainterControl>
                             </visuals:PreviewPainterControl>
                             </Panel>
                             </Panel>
-                        </Border>-->
+                        </Border>
                     </Grid>
                     </Grid>
                 </Border>
                 </Border>
             </ControlTemplate>
             </ControlTemplate>

+ 2 - 1
src/PixiEditor/ViewModels/Nodes/NodePropertyViewModel.cs

@@ -25,6 +25,8 @@ internal abstract class NodePropertyViewModel : ViewModelBase, INodePropertyHand
     private ObservableCollection<INodePropertyHandler> connectedInputs = new();
     private ObservableCollection<INodePropertyHandler> connectedInputs = new();
     private INodePropertyHandler? connectedOutput;
     private INodePropertyHandler? connectedOutput;
 
 
+    public event NodePropertyValueChanged? ValueChanged;
+
     public string DisplayName
     public string DisplayName
     {
     {
         get => displayName;
         get => displayName;
@@ -175,7 +177,6 @@ internal abstract class NodePropertyViewModel : ViewModelBase, INodePropertyHand
         return (NodePropertyViewModel)Activator.CreateInstance(viewModelType, node, type);
         return (NodePropertyViewModel)Activator.CreateInstance(viewModelType, node, type);
     }
     }
 
 
-    public event NodePropertyValueChanged? ValueChanged;
 
 
     public void InternalSetValue(object? value)
     public void InternalSetValue(object? value)
     {
     {

+ 8 - 2
src/PixiEditor/Views/Nodes/Properties/DoublePropertyView.axaml

@@ -7,11 +7,17 @@
                              xmlns:input="clr-namespace:PixiEditor.Views.Input"
                              xmlns:input="clr-namespace:PixiEditor.Views.Input"
                              xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
                              xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
                              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
                              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
+                             xmlns:properties1="clr-namespace:PixiEditor.ViewModels.Nodes.Properties"
                              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
                              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+                             x:DataType="properties1:DoublePropertyViewModel"
                              x:Class="PixiEditor.Views.Nodes.Properties.DoublePropertyView">
                              x:Class="PixiEditor.Views.Nodes.Properties.DoublePropertyView">
+    <Design.DataContext>
+        <properties1:DoublePropertyViewModel/>
+    </Design.DataContext>
     <Grid HorizontalAlignment="{Binding IsInput, Converter={converters:BoolToValueConverter FalseValue='Right', TrueValue='Stretch'}}">
     <Grid HorizontalAlignment="{Binding IsInput, Converter={converters:BoolToValueConverter FalseValue='Right', TrueValue='Stretch'}}">
         <TextBlock VerticalAlignment="Center" ui:Translator.Key="{Binding DisplayName}"/>
         <TextBlock VerticalAlignment="Center" ui:Translator.Key="{Binding DisplayName}"/>
-        <input:NumberInput EnableScrollChange="False" 
-                           HorizontalAlignment="Right" MinWidth="100" Decimals="6" IsVisible="{Binding ShowInputField}" Value="{Binding Value, Mode=TwoWay}" />
+        <input:NumberInput EnableScrollChange="False" Name="input"
+                           HorizontalAlignment="Right" MinWidth="100" Decimals="6" IsVisible="{Binding ShowInputField}"
+                           Value="{Binding Value, Mode=TwoWay}" />
     </Grid>
     </Grid>
 </properties:NodePropertyView>
 </properties:NodePropertyView>