Example #1
0
 public void AddStaveGroup(StaveGroupBounds bounds)
 {
     bounds.Index        = StaveGroups.Count;
     bounds.BoundsLookup = this;
     StaveGroups.Add(bounds);
     _currentStaveGroup = bounds;
 }
Example #2
0
        public object ToJson()
        {
            var json = Platform.Platform.NewObject();

            var staveGroups = new FastList <StaveGroupBounds>();

            json.StaveGroups = staveGroups;

            foreach (var group in StaveGroups)
            {
                StaveGroupBounds g = Platform.Platform.NewObject();
                g.VisualBounds = BoundsToJson(group.VisualBounds);
                g.RealBounds   = BoundsToJson(group.RealBounds);
                g.Bars         = new FastList <MasterBarBounds>();

                foreach (var masterBar in group.Bars)
                {
                    MasterBarBounds mb = Platform.Platform.NewObject();
                    mb.LineAlignedBounds = BoundsToJson(masterBar.LineAlignedBounds);
                    mb.VisualBounds      = BoundsToJson(masterBar.VisualBounds);
                    mb.RealBounds        = BoundsToJson(masterBar.RealBounds);
                    mb.Index             = masterBar.Index;
                    mb.Bars = new FastList <BarBounds>();

                    foreach (var bar in masterBar.Bars)
                    {
                        BarBounds b = Platform.Platform.NewObject();
                        b.VisualBounds = BoundsToJson(bar.VisualBounds);
                        b.RealBounds   = BoundsToJson(bar.RealBounds);

                        b.Beats = new FastList <BeatBounds>();

                        foreach (var beat in bar.Beats)
                        {
                            var bb = Platform.Platform.NewObject();

                            bb.VisualBounds = BoundsToJson(beat.VisualBounds);
                            bb.RealBounds   = BoundsToJson(beat.RealBounds);
                            bb.BeatIndex    = beat.Beat.Index;
                            bb.VoiceIndex   = beat.Beat.Voice.Index;
                            bb.BarIndex     = beat.Beat.Voice.Bar.Index;
                            bb.StaffIndex   = beat.Beat.Voice.Bar.Staff.Index;
                            bb.TrackIndex   = beat.Beat.Voice.Bar.Staff.Track.Index;

                            b.Beats.Add(bb);
                        }

                        mb.Bars.Add(b);
                    }

                    g.Bars.Add(mb);
                }

                staveGroups.Add(g);
            }

            return(json);
        }
Example #3
0
        public static BoundsLookup FromJson(object json, Score score)
        {
            var lookup = new BoundsLookup();

            var staveGroups = json.Member <FastList <StaveGroupBounds> >("StaveGroups");

            foreach (var staveGroup in staveGroups)
            {
                var sg = new StaveGroupBounds();
                sg.VisualBounds = staveGroup.VisualBounds;
                sg.RealBounds   = staveGroup.RealBounds;
                lookup.AddStaveGroup(sg);

                foreach (var masterBar in staveGroup.Bars)
                {
                    var mb = new MasterBarBounds();
                    mb.Index             = masterBar.Index;
                    mb.IsFirstOfLine     = masterBar.IsFirstOfLine;
                    mb.LineAlignedBounds = masterBar.LineAlignedBounds;
                    mb.VisualBounds      = masterBar.VisualBounds;
                    mb.RealBounds        = masterBar.RealBounds;
                    sg.AddBar(mb);

                    foreach (var bar in masterBar.Bars)
                    {
                        var b = new BarBounds();
                        b.VisualBounds = bar.VisualBounds;
                        b.RealBounds   = bar.RealBounds;
                        mb.AddBar(b);

                        foreach (var beat in bar.Beats)
                        {
                            var bb = new BeatBounds();
                            bb.VisualBounds = beat.VisualBounds;
                            bb.RealBounds   = beat.RealBounds;
                            bb.Beat         = score
                                              .Tracks[beat.Member <int>("TrackIndex")]
                                              .Staves[beat.Member <int>("StaffIndex")]
                                              .Bars[beat.Member <int>("BarIndex")]
                                              .Voices[beat.Member <int>("VoiceIndex")]
                                              .Beats[beat.Member <int>("BeatIndex")];

                            b.AddBeat(bb);
                        }
                    }
                }
            }

            return(lookup);
        }
