소스 검색

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 년 전
부모
커밋
f5722289a8
1개의 변경된 파일16개의 추가작업 그리고 9개의 파일을 삭제
  1. 16 9
      src/MeidoPhotoStudio.Plugin/GUI/Panes/BackgroundWindowPanes/EffectsPanes/OtherEffectsPane.cs

+ 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;
         }
     }
 }