Browse Source

Merge pull request #746 from PixiEditor/fixes/30.01.25

Fixes/30.01.25
Krzysztof Krysiński 5 months ago
parent
commit
0cae2d484a

+ 2 - 2
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/MergeNode.cs

@@ -54,12 +54,12 @@ public class MergeNode : RenderNode
         if (Bottom.Value != null && Top.Value != null)
         {
             int saved = target.Canvas.SaveLayer();
-            Bottom.Value.Paint(context, target);
+            Bottom.Value?.Paint(context, target);
 
             paint.BlendMode = RenderContext.GetDrawingBlendMode(BlendMode.Value);
             target.Canvas.SaveLayer(paint);
             
-            Top.Value.Paint(context, target);
+            Top.Value?.Paint(context, target);
             target.Canvas.RestoreToCount(saved);
             return;
         }

+ 1 - 18
src/PixiEditor/Views/Dock/ColorPickerDockView.axaml.cs

@@ -19,23 +19,6 @@ public partial class ColorPickerDockView : UserControl
         base.OnLoaded(e);
         var textBoxes = this.GetVisualDescendants().OfType<TextBox>().ToArray();
 
-        foreach (var textBox in textBoxes)
-        {
-            var existingBehaviors = Interaction.GetBehaviors(textBox);
-            if(existingBehaviors.Any(x => x is GlobalShortcutFocusBehavior)) continue;
-            bool attach = false;
-            if (existingBehaviors == null)
-            {
-                attach = true;
-                existingBehaviors = new BehaviorCollection();
-            }
-
-            existingBehaviors.Add(new GlobalShortcutFocusBehavior());
-
-            if (attach)
-            {
-                Interaction.SetBehaviors(textBox, existingBehaviors);
-            }
-        }
+        ColorSlidersDockView.AttachBehavioursToTextBoxes(textBoxes); 
     }
 }

+ 41 - 1
src/PixiEditor/Views/Dock/ColorSlidersDockView.axaml.cs

@@ -1,6 +1,10 @@
 using Avalonia;
 using Avalonia.Controls;
+using Avalonia.Interactivity;
 using Avalonia.Markup.Xaml;
+using Avalonia.VisualTree;
+using Avalonia.Xaml.Interactivity;
+using PixiEditor.Helpers.Behaviours;
 
 namespace PixiEditor.Views.Dock;
 
@@ -10,5 +14,41 @@ public partial class ColorSlidersDockView : UserControl
     {
         InitializeComponent();
     }
-}
 
+    protected override void OnLoaded(RoutedEventArgs e)
+    {
+        base.OnLoaded(e);
+        var textBoxes = this.GetVisualDescendants().OfType<TextBox>().ToArray();
+
+        AttachBehavioursToTextBoxes(textBoxes);
+    }
+
+    internal static void AttachBehavioursToTextBoxes(TextBox[] textBoxes)
+    {
+        foreach (var textBox in textBoxes)
+        {
+            var existingBehaviors = Interaction.GetBehaviors(textBox);
+            if (existingBehaviors.Any(x => x is GlobalShortcutFocusBehavior)) continue;
+            bool attach = false;
+            if (existingBehaviors == null)
+            {
+                attach = true;
+                existingBehaviors = new BehaviorCollection();
+            }
+
+            try
+            {
+                existingBehaviors.Add(new GlobalShortcutFocusBehavior());
+
+                if (attach)
+                {
+                    Interaction.SetBehaviors(textBox, existingBehaviors);
+                }
+            }
+            catch (ArgumentOutOfRangeException)
+            {
+                // avalonia's bug
+            }
+        }
+    }
+}