Clarify naming in accidental-engraver.cc.
Use AccidentalCautionary as grob for cautionaries, obviating
cautionary-style and cautionary properties. Use 'font-size and
'parenthesized instead. Use restore-first iso. general list of
alterations. Store alteration in property 'alteration
iso. 'accidentals.
Add conversion rules.
-\version "2.10.0"
+\version "2.11.5"
\header {
texidoc = "Cautionary accidentals are indicated using either
{
c''4
cis''?4
- \override Staff.Accidental #'cautionary-style = #'smaller
+ \once \override Staff.AccidentalCautionary #'font-size = #-2
cis''?4
- \override Staff.Accidental #'cautionary-style = #'parentheses
+ \once \override Staff.AccidentalCautionary #'parenthesized = ##t
cis''?4
}
}
-\version "2.10.0"
+\version "2.11.5"
\paper {
ragged-right = ##t
}
\time 2/4
\set suggestAccidentals = ##t
cis^> gis'-|
- \override AccidentalSuggestion #'cautionary-style = #'parentheses
+ \override AccidentalSuggestion #'parenthesized = ##t
cis,_"paren" gis'
- \override AccidentalSuggestion #'cautionary-style = #'()
- cis,_"no caut style" gis'
}
int get_bar_number ();
void update_local_key_signature (SCM new_signature);
void create_accidental (Accidental_entry *entry, bool, bool);
- Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans);
+ Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans, bool);
Grob *make_suggested_accidental (Stream_event *note, Grob *note_head, Engraver *trans);
protected:
if (as_suggestion)
a = make_suggested_accidental (note, support, entry->origin_engraver_);
else
- a = make_standard_accidental (note, support, entry->origin_engraver_);
+ a = make_standard_accidental (note, support, entry->origin_engraver_, cautionary);
- SCM accs = scm_cons (scm_from_int (pitch->get_alteration () * Rational (4)),
- SCM_EOL);
if (restore_natural)
{
if (to_boolean (get_property ("extraNatural")))
- accs = scm_cons (scm_from_int (0), accs);
+ a->set_property ("restore-first", SCM_BOOL_T);
}
-
- if (cautionary)
- a->set_property ("cautionary", SCM_BOOL_T);
- a->set_property ("accidentals", accs);
+ a->set_property ("alteration", scm_from_int (pitch->get_alteration () * Rational (4)));
entry->accidental_ = a;
}
Grob *
Accidental_engraver::make_standard_accidental (Stream_event *note,
Grob *note_head,
- Engraver *trans)
+ Engraver *trans,
+ bool cautionary)
{
(void)note;
level, so that we get the property settings for
Accidental from the respective Voice.
*/
- Grob *a = trans->make_item ("Accidental", note_head->self_scm ());
+ Grob *a = 0;
+ if (cautionary)
+ a = trans->make_item ("AccidentalCautionary", note_head->self_scm ());
+ else
+ a = trans->make_item ("Accidental", note_head->self_scm ());
/*
We add the accidentals to the support of the arpeggio,
Side_position_interface::add_support (a, right_objects_[i]);
a->set_parent (note_head, Y_AXIS);
+ if (cautionary)
+ a->set_property ("cautionary", SCM_BOOL_T);
+
if (!accidental_placement_)
accidental_placement_ = make_item ("AccidentalPlacement",
Accidental_placement::add_accidental (accidental_placement_, a);
note_head->set_object ("accidental-grob", a->self_scm ());
-
+
return a;
}
"This engraver usually lives at Staff level, but "
"reads the settings for Accidental at @code{Voice} level, "
"so you can @code{\\override} them at @code{Voice}. ",
- "Accidental AccidentalSuggestion",
+ /* grobs */
+ "Accidental "
+ "AccidentalCautionary"
+ "AccidentalSuggestion",
+
+ /* props */
"autoAccidentals "
"autoCautionaries "
"internalBarNumber "
#include "pitch.hh"
#include "stencil.hh"
-/*
- TODO: insert support for smaller cautionaries, tie-break-reminders.
- Either here or in new-accidental-engraver.
-
- 'accidentals should go, for a single 'accidental property -- see
- accidental-placement.cc
-*/
Stencil
parenthesize (Grob *me, Stencil m)
{
}
vector<Box>
-Accidental_interface::accurate_boxes (Grob *a, Grob **common)
+Accidental_interface::accurate_boxes (Grob *me, Grob **common)
{
Box b;
- b[X_AXIS] = a->extent (a, X_AXIS);
- b[Y_AXIS] = a->extent (a, Y_AXIS);
+ b[X_AXIS] = me->extent (me, X_AXIS);
+ b[Y_AXIS] = me->extent (me, Y_AXIS);
vector<Box> boxes;
- bool parens = false;
- if (to_boolean (a->get_property ("cautionary")))
- {
- SCM cstyle = a->get_property ("cautionary-style");
- parens = ly_is_equal (cstyle, ly_symbol2scm ("parentheses"));
- }
+ bool parens = to_boolean (me->get_property ("parenthesized"));
- SCM accs = a->get_property ("accidentals");
- SCM scm_style = a->get_property ("style");
+ SCM scm_style = me->get_property ("style");
if (!scm_is_symbol (scm_style)
- && !parens
- && scm_ilength (accs) == 1)
+ && !to_boolean (me->get_property ("restore-first"))
+ && !parens)
{
- switch (scm_to_int (scm_car (accs)))
+ int acc = scm_to_int (me->get_property ("alteration"));
+ switch (acc)
{
case FLAT:
{
if (!boxes.size ())
boxes.push_back (b);
- Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS),
- a->relative_coordinate (common[Y_AXIS], Y_AXIS));
+ Offset o (me->relative_coordinate (common[X_AXIS], X_AXIS),
+ me->relative_coordinate (common[Y_AXIS], Y_AXIS));
+
for (vsize i = boxes.size (); i--;)
boxes[i].translate (o);
style = ""; // currently same as default
if (style == "default")
style = "";
+
return style + to_string (alteration);
}
Accidental_interface::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
- bool smaller = false;
- bool parens = false;
-
- bool caut = to_boolean (me->get_property ("cautionary"));
- if (caut)
- {
- SCM cstyle = me->get_property ("cautionary-style");
- parens = ly_is_equal (cstyle, ly_symbol2scm ("parentheses"));
- smaller = ly_is_equal (cstyle, ly_symbol2scm ("smaller"));
- }
+ bool parens = to_boolean (me->get_property ("parenthesized"));
SCM scm_style = me->get_property ("style");
string style;
*/
style = "";
- Font_metric *fm = 0;
- if (smaller)
- {
- SCM ac = Font_interface::music_font_alist_chain (me);
- /*
- TODO: should calc font-size by adding -2 to current font-size
- */
- ac = scm_cons (scm_list_1 (scm_cons
- (ly_symbol2scm ("font-size"),
- scm_from_int (-2))),
- ac);
- fm = select_font (me->layout (), ac);
- }
- else
- fm = Font_interface::get_default_font (me);
+ Font_metric *fm = Font_interface::get_default_font (me);
- Stencil mol;
- for (SCM s = me->get_property ("accidentals");
- scm_is_pair (s); s = scm_cdr (s))
+ SCM stencils = me->get_property ("stencils");
+ if (!scm_is_pair (stencils)
+ || !unsmob_stencil (scm_car (stencils)))
+ return SCM_EOL;
+
+ Stencil mol (*unsmob_stencil (scm_car (stencils)));
+ if (to_boolean (me->get_property ("restore-first")))
{
- int alteration = scm_to_int (scm_car (s));
- string font_char = get_fontcharname (style, alteration);
+ string font_char = get_fontcharname (style, 0);
Stencil acc (fm->find_by_name ("accidentals." + font_char));
if (acc.is_empty ())
me->warning (_f ("accidental `%s' not found", font_char));
else
- mol.add_at_edge (X_AXIS, RIGHT, acc, 0.1, 0);
+ mol.add_at_edge (X_AXIS, LEFT, acc, 0.1, 0);
}
-
+
if (parens)
mol = parenthesize (me, mol);
return mol.smobbed_copy ();
}
+
+MAKE_SCHEME_CALLBACK (Accidental_interface, calc_stencils, 1);
+SCM
+Accidental_interface::calc_stencils (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+
+ SCM scm_style = me->get_property ("style");
+ string style;
+ if (scm_is_symbol (scm_style))
+ style = ly_symbol2string (scm_style);
+ else
+ /*
+ preferably no name for the default style.
+ */
+ style = "";
+
+
+ Font_metric *fm = Font_interface::get_default_font (me);
+ SCM acc = me->get_property ("alteration");
+ if (scm_is_number (acc))
+ {
+ string font_char = get_fontcharname (style, scm_to_int (acc));
+
+ Stencil acc_stencil (fm->find_by_name ("accidentals." + font_char));
+
+ return scm_list_1 (acc_stencil.smobbed_copy ());
+ }
+ else
+ return SCM_EOL;
+}
+
ADD_INTERFACE (Accidental_interface,
"a single accidental",
- "accidentals "
+
+ /* props */
+ "alteration "
"avoid-slur "
- "cautionary "
- "cautionary-style "
"forced "
"style "
+ "parenthesized "
"tie "
);
}
else
{
- SCM l = scm_list_1 (scm_from_int (int (Real (Rational (4) * p.get_alteration ()))));
- accidentals_[d]->set_property ("accidentals", l);
+ accidentals_[d]->set_property ("alteration", scm_from_int (int (Real (Rational (4) * p.get_alteration ()))));
}
}
while (flip (&d) != DOWN);
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_stencils, (SCM));
DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
DECLARE_GROB_INTERFACE();
trill_accidental_ = make_item ("TrillPitchAccidental", ev->self_scm ());
// fixme: naming -> alterations
- trill_accidental_->set_property ("accidentals", scm_list_1 (scm_from_int (Rational (4)
- * p->get_alteration ())));
+ trill_accidental_->set_property ("alteration", scm_from_int (Rational (4)
+ * p->get_alteration ()));
Side_position_interface::add_support (trill_accidental_, trill_head_);
trill_head_->set_object ("accidental-grob", trill_accidental_->self_scm ());
parens = ly_is_equal (cstyle, ly_symbol2scm ("parentheses"));
}
- SCM accs = g->get_property ("accidentals");
+ SCM alt = g->get_property ("alteration");
SCM scm_style = g->get_property ("style");
if (!scm_is_symbol (scm_style)
&& !parens
- && scm_ilength (accs) == 1)
+ && !to_boolean (g->get_property ("restore-first")))
{
/* End copy accidental.cc */
- switch (scm_to_int (scm_car (accs)))
+ switch (scm_to_int (alt))
{
case FLAT:
case DOUBLE_FLAT:
local-help: local-ly-help
-local-ly-help:
- @echo -e "\
- convert-ly convert all LilyPond sources\n\
-"\
-#
-
local-WWW: $(outdir)/collated-files.html $(outdir)/collated-files.pdf
#.PRECIOUS: $(outdir)/$(NAME).texi
+
conversions.append (((2, 11, 2), conv, """ly:clone-parser -> ly:parser-clone"""))
+
+
+def conv (str):
+ str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'smaller",
+ "AccidentalCautionary #'font-size = #-2", str)
+ str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'parentheses",
+ "AccidentalCautionary #'parenthesized = ##t", str)
+
+ str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'parentheses",
+ r"\1 #'parenthesized = ##t", str)
+ str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'smaller",
+ r"\1 #'font-size = #-2", str)
+
+ return str
+
+conversions.append (((2, 11, 5), conv, """ly:clone-parser -> ly:parser-clone"""))
+
(X-offset ,number? "The horizontal amount that this object is moved relative to its X-parent")
(Y-offset ,number? "The vertical amount that this object is moved
relative to its Y-parent")
- (accidentals ,list? "List of alteration numbers")
+ (alteration ,number? "alteration numbers for accidental")
(after-line-breaking ,boolean? "Dummy property, used to trigger callback for after-line-breaking")
(alteration-alist ,list? "List of @code{(@var{pitch}
. @var{accidental})} pairs for key signature.")
#t means visible, #f means killed.")
(c0-position ,integer? "An integer indicating the position of
middle C.")
- (cautionary-style ,symbol? "How to print cautionary
-accidentals. Choices are @code{smaller} or
-@code{parentheses}.")
- (cautionary ,boolean? "Is this a cautionary accidental?")
(concaveness ,number? "A beam is concave when its inner stems are
closer to the beam than the two outside stems. This number is a
measure of the closeness of the inner stems. It is used for damping
This affects the choices of the page breaker; it will avoid a page
turn at a column with a positive penalty and prefer a page turn at a column
with a negative penalty.")
+ (parenthesized ,boolean? "Parenthesize this grob.")
(line-break-penalty ,number? "Penalty for a line break at this column.
This affects the choices of the line breaker; it will avoid a line
break at a column with a positive penalty and prefer a line break at a column
(remove-empty ,boolean? "If set, remove group if it contains no
@code{interesting-items}")
(remove-first ,boolean? "Remove the first staff of a orchestral score?")
+ (restore-first ,boolean? "Print a natural before the accidental.")
(rhythmic-location ,rhythmic-location? "Where (bar number, measure position) in the score.")
(right-padding ,ly:dimension? "Space to insert on the right side of an object (eg. between note and its accidentals.)")
(rotation ,list? "Number of degrees to rotate this object, and what point
(avoid-slur . inside)
(cautionary-style . parentheses)
(stencil . ,ly:accidental-interface::print)
+ (stencils . ,ly:accidental-interface::calc-stencils)
(after-line-breaking
. ,ly:accidental-interface::after-line-breaking)
(meta . ((class . Item)
(interfaces . (accidental-interface
font-interface))))))
+ (AccidentalCautionary
+ . (
+ (avoid-slur . inside)
+ (parenthesized . #t)
+ (stencil . ,ly:accidental-interface::print)
+ (stencils . ,ly:accidental-interface::calc-stencils)
+ (after-line-breaking
+ . ,ly:accidental-interface::after-line-breaking)
+ (meta . ((class . Item)
+ (interfaces . (accidental-interface
+ font-interface))))))
+
(AccidentalSuggestion
. (
,(ly:make-simple-closure (list ly:self-alignment-interface::centered-on-x-parent))
,(ly:make-simple-closure (list ly:self-alignment-interface::x-aligned-on-self)))))
(self-alignment-X . ,CENTER)
- (cautionary . #t)
- (cautionary-style . smaller)
+ (font-size . -2)
(Y-offset . ,ly:side-position-interface::y-aligned-side)
- (cautionary-style . parentheses)
(direction . ,UP)
(staff-padding . 0.25)
+ (outside-staff-priority . 0)
(script-priority . 0)
+ (stencils . ,ly:accidental-interface::calc-stencils)
(side-axis . ,X)
(meta . ((class . Item)
(interfaces . (side-position-interface
(padding . 0.5)
(X-offset . ,ly:side-position-interface::x-aligned-side)
(direction . ,LEFT)
- (cautionary-style . parentheses)
(stencil . ,ly:accidental-interface::print)
+ (stencils . ,ly:accidental-interface::calc-stencils)
+
(after-line-breaking . ,ly:accidental-interface::after-line-breaking)
(side-axis . ,X)
(meta . ((class . Item)
(font-size . -4)
(side-axis . ,X)
(stencil . ,ly:accidental-interface::print)
+ (stencils . ,ly:accidental-interface::calc-stencils)
(meta . ((class . Item)
(interfaces . (item-interface
trill-pitch-accidental-interface
note-head-interface
rhythmic-head-interface
font-interface
- accidental-interface
axis-group-interface))))))
(TrillPitchHead