public override void AddGlyph(Glyph g) { g.X = Glyphs.Count == 0 ? 0 : (Glyphs[Glyphs.Count - 1].X + Glyphs[Glyphs.Count - 1].Width); g.Renderer = Renderer; g.DoLayout(); Width = g.X + g.Width; base.AddGlyph(g); }
public override void AddGlyph(Glyph g) { g.X = BeatGlyphs.Count == 0 ? 0 : BeatGlyphs[BeatGlyphs.Count - 1].X + BeatGlyphs[BeatGlyphs.Count - 1].Width; g.Renderer = Renderer; g.DoLayout(); BeatGlyphs.Add((BeatContainerGlyph)g); Width = g.X + g.Width; }
public override void DoLayout() { base.DoLayout(); var direction = Direction; foreach (var effectKey in BeatEffects) { var effect = BeatEffects[effectKey]; effect.Renderer = Renderer; effect.DoLayout(); } if (Beat.IsTremolo) { int offset; var baseNote = direction == BeamDirection.Up ? MinNote : MaxNote; var tremoloX = direction == BeamDirection.Up ? DisplacedX : 0; var speed = Beat.TremoloSpeed.Value; switch (speed) { case Duration.ThirtySecond: offset = direction == BeamDirection.Up ? -15 : 15; break; case Duration.Sixteenth: offset = direction == BeamDirection.Up ? -12 : 15; break; case Duration.Eighth: offset = direction == BeamDirection.Up ? -10 : 10; break; default: offset = direction == BeamDirection.Up ? -10 : 15; break; } _tremoloPicking = new TremoloPickingGlyph(tremoloX, baseNote.Glyph.Y + offset * Scale, Beat.TremoloSpeed.Value); _tremoloPicking.Renderer = Renderer; _tremoloPicking.DoLayout(); } }
public override void DoLayout() { _infos.Sort((a, b) => a.Line.CompareTo(b.Line)); const int padding = 0; // Std.int(4 * getScale()); var displacedX = 0f; var lastDisplaced = false; var lastLine = 0; var anyDisplaced = false; var direction = Direction; var w = 0f; for (int i = 0, j = _infos.Count; i < j; i++) { var g = _infos[i].Glyph; g.Renderer = Renderer; g.DoLayout(); var displace = false; if (i == 0) { displacedX = g.Width + padding; } else { // check if note needs to be repositioned if (Math.Abs(lastLine - _infos[i].Line) <= 1) { // reposition if needed if (!lastDisplaced) { displace = true; g.X = displacedX - (Scale); anyDisplaced = true; lastDisplaced = true; // let next iteration know we are displace now } else { lastDisplaced = false; // let next iteration know that we weren't displaced now } } else // offset is big enough? no displacing needed { lastDisplaced = false; } } // for beat direction down we invert the displacement. // this means: displaced is on the left side of the stem and not displaced is right if (direction == BeamDirection.Down) { g.X = displace ? padding : displacedX; } else { g.X = displace ? displacedX : padding; } lastLine = _infos[i].Line; w = Math.Max(w, g.X + g.Width); } if (anyDisplaced) { _noteHeadPadding = 0; UpLineX = displacedX; DownLineX = displacedX; } else { _noteHeadPadding = direction == BeamDirection.Down ? -displacedX : 0; w += _noteHeadPadding; UpLineX = w; DownLineX = padding; } foreach (var effectKey in BeatEffects) { var effect = BeatEffects[effectKey]; effect.Renderer = Renderer; effect.DoLayout(); } if (Beat.IsTremolo) { int offset; var baseNote = direction == BeamDirection.Up ? MinNote : MaxNote; var tremoloX = direction == BeamDirection.Up ? displacedX : 0; var speed = Beat.TremoloSpeed.Value; switch (speed) { case Duration.ThirtySecond: offset = direction == BeamDirection.Up ? -15 : 15; break; case Duration.Sixteenth: offset = direction == BeamDirection.Up ? -12 : 15; break; case Duration.Eighth: offset = direction == BeamDirection.Up ? -10 : 10; break; default: offset = direction == BeamDirection.Up ? -10 : 15; break; } _tremoloPicking = new TremoloPickingGlyph(tremoloX, baseNote.Glyph.Y + offset * Scale, Beat.TremoloSpeed.Value); _tremoloPicking.Renderer = Renderer; _tremoloPicking.DoLayout(); } Width = w + padding; }
private void AddGlyph(FastList<Glyph> c, Glyph g) { IsEmpty = false; g.X = c.Count == 0 ? 0 : (c[c.Count - 1].X + c[c.Count - 1].Width); g.Index = c.Count; g.Renderer = this; g.DoLayout(); c.Add(g); }
public override void DoLayout() { _infos.Sort((a, b) => a.Line.CompareTo(b.Line)); const int padding = 0; // Std.int(4 * getScale()); var displacedX = 0f; var lastDisplaced = false; var lastLine = 0; var anyDisplaced = false; var w = 0f; for (int i = 0, j = _infos.Count; i < j; i++) { var g = _infos[i].Glyph; g.Renderer = Renderer; g.DoLayout(); g.X = padding; if (i == 0) { displacedX = g.Width + padding; } else { // check if note needs to be repositioned if (Math.Abs(lastLine - _infos[i].Line) <= 1) { // reposition if needed if (!lastDisplaced) { g.X = displacedX - (Scale); anyDisplaced = true; lastDisplaced = true; // let next iteration know we are displace now } else { lastDisplaced = false; // let next iteration know that we weren't displaced now } } else // offset is big enough? no displacing needed { lastDisplaced = false; } } lastLine = _infos[i].Line; w = Math.Max(w, g.X + g.Width); } if (anyDisplaced) { UpLineX = displacedX; DownLineX = displacedX; } else { UpLineX = w; DownLineX = padding; } Std.Foreach(BeatEffects.Values, e => { e.Renderer = Renderer; e.DoLayout(); }); if (Beat.IsTremolo) { var direction = BeamingHelper.Direction; int offset; var baseNote = direction == BeamDirection.Up ? MinNote : MaxNote; var tremoloX = direction == BeamDirection.Up ? displacedX : 0; if (Beat.TremoloSpeed != null) { var speed = Beat.TremoloSpeed.Value; switch (speed) { case Duration.ThirtySecond: offset = direction == BeamDirection.Up ? -15 : 10; break; case Duration.Sixteenth: offset = direction == BeamDirection.Up ? -12 : 10; break; case Duration.Eighth: offset = direction == BeamDirection.Up ? -10 : 10; break; default: offset = direction == BeamDirection.Up ? -15 : 15; break; } } else { offset = direction == BeamDirection.Up ? -15 : 15; } _tremoloPicking = new TremoloPickingGlyph(tremoloX, baseNote.Glyph.Y + offset * Scale, Beat.TremoloSpeed.Value); _tremoloPicking.Renderer = Renderer; _tremoloPicking.DoLayout(); } Width = w + padding; }