private void load(IAggregateAudioAdjustment parentAdjustment)
 {
     if (parentAdjustment != null)
     {
         adjustments.BindAdjustments(parentAdjustment);
     }
 }
        private void refreshAdjustments()
        {
            // because these components may be pooled, relying on DI is not feasible.
            // in the majority of cases the traversal should be quite short. may require later attention if a use case comes up which this is not true for.
            if (parentAdjustment != null)
            {
                adjustments.UnbindAdjustments(parentAdjustment);
                parentAdjustment = null;
            }

            Drawable cursor = this;

            while ((cursor = cursor.Parent) != null)
            {
                if (!(cursor is IAggregateAudioAdjustment candidate))
                {
                    continue;
                }

                // components may be delegating the aggregates of a contained child.
                // to avoid binding to one's self, check reference equality on an arbitrary bindable.
                if (candidate.AggregateVolume != adjustments.AggregateVolume)
                {
                    parentAdjustment = candidate;
                    adjustments.BindAdjustments(parentAdjustment);
                    break;
                }
            }
        }
Esempio n. 3
0
        public void TestAdjustBoundComponentAfterBind()
        {
            var adjustments  = new AudioAdjustments();
            var adjustments2 = new AudioAdjustments();

            adjustments.BindAdjustments(adjustments2);

            adjustments2.Volume.Value = 0.5f;

            Assert.AreEqual(0.5, adjustments.AggregateVolume.Value);
        }
Esempio n. 4
0
        public void TestValueRestoredAfterComponentUnind()
        {
            var adjustments  = new AudioAdjustments();
            var adjustments2 = new AudioAdjustments();

            adjustments.BindAdjustments(adjustments2);

            adjustments2.Volume.Value = 0.5f;

            adjustments.UnbindAdjustments(adjustments2);

            Assert.AreEqual(1.0, adjustments.AggregateVolume.Value);
        }
Esempio n. 5
0
        private void refreshLayoutFromParent()
        {
            // because these components may be pooled, relying on DI is not feasible.
            // in the majority of cases the traversal should be quite short. may require later attention if a use case comes up which this is not true for.
            Drawable cursor = this;
            IAggregateAudioAdjustment newAdjustments = null;
            IAudioMixer newMixer = null;

            while ((cursor = cursor.Parent) != null)
            {
                if (newAdjustments == null && cursor is IAggregateAudioAdjustment candidateAdjustment)
                {
                    // components may be delegating the aggregates of a contained child.
                    // to avoid binding to one's self, check reference equality on an arbitrary bindable.
                    if (candidateAdjustment.AggregateVolume != adjustments.AggregateVolume)
                    {
                        newAdjustments = candidateAdjustment;
                    }
                }

                if (newMixer == null && cursor is IAudioMixer candidateMixer)
                {
                    newMixer = candidateMixer;
                }

                if (newAdjustments != null && newMixer != null)
                {
                    break;
                }
            }

            if (newAdjustments != parentAdjustment)
            {
                if (parentAdjustment != null)
                {
                    adjustments.UnbindAdjustments(parentAdjustment);
                }
                parentAdjustment = newAdjustments;
                if (parentAdjustment != null)
                {
                    adjustments.BindAdjustments(parentAdjustment);
                }
            }

            if (parentMixer != newMixer)
            {
                OnMixerChanged(new ValueChangedEvent <IAudioMixer>(parentMixer, newMixer));
            }

            parentMixer = newMixer;
        }
Esempio n. 6
0
        public void TestAdjustBoundComponentBeforeBind()
        {
            var adjustments = new AudioAdjustments();

            var adjustments2 = new AudioAdjustments
            {
                Volume =
                {
                    Value = 0.5f
                }
            };

            adjustments.BindAdjustments(adjustments2);

            Assert.AreEqual(0.5, adjustments.AggregateVolume.Value);
        }
Esempio n. 7
0
 private void bindWithoutScope(AudioAdjustments adjustments)
 {
     adjustments.BindAdjustments(new AudioAdjustments {
         Volume = { Value = 0.5 }
     });
 }