getWhitespaceOnRight method

double getWhitespaceOnRight(
  1. ChantContext ctxt
)

Implementation

double getWhitespaceOnRight(ChantContext ctxt) {
  final notations = score.notations;
  int lastIndex = notationsStartIndex + numNotationsOnLine;
  ChantNotationElement? last =
      (lastIndex > 0 && lastIndex <= notations.length)
      ? notations[lastIndex - 1]
      : null;
  if (extraTextOnlyIndex != null && last is TextOnly) {
    lastIndex = extraTextOnlyIndex!;
    last = (lastIndex > 0 && lastIndex <= notations.length)
        ? notations[lastIndex - 1]
        : null;
  }
  double lastRightNeume = last != null
      ? last.bounds.right + last.calculatedTrailingSpace
      : 0;
  final lastLyrics = lastLyricsBeforeTextOnly ?? this.lastLyrics;
  double lastRightLyric = lastLyrics.isNotEmpty
      ? LyricArray.getRight(lastLyrics)
      : 0;

  if (custos != null) {
    lastRightNeume += custos!.bounds.width + custos!.leadingSpace;
    if (custos!.hasLyrics) {
      lastRightLyric = LyricArray.getRight(custos!.lyrics);
    }
  } else if (lastIndex < notations.length) {
    lastRightNeume +=
        glyphs[GlyphCode.custosLong]!.bounds.width * ctxt.glyphScaling;
  }
  return staffRight -
      (lastRightLyric > lastRightNeume ? lastRightLyric : lastRightNeume);
}