internal override void AddAncilliaryMetricsTo(StaffMetrics staffMetrics) { base.AddAncilliaryMetricsTo(staffMetrics); if (FramedRegionEndTextMetrics != null) { staffMetrics.Add(FramedRegionEndTextMetrics); } }
internal virtual void AddAncilliaryMetricsTo(StaffMetrics staffMetrics) { if (StaffNameMetrics != null) { staffMetrics.Add(StaffNameMetrics); } if (BarnumberMetrics != null) { staffMetrics.Add(BarnumberMetrics); } }
private void SetTopAndBottomMetrics(StaffMetrics staffMetrics) { _notesTop = _notesTop < staffMetrics.Top ? _notesTop : staffMetrics.Top; _stafflinesTop = _stafflinesTop < staffMetrics.StafflinesTop ? _stafflinesTop : staffMetrics.StafflinesTop; _stafflinesBottom = _stafflinesBottom > staffMetrics.StafflinesBottom ? _stafflinesBottom : staffMetrics.StafflinesBottom; _notesBottom = _notesBottom > staffMetrics.Bottom ? _notesBottom : staffMetrics.Bottom; }
protected void SetCommonMetrics(Graphics graphics, List <DrawObject> drawObjects) { StaffMetrics staffMetrics = Voice.Staff.Metrics; foreach (DrawObject drawObject in DrawObjects) { if (drawObject is StaffNameText staffNameText) { CSSObjectClass staffClass = CSSObjectClass.staffName; StaffNameMetrics = new StaffNameMetrics(staffClass, graphics, staffNameText.TextInfo); // move the staffname vertically to the middle of this staff double staffheight = staffMetrics.StafflinesBottom - staffMetrics.StafflinesTop; double dy = (staffheight * 0.5F) + (Gap * 0.8F); StaffNameMetrics.Move(0, dy); } if (drawObject is FramedBarNumberText framedBarNumberText) { BarnumberMetrics = new BarnumberMetrics(graphics, framedBarNumberText.TextInfo, framedBarNumberText.FrameInfo); // move the bar number to its default (=lowest) position above this staff. BarnumberMetrics.Move(0, staffMetrics.StafflinesTop - BarnumberMetrics.Bottom - (Gap * 3)); } } }
/// <summary> /// noteObjects[noteObjectIndex] is the first OutputChordSymbol or OutputRestSymbol in the tuplet, and is the /// noteObject to which the tuplet is attached, /// </summary> /// <param name="graphics"></param> /// <param name="tupletDef"></param> /// <param name="noteObjects"></param> /// <param name="noteObjectIndex"></param> public Tuplet(Graphics graphics, TupletDef tupletDef, List <NoteObject> noteObjects, int noteObjectIndex) : base(noteObjects[noteObjectIndex]) { List <NoteObject> tupletChordsAndRests = GetTupletChordsAndRests(noteObjects, noteObjectIndex, tupletDef); var gap = M.PageFormat.GapVBPX; var textInfo = GetTupletTextInfo(tupletDef.InnerDuration, tupletDef.OuterDuration); Metrics = new TextMetrics(CSSObjectClass.tupletText, graphics, textInfo); var textHeight = (Metrics.Bottom - Metrics.Top); var textWidth = (Metrics.Right - Metrics.Left); bool isOver = (tupletDef.Orient == Orientation.up); double textXAlignment; if (tupletChordsAndRests.Count > 2) { int alignedIndex = (int)(tupletChordsAndRests.Count) / 2; Metrics metrics = tupletChordsAndRests[alignedIndex].Metrics; if (metrics is ChordMetrics cMetrics) { textXAlignment = cMetrics.OriginX - textWidth / 4; } else { textXAlignment = ((metrics.Right - metrics.Left) / 2) + metrics.Left; } } else { M.Assert(tupletChordsAndRests.Count == 2); Metrics metrics1 = tupletChordsAndRests[0].Metrics; Metrics metrics2 = tupletChordsAndRests[1].Metrics; textXAlignment = ((metrics1.Left + metrics2.Right) / 2) - textWidth / 4; } //textYAlignment = (isOver) ? metrics.Top - gap - (textHeight / 2) : metrics.Bottom + gap + (textHeight / 2); double textYAlignment = (isOver) ? double.MaxValue : double.MinValue;; foreach (NoteObject noteObject in tupletChordsAndRests) { var metrics = noteObject.Metrics; if (isOver) { textYAlignment = (metrics.Top < textYAlignment) ? metrics.Top : textYAlignment; } else { textYAlignment = (metrics.Bottom > textYAlignment) ? metrics.Bottom : textYAlignment; } } #region move vertically off the staff if necessary StaffMetrics staffMetrics = tupletChordsAndRests[0].Voice.Staff.Metrics; if (isOver) { double topMax = staffMetrics.StafflinesTop - gap - (textHeight / 2); if (textYAlignment > topMax) { textYAlignment = topMax; } } else { double topMin = staffMetrics.StafflinesBottom + gap + (textHeight / 2); if (textYAlignment < topMin) { textYAlignment = topMin; } } #endregion Metrics.Move(textXAlignment, textYAlignment + (textHeight / 2)); // set auto correctly later -- depends on beaming if (tupletDef.Bracket == TupletBracketDisplay.yes || tupletDef.Bracket == TupletBracketDisplay.auto) { double bracketHoriz = textYAlignment; double bracketLeft = tupletChordsAndRests[0].Metrics.Left - M.PageFormat.StafflineStemStrokeWidthVBPX; double bracketRight = tupletChordsAndRests[tupletChordsAndRests.Count - 1].Metrics.Right + M.PageFormat.StafflineStemStrokeWidthVBPX; double bracketHeight = gap * 0.75; _textAndBracketMetrics = new TupletMetrics((TextMetrics)Metrics, bracketHoriz, bracketLeft, bracketRight, bracketHeight, isOver); } }
internal override void AddAncilliaryMetricsTo(StaffMetrics metrics) { base.AddAncilliaryMetricsTo(metrics); }