summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@xs4all.nl>2006-12-28 18:08:01 +0100
committerHan-Wen Nienhuys <hanwen@xs4all.nl>2006-12-28 18:08:01 +0100
commit883e317d51c5e50011bc0e764a785631e5ea8689 (patch)
tree202823b1bf5b5d4d79be018c69ad841908f44685
parent08ac3fa9a34edfd7033d71c5bf4fda0e85a70dc4 (diff)
Cleanup of accidental-engraver.cc / accidental.cc
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.
-rw-r--r--input/regression/accidental-cautionary.ly6
-rw-r--r--input/regression/accidental-suggestions.ly6
-rw-r--r--lily/accidental-engraver.cc34
-rw-r--r--lily/accidental.cc119
-rw-r--r--lily/ambitus-engraver.cc3
-rw-r--r--lily/include/accidental-interface.hh1
-rw-r--r--lily/pitched-trill-engraver.cc4
-rw-r--r--lily/slur-scoring.cc6
-rw-r--r--make/ly-targets.make6
-rw-r--r--make/lysdoc-targets.make1
-rw-r--r--python/convertrules.py17
-rw-r--r--scm/define-grob-properties.scm8
-rw-r--r--scm/define-grobs.scm24
13 files changed, 134 insertions, 101 deletions
diff --git a/input/regression/accidental-cautionary.ly b/input/regression/accidental-cautionary.ly
index d93d253c04..b48c8b610d 100644
--- a/input/regression/accidental-cautionary.ly
+++ b/input/regression/accidental-cautionary.ly
@@ -1,4 +1,4 @@
-\version "2.10.0"
+\version "2.11.5"
\header {
texidoc = "Cautionary accidentals are indicated using either
@@ -13,9 +13,9 @@ parentheses (default) or smaller accidentals.
{
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
}
diff --git a/input/regression/accidental-suggestions.ly b/input/regression/accidental-suggestions.ly
index 8ad68e34a1..06abaedb66 100644
--- a/input/regression/accidental-suggestions.ly
+++ b/input/regression/accidental-suggestions.ly
@@ -7,7 +7,7 @@ denoting Musica Ficta."
}
-\version "2.10.0"
+\version "2.11.5"
\paper {
ragged-right = ##t
}
@@ -16,10 +16,8 @@ denoting Musica Ficta."
\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'
}
diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc
index c33bab9893..c7f956f9af 100644
--- a/lily/accidental-engraver.cc
+++ b/lily/accidental-engraver.cc
@@ -53,7 +53,7 @@ class Accidental_engraver : public Engraver
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:
@@ -375,27 +375,23 @@ Accidental_engraver::create_accidental (Accidental_entry *entry,
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;
@@ -404,7 +400,11 @@ Accidental_engraver::make_standard_accidental (Stream_event *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,
@@ -420,6 +420,9 @@ Accidental_engraver::make_standard_accidental (Stream_event *note,
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",
@@ -427,7 +430,7 @@ Accidental_engraver::make_standard_accidental (Stream_event *note,
Accidental_placement::add_accidental (accidental_placement_, a);
note_head->set_object ("accidental-grob", a->self_scm ());
-
+
return a;
}
@@ -593,8 +596,13 @@ ADD_TRANSLATOR (Accidental_engraver,
"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 "
diff --git a/lily/accidental.cc b/lily/accidental.cc
index 6b9718f61c..8359c553d0 100644
--- a/lily/accidental.cc
+++ b/lily/accidental.cc
@@ -14,13 +14,6 @@
#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)
{
@@ -57,28 +50,23 @@ Accidental_interface::after_line_breaking (SCM smob)
}
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:
{
@@ -129,8 +117,9 @@ Accidental_interface::accurate_boxes (Grob *a, Grob **common)
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);
@@ -186,6 +175,7 @@ Accidental_interface::get_fontcharname (string style, int alteration)
style = ""; // currently same as default
if (style == "default")
style = "";
+
return style + to_string (alteration);
}
@@ -194,16 +184,7 @@ SCM
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;
@@ -215,49 +196,71 @@ Accidental_interface::print (SCM smob)
*/
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 "
);
diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc
index 8f617652bf..ab2897f16d 100644
--- a/lily/ambitus-engraver.cc
+++ b/lily/ambitus-engraver.cc
@@ -158,8 +158,7 @@ Ambitus_engraver::finalize ()
}
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);
diff --git a/lily/include/accidental-interface.hh b/lily/include/accidental-interface.hh
index 8fd57a5fd9..13646895e6 100644
--- a/lily/include/accidental-interface.hh
+++ b/lily/include/accidental-interface.hh
@@ -19,6 +19,7 @@ class Accidental_interface
{
public:
DECLARE_SCHEME_CALLBACK (print, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_stencils, (SCM));
DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
DECLARE_GROB_INTERFACE();
diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc
index d29f6f42ca..811decb67d 100644
--- a/lily/pitched-trill-engraver.cc
+++ b/lily/pitched-trill-engraver.cc
@@ -110,8 +110,8 @@ Pitched_trill_engraver::make_trill (Stream_event *ev)
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 ());
diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc
index bbd257f932..85c06bf95a 100644
--- a/lily/slur-scoring.cc
+++ b/lily/slur-scoring.cc
@@ -791,14 +791,14 @@ Slur_score_state::get_extra_encompass_infos () const
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:
diff --git a/make/ly-targets.make b/make/ly-targets.make
index d01701d859..a2d621b154 100644
--- a/make/ly-targets.make
+++ b/make/ly-targets.make
@@ -6,9 +6,3 @@ local-convert-ly:
local-help: local-ly-help
-local-ly-help:
- @echo -e "\
- convert-ly convert all LilyPond sources\n\
-"\
-#
-
diff --git a/make/lysdoc-targets.make b/make/lysdoc-targets.make
index 2de20828a9..cf5a9d2e67 100644
--- a/make/lysdoc-targets.make
+++ b/make/lysdoc-targets.make
@@ -3,3 +3,4 @@
local-WWW: $(outdir)/collated-files.html $(outdir)/collated-files.pdf
#.PRECIOUS: $(outdir)/$(NAME).texi
+
diff --git a/python/convertrules.py b/python/convertrules.py
index a2ac08534b..165e0a52d8 100644
--- a/python/convertrules.py
+++ b/python/convertrules.py
@@ -2885,3 +2885,20 @@ def conv (str):
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"""))
+
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index 96a444d78e..7ae1a0e4fe 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -25,7 +25,7 @@
(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.")
@@ -98,10 +98,6 @@ tuplet bracket.")
#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
@@ -304,6 +300,7 @@ with a negative penalty.")
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
@@ -317,6 +314,7 @@ quicker the slur attains it @code{height-limit}.")
(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
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 1b0ec25293..ef150b8f48 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -22,11 +22,24 @@
(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
. (
@@ -36,13 +49,13 @@
,(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
@@ -104,8 +117,9 @@
(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)
@@ -1868,6 +1882,7 @@
(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
@@ -1888,7 +1903,6 @@
note-head-interface
rhythmic-head-interface
font-interface
- accidental-interface
axis-group-interface))))))
(TrillPitchHead