From: hanwen Date: Sun, 16 Oct 2005 12:29:40 +0000 (+0000) Subject: * lily/script-engraver.cc (make_script_from_event): don't trigger callback. X-Git-Tag: release/2.7.16^2~85 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=24825192049074075dee010230a3f2e9bf6a1870;p=lilypond.git * lily/script-engraver.cc (make_script_from_event): don't trigger callback. * lily/item-scheme.cc: new file. * lily/bar-line.cc (before_line_breaking): remove function. remove bar-size-procedure, break-glyph-function * lily/clef-engraver.cc (set_glyph): use glyph iso. glyph-name * lily/clef.cc (before_line_breaking): change to calc_glyph_name. * lily/system-start-delimiter.cc (print): suicide from here. Remove after_line_breaking_callback. * lily/script-interface.cc (calc_direction): use callback for direction. * lily/side-position-interface.cc (aligned_side): don't use Side_position_interface::get_direction directly. Use callback. * scm/define-grobs.scm: change print-function to stencil callback everywhere. * scm/define-grob-properties.scm (all-user-grob-properties): doc callbacks property. --- diff --git a/ChangeLog b/ChangeLog index 778d637a63..76f752a461 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,24 @@ 2005-10-16 Han-Wen Nienhuys + * lily/script-engraver.cc (make_script_from_event): don't trigger callback. + + * lily/item-scheme.cc: new file. + + * lily/bar-line.cc (before_line_breaking): remove function. + remove bar-size-procedure, break-glyph-function + + * lily/clef-engraver.cc (set_glyph): use glyph iso. glyph-name + + * lily/clef.cc (before_line_breaking): change to calc_glyph_name. + + * lily/system-start-delimiter.cc (print): suicide from + here. Remove after_line_breaking_callback. + + * lily/script-interface.cc (calc_direction): use callback for direction. + + * lily/side-position-interface.cc (aligned_side): don't use + Side_position_interface::get_direction directly. Use callback. + * lily/grob.cc (get_stencil): simplify: use callback mechanism to calculate stencil. (get_print_stencil): rename from get_stencil: create stencil with diff --git a/input/regression/span-bar.ly b/input/regression/span-bar.ly index 856ce1c234..ed52f420c5 100644 --- a/input/regression/span-bar.ly +++ b/input/regression/span-bar.ly @@ -18,11 +18,12 @@ between systems. \relative c' \new StaffGroup << \new Staff { - \override Score.BarLine #'transparent = ##t - a1 a1 - \revert Score.BarLine #'transparent - \override Score.SpanBar #'transparent = ##t + a1 + \once \override Score.BarLine #'transparent = ##t + a1 + \once \override Score.SpanBar #'transparent = ##t a1 a1 + \bar "|." } \lyricmode << \new Lyrics { bla1 die bla } diff --git a/lily/accidental.cc b/lily/accidental.cc index 2ce795ef0c..3ee074a818 100644 --- a/lily/accidental.cc +++ b/lily/accidental.cc @@ -36,6 +36,9 @@ parenthesize (Grob *me, Stencil m) return m; } +/* + Hmm. Need separate callback, or perhaps #'live bool property. + */ MAKE_SCHEME_CALLBACK (Accidental_interface, after_line_breaking, 1); SCM Accidental_interface::after_line_breaking (SCM smob) diff --git a/lily/bar-line.cc b/lily/bar-line.cc index ab18eb0fcb..4a9047929f 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -21,13 +21,13 @@ Bar_line::print (SCM smob) { Grob *me = unsmob_grob (smob); - SCM s = me->get_property ("glyph"); - SCM barsiz_proc = me->get_property ("bar-size-procedure"); - if (scm_is_string (s) && ly_is_procedure (barsiz_proc)) + SCM s = me->get_property ("glyph-name"); + SCM barsize = me->get_property ("bar-size"); + + if (scm_is_string (s) && scm_is_number (barsize)) { String str = ly_scm2string (s); - SCM siz = scm_call_1 (barsiz_proc, me->self_scm ()); - Real sz = robust_scm2double (siz, 0); + Real sz = robust_scm2double (barsize, 0); if (sz <= 0) return SCM_EOL; @@ -149,45 +149,14 @@ Bar_line::simple_barline (Grob *me, Interval (-h / 2, h / 2)), blot); } -MAKE_SCHEME_CALLBACK (Bar_line, before_line_breaking, 1); +MAKE_SCHEME_CALLBACK (Bar_line, calc_bar_size, 1); SCM -Bar_line::before_line_breaking (SCM smob) -{ - Grob *me = unsmob_grob (smob); - Item *item = dynamic_cast (me); - - SCM g = me->get_property ("glyph"); - SCM orig = g; - Direction bsd = item->break_status_dir (); - if (scm_is_string (g) && bsd) - { - SCM proc = me->get_property ("break-glyph-function"); - g = scm_call_2 (proc, g, scm_from_int (bsd)); - } - - if (!scm_is_string (g)) - { - me->set_property ("print-function", SCM_EOL); - me->set_extent (SCM_EOL, X_AXIS); - // leave y_extent for spanbar? - } - - if (!ly_is_equal (g, orig)) - me->set_property ("glyph", g); - - return SCM_UNSPECIFIED; -} - -MAKE_SCHEME_CALLBACK (Bar_line, get_staff_bar_size, 1); -SCM -Bar_line::get_staff_bar_size (SCM smob) +Bar_line::calc_bar_size (SCM smob) { Grob *me = unsmob_grob (smob); Real ss = Staff_symbol_referencer::staff_space (me); - SCM size = me->get_property ("bar-size"); - if (scm_is_number (size)) - return scm_from_double (scm_to_double (size) * ss); - else if (Staff_symbol_referencer::get_staff_symbol (me)) + + if (Staff_symbol_referencer::get_staff_symbol (me)) { /* If there is no staff-symbol, we get -1 from the next @@ -201,6 +170,7 @@ Bar_line::get_staff_bar_size (SCM smob) return scm_from_int (0); } + ADD_INTERFACE (Bar_line, "bar-line-interface", @@ -221,11 +191,10 @@ ADD_INTERFACE (Bar_line, /* properties */ - "bar-size-procedure " "kern " "thin-kern " "hair-thickness " "thick-thickness " "glyph " "bar-size " - "break-glyph-function"); + ); diff --git a/lily/chord-name.cc b/lily/chord-name.cc index ffcfbd71e1..ded20d4d2e 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -34,4 +34,6 @@ Chord_name::after_line_breaking (SCM smob) ADD_INTERFACE (Chord_name, "chord-name-interface", "A chord name.", + + "begin-of-line-visible"); diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index c0fb2fe4b1..f72a38bcd1 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -68,7 +68,7 @@ Clef_engraver::Clef_engraver () void Clef_engraver::set_glyph () { - SCM glyph_sym = ly_symbol2scm ("glyph-name"); + SCM glyph_sym = ly_symbol2scm ("glyph"); SCM glyph = get_property ("clefGlyph"); SCM basic = ly_symbol2scm ("Clef"); diff --git a/lily/clef.cc b/lily/clef.cc index 4007d93e9f..6743bd4e3b 100644 --- a/lily/clef.cc +++ b/lily/clef.cc @@ -13,19 +13,14 @@ #include "item.hh" #include "font-interface.hh" -/* - FIXME: should use symbol for #'style. -*/ -MAKE_SCHEME_CALLBACK (Clef, before_line_breaking, 1); +MAKE_SCHEME_CALLBACK (Clef, calc_glyph_name, 1); SCM -Clef::before_line_breaking (SCM smob) +Clef::calc_glyph_name (SCM smob) { Item *s = unsmob_item (smob); - SCM glyph = s->get_property ("glyph-name"); + SCM glyph = s->get_property ("glyph"); - if (!scm_is_string (glyph)) - s->suicide (); - else + if (scm_is_string (glyph)) { String str = ly_scm2string (glyph); @@ -34,10 +29,12 @@ Clef::before_line_breaking (SCM smob) && !to_boolean (s->get_property ("full-size-change"))) { str += "_change"; - s->set_property ("glyph-name", scm_makfrom0str (str.to_str0 ())); } + + return scm_makfrom0str (str.to_str0 ()); } + s->suicide (); return SCM_UNSPECIFIED; } @@ -60,5 +57,11 @@ Clef::print (SCM smob) ADD_INTERFACE (Clef, "clef-interface", "A clef sign", - "non-default full-size-change glyph-name"); + + /* properties */ + "full-size-change " + "glyph " + "glyph-name " + "non-default " + ); diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index 059c72190d..4e785658b7 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -134,6 +134,7 @@ Drum_notes_engraver::acknowledge_stem (Grob_info inf) Side_position_interface::add_support (e, inf.grob ()); } } + void Drum_notes_engraver::acknowledge_note_column (Grob_info inf) { diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index 972fd0bfc7..bc561caf96 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -220,25 +220,6 @@ LY_DEFINE (ly_spanner_p, "ly:spanner?", return ly_bool2scm (b); } -LY_DEFINE (ly_item_p, "ly:item?", - 1, 0, 0, (SCM g), - "Is @var{g} an @code{Item} object?") -{ - Grob *me = unsmob_grob (g); - bool b = dynamic_cast (me); - return ly_bool2scm (b); -} - -LY_DEFINE (ly_item_break_dir, "ly:item-break-dir", - 1, 0, 0, (SCM it), - "The break status dir of item @var{it}. @code{-1} is end of " - "line, @code{0} unbroken, and @code{1} begin of line.") -{ - Item *me = dynamic_cast (unsmob_grob (it)); - SCM_ASSERT_TYPE (me, it, SCM_ARG1, __FUNCTION__, "Item"); - return scm_from_int (me->break_status_dir ()); -} - LY_DEFINE (ly_grob_key, "ly:grob-key", 1, 0, 0, (SCM grob), diff --git a/lily/include/bar-line.hh b/lily/include/bar-line.hh index fc613da48b..fdd7c17e0d 100644 --- a/lily/include/bar-line.hh +++ b/lily/include/bar-line.hh @@ -20,9 +20,8 @@ public: static Stencil compound_barline (Grob *, String, Real height, bool rounded); static Stencil simple_barline (Grob *, Real wid, Real height, bool rounded); - DECLARE_SCHEME_CALLBACK (get_staff_bar_size, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_bar_size, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); }; #endif // BAR_HH diff --git a/lily/include/clef.hh b/lily/include/clef.hh index 1f3146aea9..8194194b12 100644 --- a/lily/include/clef.hh +++ b/lily/include/clef.hh @@ -14,7 +14,7 @@ struct Clef { - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_glyph_name, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); static bool has_interface (Grob *); }; diff --git a/lily/include/script-interface.hh b/lily/include/script-interface.hh index 74efaaf06c..8591ce0b47 100644 --- a/lily/include/script-interface.hh +++ b/lily/include/script-interface.hh @@ -23,7 +23,7 @@ public: static Stencil get_stencil (Grob *, Direction d); static bool has_interface (Grob *); DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); }; void make_script_from_event (Grob *p, bool *follow, Context *tg, diff --git a/lily/include/span-bar.hh b/lily/include/span-bar.hh index 7154f30365..6995a2da4d 100644 --- a/lily/include/span-bar.hh +++ b/lily/include/span-bar.hh @@ -25,10 +25,10 @@ public: static Interval get_spanned_interval (Grob *); static void add_bar (Grob *, Grob *); static void evaluate_glyph (Grob *); - static void evaluate_empty (Grob *); DECLARE_SCHEME_CALLBACK (width_callback, (SCM smob, SCM axis)); - DECLARE_SCHEME_CALLBACK (get_bar_size, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_bar_size, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_glyph_name, (SCM)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); DECLARE_SCHEME_CALLBACK (center_on_spanned_callback, (SCM element, SCM axis)); }; diff --git a/lily/include/system-start-delimiter.hh b/lily/include/system-start-delimiter.hh index 44906c9a1e..096bfa7673 100644 --- a/lily/include/system-start-delimiter.hh +++ b/lily/include/system-start-delimiter.hh @@ -21,7 +21,6 @@ public: DECLARE_SCHEME_CALLBACK (print, (SCM)); static bool has_interface (Grob *); - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); static void try_collapse (Grob *); static Stencil staff_bracket (Grob *, Real); static Stencil old_staff_bracket (Grob *, Real); diff --git a/lily/item-scheme.cc b/lily/item-scheme.cc new file mode 100644 index 0000000000..46a5633a58 --- /dev/null +++ b/lily/item-scheme.cc @@ -0,0 +1,30 @@ +/* + item-scheme.cc -- implement Item bindings. + + source file of the GNU LilyPond music typesetter + + (c) 2005 Han-Wen Nienhuys + +*/ + +#include "item.hh" + + +LY_DEFINE (ly_item_p, "ly:item?", + 1, 0, 0, (SCM g), + "Is @var{g} an @code{Item} object?") +{ + Grob *me = unsmob_grob (g); + bool b = dynamic_cast (me); + return ly_bool2scm (b); +} + +LY_DEFINE (ly_item_break_dir, "ly:item-break-dir", + 1, 0, 0, (SCM it), + "The break status dir of item @var{it}. @code{-1} is end of " + "line, @code{0} unbroken, and @code{1} begin of line.") +{ + Item *me = dynamic_cast (unsmob_grob (it)); + SCM_ASSERT_TYPE (me, it, SCM_ARG1, __FUNCTION__, "Item"); + return scm_from_int (me->break_status_dir ()); +} diff --git a/lily/script-column.cc b/lily/script-column.cc index 2fc7f2f158..7d72ffc5bb 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -8,6 +8,7 @@ #include "script-column.hh" +#include "directional-element-interface.hh" #include "side-position-interface.hh" #include "warn.hh" #include "pointer-group-interface.hh" @@ -59,13 +60,7 @@ Script_column::before_line_breaking (SCM smob) for (int i = 0; i < staff_sided.size (); i++) { Grob *g = staff_sided[i]; - Direction d = Side_position_interface::get_direction (g); - if (!d) - { - programming_error ("no direction for script"); - d = DOWN; - g->set_property ("direction", scm_from_int (d)); - } + Direction d = get_grob_direction (g); scripts_drul[d] = scm_cons (g->self_scm (), scripts_drul[d]); } diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index 09eef7460c..fdacff1079 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -135,7 +135,7 @@ void make_script_from_event (Grob *p, bool *follow, Context *tg, val = scm_from_int (prio); } - if (p->internal_get_property (sym) == SCM_EOL) + if (p->get_property_data (sym) == SCM_EOL) p->internal_set_property (sym, val); } @@ -153,17 +153,17 @@ Script_engraver::process_music () { for (int i = 0; i < scripts_.size (); i++) { - Music *m = scripts_[i].event_; + Music *music = scripts_[i].event_; - Grob *p = make_item ("Script", m->self_scm ()); + Grob *p = make_item ("Script", music->self_scm ()); make_script_from_event (p, &scripts_[i].follow_into_staff_, context (), - m->get_property ("articulation-type"), + music->get_property ("articulation-type"), i); scripts_[i].script_ = p; - SCM force_dir = m->get_property ("direction"); + SCM force_dir = music->get_property("direction"); if (is_direction (force_dir) && to_dir (force_dir)) p->set_property ("direction", force_dir); } diff --git a/lily/script-interface.cc b/lily/script-interface.cc index 6aa4c53884..015598b317 100644 --- a/lily/script-interface.cc +++ b/lily/script-interface.cc @@ -41,15 +41,11 @@ Script_interface::get_stencil (Grob *me, Direction d) return Stencil (); } -/* -todo: use proper callbacks. -*/ -MAKE_SCHEME_CALLBACK (Script_interface, before_line_breaking, 1); +MAKE_SCHEME_CALLBACK (Script_interface, calc_direction, 1); SCM -Script_interface::before_line_breaking (SCM smob) +Script_interface::calc_direction (SCM smob) { Grob *me = unsmob_grob (smob); - Direction d = Side_position_interface::get_direction (me); if (!d) @@ -58,15 +54,14 @@ Script_interface::before_line_breaking (SCM smob) d = DOWN; } - set_grob_direction (me, d); - if (Grob *par = me->get_parent (X_AXIS)) { Grob *stem = Note_column::get_stem (par); if (stem && Stem::first_head (stem)) me->set_parent (Stem::first_head (stem), X_AXIS); } - return SCM_UNSPECIFIED; + + return scm_from_int (d); } MAKE_SCHEME_CALLBACK (Script_interface, print, 1); @@ -76,12 +71,8 @@ Script_interface::print (SCM smob) { Grob *me = unsmob_grob (smob); - Direction dir = Side_position_interface::get_direction (me); - if (!dir) - { - programming_error ("script direction unknown, but stencil wanted"); - dir = DOWN; - } + Direction dir = get_grob_direction (me); + return get_stencil (me, dir).smobbed_copy (); } diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index 05539cd1e3..3546bc2b76 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -31,10 +31,6 @@ Side_position_interface::add_support (Grob *me, Grob *e) Direction Side_position_interface::get_direction (Grob *me) { - SCM d = me->get_property ("direction"); - if (is_direction (d) && to_dir (d)) - return to_dir (d); - Direction relative_dir = Direction (1); SCM reldir = me->get_property ("side-relative-direction"); // should use a lambda. if (is_direction (reldir)) @@ -96,7 +92,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten if (dim.is_empty ()) dim = Interval (0, 0); - Direction dir = Side_position_interface::get_direction (me); + Direction dir = get_grob_direction (me); Real off = me->get_parent (a)->relative_coordinate (common, a); Real minimum_space = ss * robust_scm2double (me->get_property ("minimum-space"), -1); @@ -156,7 +152,7 @@ Side_position_interface::quantised_position (SCM element_smob, SCM) { Grob *me = unsmob_grob (element_smob); - Direction d = Side_position_interface::get_direction (me); + Direction d = get_grob_direction (me); Grob *stsym = Staff_symbol_referencer::get_staff_symbol (me); if (stsym) @@ -193,8 +189,7 @@ Side_position_interface::aligned_side (SCM element_smob, SCM axis) Grob *me = unsmob_grob (element_smob); Axis a = (Axis) scm_to_int (axis); - Direction d = Side_position_interface::get_direction (me); - + Direction d = get_grob_direction (me); Real o = scm_to_double (aligned_on_support_extents (element_smob, axis)); Interval iv = me->extent (me, a); @@ -255,6 +250,8 @@ ADD_INTERFACE (Side_position_interface, "side-position-interface", "victim object relative to the support (left or right, up or down?)\n\n " "The routine also takes the size the staff into account if " "@code{staff-padding} is set. If undefined, the staff symbol is ignored.", + + /* properties */ "direction " "direction-source " "minimum-space " diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 0b018dbce6..4c2fcaba64 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -46,8 +46,7 @@ Span_bar::print (SCM smobbed_me) extract_grob_set (me, "elements", elements); Grob *refp = common_refpoint_of_array (elements, me, Y_AXIS); - Span_bar::evaluate_glyph (me); - SCM glyph = me->get_property ("glyph"); + SCM glyph = me->get_property ("glyph-name"); /* glyph may not be a string, when ME is killed by Hara Kiri in between. */ @@ -116,7 +115,7 @@ Span_bar::width_callback (SCM element_smob, SCM scm_axis) (void) scm_axis; assert ((Axis) scm_to_int (scm_axis) == X_AXIS); - String gl = ly_scm2string (se->get_property ("glyph")); + String gl = ly_scm2string (se->get_property ("glyph-name")); /* urg. @@ -130,13 +129,11 @@ MAKE_SCHEME_CALLBACK (Span_bar, before_line_breaking, 1); SCM Span_bar::before_line_breaking (SCM smob) { - Grob *g = unsmob_grob (smob); - evaluate_empty (g); - evaluate_glyph (g); + Grob *me = unsmob_grob (smob); + extract_grob_set (me, "elements", elements); + if (elements.is_empty ()) + me->suicide (); - /* No need to call Bar_line::before_line_breaking (), because the info - in ELEMENTS already has been procced by - Bar_line::before_line_breaking (). */ return SCM_UNSPECIFIED; } @@ -162,27 +159,15 @@ Span_bar::center_on_spanned_callback (SCM element_smob, SCM axis) return scm_from_double (i.center ()); } -void -Span_bar::evaluate_empty (Grob *me) -{ - /* TODO: filter all hara-kiried out of ELEMENS list, and then - optionally do suicide. Call this cleanage function from - center_on_spanned_callback () as well. */ - extract_grob_set (me, "elements", elements); - if (elements.is_empty ()) - me->suicide (); -} -void -Span_bar::evaluate_glyph (Grob *me) +MAKE_SCHEME_CALLBACK(Span_bar, calc_glyph_name, 1); +SCM +Span_bar::calc_glyph_name (SCM smob) { - SCM gl = me->get_property ("glyph"); - - if (scm_is_string (gl)) - return; - + Grob *me = unsmob_grob (smob); extract_grob_set (me, "elements", elements); + SCM gl = SCM_EOL; for (int i = elements.size (); i-- && !scm_is_string (gl);) gl = elements[i]->get_property ("glyph"); @@ -190,7 +175,7 @@ Span_bar::evaluate_glyph (Grob *me) if (!scm_is_string (gl)) { me->suicide (); - return; + return SCM_UNSPECIFIED; } String type = ly_scm2string (gl); @@ -201,10 +186,7 @@ Span_bar::evaluate_glyph (Grob *me) else if (type == ":|:") type = ".|."; - gl = scm_makfrom0str (type.to_str0 ()); - if (scm_equal_p (me->get_property ("glyph"), gl) - != SCM_BOOL_T) - me->set_property ("glyph", gl); + return scm_makfrom0str (type.to_str0 ()); } Interval @@ -214,9 +196,9 @@ Span_bar::get_spanned_interval (Grob *me) (me->self_scm (), scm_from_int (Y_AXIS))); } -MAKE_SCHEME_CALLBACK (Span_bar, get_bar_size, 1); +MAKE_SCHEME_CALLBACK (Span_bar, calc_bar_size, 1); SCM -Span_bar::get_bar_size (SCM smob) +Span_bar::calc_bar_size (SCM smob) { Grob *me = unsmob_grob (smob); Interval iv (get_spanned_interval (me)); @@ -232,5 +214,8 @@ Span_bar::get_bar_size (SCM smob) ADD_INTERFACE (Span_bar, "span-bar-interface", "A bar line that spanned between other barlines. This interface is " " used for bar lines that connect different staves.", + + /* properties */ + "glyph-name " "elements"); diff --git a/lily/staff-spacing.cc b/lily/staff-spacing.cc index 48e0c09f6b..a862a16f11 100644 --- a/lily/staff-spacing.cc +++ b/lily/staff-spacing.cc @@ -98,15 +98,15 @@ Staff_spacing::bar_y_positions (Grob *bar_grob) bar_size.set_empty (); if (Bar_line::has_interface (bar_grob)) { - SCM glyph = bar_grob->get_property ("glyph"); + SCM glyph = bar_grob->get_property ("glyph-name"); + Grob *staff_sym = Staff_symbol_referencer::get_staff_symbol (bar_grob); String glyph_string = scm_is_string (glyph) ? ly_scm2string (glyph) : ""; if (glyph_string.left_string (1) == "|" || glyph_string.left_string (1) == ".") { - SCM sz = Bar_line::get_staff_bar_size (bar_grob->self_scm ()); - bar_size = Interval (-1, 1); - bar_size *= robust_scm2double (sz, 1) - / Staff_symbol_referencer::staff_space (bar_grob); + Grob *common = bar_grob->common_refpoint (staff_sym, Y_AXIS); + Interval bar_size = bar_grob->extent (common, Y_AXIS); + bar_size *= 1.0 / Staff_symbol_referencer::staff_space (bar_grob); } } return bar_size; diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index c4aee8a7e1..8662b45b5b 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -53,44 +53,6 @@ System_start_delimiter::simple_bar (Grob *me, Real h) lt); } -MAKE_SCHEME_CALLBACK (System_start_delimiter, after_line_breaking, 1); - -SCM -System_start_delimiter::after_line_breaking (SCM smob) -{ - Spanner *me = dynamic_cast (unsmob_grob (smob)); - - SCM gl = me->get_property ("glyph"); - if (ly_is_equal (gl, scm_makfrom0str ("bar-line"))) - { - int count = 0; - Paper_column *left_column = me->get_bound (LEFT)->get_column (); - - /* - Get all coordinates, to trigger Hara kiri. - */ - extract_grob_set (me, "elements", elts); - Grob *common = common_refpoint_of_array (elts, me, Y_AXIS); - - for (int i = elts.size (); i--;) - { - Spanner *staff = dynamic_cast (elts[i]); - if (!staff - || staff->get_bound (LEFT)->get_column () != left_column) - continue; - - Interval v = staff->extent (common, Y_AXIS); - - if (!v.is_empty ()) - count++; - } - - if (count <= 1) - me->suicide (); - } - return SCM_UNSPECIFIED; -} - MAKE_SCHEME_CALLBACK (System_start_delimiter, print, 1); SCM System_start_delimiter::print (SCM smob) @@ -111,18 +73,30 @@ System_start_delimiter::print (SCM smob) Interval ext; + int non_empty_count = 0; for (int i = elts.size (); i--;) { Spanner *sp = dynamic_cast (elts[i]); + if (sp && sp->get_bound (LEFT) == me->get_bound (LEFT)) { Interval dims = sp->extent (common, Y_AXIS); if (!dims.is_empty ()) - ext.unite (dims); + { + non_empty_count ++; + ext.unite (dims); + } } } + if (gsym == ly_symbol2scm ("bar-line") + && non_empty_count <= 1) + { + me->suicide (); + return SCM_EOL; + } + ext -= me->relative_coordinate (common, Y_AXIS); Real len = ext.length () / staff_space; diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 508e8578b3..b80e958b39 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -61,7 +61,6 @@ original stencil drawer to draw the balloon around.") (bar-size ,ly:dimension? "size of a bar line.") - (bar-size-procedure ,procedure? "Procedure that computes the size of a bar line.") (barre-type ,symbol? "Type of barre indication used in a fret diagram. Choices include @code{curved} and @code{straight}.") (base-shortest-duration ,ly:moment? @@ -109,9 +108,6 @@ For example, clefs are put after key signatures by setting clef time-signature)) @end example") - (break-glyph-function ,procedure? "This function determines the -appearance of a bar line at the line break. It takes a glyph and -break-direction and returns the glyph at a line break.") (break-overshoot ,number-pair? "How much does a broken spanner stick out of its bounds?") (bracket-visibility ,boolean-or-symbol? "This controls the @@ -260,7 +256,6 @@ stem. The stem will stop at the innermost beams.") (glyph ,string? "a string determining what (style) of glyph is typeset. Valid choices depend on the function that is reading this property.") - (glyph-name ,string? "a name of character within font.") (glyph-name-procedure ,procedure? "Return the name of a character within font, to use for printing a symbol.") @@ -536,6 +531,7 @@ function is to protect objects from being garbage collected.") set, which grob to get the direction from .") (dot ,ly:grob? "reference to Dots object.") (figures ,ly:grob-array? "Figured bass objects for continuation line.") + (glyph-name ,string? "a name of character within font.") (pedal-text ,ly:grob? "Pointer to the text of a mixed-style piano pedal.") (stem ,ly:grob? "pointer to Stem object.") (tremolo-flag ,ly:grob? "The tremolo object on a stem.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 46c531d868..d16e1c4b9a 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -139,13 +139,13 @@ . ( (break-align-symbol . staff-bar) (glyph . "|") - (break-glyph-function . ,default-break-barline) (layer . 0) - (bar-size-procedure . ,Bar_line::get_staff_bar_size) (break-visibility . ,all-visible) (breakable . #t) (callbacks . ((stencil . ,Bar_line::print) - (before-line-breaking . ,Bar_line::before_line_breaking))) + (glyph-name . ,bar-line::calc-glyph-name) + (bar-size . ,Bar_line::calc_bar_size) + )) (space-alist . ( (time-signature . (extra-space . 0.75)) (custos . (minimum-space . 2.0)) @@ -379,7 +379,7 @@ (Clef . ( (callbacks . ((stencil . ,Clef::print) - (before-line-breaking . ,Clef::before_line_breaking) + (glyph-name . ,Clef::calc_glyph_name) )) (breakable . #t) (font-family . music) @@ -547,7 +547,7 @@ ;; todo. (callbacks . ((stencil . ,Text_interface::print) - (before-line-breaking . ,Script_interface::before_line_breaking))) + (direction . ,Script_interface::calc_direction))) (X-offset-callbacks . (,Self_alignment_interface::aligned_on_self)) (self-alignment-X . 0) (Y-offset-callbacks . (,Self_alignment_interface::aligned_on_self)) @@ -597,7 +597,7 @@ (self-alignment-Y . 0) (script-priority . 100) (callbacks . ((stencil . ,Text_interface::print) - (before-line-breaking . ,Script_interface::before_line_breaking))) + (direction . ,Script_interface::calc_direction))) (font-encoding . fetaNumber) (font-size . -5) ; don't overlap when next to heads. (meta . ((class . Item) @@ -1202,7 +1202,7 @@ ;; (script-priority . 0) priorities for scripts, see script.scm (X-offset-callbacks . (,Self_alignment_interface::centered_on_parent)) (callbacks . ((stencil . ,Script_interface::print) - (before-line-breaking . ,Script_interface::before_line_breaking))) + (direction . ,Script_interface::calc_direction))) (font-encoding . fetaMusic) (meta . ((class . Item) (interfaces . (script-interface @@ -1261,12 +1261,13 @@ (SpanBar . ( (break-align-symbol . staff-bar) - (bar-size-procedure . ,Span_bar::get_bar_size) (X-extent-callback . ,Span_bar::width_callback) (Y-extent-callback . ()) (layer . 0) (breakable . #t) (callbacks . ((stencil . ,Span_bar::print) + (bar-size . ,Span_bar::calc_bar_size) + (glyph-name . ,Span_bar::calc_glyph_name) (before-line-breaking . ,Span_bar::before_line_breaking))) ;; ugh duplication! @@ -1487,8 +1488,7 @@ (glyph . "bar-line") (thickness . 1.6) (callbacks . ((stencil . ,System_start_delimiter::print) - (after-line-breaking . ,System_start_delimiter::after_line_breaking))) - + )) (meta . ((class . Spanner) (interfaces . (system-start-delimiter-interface)))))) @@ -1517,7 +1517,7 @@ (padding . 0.5) (staff-padding . 0.5) (callbacks . ((stencil . ,Text_interface::print) - (before-line-breaking . ,Script_interface::before_line_breaking))) + (direction . ,Script_interface::calc_direction))) (avoid-slur . around) (slur-padding . 0.5) (script-priority . 200) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 96cc55cdd6..2546012680 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -194,8 +194,11 @@ centered, X==1 is at the right, X == -1 is at the left." ;; How should a bar line behave at a break? ;; ;; Why prepend `default-' to every scm identifier? -(define-public (default-break-barline glyph dir) - (let ((result (assoc glyph +(define-public (bar-line::calc-glyph-name grob) + (let* ( + (glyph (ly:grob-property grob 'glyph)) + (dir (ly:item-break-dir grob)) + (result (assoc glyph '((":|:" . (":|" . "|:")) ("||:" . ("||" . "|:")) ("|" . ("|" . ())) @@ -213,11 +216,18 @@ centered, X==1 is at the right, X == -1 is at the left." (":" . (":" . "")) ("empty" . (() . ())) ("brace" . (() . "brace")) - ("bracket" . (() . "bracket")) )))) + ("bracket" . (() . "bracket")) ))) + (glyph-name (if (= dir CENTER) + glyph + (if (and result (string? (index-cell (cdr result) dir))) + (index-cell (cdr result) dir) + #f))) + ) + + (if glyph-name + (set! (ly:grob-property grob 'glyph-name) glyph-name) + (ly:grob-suicide! grob)))) - (if (equal? result #f) - (ly:warning (_ "unknown bar glyph: `~S'" glyph)) - (index-cell (cdr result) dir)))) (define-public (shift-right-at-line-begin g) "Shift an item to the right, but only at the start of the line." diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index 3ab99b4988..cfa6cb4031 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -150,7 +150,6 @@ Arpeggio::brew_chord_bracket Arpeggio::width_callback Axis_group_interface::group_extent_callback - Bar_line::get_staff_bar_size Bar_line::print Breathing_sign::offset_callback Clef::print @@ -195,7 +194,6 @@ Slur::height Slur::print Spacing_spanner::set_springs - Span_bar::get_bar_size Span_bar::print Span_bar::width_callback Spanner::set_spacing_rods