Просмотр исходного кода

Fix blur slider not setting BlurSize when inactive

BlurSize was only set when the effect is active so when the slider's
value is 0, the effect is deactivated but the effect's BlurSize is
never updated. This results in the blur effect reactivating when
switching over to the 'Env' tab because the blur effect's BlurSize is
actually non-zero.
habeebweeb 3 лет назад
Родитель
Сommit
f5722289a8

+ 16 - 9
src/MeidoPhotoStudio.Plugin/GUI/Panes/BackgroundWindowPanes/EffectsPanes/OtherEffectsPane.cs

@@ -27,11 +27,17 @@ namespace MeidoPhotoStudio.Plugin
             blurSlider = new Slider(Translation.Get("otherEffectsPane", "blurSlider"), 0f, 18f);
             blurSlider.ControlEvent += (s, a) =>
             {
-                float value = blurSlider.Value;
-                if (!blurEffectManager.Active && value > 0f) blurEffectManager.SetEffectActive(true);
-                else if (blurEffectManager.Active && value == 0f) blurEffectManager.SetEffectActive(false);
+                if (updating)
+                    return;
 
-                if (blurEffectManager.Active) blurEffectManager.BlurSize = blurSlider.Value;
+                var value = blurSlider.Value;
+
+                if (!blurEffectManager.Active && value > 0f)
+                    blurEffectManager.SetEffectActive(true);
+                else if (blurEffectManager.Active && Mathf.Approximately(value, 0f))
+                    blurEffectManager.SetEffectActive(false);
+
+                blurEffectManager.BlurSize = value;
             };
         }
 
@@ -51,14 +57,15 @@ namespace MeidoPhotoStudio.Plugin
 
         public override void UpdatePane()
         {
+            updating = true;
+
             if (sepiaToneEffectManger.Ready)
-            {
-                updating = true;
                 sepiaToggle.Value = sepiaToneEffectManger.Active;
-                updating = false;
-            }
 
-            if (blurEffectManager.Ready) blurSlider.Value = blurEffectManager.BlurSize;
+            if (blurEffectManager.Ready)
+                blurSlider.Value = blurEffectManager.BlurSize;
+
+            updating = false;
         }
     }
 }