This public class stores size information about a stave. It is used by the layout engine to collect the sizes of score parts to align the parts across multiple staves.
Beispiel #1
0
        public void AddBar(Bar bar, BarLayoutingInfo layoutingInfo)
        {
            BarRendererBase renderer;

            if (bar == null)
            {
                renderer = new BarRendererBase(StaveGroup.Layout.Renderer, bar);
            }
            else
            {
                renderer = _factory.Create(StaveGroup.Layout.Renderer, bar, StaveGroup.Layout.Renderer.Settings.Staves);
            }
            renderer.Staff         = this;
            renderer.Index         = BarRenderers.Count;
            renderer.LayoutingInfo = layoutingInfo;
            renderer.DoLayout();
            renderer.RegisterLayoutingInfo();
            BarRenderers.Add(renderer);
            if (bar != null)
            {
                StaveGroup.Layout.RegisterBarRenderer(StaveId, renderer);
            }
        }
Beispiel #2
0
        public AddBarsToStaveGroupResult AddBars(Track[] tracks, int barIndex)
        {
            if (tracks.Length == 0) return null;

            var result = new AddBarsToStaveGroupResult();
            var score = tracks[0].Score;
            var masterBar = score.MasterBars[barIndex];
            MasterBars.Add(masterBar);

            Helpers.BuildHelpers(tracks, barIndex);

            if (!_accoladeSpacingCalculated && Index == 0)
            {
                _accoladeSpacingCalculated = true;
                var canvas = Layout.Renderer.Canvas;
                var res = Layout.Renderer.RenderingResources.EffectFont;
                canvas.Font = res;
                for (var i = 0; i < tracks.Length; i++)
                {
                    AccoladeSpacing = Math.Max(AccoladeSpacing, canvas.MeasureText(tracks[i].ShortName));
                }
                AccoladeSpacing += (2 * AccoladeLabelSpacing);
                Width += AccoladeSpacing;
            }

            // add renderers
            var maxSizes = new BarLayoutingInfo();
            for (int i = 0, j = Staves.Count; i < j; i++)
            {
                var g = Staves[i];
                for (int k = 0, l = g.Staves.Count; k < l; k++)
                {
                    var s = g.Staves[k];
                    s.AddBar(g.Track.Staves[s.ModelStaff.Index].Bars[barIndex]);
                    s.BarRenderers[s.BarRenderers.Count - 1].RegisterLayoutingInfo(maxSizes);
                    if (s.BarRenderers[s.BarRenderers.Count - 1].IsLinkedToPrevious)
                    {
                        result.IsLinkedToPrevious = true;
                    }
                }
            }

            maxSizes.Finish();

            // ensure same widths of new renderer
            var realWidth = 0f;
            for (int i = 0, j = _allStaves.Count; i < j; i++)
            {
                var s = _allStaves[i];
                s.BarRenderers[s.BarRenderers.Count - 1].ApplyLayoutingInfo();
                if (s.BarRenderers[s.BarRenderers.Count - 1].Width > realWidth)
                {
                    realWidth = s.BarRenderers[s.BarRenderers.Count - 1].Width;
                }
            }

            Width += realWidth;
            result.Width = realWidth;

            return result;
        }
Beispiel #3
0
        public AddBarsToStaveGroupResult AddBars(Track[] tracks, int barIndex)
        {
            if (tracks.Length == 0)
            {
                return(null);
            }

            var result    = new AddBarsToStaveGroupResult();
            var score     = tracks[0].Score;
            var masterBar = score.MasterBars[barIndex];

            MasterBars.Add(masterBar);

            Helpers.BuildHelpers(tracks, barIndex);

            if (!_accoladeSpacingCalculated && Index == 0)
            {
                _accoladeSpacingCalculated = true;
                var canvas = Layout.Renderer.Canvas;
                var res    = Layout.Renderer.RenderingResources.EffectFont;
                canvas.Font = res;
                for (var i = 0; i < tracks.Length; i++)
                {
                    AccoladeSpacing = Math.Max(AccoladeSpacing, canvas.MeasureText(tracks[i].ShortName));
                }
                AccoladeSpacing += (2 * AccoladeLabelSpacing);
                Width           += AccoladeSpacing;
            }

            // add renderers
            var maxSizes = new BarLayoutingInfo();

            for (int i = 0, j = Staves.Count; i < j; i++)
            {
                var g = Staves[i];
                for (int k = 0, l = g.Staves.Count; k < l; k++)
                {
                    var s = g.Staves[k];
                    s.AddBar(g.Track.Staves[s.ModelStaff.Index].Bars[barIndex]);
                    s.BarRenderers[s.BarRenderers.Count - 1].RegisterLayoutingInfo(maxSizes);
                    if (s.BarRenderers[s.BarRenderers.Count - 1].IsLinkedToPrevious)
                    {
                        result.IsLinkedToPrevious = true;
                    }
                }
            }

            maxSizes.Finish();

            // ensure same widths of new renderer
            var realWidth = 0f;

            for (int i = 0, j = _allStaves.Count; i < j; i++)
            {
                var s = _allStaves[i];
                s.BarRenderers[s.BarRenderers.Count - 1].ApplyLayoutingInfo();
                if (s.BarRenderers[s.BarRenderers.Count - 1].Width > realWidth)
                {
                    realWidth = s.BarRenderers[s.BarRenderers.Count - 1].Width;
                }
            }

            Width       += realWidth;
            result.Width = realWidth;

            return(result);
        }
 public void ApplyLayoutingInfo(BarLayoutingInfo info)
 {
     for (int i = 0, j = BeatGlyphs.Count; i < j; i++)
     {
         var b = BeatGlyphs[i];
         b.ApplyLayoutingInfo(info);
     }
     ScaleToForce(Math.Max(Renderer.Settings.StretchForce, info.MinStretchForce));
 }
 public void RegisterLayoutingInfo(BarLayoutingInfo info)
 {
     info.UpdateVoiceSize(Width);
     for (int i = 0, j = BeatGlyphs.Count; i < j; i++)
     {
         var b = BeatGlyphs[i];
         b.RegisterLayoutingInfo(info);
     }
 }
Beispiel #6
0
        public virtual void RegisterLayoutingInfo(BarLayoutingInfo info)
        {
            LayoutingInfo = info;

            var preSize = _preBeatGlyphs.Width;
            if (info.PreBeatSize < preSize)
            {
                info.PreBeatSize = preSize;
            }

            foreach (var voice in _voiceContainers)
            {
                var c = _voiceContainers[voice];
                c.RegisterLayoutingInfo(info);
            }

            var postSize = _postBeatGlyphs.Width;
            if (info.PostBeatSize < postSize)
            {
                info.PostBeatSize = postSize;
            }
        }
 public void ApplyLayoutingInfo(BarLayoutingInfo info)
 {
     if (UseLayoutingInfo)
     {
         PreNotes.Width = info.GetPreBeatSize(Beat);
         OnNotes.Width = info.GetOnBeatSize(Beat);
         OnNotes.X = PreNotes.X + PreNotes.Width;
         OnTimeX = OnNotes.X + OnNotes.Width / 2;
     }
 }
 public void RegisterLayoutingInfo(BarLayoutingInfo layoutings)
 {
     var preBeatStretch = PreNotes.Width + OnNotes.Width / 2;
     layoutings.AddBeatSpring(Beat, MinWidth, preBeatStretch);
     // store sizes for special renderers like the EffectBarRenderer
     layoutings.SetPreBeatSize(Beat, PreNotes.Width);
     layoutings.SetOnBeatSize(Beat, OnNotes.Width);
 }