Example #1
0
        float SetItemReferencePosition(VoiceLayout.ScoreLine.Element element, VoiceLayout.ScoreLine.Measure measure, float advanceAmount)
        {
            float spacer       = Mathf.Max(minimumAdavance, advanceAmount - element.prefixAmount);
            float alignmentPos = measure.insertX + spacer + element.prefixAmount;

            measure.spacers[measure.spacers.Count - 1] += spacer;
            measure.AdvaceInsertPos(spacer);

            measure.EncapsulateAppendedBounds(element.info.totalBounding);

            return(alignmentPos);
        }
Example #2
0
        /// <summary>
        /// Sets the position of a full measure rest such that it is centered in the available space.
        /// Positions the bar first, then centers the rest in the remaining space.
        /// </summary>
        Bounds PositionMeasureRest(VoiceLayout.ScoreLine.Measure measure, float allocatedWidth)
        {
            var   bar  = measure.elements[measure.elements.Count - 1];
            float barX = allocatedWidth - bar.totalWidth;

            bar.container.transform.localPosition = new Vector3(barX, 0.0f, 0.0f);

            var rest          = measure.elements[0];
            var measureCenter = barX / 2.0f;
            var posX          = measureCenter - rest.info.totalBounding.size.x / 2.0f;

            rest.container.transform.localPosition = new Vector3(posX, 0.0f, 0.0f);

            Bounds actualBounds = new Bounds(Vector3.zero, Vector3.zero);

            actualBounds.Encapsulate(new Vector3(allocatedWidth, 0.0f, 0.0f));

            return(actualBounds);
        }
Example #3
0
        Bounds PositionMeasureItems(VoiceLayout.ScoreLine.Measure measure, float actualmeasureWidth)
        {
            Bounds         actualBounds = new Bounds(Vector3.zero, Vector3.zero);
            List <Vector3> beamVertices = null;

            float positionX    = 0.0f;
            float deltaWidth   = actualmeasureWidth - measure.minWidth;
            float deltaWidth2  = actualmeasureWidth - measure.insertX;
            float spacerAdjust = deltaWidth / (measure.elements.Count - 1);

            for (int i = 0; i < measure.elements.Count; i++)
            {
                var item = measure.elements[i];
                positionX += measure.spacers[i];
                if (i > 0)
                {
                    positionX += spacerAdjust;
                }

                if (item.item == null)
                {
                    continue;
                }

                Vector3 insertPos = new Vector3(positionX, 0.0f, 0.0f);
                item.container.transform.localPosition = insertPos;
                positionX += item.totalWidth;

                var actualNoteInfo = item.OffsetNoteInfo(insertPos);
                actualBounds.Encapsulate(actualNoteInfo.totalBounding);

                var duration = item.item as ABC.Duration;
                if (duration != null && beams.TryGetValue(duration.beam, out Beam beam))
                {
                    beam.Update(actualNoteInfo.rootBounding);

                    if (beam.isReadyToCreate)
                    {
                        if (beam.type == Beam.Type.Angle)
                        {
                            if (beamVertices == null)
                            {
                                beamVertices = new List <Vector3>();
                            }

                            beam.CreateAngledBeam(beamVertices);
                        }
                        else
                        {
                            beam.CreateBasicBeam(cache, measure.container);
                        }
                    }
                }
            }

            if (beamVertices != null)
            {
                Beam.CreateMesh(beamVertices, NoteMaterial, measure.container);
            }

            return(actualBounds);
        }