A game framework written with osu! in mind.

Fix parent adjustment not updated in DrawableTrack/DrawableSample

+28 -1
+21
osu.Framework.Tests/Audio/TestSceneDrawableTrack.cs
··· 6 6 using osu.Framework.Audio; 7 7 using osu.Framework.Audio.Track; 8 8 using osu.Framework.Bindables; 9 + using osu.Framework.Graphics; 9 10 using osu.Framework.Graphics.Audio; 11 + using osu.Framework.Graphics.Containers; 10 12 using osu.Framework.Testing; 11 13 using osu.Framework.Tests.Visual; 12 14 using osu.Framework.Utils; ··· 49 51 50 52 AddStep("reset", () => track.Reset()); 51 53 AddAssert("track volume is 1", () => Precision.AlmostEquals(1, track.Volume.Value)); 54 + } 55 + 56 + [Test] 57 + public void TestTrackingParentAdjustmentChangedWhenMovedParents() 58 + { 59 + AddStep("set volume 1", () => track.Volume.Value = 1); 60 + 61 + AddStep("move track a container with 0 volume", () => 62 + { 63 + Remove(track); 64 + Child = new AudioContainer 65 + { 66 + RelativeSizeAxes = Axes.Both, 67 + Volume = { Value = 0 }, 68 + Child = track 69 + }; 70 + }); 71 + 72 + AddAssert("track has 0 volume", () => track.AggregateVolume.Value == 0); 52 73 } 53 74 } 54 75 }
+7 -1
osu.Framework/Graphics/Audio/DrawableAudioWrapper.cs
··· 51 51 52 52 private readonly LayoutValue parentAdjustmentLayout = new LayoutValue(Invalidation.Parent); 53 53 54 + private DrawableAudioWrapper() 55 + { 56 + AddLayout(parentAdjustmentLayout); 57 + } 58 + 54 59 /// <summary> 55 60 /// Creates a <see cref="DrawableAudioWrapper"/> that will contain a drawable child. 56 61 /// Generally used to add adjustments to a hierarchy without adding an audio component. 57 62 /// </summary> 58 63 /// <param name="content">The <see cref="Drawable"/> to be wrapped.</param> 59 64 protected DrawableAudioWrapper(Drawable content) 65 + : this() 60 66 { 61 67 AddInternal(content); 62 - AddLayout(parentAdjustmentLayout); 63 68 } 64 69 65 70 /// <summary> ··· 68 73 /// <param name="component">The audio component to wrap.</param> 69 74 /// <param name="disposeUnderlyingComponentOnDispose">Whether the component should be automatically disposed on drawable disposal/expiry.</param> 70 75 protected DrawableAudioWrapper([NotNull] IAdjustableAudioComponent component, bool disposeUnderlyingComponentOnDispose = true) 76 + : this() 71 77 { 72 78 this.component = component ?? throw new ArgumentNullException(nameof(component)); 73 79 this.disposeUnderlyingComponentOnDispose = disposeUnderlyingComponentOnDispose;