finishLayout method

void finishLayout(
  1. ChantContext ctxt
)

Implementation

void finishLayout(ChantContext ctxt) {
  bounds = bounds.copyWith(x: 0);

  final language =
      lyrics.elementAtOrNull(0)?.language ?? ctxt.defaultLanguage;

  final calculateLyricX = language.centerNeume
      ? (Lyric l) {
          final offset = ctxt.staffInterval < l.vowelSegmentWidth
              ? bounds.width / 2 - l.origin.x
              : origin.x - l.origin.x;
          l.bounds = l.bounds.copyWith(x: bounds.width + offset);
        }
      : (Lyric l) {
          l.bounds = l.bounds.copyWith(x: origin.x - l.origin.x);
        };
  lyrics.forEach(calculateLyricX);

  needsLayout = false;
}