public BendNoteHeadGroupGlyph(Beat beat, bool showParenthesis = false)
 {
     _beat            = beat;
     _showParenthesis = showParenthesis;
     IsEmpty          = true;
     _accidentals     = new AccidentalGroupGlyph();
     _noteValueLookup = new FastDictionary <int, Glyph>();
     if (showParenthesis)
     {
         _preNoteParenthesis  = new GhostNoteContainerGlyph(true);
         _postNoteParenthesis = new GhostNoteContainerGlyph(false);
     }
 }
Example #2
0
        public override void DoLayout()
        {
            // create glyphs
            var sr = (ScoreBarRenderer)Renderer;

            if (!Container.Beat.IsEmpty)
            {
                if (!Container.Beat.IsRest)
                {
                    //
                    // Note heads
                    //
                    NoteHeads               = new ScoreNoteChordGlyph();
                    NoteHeads.Beat          = Container.Beat;
                    NoteHeads.BeamingHelper = BeamingHelper;

                    var ghost = new GhostNoteContainerGlyph(false);
                    ghost.Renderer = Renderer;

                    foreach (var note in Container.Beat.Notes)
                    {
                        if (note.IsVisible)
                        {
                            CreateNoteGlyph(note);
                            ghost.AddParenthesis(note);
                        }
                    }
                    AddGlyph(NoteHeads);

                    if (!ghost.IsEmpty)
                    {
                        AddGlyph(new SpacingGlyph(0, 0, 4 * (Container.Beat.GraceType != GraceType.None ? NoteHeadGlyph.GraceScale : 1) * Scale));
                        AddGlyph(ghost);
                    }

                    //
                    // Whammy Bar
                    if (Container.Beat.HasWhammyBar)
                    {
                        var whammy = new ScoreWhammyBarGlyph(Container.Beat);
                        whammy.Renderer = Renderer;
                        whammy.DoLayout();

                        Container.Ties.Add(whammy);
                    }

                    //
                    // Note dots
                    //
                    if (Container.Beat.Dots > 0)
                    {
                        AddGlyph(new SpacingGlyph(0, 0, 5 * Scale));
                        for (var i = 0; i < Container.Beat.Dots; i++)
                        {
                            var group = new GlyphGroup(0, 0);
                            foreach (var note in Container.Beat.Notes)
                            {
                                CreateBeatDot(sr.GetNoteLine(note), group);
                            }
                            AddGlyph(group);
                        }
                    }
                }
                else
                {
                    var dotLine = 0;
                    var line    = 0;
                    var offset  = 0;

                    switch (Container.Beat.Duration)
                    {
                    case Duration.QuadrupleWhole:
                        line    = 6;
                        dotLine = 5;
                        break;

                    case Duration.DoubleWhole:
                        line    = 6;
                        dotLine = 5;
                        break;

                    case Duration.Whole:
                        line    = 4;
                        dotLine = 5;
                        break;

                    case Duration.Half:
                        line    = 6;
                        dotLine = 5;
                        break;

                    case Duration.Quarter:
                        line    = 6;
                        offset  = -2;
                        dotLine = 5;
                        break;

                    case Duration.Eighth:
                        line    = 6;
                        dotLine = 5;
                        break;

                    case Duration.Sixteenth:
                        line    = 6;
                        dotLine = 5;
                        break;

                    case Duration.ThirtySecond:
                        line    = 6;
                        dotLine = 3;
                        break;

                    case Duration.SixtyFourth:
                        line    = 6;
                        dotLine = 3;
                        break;

                    case Duration.OneHundredTwentyEighth:
                        line    = 6;
                        dotLine = 3;
                        break;

                    case Duration.TwoHundredFiftySixth:
                        line    = 6;
                        dotLine = 3;
                        break;
                    }

                    var y = sr.GetScoreY(line, offset);

                    RestGlyph               = new ScoreRestGlyph(0, y, Container.Beat.Duration);
                    RestGlyph.Beat          = Container.Beat;
                    RestGlyph.BeamingHelper = BeamingHelper;
                    AddGlyph(RestGlyph);

                    //
                    // Note dots
                    //
                    if (Container.Beat.Dots > 0)
                    {
                        AddGlyph(new SpacingGlyph(0, 0, 5 * Scale));
                        for (var i = 0; i < Container.Beat.Dots; i++)
                        {
                            var group = new GlyphGroup(0, 0);
                            CreateBeatDot(dotLine, group);
                            AddGlyph(group);
                        }
                    }
                }
            }

            base.DoLayout();

            if (Container.Beat.IsEmpty)
            {
                CenterX = Width / 2;
            }
            else if (Container.Beat.IsRest)
            {
                CenterX = RestGlyph.X + RestGlyph.Width / 2;
            }
            else
            {
                CenterX = NoteHeads.X + NoteHeads.Width / 2;
            }
        }
        public override void DoLayout()
        {
            if (!Container.Beat.IsRest)
            {
                var accidentals = new AccidentalGroupGlyph();
                var ghost       = new GhostNoteContainerGlyph(true);
                ghost.Renderer     = Renderer;
                _prebends          = new BendNoteHeadGroupGlyph(Container.Beat, true);
                _prebends.Renderer = Renderer;
                foreach (var note in Container.Beat.Notes)
                {
                    if (note.IsVisible)
                    {
                        if (note.HasBend)
                        {
                            switch (note.BendType)
                            {
                            case BendType.PrebendBend:
                            case BendType.Prebend:
                            case BendType.PrebendRelease:
                                _prebends.AddGlyph(note.DisplayValue - note.BendPoints[0].Value / 2);
                                break;
                            }
                        }
                        else if (note.Beat.HasWhammyBar)
                        {
                            switch (note.Beat.WhammyBarType)
                            {
                            case WhammyType.PrediveDive:
                            case WhammyType.Predive:
                                _prebends.AddGlyph(note.DisplayValue - note.Beat.WhammyBarPoints[0].Value / 2);
                                break;
                            }
                        }

                        CreateAccidentalGlyph(note, accidentals);
                        ghost.AddParenthesis(note);
                    }
                }

                if (!_prebends.IsEmpty)
                {
                    AddGlyph(_prebends);
                    AddGlyph(new SpacingGlyph(0, 0, 4 * (Container.Beat.GraceType != GraceType.None ? NoteHeadGlyph.GraceScale : 1) * Scale));
                }

                if (Container.Beat.BrushType != BrushType.None)
                {
                    AddGlyph(new ScoreBrushGlyph(Container.Beat));
                    AddGlyph(new SpacingGlyph(0, 0, 4 * Scale));
                }

                if (!ghost.IsEmpty)
                {
                    AddGlyph(ghost);
                    AddGlyph(new SpacingGlyph(0, 0, 4 * (Container.Beat.GraceType != GraceType.None ? NoteHeadGlyph.GraceScale : 1) * Scale));
                }

                if (!accidentals.IsEmpty)
                {
                    AddGlyph(accidentals);
                    AddGlyph(new SpacingGlyph(0, 0, 4 * (Container.Beat.GraceType != GraceType.None ? NoteHeadGlyph.GraceScale : 1) * Scale));
                }
            }

            base.DoLayout();
        }