Browse Source

Merge branch 'master' into opengl-win-linux

Krzysztof Krysiński 1 week ago
parent
commit
a1e23f3a3b

+ 22 - 4
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/LerpColorNode.cs

@@ -10,11 +10,11 @@ namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
 [NodeInfo("Lerp")]
 public class LerpColorNode : Node // TODO: ILerpable as inputs? 
 {
-    public FuncOutputProperty<Half4> Result { get; } 
+    public FuncOutputProperty<Half4> Result { get; }
     public FuncInputProperty<Half4> From { get; }
     public FuncInputProperty<Half4> To { get; }
     public FuncInputProperty<Float1> Time { get; }
-    
+
     public LerpColorNode()
     {
         Result = CreateFuncOutput<Half4>("Result", "RESULT", Lerp);
@@ -28,8 +28,26 @@ public class LerpColorNode : Node // TODO: ILerpable as inputs?
         var from = arg.GetValue(From);
         var to = arg.GetValue(To);
         var time = arg.GetValue(Time);
-        
-        return arg.NewHalf4(ShaderMath.Lerp(from, to, time)); 
+
+        if (arg.HasContext)
+        {
+            return arg.NewHalf4(ShaderMath.Lerp(from, to, time));
+        }
+
+        var constFrom = (Color)from.GetConstant();
+        var constTo = (Color)to.GetConstant();
+        var constTime = time.GetConstant();
+
+        double dTime = constTime switch
+        {
+            double d => d,
+            int i => i,
+            float f => f,
+            _ => throw new InvalidOperationException("Unsupported constant type for time.")
+        };
+
+        Color result = Color.Lerp(constFrom, constTo, dTime);
+        return new Half4("") { ConstantValue = result };
     }
 
     protected override void OnExecute(RenderContext context)

+ 9 - 0
src/PixiEditor.UI.Common/Localization/Translate.cs

@@ -12,6 +12,15 @@ public class Translate : MarkupExtension
 
     public Translate()
     {
+        if (ILocalizationProvider.Current == null)
+        {
+            ILocalizationProvider.OnLocalizationProviderChanged += (provider) =>
+            {
+                ILocalizationProvider.Current.OnLanguageChanged += (lang) => LanguageChanged();
+            };
+            return;
+        }
+
         ILocalizationProvider.Current.OnLanguageChanged += (lang) => LanguageChanged();
     }