Example #4
0
        public static BoundsLookup FromJson(object json, Score score)
        {
            var lookup = new BoundsLookup();

            var staveGroups = json.Member("StaveGroups").As<FastList<StaveGroupBounds>>();
            foreach (var staveGroup in staveGroups)
            {
                var sg = new StaveGroupBounds();
                sg.VisualBounds = staveGroup.VisualBounds;
                sg.RealBounds = staveGroup.RealBounds;
                lookup.AddStaveGroup(sg);

                foreach (var masterBar in staveGroup.Bars)
                {
                    var mb = new MasterBarBounds();
                    mb.IsFirstOfLine = masterBar.IsFirstOfLine;
                    mb.VisualBounds = masterBar.VisualBounds;
                    mb.RealBounds = masterBar.RealBounds;
                    sg.AddBar(mb);

                    foreach (var bar in masterBar.Bars)
                    {
                        var b = new BarBounds();
                        b.VisualBounds = bar.VisualBounds;
                        b.RealBounds = bar.RealBounds;
                        mb.AddBar(b);

                        foreach (var beat in bar.Beats)
                        {
                            var bb = new BeatBounds();
                            bb.VisualBounds = beat.VisualBounds;
                            bb.RealBounds = beat.RealBounds;
                            bb.Beat = score
                                .Tracks[beat.Member("TrackIndex").As<int>()]
                                .Staves[beat.Member("StaffIndex").As<int>()]
                                .Bars[beat.Member("BarIndex").As<int>()]
                                .Voices[beat.Member("VoiceIndex").As<int>()]
                                .Beats[beat.Member("BeatIndex").As<int>()];

                            b.AddBeat(bb);
                        }
                    }
                }
            }

            return lookup;
        }
Example #5
0
        private void BuildBoundingsLookup(float cx, float cy)
        {
            if (Layout.Renderer.BoundsLookup.IsFinished) return;
            if (_firstStaffInAccolade == null || _lastStaffInAccolade == null) return;

            var visualTop = cy + Y + _firstStaffInAccolade.Y;
            var visualBottom = cy + Y + _lastStaffInAccolade.Y + _lastStaffInAccolade.Height;
            var realTop = cy + Y + _allStaves[0].Y;
            var realBottom = cy + Y + _allStaves[_allStaves.Count - 1].Y + _allStaves[_allStaves.Count - 1].Height;

            var visualHeight = visualBottom - visualTop;
            var realHeight = realBottom - realTop;

            var x = X + _firstStaffInAccolade.X;

            var staveGroupBounds = new StaveGroupBounds();
            staveGroupBounds.VisualBounds = new Bounds
            {
                X = cx,
                Y = cy + Y,
                W = Width,
                H = Height
            };
            staveGroupBounds.RealBounds = new Bounds
            {
                X = cx,
                Y = cy + Y,
                W = Width,
                H = Height
            };
            Layout.Renderer.BoundsLookup.AddStaveGroup(staveGroupBounds);

            var masterBarBoundsLookup = new FastList<MasterBarBounds>();
            for (int i = 0; i < Staves.Count; i++)
            {
                for (int j = 0, k = Staves[i].FirstStaffInAccolade.BarRenderers.Count; j < k; j++)
                {
                    var renderer = Staves[i].FirstStaffInAccolade.BarRenderers[j];

                    if (i == 0)
                    {
                        var masterBarBounds = new MasterBarBounds();
                        masterBarBounds.IsFirstOfLine = renderer.IsFirstOfLine;
                        masterBarBounds.RealBounds = new Bounds
                        {
                            X = x + renderer.X,
                            Y = realTop,
                            W = renderer.Width,
                            H = realHeight
                        };
                        masterBarBounds.VisualBounds = new Bounds
                        {
                            X = x + renderer.X,
                            Y = visualTop,
                            W = renderer.Width,
                            H = visualHeight
                        };
                        Layout.Renderer.BoundsLookup.AddMasterBar(masterBarBounds);
                        masterBarBoundsLookup.Add(masterBarBounds);
                    }

                    renderer.BuildBoundingsLookup(masterBarBoundsLookup[j], x, cy + Y + _firstStaffInAccolade.Y);
                }
            }
        }
Example #6
0
 public void AddStaveGroup(StaveGroupBounds bounds)
 {
     bounds.BoundsLookup = this;
     StaveGroups.Add(bounds);
     _currentStaveGroup = bounds;
 }