-/*
- * TODO: note-head collision handling
- *
- * TODO: accidentals collision handling
- *
- * TODO: alternative representation: adding the ambitus as text script
- * to the instrument name (e.g. "Soprano (c^1 - f^2)").
- *
- * FIXME: Accidentals are too close at the note heads (it seems that
- * the extent of the ledger lines is ignored).
- *
- * TODO: If (depending on breakAlignOrder) ambitus is put behind
- * key-signature, then do not repeat accidentals that already appear
- * in the key signature.
- *
- * FIXME: A staff containing more than a single context will result in
- * multiple ambitus grobs per staff. This is basically ok, but there is
- * currently no proper collision handling for this case.
- *
- * TODO: make ignore_octave and force_accidental of function
- * number_accidentals accessible via grob properties.
- */
-
-/**
- Given a pitch and a key_signature, decide what accidentals to show.
-
- Possible return values:
-
- 0: do not show any accidental
- 1: show pitch->alteration_ only
- 2: show pitch->get_alteration, preceded by a natural sign
-
- UGH: code duplication! See accidental-engraver.
-
- */
-static int
-number_accidentals (SCM key_signature, Pitch *pitch,
- bool ignore_octave_b, bool force_accidental)
-{
- int notename = pitch->get_notename ();
- int octave = pitch->get_octave();
- int alteration = pitch->get_alteration();
-
- if (force_accidental) // ignore key signature
- return 1;
-
-
-#if DEBUG_AMBITUS
- scm_display (key_signature, scm_current_output_port ());
-#endif
-
- SCM prev;
- if (ignore_octave_b)
- prev = ly_assoc_cdr (scm_int2num (notename), key_signature);
- else
- prev = scm_assoc (gh_cons (scm_int2num (octave), scm_int2num (notename)),
- key_signature);
-
- /* should really be true unless prev == SCM_BOOL_F */
- if (gh_pair_p (prev) && gh_pair_p (ly_cdr (prev)))
- {
- prev = gh_cons (ly_car (prev), ly_cadr (prev));
- }
-
- /* If an accidental was not found */
- if (prev == SCM_BOOL_F)
- prev = scm_assoc (scm_int2num (notename), key_signature);
-
- SCM prev_acc = (prev == SCM_BOOL_F) ? scm_int2num (0) : ly_cdr (prev);
- int sig_alteration = gh_number_p (prev_acc) ? gh_scm2int (prev_acc) : 0;
-
- if (alteration == sig_alteration) // no accidental at all needed
- return 0;
-
- if ((alteration == 0) && (sig_alteration != 0)) // need ordinary natural
- return 2;
-
- if (sig_alteration == 0) // use pitch's alteration
- return 1;
-
- return 2;
-}
-
-void
-add_accidentals (Item *me, Molecule *head, int num_acc,
- Pitch *pitch, String accidentals_style, Real yoffs)
-{
- if (!num_acc)
- return;
- if (pitch->get_alteration())
- {
- Molecule accidental (Font_interface::get_default_font (me)->
- find_by_name (String ("accidentals-") +
- accidentals_style +
- to_string (pitch->get_alteration())));
- accidental.translate_axis (yoffs, Y_AXIS);
- head->add_at_edge (X_AXIS, LEFT, accidental, 0.1, 0);
- }
- if (num_acc == 2)
- {
- Molecule natural (Font_interface::get_default_font (me)->
- find_by_name (String ("accidentals-") +
- accidentals_style +
- to_string ("0")));
- natural.translate_axis (yoffs, Y_AXIS);
- head->add_at_edge (X_AXIS, LEFT, natural, 0.1, 0);
- }
-}
-
-MAKE_SCHEME_CALLBACK (Ambitus,brew_molecule,1);