From 85e92541326f7caccb6a2b6e85ea5d6e29a8b1ab Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 29 Sep 2003 22:33:12 +0000 Subject: [PATCH] * lily/slur.cc (get_attachment): do something sensible when attaching to stem without heads (eg. a rest). * lily/stem.cc: remove #'up-to-staff ; use #'stem-end for forcing up to staff. Add #'rests. remove #'support-head property (brew_molecule): small cleanup. (flag): remove #'grace property. --- ChangeLog | 13 +++++- lily/custos.cc | 4 +- lily/slur.cc | 28 +++++++----- lily/stem.cc | 79 ++++++++++------------------------ scm/define-grob-properties.scm | 4 -- scm/define-grobs.scm | 2 - scm/output-lib.scm | 4 +- 7 files changed, 55 insertions(+), 79 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3fad186f00..5e11ed1ec8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-09-30 Han-Wen Nienhuys + + * lily/slur.cc (get_attachment): do something sensible when + attaching to stem without heads (eg. a rest). + + * lily/stem.cc: remove #'up-to-staff ; use #'stem-end for forcing + up to staff. Add #'rests. + remove #'support-head property + (brew_molecule): small cleanup. + (flag): remove #'grace property. + 2003-09-29 Jan Nieuwenhuizen * cygwin/postinstall-lilypond.sh: @@ -38,7 +49,7 @@ * input/regression/bar-scripts.ly (onestaff): raggedright -v/pri2003-09-28 Han-Wen Nienhuys +2003-09-28 Han-Wen Nienhuys * lily/*.cc: remove #if 0'd code in couple of places. diff --git a/lily/custos.cc b/lily/custos.cc index 4471e9042b..ad8d408ea9 100644 --- a/lily/custos.cc +++ b/lily/custos.cc @@ -48,8 +48,8 @@ Custos::brew_molecule (SCM smob) * staffline or not, or shall we use individual font characters * for both cases? */ - bool adjust = - to_boolean (me->get_grob_property ("adjust-if-on-staffline")); + bool adjust + = to_boolean (me->get_grob_property ("adjust-if-on-staffline")); int neutral_pos; SCM ntr_pos = me->get_grob_property ("neutral-position"); diff --git a/lily/slur.cc b/lily/slur.cc index 0d3ce25aa5..c3d7b1e2c1 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -129,7 +129,6 @@ Slur::after_line_breaking (SCM smob) void Slur::check_slope (Grob *me) { - /* Avoid too steep slurs. */ @@ -294,37 +293,44 @@ Slur::get_attachment (Grob *me, Direction dir, s = set_extremities (me); } - SCM a = dir == LEFT ? ly_car (s) : ly_cdr (s); + SCM a = (dir == LEFT) ? ly_car (s) : ly_cdr (s); Spanner*sp = dynamic_cast (me); String str = ly_symbol2string (a); + Real staff_space = Staff_symbol_referencer::staff_space ((Grob*)me); Real hs = staff_space / 2.0; Offset o; - int slurdir = gh_scm2int (me->get_grob_property ("direction")); + Direction slurdir = to_dir (me->get_grob_property ("direction")); Grob *stem = 0; if (Note_column::has_interface (sp->get_bound (dir))) { Grob * n =sp->get_bound (dir); - if ((stem = Note_column::get_stem (n))) + stem = Note_column::get_stem (n); + if (stem) { Real x_extent; - if (Grob *head = Note_column::first_head (n)) + Grob *head = Note_column::first_head (n); + if (head) x_extent = head->extent (head, X_AXIS).length (); else x_extent = n->extent (n, X_AXIS).length (); - if (str == "head") + if (!head) + { + o = Offset (0, n->extent (n, Y_AXIS)[slurdir]); + } + else if (str == "head") { o = Offset (0, Stem::head_positions (stem) - [Directional_element_interface::get (me)] * hs); + [slurdir] * hs); /* Default position is centered in X, on outer side of head Y */ o += Offset (0.5 * x_extent, 0.5 * staff_space - * Directional_element_interface::get (me)); + * slurdir); } else if (str == "alongside-stem") { @@ -334,7 +340,7 @@ Slur::get_attachment (Grob *me, Direction dir, */ o += Offset (x_extent * (1 + Stem::get_direction (stem)), 0.5 * staff_space - * Directional_element_interface::get (me)); + * slurdir); } else if (str == "stem") { @@ -378,7 +384,7 @@ Slur::get_attachment (Grob *me, Direction dir, { Offset off = ly_scm2offset (ly_cdr (l)) * staff_space; off[X_AXIS] *= dir; - off[Y_AXIS] *= Directional_element_interface::get (me); + off[Y_AXIS] *= slurdir; o += off; } @@ -396,7 +402,7 @@ Slur::get_attachment (Grob *me, Direction dir, ("attachment-offset"), dir)) * staff_space; - off[Y_AXIS] *= Directional_element_interface::get (me); + off[Y_AXIS] *= slurdir; o += off; return o; } diff --git a/lily/stem.cc b/lily/stem.cc index 32576c2170..968339aec4 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -130,11 +130,7 @@ Stem::set_stemend (Grob*me, Real se) Grob* Stem::support_head (Grob*me) { - SCM h = me->get_grob_property ("support-head"); - Grob * nh = unsmob_grob (h); - if (nh) - return nh; - else if (head_count (me) == 1) + if (head_count (me) == 1) { /* UGH. @@ -242,6 +238,9 @@ Stem::add_head (Grob*me, Grob *n) n->set_grob_property ("stem", me->self_scm ()); n->add_dependency (me); + /* + TODO: why not store Rest pointers? + */ if (Note_head::has_interface (n)) { Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-heads"), n); @@ -277,19 +276,10 @@ Stem::get_default_dir (Grob*me) Real Stem::get_default_stem_end_position (Grob*me) { - /* Tab notation feature: make stem end extend out of staff. */ - SCM up_to_staff = me->get_grob_property ("up-to-staff"); - if (to_boolean (up_to_staff)) - { - int line_count = Staff_symbol_referencer::line_count (me); - Direction dir = get_direction (me); - return dir * (line_count + 3.5); - } Real ss = Staff_symbol_referencer::staff_space (me); int durlog = duration_log (me); - bool grace_b = to_boolean (me->get_grob_property ("grace")); SCM s; Array a; @@ -387,7 +377,7 @@ Stem::get_default_stem_end_position (Grob*me) TODO: change name to extend-stems to staff/center/'() */ bool no_extend_b = to_boolean (me->get_grob_property ("no-stem-extend")); - if (!grace_b && !no_extend_b && dir * st < 0) // junkme? + if (!no_extend_b && dir * st < 0) // junkme? st = 0.0; /* @@ -708,31 +698,18 @@ Stem::brew_molecule (SCM smob) - Real y1; - - /* - This is required to avoid stems passing in tablature chords... - */ - - /* TODO: make the stem start a direction ? + + This is required to avoid stems passing in tablature chords... */ - if (to_boolean (me->get_grob_property ("avoid-note-head"))) - { - Grob * lh = last_head (me); - if (!lh) - return SCM_EOL; - y1 = Staff_symbol_referencer::get_position (lh); - } - else - { - Grob * lh = first_head (me); - if (!lh) - return SCM_EOL; - y1 = Staff_symbol_referencer::get_position (lh); - } + Grob *lh = to_boolean (me->get_grob_property ("avoid-note-head")) + ? last_head (me) : lh = first_head (me); + + if (!lh) + return SCM_EOL; + Real y1 = Staff_symbol_referencer::get_position (lh); Real y2 = stem_end_position (me); Interval stem_y (y1 ? y1); @@ -858,22 +835,6 @@ Stem::get_stem_info (Grob *me) void Stem::calc_stem_info (Grob *me) { - /* Tab notation feature: make stem end extend out of staff. */ - SCM up_to_staff = me->get_grob_property ("up-to-staff"); - if (to_boolean (up_to_staff)) - { - int line_count = Staff_symbol_referencer::line_count (me); - Direction dir = get_direction (me); - Real ideal_y = dir * (line_count + 1.5); - Real shortest_y = ideal_y; - - me->set_grob_property ("stem-info", - scm_list_n (gh_double2scm (ideal_y), - gh_double2scm (shortest_y), - SCM_UNDEFINED)); - return; - } - Direction my_dir = Directional_element_interface::get (me); Real staff_space = Staff_symbol_referencer::staff_space (me); Grob *beam = get_beam (me); @@ -939,11 +900,9 @@ Stem::calc_stem_info (Grob *me) Obviously not for grace beams. Also, not for knees. Seems to be a good thing. */ - SCM grace = me->get_grob_property ("grace"); - bool grace_b = to_boolean (grace); bool no_extend_b = to_boolean (me->get_grob_property ("no-stem-extend")); bool knee_b = to_boolean (beam->get_grob_property ("knee")); - if (!grace_b && !no_extend_b && !knee_b) + if (!no_extend_b && !knee_b) { /* Highest beam of (UP) beam must never be lower than middle staffline */ @@ -998,7 +957,13 @@ Stem::beam_multiplicity (Grob *stem) these are too many props. */ ADD_INTERFACE (Stem,"stem-interface", - "A stem", - "tremolo-flag french-beaming up-to-staff avoid-note-head adjust-if-on-staffline thickness stem-info beamed-lengths beamed-minimum-free-lengths beamed-extreme-minimum-free-lengths lengths beam stem-shorten duration-log beaming neutral-direction stem-end-position support-head note-heads direction length flag-style no-stem-extend stroke-style"); + "A stem", + "tremolo-flag french-beaming " + "avoid-note-head adjust-if-on-staffline thickness " + "stem-info beamed-lengths beamed-minimum-free-lengths " + "beamed-extreme-minimum-free-lengths lengths beam stem-shorten " + "duration-log beaming neutral-direction stem-end-position " + "note-heads direction length flag-style " + "no-stem-extend stroke-style "); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index e6004e4cf4..978fb0f950 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -434,8 +434,6 @@ the Nth element of the list gives the amount stem shortening of a note with N fl (grob-property-description 'stems grob-list? "list of stem objects, corresponding to the notes that the arpeggio has to be before.") (grob-property-description 'stropha boolean? "is this neume a stropha?.") (grob-property-description 'style symbol? "a string determining what style of glyph is typeset. Valid choices depend on the function that is reading this property. .") -(grob-property-description 'support-head ly:grob? "the note head at -one end of the stem.") (grob-property-description 'text markup? "Text markup. See the notation manual for more information.") (grob-property-description 'thick-thickness number? "thickness, measured in stafflinethickness.") @@ -547,8 +545,6 @@ functions set spanner positions.") (grob-property-description 'avoid-note-head boolean? "if set, the stem of a chord does not pass through all note head, but start at the last note head. Used by tablature.") -(grob-property-description 'up-to-staff boolean? "if set, stems' lengths are set so as stems end out of the staff. Used by tablature.") - (grob-property-description 'use-breve-rest boolean? "boolean that tells multi-measure-rest to use a breve rest to represent the duration of 1 measure instead of whole rest. It defaults to false. It is set diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index be9b6422df..c0e8d887d6 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -966,8 +966,6 @@ (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (adjust-if-on-staffline . #t) (font-family . music) - (avoid-note-head . #f) - (up-to-staff . #f) (meta . ((interfaces . (stem-interface font-interface item-interface )))) )) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index fc9b682897..f47c98bedd 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -133,8 +133,8 @@ (define-public (number-pair->string c) - (string-append (number->string (car c)) " " - (number->string (cdr c)) " ")) + (string-append (ly:number->string (car c)) " " + (ly:number->string (cdr c)) " ")) (define (font i) (string-append -- 2.39.2