From: fred Date: Wed, 27 Mar 2002 00:33:48 +0000 (+0000) Subject: lilypond-1.3.112 X-Git-Tag: release/1.5.59~1083 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=469bf9896de69497cf0fd77ec947d02ae3ea4d18;p=lilypond.git lilypond-1.3.112 --- diff --git a/input/test/broken-thread-line.ly b/input/test/broken-thread-line.ly new file mode 100644 index 0000000000..6c765fe44b --- /dev/null +++ b/input/test/broken-thread-line.ly @@ -0,0 +1,23 @@ + + +% followThread: connect note heads with line when thread switches staff + +\score{ + \context PianoStaff < + \context Staff=one \notes\relative c''{ + \context Thread + a1 \break + \translator Staff=two + a, + + } + \context Staff=two { \clef bass; \skip 1*2; } + > + \paper{ + linewidth = 70.\mm; + \translator { + \ScoreContext + followThread = ##t + } + } +} diff --git a/lily/grob.cc b/lily/grob.cc index 3cf09fcc4a..fdfb97c069 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -77,7 +77,7 @@ Grob::Grob(SCM basicprops) /* Should change default to be empty? */ - if (!gh_procedure_p (cb) && !gh_pair_p (cb)) + if (cb != SCM_BOOL_F && !gh_procedure_p (cb) && !gh_pair_p (cb)) cb = molecule_extent_proc; dim_cache_[a].dimension_ = cb; diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc new file mode 100644 index 0000000000..bece984882 --- /dev/null +++ b/lily/line-spanner.cc @@ -0,0 +1,137 @@ +/* + line-spanner.cc -- implement Line_spanner + + source file of the GNU LilyPond music typesetter + + (c) 2000 Jan Nieuwenhuizen +*/ + +#include "molecule.hh" +#include "item.hh" +#include "spanner.hh" +#include "line-spanner.hh" +#include "paper-def.hh" +#include "paper-column.hh" +#include "staff-symbol-referencer.hh" + +SCM +Line_spanner::line_atom (Grob* me, Real dx, Real dy) +{ + SCM list = SCM_EOL; + SCM type = me->get_grob_property ("type"); + if (gh_symbol_p (type) + && (type == ly_symbol2scm ("line") + || type == ly_symbol2scm ("dashed-line") + || type == ly_symbol2scm ("dotted-line"))) + { + Real staff_space = Staff_symbol_referencer::staff_space (me); + Real thick = me->paper_l ()->get_var ("stafflinethickness"); + + SCM s = me->get_grob_property ("line-thickness"); + if (gh_number_p (s)) + thick *= gh_scm2double (s); + + // maybe these should be in line-thickness? + Real length = staff_space; + s = me->get_grob_property ("dash-length"); + if (gh_number_p (s)) + length = gh_scm2double (s) * staff_space; + + Real period = 2 * length + thick; + s = me->get_grob_property ("dash-period"); + if (gh_number_p (s)) + period = gh_scm2double (s) * staff_space; + + if (type == ly_symbol2scm ("dotted-line")) + length = thick; + + if (type == ly_symbol2scm ("line")) + length = period + thick; + + Real on = length - thick; + Real off = period - on; + + list = gh_list (ly_symbol2scm ("dashed-line"), + gh_double2scm (thick), + gh_double2scm (on), + gh_double2scm (off), + gh_double2scm (dx), + gh_double2scm (dy), + SCM_UNDEFINED); + } + return list; +} + + + +/* + Warning: this thing is a cross-staff object, so it should have empty Y-dimensions. + + (If not, you risk that this is called from the staff-alignment + routine, via molecule_extent. At this point, the staffs aren't + separated yet, so it doesn't work cross-staff. + +*/ + +MAKE_SCHEME_CALLBACK (Line_spanner, brew_molecule, 1); +SCM +Line_spanner::brew_molecule (SCM smob) +{ + Grob *me= unsmob_grob (smob); + Spanner *spanner = dynamic_cast (me); + + Grob *common[] = { 0, 0 }; + + Item *l = spanner->get_bound (LEFT); + Item *r = spanner->get_bound (RIGHT); + + /* + FIXME: should also do something sensible across line breaks. + */ + if (l->break_status_dir () || r->break_status_dir ()) + return SCM_EOL; + + for (Axis a = X_AXIS; a < NO_AXES; a = Axis (a + 1)) + { + common[a] = l->common_refpoint (r, a); + + if (!common[a]) + return SCM_EOL; + } + + Offset dxy ; + for (Axis a = X_AXIS; a < NO_AXES; a = Axis (a + 1)) + { + dxy[a] = r->extent (common[a], a)[LEFT] - + l->extent (common[a], a)[RIGHT]; + } + + Molecule line; + Real gap = gh_scm2double (me->get_grob_property ("gap")); + + Offset my_off(me->relative_coordinate (common[X_AXIS], X_AXIS), + me->relative_coordinate (common[Y_AXIS], Y_AXIS) ); + + Offset his_off(l->relative_coordinate (common[X_AXIS], X_AXIS), + l->relative_coordinate (common[Y_AXIS], Y_AXIS) ); + + dxy *= (dxy.length () - 2 * gap) / dxy.length (); + + SCM list = Line_spanner::line_atom (me, dxy[X_AXIS], dxy[Y_AXIS]); + + if (list == SCM_EOL) + return SCM_EOL; + + Box b (Interval (0, dxy[X_AXIS]), Interval (0, dxy[Y_AXIS])); + + line = Molecule (b, list); + line.translate_axis (l->extent (l, X_AXIS).length (), X_AXIS); + + + Offset g = dxy * (gap / dxy.length ()); + line.translate (g - my_off + his_off); + + return line.smobbed_copy (); +} + + diff --git a/scm/element-descriptions.scm b/scm/element-descriptions.scm index 97c1fac4b0..5ab89e84df 100644 --- a/scm/element-descriptions.scm +++ b/scm/element-descriptions.scm @@ -4,6 +4,7 @@ (define all-element-descriptions `((Arpeggio . ( (X-extent-callback . ,Arpeggio::width_callback) + (Y-extent-callback . #f) (molecule-callback . ,Arpeggio::brew_molecule) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (X-offset-callbacks . (,Side_position::aligned_side)) @@ -286,6 +287,15 @@ rhythmic-head-interface font-interface note-head-interface )) )) + (NoteHeadLine . ( + (type . line) + (gap . 0.5) + (X-extent-callback . #f) + (Y-extent-callback . #f) + (molecule-callback . ,Line_spanner::brew_molecule) + (meta . ,(element-description "NoteHeadLine" + line-spanner-interface)) + )) (NoteName . ( (molecule-callback . ,Text_item::brew_molecule) @@ -357,7 +367,6 @@ (meta . ,(element-description "SpacingSpanner" spacing-spanner-interface)) )) (SpanBar . ( - (break-align-symbol . Staff_bar) (barsize-procedure . ,Span_bar::get_bar_size) (molecule-callback . ,Bar::brew_molecule) @@ -455,6 +464,7 @@ (meta . ,(element-description "SustainPedal" sustain-pedal-interface side-position-interface font-interface)) )) + ; should split in 3 (SystemStartDelimiter . ( (molecule-callback . ,System_start_delimiter::brew_molecule) (after-line-breaking-callback . ,System_start_delimiter::after_line_breaking) diff --git a/scm/interface.scm b/scm/interface.scm index a989bdbef8..f8e19e52ce 100644 --- a/scm/interface.scm +++ b/scm/interface.scm @@ -472,20 +472,29 @@ font-point-size font-relative-size) ))) +(define line-spanner-interface + (lily-interface + 'line-spanner-interface + "Generic line drawn between two objects, eg. for use with glissandi. +gap is relative to the total length of the line. " + + '(gap + dash-period + dash-length + line-thickness + type + ) + )) + (define lyric-hyphen-interface (lily-interface 'lyric-hyphen-interface "A centred hyphen is a simple line between lyrics used to divide syllables. The length of the hyphen line should stretch based on the size of the gap between syllables." - '( - - thickness - height - minimum-length - word-space - ))) + '( thickness height minimum-length word-space ) + )) (define key-signature-interface (lily-interface @@ -534,32 +543,21 @@ numbers, fields from font-interface may be used. padding is the space between number and rest. Measured in staffspace. " - '( - - columns - expand-limit - minimum-width - padding - ))) + '( columns expand-limit minimum-width padding ) + + )) (define paper-column-interface (lily-interface 'paper-column-interface "" - '( - column-space-strength - before-musical-spacing-factor - stem-spacing-correction - before-grace-spacing-factor - when - bounded-by-me - dir-list - shortest-playing-duration - shortest-starter-duration - contains-grace - extra-space - stretch-distance - ))) + + '(column-space-strength before-musical-spacing-factor +stem-spacing-correction before-grace-spacing-factor when bounded-by-me +dir-list shortest-playing-duration shortest-starter-duration +contains-grace extra-space stretch-distance )) + + ) (define spaceable-element-interface (lily-interface