From ef75585c081fe2d8da2353c6d816f4765238d348 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 22:44:12 +0000 Subject: [PATCH] lilypond-1.3.11 --- CHANGES | 17 ++ Documentation/programmer/regression-test.tely | 4 +- TODO | 4 +- lily/align-element.cc | 5 +- lily/axis-group-element.cc | 37 +-- lily/axis-group-engraver.cc | 2 +- lily/bar-script-engraver.cc | 2 +- lily/beam-engraver.cc | 3 +- lily/beam.cc | 264 +++++++++--------- lily/bow.cc | 2 +- lily/breathing-sign-engraver.cc | 3 + lily/breathing-sign.cc | 7 +- lily/chord-tremolo-engraver.cc | 12 +- lily/clef-engraver.cc | 12 +- lily/clef-item.cc | 4 +- lily/collision.cc | 2 +- lily/dimension-cache.cc | 17 +- lily/directional-spanner.cc | 10 +- lily/dot-column.cc | 22 +- lily/dots.cc | 6 +- lily/dynamic-engraver.cc | 2 +- lily/grace-position-engraver.cc | 5 +- lily/group-interface.cc | 7 +- lily/include/axis-group-element.hh | 20 -- lily/include/axis-group-item.hh | 5 +- lily/include/axis-group-spanner.hh | 3 - lily/include/beam.hh | 24 +- lily/include/breathing-sign.hh | 2 - lily/include/clef-item.hh | 5 +- lily/include/dots.hh | 5 +- lily/include/group-interface.hh | 2 +- lily/include/key-item.hh | 5 +- lily/include/local-key-item.hh | 5 +- lily/include/multi-measure-rest.hh | 5 +- lily/include/note-head.hh | 5 +- lily/include/rest.hh | 3 - lily/include/rhythmic-head.hh | 12 +- lily/include/score-element.hh | 11 +- lily/include/side-position-interface.hh | 41 +++ lily/include/spanner.hh | 1 - lily/include/staff-bar.hh | 5 +- lily/include/staff-symbol.hh | 2 + lily/include/stem-info.hh | 15 +- lily/include/stem.hh | 22 +- lily/key-engraver.cc | 4 + lily/key-item.cc | 5 +- lily/line-of-score.cc | 7 - lily/local-key-engraver.cc | 4 + lily/local-key-item.cc | 4 +- lily/multi-measure-rest-engraver.cc | 5 + lily/multi-measure-rest.cc | 12 +- lily/note-column.cc | 19 +- lily/note-head-side.cc | 2 +- lily/note-head.cc | 44 +-- lily/note-heads-engraver.cc | 15 +- lily/paper-score.cc | 11 + lily/pitch-squash-engraver.cc | 3 +- lily/rest-engraver.cc | 14 +- lily/rest.cc | 39 ++- lily/rhythmic-head.cc | 29 +- lily/score-element.cc | 70 ++--- lily/script-column-engraver.cc | 4 +- lily/script-column.cc | 2 +- lily/script-engraver.cc | 5 +- lily/script.cc | 2 +- lily/spanner.cc | 23 +- lily/staff-bar.cc | 12 +- lily/staff-margin-engraver.cc | 2 +- lily/staff-symbol-engraver.cc | 94 +++++++ lily/staff-symbol.cc | 79 ++++++ lily/stem-engraver.cc | 12 +- lily/stem-tremolo.cc | 23 +- lily/stem.cc | 169 ++++++++--- lily/tie.cc | 28 +- lily/vertical-align-engraver.cc | 7 - ly/params.ly | 4 +- 76 files changed, 852 insertions(+), 548 deletions(-) create mode 100644 lily/include/side-position-interface.hh create mode 100644 lily/staff-symbol-engraver.cc create mode 100644 lily/staff-symbol.cc diff --git a/CHANGES b/CHANGES index 6742e3945c..db957bac39 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,20 @@ + +pl 10.uu1 + - various small bfs + - bf: alignment reversed + - Staff_symbol_referencer -> Staff_symbol_referencer_interface + - bf: staccato pos + - Knee fixes (thanks, Jan) + +pl 10.jcn2 + - fixes for invisible beamed stems + - removed steminfo from properties, don't cache Stem_info + +pl 10.jcn1 + - steminfo to properties + - dropped internote dim for stem-beams + +********** pl 9.hwn1 - abstracting Staff_symbol_referencer to an interface. - quantised_position for staccato dots. diff --git a/Documentation/programmer/regression-test.tely b/Documentation/programmer/regression-test.tely index 2496262883..de989ac512 100644 --- a/Documentation/programmer/regression-test.tely +++ b/Documentation/programmer/regression-test.tely @@ -67,7 +67,7 @@ like beam segments crossing stems. If the stem is in a beam, the tremolo must be parallel to the beam. If the stem is invisible (eg. on a whole note), the tremolo must be centered on the note. -@mudelafile{stem-tremolo.ly} +@c @mu delafile{stem-tremolo.ly} Chord tremolos look like beams, but are a kind of repeat symbol. To avoid confusion, chord tremolo beams do not reach the stems, but @@ -75,7 +75,7 @@ leave a gap. Chord tremolo beams on half notes are not ambiguous, as half notes cannot appear in a regular beam, and should reach the stems. -@mudelafile{chord-tremolo.sly} +@c miudelafile{chord-tremolo.sly} Beams, stems and noteheads often have communication troubles, since the two systems for y dimensions (1 unit = staffspace, 1 unit = 1 diff --git a/TODO b/TODO index 48be8ed92c..5bf1c889c4 100644 --- a/TODO +++ b/TODO @@ -11,6 +11,8 @@ Grep -i for TODO, FIXME and ugh/ugr/urg. .* TODO . * use hash tabs iso. alist_ for elt property? . * agressive type-checking for SCM stuff. +. * use "staff-space" and "half-space" iso interline, + staff_line_leading () etc. . * TODO^2: . * make a TODO.texi, like http://www.gnu.org/software/guile/ideas.html @@ -24,8 +26,6 @@ Grep -i for TODO, FIXME and ugh/ugr/urg. ctor_dict["Score_element"]->create_func (); . * acc at tied note after linebreak. . * fix font-naming and selecting -. * fix naming: \interline Context.staffLineLeading, staff_line_leading (), -staff_position staff_space . * chord tonic: placement of accidental C#, Cb (from scm and C++) . * note head on stem err msg in dutch. . * why need to run -C mf twice? diff --git a/lily/align-element.cc b/lily/align-element.cc index 4134d8e3e2..5f4080015c 100644 --- a/lily/align-element.cc +++ b/lily/align-element.cc @@ -97,12 +97,13 @@ Align_element::do_side_processing () if (center_f) translate_axis ( - center_f, axis ()); - dim_cache_[axis ()]->invalidate (); + + // dim_cache_[axis ()]->invalidate (); + } Align_element::Align_element() { - ordered_b_ = true; threshold_interval_ = Interval (0, Interval::infinity ()); stacking_dir_ = DOWN; align_dir_ = CENTER; diff --git a/lily/axis-group-element.cc b/lily/axis-group-element.cc index 5992ea4614..081b42a22f 100644 --- a/lily/axis-group-element.cc +++ b/lily/axis-group-element.cc @@ -6,9 +6,9 @@ (c) 1997--1999 Han-Wen Nienhuys */ -#include "axis-group-element.hh" #include "axis-group-element.hh" #include "dimension-cache.hh" +#include "group-interface.hh" Link_array Axis_group_element::get_extra_dependencies() const @@ -20,17 +20,8 @@ Axis_group_element::get_extra_dependencies() const Link_array Axis_group_element::elem_l_arr () const { - /* - ugh. I know - */ - Link_array r; - for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) - { - SCM e=gh_car (s); - r.push (unsmob_element (e)); - } - - return r; + return + Group_interface__extract_elements (this, (Score_element*)0, "elements"); } Link_array @@ -96,15 +87,6 @@ Axis_group_element::extent_callback (Dimension_cache const *c) } -/* - UGH. - */ -void -Axis_group_element::add_extra_element (Score_element *e) -{ - add_element (e); -} - void Axis_group_element::add_element (Score_element *e) @@ -117,16 +99,7 @@ Axis_group_element::add_element (Score_element *e) if (!e->parent_l (axes_[i])) e->set_parent (this, axes_[i]); } - set_elt_property ("elements", - gh_cons (e->self_scm_, - get_elt_property ("elements"))); - - assert (e->parent_l(Y_AXIS) == this || e->parent_l (X_AXIS) == this); + Group_interface gi (this); + gi.add_element (e); } - - - - - - diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc index 85d21f0f8c..22cfb5fdf3 100644 --- a/lily/axis-group-engraver.cc +++ b/lily/axis-group-engraver.cc @@ -55,7 +55,7 @@ Axis_group_engraver::process_acknowledged () && ! dynamic_cast (elts_[i]->parent_l (Y_AXIS))) { - staffline_p_->add_extra_element (elts_[i]); + staffline_p_->add_element (elts_[i]); } } elts_.clear (); diff --git a/lily/bar-script-engraver.cc b/lily/bar-script-engraver.cc index 1e82d91657..f4fa06452c 100644 --- a/lily/bar-script-engraver.cc +++ b/lily/bar-script-engraver.cc @@ -10,7 +10,7 @@ #include "bar-script-engraver.hh" #include "bar.hh" #include "clef-item.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" #include "text-item.hh" #include "lily-guile.hh" #include "paper-column.hh" diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 1d1a70addf..1fa729cc51 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -183,7 +183,8 @@ Beam_engraver::acknowledge_element (Score_element_info info) return; } - stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_; + stem_l->set_elt_property ("duration-log", + gh_int2scm (rhythmic_req->duration_.durlog_i_)); Moment stem_location = now_mom () - beam_start_mom_ + beam_start_location_; beam_info_p_->add_stem (stem_location, rhythmic_req->duration_.durlog_i_ - 2); beam_p_->add_stem (stem_l); diff --git a/lily/beam.cc b/lily/beam.cc index 0335ff7256..8b25aeb5d5 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -13,12 +13,6 @@ [TODO] * center beam symbol * less hairy code - * redo grouping - -TODO: - -The relationship Stem <-> Beam is way too hairy. Let's figure who -needs what, and what information should be available when. */ @@ -36,6 +30,8 @@ needs what, and what information should be available when. #include "paper-def.hh" #include "lookup.hh" #include "group-interface.hh" +#include "staff-symbol-referencer.hh" +#include "cross-staff.hh" Beam::Beam () { @@ -44,7 +40,7 @@ Beam::Beam () slope_f_ = 0; left_y_ = 0; - multiple_i_ = 0; + multiplicity_i_ = 0; } /* @@ -63,6 +59,54 @@ Beam::stem_count ()const return gi.count (); } +Stem* +Beam::stem_top ()const +{ + return Group_interface__extract_elements ((Beam*) this, (Stem*) 0, "stems")[stem_count () - 1]; +} + +/* burp */ +int +Beam::visible_stem_count () const +{ + int c = 0; + for (int i = 0; i < stem_count (); i++) + { + if (!stem (i)->invisible_b ()) + c++; + } + return c; +} + +Stem* +Beam::first_visible_stem () const +{ + for (int i = 0; i < stem_count (); i++) + { + Stem* s = stem (i); + if (!s->invisible_b ()) + return s; + } + + assert (0); + // sigh + return 0; +} + +Stem* +Beam::last_visible_stem () const +{ + for (int i = stem_count (); i > 0; i--) + { + Stem* s = stem (i - 1); + if (!s->invisible_b ()) + return s; + } + + assert (0); + // sigh + return 0; +} void Beam::add_stem (Stem*s) @@ -81,27 +125,14 @@ Beam::add_stem (Stem*s) set_bounds (RIGHT,s); } -Stem_info -Beam::get_stem_info (Stem *s) -{ - Stem_info i; - for (int i=0; i < sinfo_.size (); i++) - { - if (sinfo_[i].stem_l_ == s) - return sinfo_[i]; - } - assert (false); - return i; -} - Molecule* Beam::do_brew_molecule_p () const { Molecule *mol_p = new Molecule; - if (!sinfo_.size ()) + if (!stem_count ()) return mol_p; - Real x0 = stem (0)->hpos_f (); + Real x0 = first_visible_stem ()->hpos_f (); for (int j=0; j hpos_f ()-x0; - sb.translate (Offset (x, (x * slope_f_ + left_y_) * - i->staff_line_leading_f ()/2 )); + sb.translate (Offset (x, x * slope_f_ + left_y_)); mol_p->add_molecule (sb); } mol_p->translate_axis (x0 @@ -123,11 +153,8 @@ Beam::do_brew_molecule_p () const Offset Beam::center () const { - Stem_info si = sinfo_[0]; - - Real w= (si.stem_l_->note_delta_f () + extent (X_AXIS).length ())/2.0; - return Offset (w, ( w* slope_f_) * - si.stem_l_->staff_line_leading_f ()/2); + Real w = (first_visible_stem ()->note_delta_f () + extent (X_AXIS).length ())/2.0; + return Offset (w, w * slope_f_); } /* @@ -139,17 +166,17 @@ Beam::auto_knee (SCM gap, bool interstaff_b) { bool knee = false; int knee_y = 0; - Real internote_f = stem (0)->staff_line_leading_f ()/2; if (gap != SCM_UNDEFINED) { int auto_gap_i = gh_scm2int (gap); for (int i=1; i < stem_count (); i++) { - bool is_b = (bool)(sinfo_[i].interstaff_f_ - sinfo_[i-1].interstaff_f_); - int l_y = (int)(stem (i-1)->chord_start_f () / internote_f) - + (int)sinfo_[i-1].interstaff_f_; - int r_y = (int)(stem (i)->chord_start_f () / internote_f) - + (int)sinfo_[i].interstaff_f_; + bool is_b = (bool)(calc_interstaff_dist (stem (i), this) + - calc_interstaff_dist (stem (i-1), this)); + int l_y = (int)(stem (i-1)->chord_start_f ()) + + (int)calc_interstaff_dist (stem (i-1), this); + int r_y = (int)(stem (i)->chord_start_f ()) + + (int)calc_interstaff_dist (stem (i), this); int gap_i = r_y - l_y; /* @@ -168,8 +195,8 @@ Beam::auto_knee (SCM gap, bool interstaff_b) { for (int i=0; i < stem_count (); i++) { - int y = (int)(stem (i)->chord_start_f () / internote_f) - + (int)sinfo_[i].interstaff_f_; + int y = (int)(stem (i)->chord_start_f ()) + + (int)calc_interstaff_dist (stem (i), this); stem (i)->set_direction ( y < knee_y ? UP : DOWN); stem (i)->set_elt_property ("dir-forced", SCM_BOOL_T); } @@ -212,20 +239,20 @@ Beam::do_print () const void Beam::do_post_processing () { - if (stem_count () < 2) + if (visible_stem_count () < 2) { warning (_ ("beam with less than two stems")); set_elt_property ("transparent", SCM_BOOL_T); return; } - set_steminfo (); + set_stem_shorten (); if (auto_knees ()) { /* if auto-knee did its work, most probably stem directions have changed, so we must recalculate all. */ - set_direction ( get_default_dir ()); + set_direction (get_default_dir ()); set_direction (get_direction ()); /* auto-knees used to only work for slope = 0 @@ -233,22 +260,14 @@ Beam::do_post_processing () set_elt_property ("damping", gh_int2scm(1000)); */ - sinfo_.clear (); - set_steminfo (); + set_stem_shorten (); } calculate_slope (); set_stemlens (); } -#if 0 -Interval -Beam::do_width () const -{ - return Interval (stem (0)->hpos_f (), - stems_.top ()->hpos_f ()); -} -#endif + Direction Beam::get_default_dir () const @@ -325,7 +344,7 @@ Beam::set_direction (Direction d) Stem *s = stem (i); s->set_elt_property ("beam-dir", gh_int2scm (d)); - SCM force = s->remove_elt_property ("dir-forced"); + SCM force = s->get_elt_property ("dir-forced"); // remove_prop? if (force == SCM_UNDEFINED) s->set_direction ( d); } @@ -338,12 +357,16 @@ Beam::set_direction (Direction d) void Beam::solve_slope () { - assert (sinfo_.size () > 1); + assert (visible_stem_count () > 1); Least_squares l; - for (int i=0; i < sinfo_.size (); i++) + Real x0 = first_visible_stem ()->hpos_f (); + for (int i=0; i < stem_count (); i++) { - l.input.push (Offset (sinfo_[i].x_, sinfo_[i].idealy_f_)); + Stem* s = stem (i); + if (s->invisible_b ()) + continue; + l.input.push (Offset (s->hpos_f () - x0, s->calc_stem_info ().idealy_f_)); } l.minimise (slope_f_, left_y_); } @@ -351,56 +374,67 @@ Beam::solve_slope () /* ugh. Naming: this doesn't check, but sets as well. */ - Real Beam::check_stemlengths_f (bool set_b) { - Real interbeam_f = paper_l ()->interbeam_f (multiple_i_); + Real interbeam_f = paper_l ()->interbeam_f (multiplicity_i_); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness")); Real staffline_f = paper_l ()-> get_var ("stafflinethickness"); Real epsilon_f = staffline_f / 8; Real dy_f = 0.0; - for (int i=0; i < sinfo_.size (); i++) + Real x0 = first_visible_stem ()->hpos_f (); + Real internote_f = paper_l ()->get_var ("interline"); + for (int i=0; i < stem_count (); i++) { - Real y = sinfo_[i].x_ * slope_f_ + left_y_; + Stem* s = stem (i); + if (s->invisible_b ()) + continue; + Real y = (s->hpos_f () - x0) * slope_f_ + left_y_; + Stem_info info = s->calc_stem_info (); // correct for knee - if (get_direction () != sinfo_[i].get_direction ()) + if (get_direction () != s->get_direction ()) { - Real internote_f = sinfo_[i].stem_l_->staff_line_leading_f ()/2; y -= get_direction () * (beam_f / 2 - + (sinfo_[i].mult_i_ - 1) * interbeam_f) / internote_f; - if (!i && sinfo_[i].stem_l_->staff_symbol_l () != - sinfo_.top ().stem_l_->staff_symbol_l ()) - y += get_direction () * (multiple_i_ - (sinfo_[i].stem_l_->flag_i_ - 2) >? 0) - * interbeam_f / internote_f; + + (multiplicity_i_ - 1) * interbeam_f); + + + Staff_symbol_referencer_interface s1 (s); + Staff_symbol_referencer_interface s2 (stem_top ()); + + if (!i + && s1.staff_symbol_l () != s2.staff_symbol_l ()) + y += get_direction () * (multiplicity_i_ - (s->flag_i () - 2) >? 0) + * interbeam_f; } + /* caution: stem measures in staff-positions */ if (set_b) - sinfo_[i].stem_l_->set_stemend (y - sinfo_[i].interstaff_f_); + s->set_stemend ((y - calc_interstaff_dist (s, this)) + / internote_f); y *= get_direction (); - if (y > sinfo_[i].maxy_f_) - dy_f = dy_f info.maxy_f_) + dy_f = dy_f ? sinfo_[i].miny_f_ - y; + dy_f = dy_f >? info.miny_f_ - y; } } return dy_f; } void -Beam::set_steminfo () +Beam::set_stem_shorten () { if(!stem_count ()) return; - assert (multiple_i_); + assert (multiplicity_i_); int total_count_i = 0; int forced_count_i = 0; @@ -416,13 +450,13 @@ Beam::set_steminfo () total_count_i++; } + Real internote_f = paper_l ()->get_var ("interline"); bool grace_b = get_elt_property ("grace") == SCM_BOOL_T; String type_str = grace_b ? "grace_" : ""; int stem_max = (int)rint(paper_l ()->get_var ("stem_max")); Real shorten_f = paper_l ()->get_var (type_str + "forced_stem_shorten" - + to_str (multiple_i_ get_direction () == get_direction ()) { if (forced_count_i == total_count_i) - info.idealy_f_ -= shorten_f; + s->set_real ("shorten", shorten_f); else if (forced_count_i > total_count_i / 2) - info.idealy_f_ -= shorten_f / 2; + s->set_real ("shorten", shorten_f/2); } - sinfo_.push (info); } } void Beam::calculate_slope () { - if (!sinfo_.size ()) + if (!stem_count ()) slope_f_ = left_y_ = 0; - else if (sinfo_[0].idealy_f_ == sinfo_.top ().idealy_f_) + else if (first_visible_stem ()->calc_stem_info ().idealy_f_ == last_visible_stem ()->calc_stem_info ().idealy_f_) { slope_f_ = 0; - left_y_ = sinfo_[0].idealy_f_; + left_y_ = first_visible_stem ()->calc_stem_info ().idealy_f_; left_y_ *= get_direction (); } else @@ -470,16 +499,13 @@ Beam::calculate_slope () /* steep slope running against lengthened stem is suspect */ - Real dx_f = stem (stem_count () -1)->hpos_f () - stem (0)->hpos_f (); + Real dx_f = stem (stem_count () -1)->hpos_f () - first_visible_stem ()->hpos_f (); - // urg, these y internote-y-dimensions - Real internote_f = stem (0)->staff_line_leading_f ()/2; - - Real lengthened = paper_l ()->get_var ("beam_lengthened") / internote_f; - Real steep = paper_l ()->get_var ("beam_steep_slope") / internote_f; - if (((left_y_ - sinfo_[0].idealy_f_ > lengthened) + Real lengthened = paper_l ()->get_var ("beam_lengthened"); + Real steep = paper_l ()->get_var ("beam_steep_slope"); + if (((left_y_ - first_visible_stem ()->calc_stem_info ().idealy_f_ > lengthened) && (slope_f_ > steep)) - || ((left_y_ + slope_f_ * dx_f - sinfo_.top ().idealy_f_ > lengthened) + || ((left_y_ + slope_f_ * dx_f - last_visible_stem ()->calc_stem_info ().idealy_f_ > lengthened) && (slope_f_ < -steep))) { slope_f_ = 0; @@ -525,15 +551,15 @@ Beam::quantise_dy () if (q == ly_symbol2scm ("none")) return; - Real interline_f = stem (0)->staff_line_leading_f (); - Real internote_f = interline_f / 2; + Staff_symbol_referencer_interface st (this); + Real interline_f = st.staff_line_leading_f (); + Real staffline_f = paper_l ()->get_var ("stafflinethickness"); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));; - Real dx_f = stem (stem_count () -1 )->hpos_f () - stem (0)->hpos_f (); + Real dx_f = stem (stem_count () -1 )->hpos_f () - first_visible_stem ()->hpos_f (); - // dim(y) = internote; so slope = (y/internote)/x - Real dy_f = dx_f * abs (slope_f_ * internote_f); + Real dy_f = dx_f * abs (slope_f_); Real quanty_f = 0.0; @@ -542,14 +568,12 @@ Beam::quantise_dy () allowed_fraction[1] = (beam_f / 2 + staffline_f / 2); allowed_fraction[2] = (beam_f + staffline_f); - Interval iv = quantise_iv (allowed_fraction, interline_f, dy_f); quanty_f = (dy_f - iv[SMALLER] <= iv[BIGGER] - dy_f) ? iv[SMALLER] : iv[BIGGER]; - - slope_f_ = (quanty_f / dx_f) / internote_f * sign (slope_f_); + slope_f_ = (quanty_f / dx_f) * sign (slope_f_); } /* @@ -578,8 +602,8 @@ Beam::quantise_left_y (bool extend_b) hang straddle sit inter hang */ - Real space = stem (0)->staff_line_leading_f (); - Real internote_f = space /2; + Staff_symbol_referencer_interface sinf (this); + Real space = sinf.staff_line_leading_f (); Real staffline_f = paper_l ()->get_var ("stafflinethickness"); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));; @@ -603,27 +627,26 @@ Beam::quantise_left_y (bool extend_b) */ // isn't this asymmetric ? --hwn - // dim(left_y_) = internote - Real dy_f = get_direction () * left_y_ * internote_f; + Real dy_f = get_direction () * left_y_; - Real beamdx_f = stem (stem_count () -1)->hpos_f () - stem (0)->hpos_f (); - Real beamdy_f = beamdx_f * slope_f_ * internote_f; + Real beamdx_f = stem (stem_count () -1)->hpos_f () - first_visible_stem ()->hpos_f (); + Real beamdy_f = beamdx_f * slope_f_; Array allowed_position; if (q == ly_symbol2scm ("normal")) { - if ((multiple_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2)) + if ((multiplicity_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2)) allowed_position.push (straddle); - if ((multiple_i_ <= 1) || (abs (beamdy_f) >= staffline_f / 2)) + if ((multiplicity_i_ <= 1) || (abs (beamdy_f) >= staffline_f / 2)) allowed_position.push (sit); allowed_position.push (hang); } else if (q == ly_symbol2scm ("traditional")) { // TODO: check and fix TRADITIONAL - if ((multiple_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2)) + if ((multiplicity_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2)) allowed_position.push (straddle); - if ((multiple_i_ <= 1) && (beamdy_f <= staffline_f / 2)) + if ((multiplicity_i_ <= 1) && (beamdy_f <= staffline_f / 2)) allowed_position.push (sit); if (beamdy_f >= -staffline_f / 2) allowed_position.push (hang); @@ -636,8 +659,7 @@ Beam::quantise_left_y (bool extend_b) if (extend_b) quanty_f = iv[BIGGER]; - // dim(left_y_) = internote - left_y_ = get_direction () * quanty_f / internote_f; + left_y_ = get_direction () * quanty_f; } void @@ -685,18 +707,10 @@ Beam::do_add_processing () { Direction d = LEFT; do { - multiple_i_ = multiple_i_ >? stem (i)->beams_i_drul_[d]; + multiplicity_i_ = multiplicity_i_ >? stem (i)->beams_i_drul_[d]; } while ((flip (&d)) != LEFT); } - /* - Why? - */ - if (stem_count ()) - { - stem (0)->beams_i_drul_[LEFT] =0; - stem (stem_count () -1)->beams_i_drul_[RIGHT] =0; - } } @@ -714,14 +728,12 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const programming_error ("Beams are not left-to-right"); Real staffline_f = paper_l ()->get_var ("stafflinethickness"); - Real interbeam_f = paper_l ()->interbeam_f (multiple_i_); - - Real internote_f = here->staff_line_leading_f ()/2; + Real interbeam_f = paper_l ()->interbeam_f (multiplicity_i_); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));; Real dy = interbeam_f; Real stemdx = staffline_f; - Real sl = slope_f_* internote_f; + Real sl = slope_f_; Molecule leftbeams; Molecule rightbeams; diff --git a/lily/bow.cc b/lily/bow.cc index ca967f0ee3..5d44313d04 100644 --- a/lily/bow.cc +++ b/lily/bow.cc @@ -6,8 +6,8 @@ (c) 1997--1999 Han-Wen Nienhuys Jan Nieuwenhuizen */ -#include "dimension-cache.hh" +#include "dimension-cache.hh" #include "bow.hh" #include "debug.hh" #include "paper-def.hh" diff --git a/lily/breathing-sign-engraver.cc b/lily/breathing-sign-engraver.cc index df9c9a70bd..669a606353 100644 --- a/lily/breathing-sign-engraver.cc +++ b/lily/breathing-sign-engraver.cc @@ -13,6 +13,7 @@ TODO: */ +#include "staff-symbol-referencer.hh" #include "breathing-sign-engraver.hh" #include "breathing-sign.hh" #include "musical-request.hh" @@ -44,6 +45,8 @@ Breathing_sign_engraver::do_process_requests() { if(breathing_sign_req_l_) { breathing_sign_p_ = new Breathing_sign; + Staff_symbol_referencer_interface st (breathing_sign_p_); + st.set_interface (); announce_element (Score_element_info (breathing_sign_p_, breathing_sign_req_l_)); } diff --git a/lily/breathing-sign.cc b/lily/breathing-sign.cc index 3578e06210..bf1f8dea96 100644 --- a/lily/breathing-sign.cc +++ b/lily/breathing-sign.cc @@ -8,6 +8,7 @@ TODO: --> see breathing-sign-engraver.cc */ +#include "staff-symbol-referencer.hh" #include "breathing-sign.hh" #include "string.hh" @@ -30,7 +31,9 @@ Breathing_sign::Breathing_sign () Molecule* Breathing_sign::do_brew_molecule_p () const { - Real dl = staff_line_leading_f(); + Staff_symbol_referencer_interface si (this); + + Real dl = si.staff_line_leading_f(); Interval i1(0, dl / 6), i2(-dl / 2, dl / 2); Box b(i1, i2); @@ -42,7 +45,7 @@ Breathing_sign::do_brew_molecule_p () const void Breathing_sign::do_post_processing() { - Real dl = staff_line_leading_f(); + Real dl = Staff_symbol_referencer_interface (this).staff_line_leading_f(); translate_axis(2.0 * dl * get_direction (), Y_AXIS); } diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index 567c31ec6a..c705ea05a3 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -137,25 +137,25 @@ Chord_tremolo_engraver::acknowledge_element (Score_element_info i) if (Stem* s = dynamic_cast (i.elem_l_)) { int type_i = prev_start_req_->type_i_; - s->flag_i_ = intlog2 (type_i) - 2; + s->set_elt_property ("duration-log", gh_int2scm (intlog2 (type_i) - 2)); - s->beams_i_drul_[LEFT] = s->flag_i_; - s->beams_i_drul_[RIGHT] = s->flag_i_; + s->beams_i_drul_[LEFT] = s->flag_i (); + s->beams_i_drul_[RIGHT] = s->flag_i (); - abeam_p_->multiple_i_ = s->flag_i_; + abeam_p_->multiplicity_i_ = s->flag_i (); /* abbrev gaps on all but half note */ #if 0 if (s->type_i () != 1) { - int gap_i =s->flag_i_ - ((s->type_i () >? 2) - 2); + int gap_i =s->flag_i () - ((s->type_i () >? 2) - 2); s->set_elt_property ("beam-gap", gh_int2scm(gap_i)); } #else if (s->type_i () != 1) { - int gap_i =s->flag_i_ - ((s->type_i () >? 2) - 2); + int gap_i =s->flag_i () - ((s->type_i () >? 2) - 2); abeam_p_->set_elt_property ("beam-gap", gh_int2scm(gap_i)); } #endif diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index 2ec5e9c569..226e7adaa4 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -13,6 +13,7 @@ */ #include +#include "staff-symbol-referencer.hh" #include "bar.hh" #include "clef-engraver.hh" #include "clef-item.hh" @@ -126,7 +127,8 @@ Clef_engraver::acknowledge_element (Score_element_info info) { if (Note_head * h = dynamic_cast(it_l)) { - h->set_position (int (h->position_f ()) + c0_position_i_); + Staff_symbol_referencer_interface si (h); + si.set_position (int (si.position_f ()) + c0_position_i_); } else if (Local_key_item *i = dynamic_cast (it_l)) { @@ -178,11 +180,15 @@ Clef_engraver::create_clef() Clef_item *c= new Clef_item; c->set_elt_property ("break-aligned", SCM_BOOL_T); announce_element (Score_element_info (c, clef_req_l_)); + + Staff_symbol_referencer_interface si(c); + si.set_interface (); + clef_p_ = c; } - + Staff_symbol_referencer_interface si(clef_p_); clef_p_->symbol_ = clef_type_str_; - clef_p_->set_position(clef_position_i_); + si.set_position (clef_position_i_); if (octave_dir_) { clef_p_->set_elt_property ("octave-dir", gh_int2scm (octave_dir_)); diff --git a/lily/clef-item.cc b/lily/clef-item.cc index 838d06a808..c98c188f7c 100644 --- a/lily/clef-item.cc +++ b/lily/clef-item.cc @@ -15,12 +15,11 @@ #include "text-item.hh" #include "paper-score.hh" #include "dimension-cache.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" void Clef_item::do_pre_processing() { - Staff_symbol_referencer::do_pre_processing(); SCM style_sym =get_elt_property ("style"); String style; if (style_sym != SCM_UNDEFINED) @@ -43,7 +42,6 @@ Clef_item::Clef_item() set_elt_property ("breakable", SCM_BOOL_T); symbol_ = "treble"; - set_position(-2); } void diff --git a/lily/collision.cc b/lily/collision.cc index f1691792c6..1ee27e6c37 100644 --- a/lily/collision.cc +++ b/lily/collision.cc @@ -155,7 +155,7 @@ Collision::automatic_shift () bool merge = downpos == uppos - && nu_l->balltype_i_ == nd_l->balltype_i_ + && nu_l->balltype_i () == nd_l->balltype_i () && nu_l->dots_i () == nd_l->dots_i (); /* diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index aacf58aadc..ce851df2bd 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -46,8 +46,8 @@ Dimension_cache::init() void Dimension_cache::invalidate () { - off_valid_b_ =false; - valid_b_ = false; + /* off_valid_b_ =false; + valid_b_ = false;*/ } @@ -99,16 +99,13 @@ Dimension_cache::axis () const Real Dimension_cache::get_offset () const { - if (!off_valid_b_) + Dimension_cache *me = (Dimension_cache*) this; + while (off_callbacks_.size ()) { - Dimension_cache *d = (Dimension_cache*) this; - - d->basic_offset_ =0.0; - d->off_valid_b_ = true; - for (int i=0; i < off_callbacks_.size (); i++) - d->basic_offset_ += (*off_callbacks_[i]) (d); + Offset_cache_callback c = me->off_callbacks_[0]; + me->off_callbacks_.del (0); + me->basic_offset_ += (*c) (me); } - return basic_offset_ + extra_offset_; } diff --git a/lily/directional-spanner.cc b/lily/directional-spanner.cc index eb6b471fc6..41751d77a2 100644 --- a/lily/directional-spanner.cc +++ b/lily/directional-spanner.cc @@ -14,12 +14,4 @@ Directional_spanner::do_pre_processing() set_direction (get_default_dir()); } -#if 0 -Offset -Directional_spanner::center () const -{ - Real w= extent (X_AXIS).length (); - Offset o (w/2, 0); - return o; -} -#endif + diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 730228eeec..d085bf4011 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -10,6 +10,7 @@ #include "dot-column.hh" #include "rhythmic-head.hh" #include "group-interface.hh" +#include "staff-symbol-referencer.hh" void Dot_column::add_dots (Dots *d) @@ -35,7 +36,11 @@ Dot_column::add_head (Rhythmic_head *r) int Dot_column::compare (Dots * const &d1, Dots * const &d2) { - return int (d1->position_f () - d2->position_f ()); + Staff_symbol_referencer_interface s1(d1); + Staff_symbol_referencer_interface s2(d2); + + + return int (s1.position_f () - s2.position_f ()); } @@ -78,12 +83,15 @@ Dot_column::do_post_processing () int conflicts = 0; for (int i=0; i < dots.size (); i++) { + Real p = Staff_symbol_referencer_interface (dots[i]).position_f (); for (int j=0; j < taken_posns.size (); j++) - if (taken_posns[j] == (int) dots[i]->position_f ()) - conflicts++; - taken_posns.push ((int)dots[i]->position_f ()); - s.unite (Slice ((int)dots[i]->position_f (), - (int)dots[i]->position_f ())); + { + if (taken_posns[j] == (int) p) + conflicts++; + } + taken_posns.push ((int)p); + s.unite (Slice ((int)p, + (int)p)); } if (!conflicts) @@ -99,6 +107,6 @@ Dot_column::do_post_processing () for (int i=0; i set_position(pos); + staff_symbol_referencer_interface (dots[i]).set_position(pos); } } diff --git a/lily/dots.cc b/lily/dots.cc index 6fc996328c..92d564478e 100644 --- a/lily/dots.cc +++ b/lily/dots.cc @@ -10,6 +10,7 @@ #include "molecule.hh" #include "paper-def.hh" #include "lookup.hh" +#include "staff-symbol-referencer.hh" Dots::Dots () { @@ -30,9 +31,10 @@ Dots::do_post_processing () if (!get_direction ()) set_direction (UP); - int p = int (position_f ()); + Staff_symbol_referencer_interface si (this); + int p = si.position_f (); if (!(p % 2)) - set_position (p + get_direction ()); + si.set_position (p + get_direction ()); } } Molecule* diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index d112945de1..f117c9c49d 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -14,7 +14,7 @@ #include "staff-symbol.hh" #include "note-column.hh" #include "text-item.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" #include "engraver.hh" #include "stem.hh" #include "note-head.hh" diff --git a/lily/grace-position-engraver.cc b/lily/grace-position-engraver.cc index 172f26968f..03be73a2d2 100644 --- a/lily/grace-position-engraver.cc +++ b/lily/grace-position-engraver.cc @@ -87,11 +87,12 @@ Grace_position_engraver::do_pre_move_processing () return; warning (_("Unattached grace notes. Attaching to last musical column.")); - Axis_group_element * ae = dynamic_cast (elt); /* if (ae) ae->remove_element (align_l_); else if (elt)*/ - align_l_->set_parent (0, X_AXIS); + + + align_l_->set_parent (0, X_AXIS); last_musical_col_l_->add_element (align_l_); } diff --git a/lily/group-interface.cc b/lily/group-interface.cc index e9b79eeb19..b8388670ef 100644 --- a/lily/group-interface.cc +++ b/lily/group-interface.cc @@ -22,7 +22,7 @@ Group_interface::Group_interface (Score_element const *e, String s) name_ = s; } bool -Group_interface::supports_interface_b () +Group_interface::has_interface_b () { SCM el = elt_l_->get_elt_property (name_); @@ -33,6 +33,9 @@ Group_interface::supports_interface_b () void Group_interface::add_element (Score_element*p) { + p->used_b_ = true; + elt_l_->used_b_ = true; + elt_l_->set_elt_property (name_, gh_cons (p->self_scm_, elt_l_->get_elt_property (name_))); } @@ -46,7 +49,7 @@ Group_interface::count () void Group_interface::set_interface () { - if (!supports_interface_b ()) + if (!has_interface_b ()) { elt_l_->set_elt_property (name_, SCM_EOL); } diff --git a/lily/include/axis-group-element.hh b/lily/include/axis-group-element.hh index 270bcdb03e..3b1264d5fc 100644 --- a/lily/include/axis-group-element.hh +++ b/lily/include/axis-group-element.hh @@ -21,37 +21,17 @@ class Axis_group_element : public virtual Score_element { /// modify fields of E for removal. void do_remove (Score_element*e); - void purge_extra (); - - protected: virtual Link_array get_extra_dependencies() const; virtual Link_array elem_l_arr() const; static Interval extent_callback (Dimension_cache const*); - - - Interval extra_extent (Axis a) const; public: - // keep array in order. - bool ordered_b_; Axis axes_[2]; - Interval my_extent (Axis) const; - - - - bool contains_b (Score_element const *) const; void add_element (Score_element*); - /** - add an element that only influences size, but does not have X/Y parent - relationship with THIS. - */ - void add_extra_element (Score_element*); - - Axis_group_element (); void set_axes (Axis,Axis); diff --git a/lily/include/axis-group-item.hh b/lily/include/axis-group-item.hh index 8f59c298a2..3f75d905e7 100644 --- a/lily/include/axis-group-item.hh +++ b/lily/include/axis-group-item.hh @@ -18,9 +18,8 @@ */ class Axis_group_item : public virtual Axis_group_element, - public virtual Item { -protected: - virtual void do_breakable_col_processing(); + public virtual Item +{ public: VIRTUAL_COPY_CONS(Score_element); }; diff --git a/lily/include/axis-group-spanner.hh b/lily/include/axis-group-spanner.hh index f81b7354c7..9d7e0c8382 100644 --- a/lily/include/axis-group-spanner.hh +++ b/lily/include/axis-group-spanner.hh @@ -19,9 +19,6 @@ class Axis_group_spanner : public virtual Axis_group_element, public virtual Spanner { - void do_break_processing_if_unbroken(); -protected: - virtual void do_break_processing(); public: VIRTUAL_COPY_CONS(Score_element); }; diff --git a/lily/include/beam.hh b/lily/include/beam.hh index cfcc305e65..d3d3c71afd 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -9,7 +9,6 @@ #include "lily-proto.hh" #include "directional-spanner.hh" -#include "stem-info.hh" /** a beam connects multiple stems. @@ -29,8 +28,12 @@ slope_quantisation: 'none, 'normal or 'traditional class Beam : public Directional_spanner { public: - int stem_count ()const; - Stem * stem (int )const; + int stem_count () const; + Stem* stem (int) const; + Stem* stem_top () const; + int visible_stem_count () const; + Stem* first_visible_stem () const; + Stem* last_visible_stem () const; /** the slope of the beam in (staffpositions) per (X-dimension, in PT). @@ -41,15 +44,14 @@ public: /// position of leftmost end of beam Real left_y_; + /** + highest number of beams present, for opening-up of beam-spacing + and calculation of stem lengths + */ + int multiplicity_i_; - /// maximum number of beams (for opening-up of beam-spacing) - int multiple_i_; - - Array sinfo_; - - Beam(); + Beam (); void add_stem (Stem*); - Stem_info get_stem_info (Stem*); void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current); void set_beaming (Beaming_info_list *); @@ -60,7 +62,7 @@ protected: Offset center () const; Direction get_default_dir () const; void set_direction (Direction); - void set_steminfo (); + void set_stem_shorten (); bool auto_knee (SCM gap, bool interstaff_b); bool auto_knees (); diff --git a/lily/include/breathing-sign.hh b/lily/include/breathing-sign.hh index 0378d62078..ffc2f3d7eb 100644 --- a/lily/include/breathing-sign.hh +++ b/lily/include/breathing-sign.hh @@ -11,12 +11,10 @@ #define BREATHING_SIGN_HH #include "item.hh" -#include "staff-symbol-referencer.hh" #include "parray.hh" #include "directional-element.hh" class Breathing_sign : public Item, - public Staff_symbol_referencer, public Directional_element { public: diff --git a/lily/include/clef-item.hh b/lily/include/clef-item.hh index 11362d72fa..e35b20c9c0 100644 --- a/lily/include/clef-item.hh +++ b/lily/include/clef-item.hh @@ -10,7 +10,7 @@ #include "direction.hh" #include "pointer.hh" -#include "staff-symbol-referencer.hh" + /** Set a clef in a staff. @@ -23,7 +23,8 @@ change: is this a change clef (smaller size)? */ -class Clef_item : public Item, public Staff_symbol_referencer { +class Clef_item : public Item +{ protected: virtual void do_pre_processing(); virtual Molecule* do_brew_molecule_p() const; diff --git a/lily/include/dots.hh b/lily/include/dots.hh index 05aeec680d..8225860aa9 100644 --- a/lily/include/dots.hh +++ b/lily/include/dots.hh @@ -11,14 +11,15 @@ #define DOTS_HH #include "item.hh" -#include "staff-symbol-referencer.hh" + #include "directional-element.hh" /** The dots to go with a notehead/rest. A separate class, since they are a party in collision resolution. */ -class Dots : public Item, public Staff_symbol_referencer, +class Dots : + public Item, public Directional_element { protected: diff --git a/lily/include/group-interface.hh b/lily/include/group-interface.hh index 289ba913ba..fc832a5426 100644 --- a/lily/include/group-interface.hh +++ b/lily/include/group-interface.hh @@ -23,7 +23,7 @@ public: Group_interface (Score_element const*); Group_interface (Score_element const*, String); int count (); - bool supports_interface_b (); + bool has_interface_b (); void set_interface (); void add_element (Score_element*); }; diff --git a/lily/include/key-item.hh b/lily/include/key-item.hh index 82f72cb871..ac80432208 100644 --- a/lily/include/key-item.hh +++ b/lily/include/key-item.hh @@ -9,10 +9,11 @@ #include "item.hh" #include "array.hh" -#include "staff-symbol-referencer.hh" + /// An item which places accidentals at the start of the line -class Key_item :public Item, public Staff_symbol_referencer { +class Key_item :public Item +{ Array pitch_arr_; Array acc_arr_; Array old_pitch_arr_; diff --git a/lily/include/local-key-item.hh b/lily/include/local-key-item.hh index e10468474a..25a1a2d3dd 100644 --- a/lily/include/local-key-item.hh +++ b/lily/include/local-key-item.hh @@ -9,7 +9,7 @@ #include "item.hh" #include "array.hh" #include "musical-pitch.hh" -#include "staff-symbol-referencer.hh" + #include "note-head-side.hh" struct Local_key_cautionary_tuple @@ -40,7 +40,8 @@ struct Local_key_cautionary_tuple */ -class Local_key_item : public Note_head_side, public Staff_symbol_referencer { +class Local_key_item : public Note_head_side +{ Array accidental_arr_; Molecule accidental (int,bool,bool) const; diff --git a/lily/include/multi-measure-rest.hh b/lily/include/multi-measure-rest.hh index 23cea928fd..1d5fc2bcce 100644 --- a/lily/include/multi-measure-rest.hh +++ b/lily/include/multi-measure-rest.hh @@ -11,9 +11,9 @@ #define MULTI_MEASURE_REST_HH #include "spanner.hh" -#include "staff-symbol-referencer.hh" -class Multi_measure_rest : public Spanner, public Staff_symbol_referencer + +class Multi_measure_rest : public Spanner { public: Multi_measure_rest (); @@ -26,7 +26,6 @@ protected: virtual void do_add_processing (); virtual void do_post_processing (); - virtual void do_print () const; virtual Array get_rods () const; }; diff --git a/lily/include/note-head.hh b/lily/include/note-head.hh index 308ff1c1eb..bbc051d239 100644 --- a/lily/include/note-head.hh +++ b/lily/include/note-head.hh @@ -15,15 +15,14 @@ */ -class Note_head : public Rhythmic_head { +class Note_head : public Rhythmic_head +{ public: - Note_head (); void flip_around_stem (Direction); static int compare (Note_head * const &a, Note_head *const &b) ; protected: Molecule make_molecule () const; - static Interval dim_callback (Dimension_cache const*); virtual void do_pre_processing(); diff --git a/lily/include/rest.hh b/lily/include/rest.hh index 8614789684..591c9eb81b 100644 --- a/lily/include/rest.hh +++ b/lily/include/rest.hh @@ -14,10 +14,7 @@ class Rest : public Rhythmic_head { -public: - protected: - virtual void do_add_processing (); virtual void do_post_processing (); virtual Molecule * do_brew_molecule_p () const; }; diff --git a/lily/include/rhythmic-head.hh b/lily/include/rhythmic-head.hh index 58063bd501..9013c0eb42 100644 --- a/lily/include/rhythmic-head.hh +++ b/lily/include/rhythmic-head.hh @@ -11,25 +11,19 @@ #define RHYTHMIC_HEAD_HH #include "item.hh" -#include "staff-symbol-referencer.hh" -class Rhythmic_head : public Item, public Staff_symbol_referencer + +class Rhythmic_head : public Item { - Dots * dots_l_; - Stem * stem_l_; public: - - int balltype_i_; + int balltype_i () const; void add_dots (Dots *); - Rhythmic_head (); Stem * stem_l ()const; Dots * dots_l ()const; int dots_i ()const; protected: virtual void do_post_processing (); - - virtual void do_print () const; }; #endif // RHYTHMIC_HEAD_HH diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index f5a26a030f..ba75990681 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -43,7 +43,6 @@ class Score_element { */ SCM element_property_alist_; - Link_array dependency_arr_; /** The lookup, determined by the font size. Cache this value. */ @@ -74,6 +73,9 @@ public: void set_elt_property (String, SCM val); SCM remove_elt_property (String nm); + void Score_element::set_real (String, Real); + Real Score_element::get_real (String s) const; + /* related classes. */ @@ -103,7 +105,7 @@ public: static SCM handle_broken_smobs (SCM, SCM criterion); void recurse_into_smobs (SCM s, void (Score_element::*meth_ptr)()); - + virtual void do_break_processing (); virtual Score_element *find_broken_piece (Line_of_score*) const; protected: @@ -112,9 +114,6 @@ protected: be handled by GUILE gc. */ virtual ~Score_element (); - Score_element* dependency (int) const; - int dependency_size () const; - virtual void output_processing (); static Interval molecule_extent (Dimension_cache const*); @@ -134,8 +133,6 @@ protected: /// do calculations after determining horizontal spacing virtual void do_post_processing (); - virtual void do_break_processing (); - virtual Link_array get_extra_dependencies () const; static Interval dim_cache_callback (Dimension_cache const*); diff --git a/lily/include/side-position-interface.hh b/lily/include/side-position-interface.hh new file mode 100644 index 0000000000..55a15f308a --- /dev/null +++ b/lily/include/side-position-interface.hh @@ -0,0 +1,41 @@ +/* + side-position-interface.hh -- declare Side_position_interface + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ + +#ifndef SIDE_POSITION_INTERFACE_HH +#define SIDE_POSITION_INTERFACE_HH + +#include "spanner.hh" +#include "item.hh" + +#include "directional-element.hh" + +struct Side_position_interface +{ + Score_element * elt_l_; +public: + Side_position_interface (Score_element const*); + static Real side_position (Dimension_cache const *); + static Real self_alignment (Dimension_cache const *); + static Real aligned_side (Dimension_cache const *); + static Real quantised_position (Dimension_cache const*); + void set_axis (Axis); + void set_quantised (Axis); + Axis get_axis () const; + + bool supported_b () const; + bool has_interface_b () const; + void add_support (Score_element*); + + Direction get_direction () const; + void set_direction (Direction); +}; + + +#endif /* SIDE_POSITION_INTERFACE_HH */ + diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index 08c7f361f3..6ef182fe13 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -63,7 +63,6 @@ protected: friend Axis_group_spanner; // UGH virtual void do_space_processing (); - // void handle_broken_dependents (); virtual void do_break_processing (); Real spanner_length () const; virtual Line_of_score*line_l () const; diff --git a/lily/include/staff-bar.hh b/lily/include/staff-bar.hh index 171ec1ddc0..244f36a849 100644 --- a/lily/include/staff-bar.hh +++ b/lily/include/staff-bar.hh @@ -11,16 +11,15 @@ #define STAFF_BAR_HH #include "bar.hh" -#include "staff-symbol-referencer.hh" + /** A bar that is on a staff. Ugh. Entita non multiplicandum ... */ -class Staff_bar : public Bar, public Staff_symbol_referencer +class Staff_bar : public Bar { public: - virtual void do_pre_processing (); VIRTUAL_COPY_CONS(Score_element); virtual Real get_bar_size () const; }; diff --git a/lily/include/staff-symbol.hh b/lily/include/staff-symbol.hh index afe679d65b..89dc0d63cd 100644 --- a/lily/include/staff-symbol.hh +++ b/lily/include/staff-symbol.hh @@ -21,6 +21,8 @@ public: /// this many lines. int no_lines_i_; Real staff_line_leading_f_; + Real staff_line_leading_f (); + Staff_symbol (); int steps_i() const; diff --git a/lily/include/stem-info.hh b/lily/include/stem-info.hh index 248f71b82d..096671a6d5 100644 --- a/lily/include/stem-info.hh +++ b/lily/include/stem-info.hh @@ -12,22 +12,11 @@ #include "real.hh" -struct Stem_info { - Real x_; - Direction dir_; - void set_direction (Direction d ) { dir_ = d; } - Direction get_direction () const { return dir_; } - - int beam_dir_; +struct Stem_info +{ Real idealy_f_; Real miny_f_; Real maxy_f_; - int mult_i_; - Real interstaff_f_; - Stem* stem_l_; - - Stem_info (); - Stem_info (Stem *, int); }; #endif // STEM_INFO_HH diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 3f1b583565..a40484123c 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -6,12 +6,13 @@ #ifndef STEM_HH #define STEM_HH + #include "item.hh" #include "array.hh" #include "moment.hh" #include "molecule.hh" -#include "staff-symbol-referencer.hh" #include "directional-element.hh" +#include "stem-info.hh" /**the rule attached to the ball. takes care of: @@ -40,22 +41,21 @@ */ -// todo: remove baseclass Staff_symbol_referencer, since stem -// can be across a staff. -class Stem : public Item, public Staff_symbol_referencer, +class Stem : public Item, public Directional_element { /**extent of the stem (positions). fractional, since Beam has to adapt them. */ - Drul_array yextent_drul_; + Interval yextent_; public: - - /// log of the duration. Eg. 4 -> 16th note -> 2 flags - int flag_i_; + int flag_i () const; + + Drul_array beams_i_drul_; + /** don't print flag when in beam. @@ -63,19 +63,17 @@ public: */ Beam* beam_l () const; Note_head * first_head () const; - - Drul_array beams_i_drul_; Stem (); /// ensure that this Stem also encompasses the Notehead #n# void add_head (Rhythmic_head*n); Real hpos_f () const; + Stem_info calc_stem_info () const; + Real chord_start_f () const; int type_i () const; - - void do_print() const; void set_stemend (Real); Direction get_default_dir() const; diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index d477f00620..6758de4207 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -14,6 +14,7 @@ #include "local-key-item.hh" #include "bar.hh" #include "timing-translator.hh" +#include "staff-symbol-referencer.hh" Key_engraver::Key_engraver () { @@ -33,6 +34,9 @@ Key_engraver::create_key () if (!item_p_) { item_p_ = new Key_item; + Staff_symbol_referencer_interface st (item_p_); + st.set_interface (); + item_p_->set_elt_property ("break-aligned", SCM_BOOL_T); // ugh item_p_->multi_octave_b_ = key_.multi_octave_b_; diff --git a/lily/key-item.cc b/lily/key-item.cc index 7b7631fe9a..c39f0e4e5c 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -15,6 +15,7 @@ #include "paper-def.hh" #include "lookup.hh" #include "musical-pitch.hh" +#include "staff-symbol-referencer.hh" const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */ const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */ @@ -97,7 +98,9 @@ Molecule* Key_item::do_brew_molecule_p() const { Molecule*output = new Molecule; - Real inter = staff_line_leading_f ()/2.0; + + Staff_symbol_referencer_interface si (this); + Real inter = si.staff_line_leading_f ()/2.0; int j; if ((break_status_dir () == LEFT || break_status_dir () == CENTER) diff --git a/lily/line-of-score.cc b/lily/line-of-score.cc index 5fb4931a2a..28d2477f68 100644 --- a/lily/line-of-score.cc +++ b/lily/line-of-score.cc @@ -58,13 +58,6 @@ Line_of_score::break_into_pieces (Array const &breaking) broken_into_l_arr_.push (line_l); } - - for (int i=0; i < broken_into_l_arr_.size (); i++) - { - broken_into_l_arr_[i]->handle_broken_dependencies (); - } - - handle_broken_dependencies (); } void diff --git a/lily/local-key-engraver.cc b/lily/local-key-engraver.cc index beff1c9148..100bac981d 100644 --- a/lily/local-key-engraver.cc +++ b/lily/local-key-engraver.cc @@ -16,6 +16,7 @@ #include "timing-translator.hh" #include "engraver-group-engraver.hh" #include "grace-align-item.hh" +#include "staff-symbol-referencer.hh" Local_key_engraver::Local_key_engraver() { @@ -82,6 +83,9 @@ Local_key_engraver::process_acknowledged () if (!key_item_p_) { key_item_p_ = new Local_key_item; + Staff_symbol_referencer_interface si(key_item_p_); + si.set_interface (); + announce_element (Score_element_info (key_item_p_, 0)); } diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index a8823c59c9..72c7104e4a 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -7,6 +7,7 @@ */ #include "local-key-item.hh" #include "molecule.hh" +#include "staff-symbol-referencer.hh" #include "lookup.hh" #include "paper-def.hh" @@ -67,7 +68,8 @@ Molecule* Local_key_item::do_brew_molecule_p() const { Molecule*output = new Molecule; - Real note_distance = staff_line_leading_f ()/2; + Staff_symbol_referencer_interface si (this); + Real note_distance = si.staff_line_leading_f ()/2; Molecule *octave_mol_p = 0; int lastoct = -100; diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index 609cf8c720..d6c065ccf2 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -13,6 +13,7 @@ #include "engraver-group-engraver.hh" #include "timing-translator.hh" #include "bar.hh" +#include "staff-symbol-referencer.hh" ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver); @@ -77,6 +78,10 @@ Multi_measure_rest_engraver::do_process_requests () Timing_translator * time = dynamic_cast (tr); mmrest_p_ = new Multi_measure_rest; + Staff_symbol_referencer_interface si (mmrest_p_); + si.set_interface (); + + if(dynamic_cast (multi_measure_req_l_)) mmrest_p_->set_elt_property ("alt-symbol", ly_str02scm ("scripts-repeatsign")); diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index d69333940f..5edec8fc3e 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -18,6 +18,7 @@ #include "misc.hh" #include "group-interface.hh" #include "stem.hh" +#include "staff-symbol-referencer.hh" Multi_measure_rest::Multi_measure_rest () { @@ -25,13 +26,7 @@ Multi_measure_rest::Multi_measure_rest () set_elt_property ("columns", SCM_EOL); } -void -Multi_measure_rest::do_print () const -{ -#ifndef NPRINT - DEBUG_OUT << "measures_i_ " << measures_i_; -#endif -} + @@ -94,7 +89,8 @@ Multi_measure_rest::do_brew_molecule_p () const } mol_p->add_molecule (s); - Real interline_f = staff_line_leading_f (); + Real interline_f + = staff_symbol_referencer_interface (this).staff_line_leading_f (); if (measures_i_ == 1 && rest_symbol) { mol_p->translate_axis (interline_f, Y_AXIS); diff --git a/lily/note-column.cc b/lily/note-column.cc index 21740f4513..439cb08186 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -14,6 +14,7 @@ #include "debug.hh" #include "paper-def.hh" #include "group-interface.hh" +#include "staff-symbol-referencer.hh" bool Note_column::rest_b () const @@ -61,8 +62,9 @@ Note_column::head_positions_interval() const for (; gh_pair_p (h); h = gh_cdr (h)) { Score_element *se = unsmob_element (gh_car (h)); + Staff_symbol_referencer_interface si (se); - int j = int (dynamic_cast (se)->position_f ()); + int j = int (si.position_f ()); iv.unite (Slice (j,j)); } return iv; @@ -114,14 +116,15 @@ Note_column::add_head (Rhythmic_head *h) void Note_column::translate_rests (int dy_i) { - invalidate_cache (Y_AXIS); + // invalidate_cache (Y_AXIS); SCM s = get_elt_property ("rests"); for (; gh_pair_p (s); s = gh_cdr (s)) { - Score_element * se = unsmob_element ( gh_car (s)); - Staff_symbol_referencer *str = dynamic_cast (se); - se->translate_axis (dy_i * str->staff_line_leading_f ()/2.0, Y_AXIS); + Score_element * se = unsmob_element (gh_car (s)); + Staff_symbol_referencer_interface si (se); + + se->translate_axis (dy_i * si.staff_line_leading_f ()/2.0, Y_AXIS); } } @@ -159,9 +162,9 @@ Note_column::do_post_processing () SCM s = get_elt_property ("rests"); Score_element * se = unsmob_element (gh_car (s)); - Staff_symbol_referencer *str = dynamic_cast (se); + Staff_symbol_referencer_interface si (se); - Real staff_space = str->staff_line_leading_f (); + Real staff_space = si.staff_line_leading_f (); Real rest_dim = extent (Y_AXIS)[d]*2.0 /staff_space ; Real minimum_dist @@ -169,7 +172,7 @@ Note_column::do_post_processing () Real dist = minimum_dist + -d * (beamy - rest_dim) >? 0; - int stafflines = str->lines_i (); + int stafflines = si.lines_i (); // move discretely by half spaces. int discrete_dist = int (ceil (dist )); diff --git a/lily/note-head-side.cc b/lily/note-head-side.cc index 1406da12a6..b84b895334 100644 --- a/lily/note-head-side.cc +++ b/lily/note-head-side.cc @@ -7,7 +7,7 @@ */ -#include "staff-side.hh" +#include "side-position-interface.hh" #include "note-head-side.hh" void Note_head_side::add_support (Item*head_l) diff --git a/lily/note-head.cc b/lily/note-head.cc index 17bc7d6b30..4ddaac0848 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -14,6 +14,7 @@ #include "molecule.hh" #include "musical-request.hh" #include "dimension-cache.hh" +#include "staff-symbol-referencer.hh" void Note_head::flip_around_stem (Direction d) @@ -37,8 +38,6 @@ Note_head::Note_head () void Note_head::do_pre_processing () { - Rhythmic_head::do_pre_processing (); - // 8 ball looks the same as 4 ball: String type; SCM style = get_elt_property ("style"); @@ -48,24 +47,27 @@ Note_head::do_pre_processing () } - if (balltype_i_ > 2 || type == "harmonic" || type == "cross") - balltype_i_ = 2; + if (balltype_i () > 2 || type == "harmonic" || type == "cross") + set_elt_property ("duration-log", gh_int2scm (2)); - if (dots_l ()) // move into Rhythmic_head? - dots_l ()->set_position(int (position_f ())); + if (Dots *d = dots_l ()) + { // move into Rhythmic_head? - + Staff_symbol_referencer_interface si (d); + Staff_symbol_referencer_interface me (this); + + si.set_position(int (me.position_f ())); + } } - - int Note_head::compare (Note_head *const &a, Note_head * const &b) { - return sign(a->position_f () - b->position_f ()); -} - + Staff_symbol_referencer_interface s1(a); + Staff_symbol_referencer_interface s2(b); + return sign(s1.position_f () - s2.position_f ()); +} Molecule Note_head::make_molecule () const @@ -78,18 +80,20 @@ Note_head::make_molecule () const } return lookup_l()->afm_find (String ("noteheads-") - + to_str (balltype_i_) + type); + + to_str (balltype_i ()) + type); } Molecule* Note_head::do_brew_molecule_p() const { - Real inter_f = staff_line_leading_f ()/2; - int sz = lines_i ()-1; - - int streepjes_i = abs (position_f ()) < sz + Staff_symbol_referencer_interface si (this); + + Real inter_f = si.staff_line_leading_f ()/2; + int sz = si.lines_i ()-1; + Real p = si.position_f (); + int streepjes_i = abs (p) < sz ? 0 - : (abs((int)position_f ()) - sz) /2; + : (abs((int)p) - sz) /2; Molecule* out = new Molecule (make_molecule ()); @@ -97,7 +101,7 @@ Note_head::do_brew_molecule_p() const if (streepjes_i) { - Direction dir = (Direction)sign (position_f ()); + Direction dir = (Direction)sign (p); Interval hd = out->dim_[X_AXIS]; Real hw = hd.length ()/4; @@ -105,7 +109,7 @@ Note_head::do_brew_molecule_p() const = lookup_l ()->ledger_line (Interval (hd[LEFT] - hw, hd[RIGHT] + hw)); - int parity = abs(int (position_f ())) % 2; + int parity = abs(int (p)) % 2; for (int i=0; i < streepjes_i; i++) { diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index c1bfea9317..ce6c46dcf5 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -10,6 +10,7 @@ #include "musical-request.hh" #include "dots.hh" #include "dot-column.hh" +#include "staff-symbol-referencer.hh" Note_heads_engraver::Note_heads_engraver() { @@ -61,19 +62,29 @@ Note_heads_engraver::do_process_requests() for (int i=0; i < note_req_l_arr_.size (); i++) { Note_head *note_p = new Note_head; + + Staff_symbol_referencer_interface si (note_p); + si.set_interface (); + + Note_req * note_req_l = note_req_l_arr_[i]; - note_p->balltype_i_ = note_req_l->duration_.durlog_i_ set_elt_property ("duration-log", + gh_int2scm (note_req_l->duration_.durlog_i_ duration_.dots_i_) { Dots * d = new Dots; + + Staff_symbol_referencer_interface sd (d); + sd.set_interface (); + note_p->add_dots (d); d->dots_i_ = note_req_l->duration_.dots_i_; announce_element (Score_element_info (d,0)); dot_p_arr_.push (d); } - note_p->set_position(note_req_l->pitch_.steps ()); + si.set_position(note_req_l->pitch_.steps ()); /* TODO: transparent note heads. diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 960dffd675..adb3b1f0ca 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -123,6 +123,17 @@ Paper_score::process () Array breaking = calc_breaking (); line_l_->break_into_pieces (breaking); + for (SCM s = element_smob_list_; gh_pair_p (s); s = gh_cdr (s)) + { + Score_element *sc = unsmob_element (gh_car (s)); + sc->do_break_processing (); + } + for (SCM s = element_smob_list_; gh_pair_p (s); s = gh_cdr (s)) + { + Score_element *sc = unsmob_element (gh_car (s)); + sc->handle_broken_dependencies (); + } + outputter_l_ = new Paper_outputter ; outputter_l_->output_header (); diff --git a/lily/pitch-squash-engraver.cc b/lily/pitch-squash-engraver.cc index 8218ff66c9..7ed7a8c085 100644 --- a/lily/pitch-squash-engraver.cc +++ b/lily/pitch-squash-engraver.cc @@ -6,6 +6,7 @@ (c) 1997--1999 Han-Wen Nienhuys */ +#include "staff-symbol-referencer.hh" #include "pitch-squash-engraver.hh" #include "note-head.hh" @@ -15,7 +16,7 @@ Pitch_squash_engraver::acknowledge_element (Score_element_info i) { if (Note_head *nh = dynamic_cast (i.elem_l_)) { - nh->set_position(0); + Staff_symbol_referencer_interface (nh).set_position(0); } } diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index 93b182591f..368f6fdae2 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -5,7 +5,7 @@ (c) 1997--1999 Han-Wen Nienhuys */ - +#include "staff-symbol-referencer.hh" #include "rest-engraver.hh" #include "musical-request.hh" #include "dots.hh" @@ -47,11 +47,19 @@ Rest_engraver::do_process_requests () if (rest_req_l_ && !rest_p_) { rest_p_ = new Rest; - rest_p_->balltype_i_ = rest_req_l_->duration_.durlog_i_; - + Staff_symbol_referencer_interface si (rest_p_); + si.set_interface (); + + rest_p_->set_elt_property ("duration-log", + gh_int2scm (rest_req_l_->duration_.durlog_i_)); + if (rest_req_l_->duration_.dots_i_) { dot_p_ = new Dots; + + Staff_symbol_referencer_interface si (dot_p_); + si.set_interface (); + rest_p_->add_dots (dot_p_); dot_p_->dots_i_ = rest_req_l_->duration_.dots_i_; announce_element (Score_element_info (dot_p_,0)); diff --git a/lily/rest.cc b/lily/rest.cc index 10455405f8..5caadb0999 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -13,30 +13,26 @@ #include "dots.hh" #include "axis-group-element.hh" #include "paper-score.hh" +#include "staff-symbol-referencer.hh" -void -Rest::do_add_processing () -{ - if (balltype_i_ == 0) - set_position (position_f () + 2); - - Rhythmic_head::do_add_processing (); -} void Rest::do_post_processing () { - Rhythmic_head::do_post_processing (); - if (dots_l () - && balltype_i_ > 4) // UGH. + if (balltype_i () == 0) + { + Staff_symbol_referencer_interface si (this); + si.set_position (si.position_f () + 2); + } + + Dots * d = dots_l (); + if (d && balltype_i () > 4) // UGH. { /* UGH. */ - if (balltype_i_ == 7) - dots_l ()->set_position (4); - else - dots_l ()->set_position (3); + staff_symbol_referencer_interface (d) + .set_position ((balltype_i () == 7) ? 4 : 3); } } @@ -46,18 +42,21 @@ Rest::do_brew_molecule_p () const { bool ledger_b =false; - if (balltype_i_ == 0 || balltype_i_ == 1) - ledger_b = abs(position_f () - (2* balltype_i_ - 1)) > lines_i (); - + if (balltype_i () == 0 || balltype_i () == 1) + { + Staff_symbol_referencer_interface si(this); + ledger_b = abs(si.position_f () - (2* balltype_i () - 1)) + > si.lines_i (); + } String style; SCM style_sym =get_elt_property ("style"); - if (balltype_i_ >= 2 && style_sym != SCM_UNDEFINED) + if (balltype_i () >= 2 && style_sym != SCM_UNDEFINED) { style = ly_scm2string (style_sym); } - String idx = ("rests-") + to_str (balltype_i_) + (ledger_b ? "o" : "") + style; + String idx = ("rests-") + to_str (balltype_i ()) + (ledger_b ? "o" : "") + style; return new Molecule(lookup_l ()->afm_find (idx)); } diff --git a/lily/rhythmic-head.cc b/lily/rhythmic-head.cc index 171c93cb7b..9e354bde2f 100644 --- a/lily/rhythmic-head.cc +++ b/lily/rhythmic-head.cc @@ -16,6 +16,7 @@ #include "axis-group-element.hh" #include "paper-score.hh" #include "stem.hh" +#include "staff-symbol-referencer.hh" Dots* @@ -25,6 +26,14 @@ Rhythmic_head::dots_l () const return dynamic_cast (unsmob_element (s)); } +int +Rhythmic_head::balltype_i () const +{ + SCM s = get_elt_property ("duration-log"); + + return gh_number_p (s) ? gh_scm2int (s) : 0; +} + Stem* Rhythmic_head::stem_l () const { @@ -41,9 +50,11 @@ Rhythmic_head::dots_i () const void Rhythmic_head::do_post_processing () { - if (dots_l ()) + if (Dots *d = dots_l ()) { - dots_l ()->set_position(int (position_f ())); + Staff_symbol_referencer_interface si (d); + Staff_symbol_referencer_interface me (d); + si.set_position(int (me.position_f ())); } } @@ -55,18 +66,4 @@ Rhythmic_head::add_dots (Dots *dot_l) dot_l->add_dependency (this); } -Rhythmic_head::Rhythmic_head () -{ - balltype_i_ =0; -} - - - -void -Rhythmic_head::do_print () const -{ -#ifndef NPRINT - DEBUG_OUT << "balltype = "<< balltype_i_ << "dots = " << dots_i (); -#endif -} diff --git a/lily/score-element.cc b/lily/score-element.cc index 45fbc03ed6..918550d158 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -9,6 +9,7 @@ #include +#include "group-interface.hh" #include "misc.hh" #include "paper-score.hh" #include "paper-def.hh" @@ -24,10 +25,9 @@ #include "misc.hh" #include "paper-outputter.hh" #include "dimension-cache.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" #include "item.hh" - Score_element::Score_element() { output_p_ =0; @@ -48,6 +48,9 @@ Score_element::Score_element() element_property_alist_ = SCM_EOL; smobify_self (); + + + set_elt_property ("dependencies", SCM_EOL); } SCM ly_deep_copy (SCM); @@ -78,7 +81,7 @@ Score_element::Score_element (Score_element const&s) should protect because smobify_self () might trigger GC. */ element_property_alist_ = scm_protect_object (ly_deep_copy (s.element_property_alist_)); - dependency_arr_ = s.dependency_arr_; + output_p_ =0; status_i_ = s.status_i_; lookup_l_ = s.lookup_l_; @@ -97,16 +100,17 @@ Score_element::~Score_element() delete dim_cache_[Y_AXIS]; } -Score_element* -Score_element::dependency (int i) const + +Real +Score_element::get_real (String s) const { - return dependency_arr_ [i]; + return gh_scm2double (get_elt_property (s)); } -int -Score_element::dependency_size () const +void +Score_element::set_real (String s, Real r) { - return dependency_arr_.size (); + set_elt_property (s, gh_double2scm (r)); } // should also have one that takes SCM arg. @@ -173,7 +177,6 @@ Score_element::print() const if (flower_dstream && !flower_dstream->silent_b ("Score_element")) ly_display_scm (element_property_alist_); - DEBUG_OUT << "dependencies: " << dependency_size(); if (original_l_) DEBUG_OUT << "Copy "; do_print(); @@ -185,7 +188,7 @@ Score_element::print() const Paper_def* Score_element::paper_l () const { - return pscore_l_->paper_l_; + return pscore_l_ ? pscore_l_->paper_l_ : 0; } Lookup const * @@ -245,8 +248,11 @@ Score_element::calculate_dependencies (int final, int busy, assert (status_i_!= busy); status_i_= busy; - for (int i=0; i < dependency_arr_.size(); i++) - dependency_arr_[i]->calculate_dependencies (final, busy, funcptr); + Link_array dependency_arr = + Group_interface__extract_elements (this, (Score_element*)0, "dependencies"); + + for (int i=0; i < dependency_arr.size(); i++) + dependency_arr[i]->calculate_dependencies (final, busy, funcptr); Link_array extra (get_extra_dependencies()); for (int i=0; i < extra.size(); i++) @@ -293,7 +299,6 @@ Score_element::output_processing () void Score_element::do_break_processing() { - handle_broken_dependencies(); } void @@ -345,8 +350,8 @@ Score_element::add_dependency (Score_element*e) { if (e) { - dependency_arr_.push (e); - e->used_b_ = true; + Group_interface gi (this, "dependencies"); + gi.add_element (e); } else programming_error ("Null dependency added"); @@ -400,12 +405,17 @@ Score_element::handle_broken_smobs (SCM s, SCM criterion) gh_set_car_x (s, handle_broken_smobs (gh_car (s), criterion)); gh_set_cdr_x (s, handle_broken_smobs (gh_cdr (s), criterion)); - if (gh_car (s) == SCM_UNDEFINED && gh_list_p (gh_cdr(s))) - return gh_cdr (s); + SCM c = gh_cdr(s); + + // gh_list_p () is linear, this is O(1) + bool list = gh_pair_p (c) || c == SCM_EOL; + + if (gh_car (s) == SCM_UNDEFINED && list) + return c; } return s; } - +#if 0 void Score_element::recurse_into_smobs (SCM s, void (Score_element::*meth_ptr)()) { @@ -420,6 +430,7 @@ Score_element::recurse_into_smobs (SCM s, void (Score_element::*meth_ptr)()) recurse_into_smobs (gh_cdr (s), meth_ptr); } } +#endif void Score_element::handle_broken_dependencies() @@ -435,27 +446,8 @@ Score_element::handle_broken_dependencies() line ? line->self_scm_ : SCM_UNDEFINED); - recurse_into_smobs (element_property_alist_, - &Score_element::handle_broken_dependencies); - if (!line) return; - - - Link_array new_deps; - - for (int i=0; i < dependency_size(); i++) - { - Score_element * elt = dependency (i); - if (elt->line_l() != line) - { - Score_element * broken = elt->find_broken_piece (line); - elt = broken ; - } - if (elt) - new_deps.push (elt); - } - dependency_arr_ = new_deps; } @@ -597,7 +589,7 @@ unsmob_element (SCM s) void Score_element::invalidate_cache (Axis a) { - dim_cache_[a]->invalidate (); + // dim_cache_[a]->invalidate (); } Score_element* diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index b39e2b0524..793ef46e97 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -9,7 +9,7 @@ #include "engraver.hh" #include "script-column.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" #include "dimension-cache.hh" /** @@ -60,7 +60,7 @@ Script_column_engraver::acknowledge_element( Score_element_info inf) if (!thing) return; - if (Side_position_interface (thing).is_staff_side_b ()) + if (Side_position_interface (thing).has_interface_b ()) { if (!thing->breakable_b () && Side_position_interface (thing).get_axis () == Y_AXIS) { diff --git a/lily/script-column.cc b/lily/script-column.cc index d9da8bc789..18a7fac8b0 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -7,7 +7,7 @@ */ #include "script-column.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" #include "dimension-cache.hh" #include "group-interface.hh" diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index cde149793f..bb38f28339 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -6,7 +6,7 @@ #include "script-engraver.hh" #include "script.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" #include "musical-request.hh" #include "stem.hh" #include "staff-symbol.hh" @@ -50,7 +50,8 @@ Script_engraver::do_process_requests() continue; } Script *p =new Script; - Side_position_interface stafy (p); + Side_position_interface stafy (p); + list = gh_cdr (list); p->set_elt_property ("molecule", diff --git a/lily/script.cc b/lily/script.cc index 430b03acfe..cc5db9d748 100644 --- a/lily/script.cc +++ b/lily/script.cc @@ -10,7 +10,7 @@ #include "debug.hh" #include "script.hh" #include "lookup.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" #include "paper-def.hh" #include "dimension-cache.hh" diff --git a/lily/spanner.cc b/lily/spanner.cc index dd3d24ead3..5fb0da4792 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -58,8 +58,6 @@ Spanner::break_into_pieces () span_p->set_bounds(RIGHT,bounds[RIGHT]); pscore_l_->typeset_element (span_p); - span_p->handle_broken_dependencies(); - broken_into_l_arr_.push (span_p); } @@ -106,7 +104,6 @@ void Spanner::do_break_processing() { break_into_pieces (); - handle_broken_dependencies(); } Spanner::Spanner () @@ -149,7 +146,7 @@ Score_element* Spanner::find_broken_piece (Line_of_score*l) const { Spanner* me = (Spanner*) this; - break_into_pieces (); + me->break_into_pieces (); int idx = binsearch_link_array (broken_into_l_arr_, (Spanner*)l, Spanner::compare); @@ -217,24 +214,12 @@ Spanner::get_broken_left_end_align () const if(sc != NULL && sc->break_status_dir () == RIGHT) { - // We could possibly return the right edge of the whole Score_column here, - // but we do a full search for the Break_align_item. - /* - In fact that doesn't make a difference, since the Score_column + + We used to do a full search for the Break_align_item. + But that doesn't make a difference, since the Score_column is likely to contain only a Break_align_item. */ -#if 0 - for(SCM s = sc->get_elt_property ("elements"); gh_pair_p (s); - s = gh_cdr (s)) - { - Score_element *e = SMOB_TO_TYPE (Score_element, gh_car (s)); - if(dynamic_cast (e)) - { - return e->extent (X_AXIS) [RIGHT]; - } - } -#endif return sc->extent (X_AXIS)[RIGHT]; } diff --git a/lily/staff-bar.cc b/lily/staff-bar.cc index 55167bbd32..bf62e781e0 100644 --- a/lily/staff-bar.cc +++ b/lily/staff-bar.cc @@ -8,6 +8,7 @@ */ #include "staff-bar.hh" +#include "staff-symbol-referencer.hh" Real Staff_bar::get_bar_size () const @@ -16,12 +17,9 @@ Staff_bar::get_bar_size () const if (gh_number_p (size)) return gh_scm2double (size); else - return (lines_i () -1) * staff_line_leading_f (); + { + Staff_symbol_referencer_interface si (this); + return (si.lines_i () -1) * si.staff_line_leading_f (); + } } -void -Staff_bar::do_pre_processing () -{ - Bar::do_pre_processing (); - Staff_symbol_referencer::do_pre_processing (); -} diff --git a/lily/staff-margin-engraver.cc b/lily/staff-margin-engraver.cc index dc67ca5cf4..bc52eb857d 100644 --- a/lily/staff-margin-engraver.cc +++ b/lily/staff-margin-engraver.cc @@ -10,7 +10,7 @@ #include "bar.hh" #include "timing-translator.hh" #include "text-item.hh" -#include "staff-side.hh" +#include "side-position-interface.hh" ADD_THIS_TRANSLATOR (Staff_margin_engraver); diff --git a/lily/staff-symbol-engraver.cc b/lily/staff-symbol-engraver.cc new file mode 100644 index 0000000000..9b2575a30f --- /dev/null +++ b/lily/staff-symbol-engraver.cc @@ -0,0 +1,94 @@ +/* + staff-sym-reg.cc -- implement Staff_symbol_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1997--1999 Han-Wen Nienhuys +*/ + +#include "staff-symbol.hh" +#include "score.hh" +#include "paper-column.hh" +#include "paper-def.hh" +#include "side-position-interface.hh" +#include "engraver.hh" +#include "moment.hh" + +/** + Manage the staff symbol. + */ +class Staff_symbol_engraver : public Engraver { + Staff_symbol *span_p_; +public: + VIRTUAL_COPY_CONS(Translator); + Staff_symbol_engraver(); + +protected: + virtual ~Staff_symbol_engraver(); + + virtual void acknowledge_element (Score_element_info); + virtual void do_removal_processing(); + virtual void do_creation_processing(); + +}; + + +Staff_symbol_engraver::~Staff_symbol_engraver() +{ + assert (!span_p_); +} + +Staff_symbol_engraver::Staff_symbol_engraver() +{ + span_p_ = 0; +} + +void +Staff_symbol_engraver::do_creation_processing() +{ + span_p_ = new Staff_symbol; + span_p_->set_bounds(LEFT,get_staff_info().command_pcol_l ()); + announce_element (Score_element_info (span_p_, 0)); +} + +void +Staff_symbol_engraver::do_removal_processing() +{ + SCM l (get_property ("numberOfStaffLines", 0)); + if (gh_number_p(l)) + { + span_p_->no_lines_i_ = gh_scm2int (l); + } + + SCM sz (get_property ("staffLineLeading", 0)); + if (gh_number_p(sz)) + { + span_p_->staff_line_leading_f_ = gh_scm2double (sz); + } + else + { + span_p_->staff_line_leading_f_ = paper_l ()->get_var ("interline"); + } + span_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ()); + typeset_element (span_p_); + span_p_ =0; +} + +void +Staff_symbol_engraver::acknowledge_element (Score_element_info s) +{ + s.elem_l_->set_elt_property ("staff-symbol", span_p_->self_scm_); + s.elem_l_->add_dependency (span_p_); // UGH. UGH. UGH + + SCM ss =s.elem_l_->remove_elt_property ("staff-support"); + if (gh_boolean_p (ss) && gh_scm2bool (ss)) + { + Side_position_interface si (s.elem_l_); + if (si.has_interface_b ()) + si.add_support (span_p_); + } +} + + +ADD_THIS_TRANSLATOR(Staff_symbol_engraver); + diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc new file mode 100644 index 0000000000..bd9d63bbcd --- /dev/null +++ b/lily/staff-symbol.cc @@ -0,0 +1,79 @@ +/* + staffsym.cc -- implement Staff_symbol + + source file of the GNU LilyPond music typesetter + + (c) 1997--1999 Han-Wen Nienhuys +*/ +#include "staff-symbol.hh" +#include "lookup.hh" +#include "dimensions.hh" +#include "paper-def.hh" +#include "molecule.hh" +#include "debug.hh" +#include "item.hh" + + +Staff_symbol::Staff_symbol () +{ + no_lines_i_ = 5; + staff_line_leading_f_ = 5.0 PT; +} + +void +Staff_symbol::do_print() const +{ +#ifndef NPRINT + Spanner::do_print(); + DEBUG_OUT << "lines: " << no_lines_i_; +#endif +} + + +Molecule* +Staff_symbol::do_brew_molecule_p() const +{ + Score_element * common + = spanned_drul_[LEFT]->common_refpoint (spanned_drul_[RIGHT], X_AXIS); + +#if 0 + Interval r = spanned_drul_[RIGHT]->extent (X_AXIS); + Interval l = spanned_drul_[LEFT]->extent (X_AXIS); + + Real left_shift =l.empty_b () ? 0.0: l[LEFT]; + Real right_shift =r.empty_b () ? 0.0: r[RIGHT]; +#endif + Real width = + // right_shift - left_shift + + spanned_drul_[RIGHT]->relative_coordinate (common , X_AXIS) + - spanned_drul_[LEFT]->relative_coordinate (common, X_AXIS) + ; + + Real t = paper_l ()->get_var ("stafflinethickness"); + Molecule rule = lookup_l ()->filledbox (Box (Interval (0,width), + Interval (-t/2, t/2))); + + Real height = (no_lines_i_-1) * staff_line_leading_f_ /2; + Molecule * m = new Molecule; + for (int i=0; i < no_lines_i_; i++) + { + Molecule a (rule); + a.translate_axis (height - i * staff_line_leading_f_, Y_AXIS); + m->add_molecule (a); + } + + // m->translate_axis (left_shift, X_AXIS); + return m; +} + + +int +Staff_symbol::steps_i() const +{ + return no_lines_i_*2; +} +Real +Staff_symbol::staff_line_leading_f () +{ + return staff_line_leading_f_; +} diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index cdb819767c..e6bd43c2bd 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -6,6 +6,7 @@ (c) 1997--1999 Han-Wen Nienhuys */ +#include "staff-symbol-referencer.hh" #include "stem-engraver.hh" #include "note-head.hh" #include "stem.hh" @@ -48,7 +49,10 @@ Stem_engraver::acknowledge_element(Score_element_info i) if (!stem_p_) { stem_p_ = new Stem; - stem_p_->flag_i_ = duration_log; + Staff_symbol_referencer_interface st(stem_p_); + st.set_interface (); + + stem_p_->set_elt_property ("duration-log", gh_int2scm (duration_log)); if (abbrev_req_l_) { @@ -75,9 +79,9 @@ Stem_engraver::acknowledge_element(Score_element_info i) announce_element (Score_element_info (stem_p_, r)); } - if (stem_p_->flag_i_ != duration_log) + if (stem_p_->flag_i () != duration_log) { - r->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << stem_p_->flag_i_)); + r->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << stem_p_->flag_i ())); } stem_p_->add_head (h); @@ -112,7 +116,7 @@ Stem_engraver::do_pre_move_processing() // UGH. Should mark non-forced instead. SCM dir = stem_p_->get_elt_property ("direction"); - if (gh_number_p (dir) && gh_int2scm (dir)) + if (gh_number_p (dir) && to_dir(dir)) { stem_p_->set_elt_property ("dir-forced", SCM_BOOL_T); } diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index d55cd55272..069ef6259c 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -15,6 +15,8 @@ #include "stem.hh" #include "offset.hh" #include "dimension-cache.hh" +#include "staff-symbol-referencer.hh" + Stem_tremolo::Stem_tremolo () { @@ -40,7 +42,8 @@ Interval Stem_tremolo::dim_callback (Dimension_cache const *c) { Stem_tremolo * s = dynamic_cast (c->element_l ()); - Real space = s->stem_l ()->staff_line_leading_f (); + Real space = Staff_symbol_referencer_interface (s->stem_l ()) + .staff_line_leading_f (); return Interval (-space, space); } @@ -52,28 +55,25 @@ Stem_tremolo::do_brew_molecule_p () const int mult =0; if (Beam * b = st->beam_l ()) { - Stem_info i = b->get_stem_info (st); - mult = i.mult_i_; + mult = b->multiplicity_i_; } Real interbeam_f = paper_l ()->interbeam_f (mult); Real w = gh_scm2double (get_elt_property ("beam-width")); - Real space = st->staff_line_leading_f (); - Real internote_f = space/2; - + Real space = Staff_symbol_referencer_interface (st).staff_line_leading_f (); + Real internote_f = space / 2; Real beam_f = gh_scm2double (get_elt_property ("beam-thickness")); int beams_i = 0; - Real slope_f = internote_f / 4 / internote_f; // HUH? + Real slope_f = 0.25; if (st && st->beam_l ()) { slope_f = st->beam_l ()->slope_f_; // ugh, rather calc from Stem_tremolo_req beams_i = st->beams_i_drul_[RIGHT] >? st->beams_i_drul_[LEFT]; } - Real sl = slope_f * internote_f; - Molecule a (lookup_l ()->beam (sl, w, beam_f)); + Molecule a (lookup_l ()->beam (slope_f, w, beam_f)); a.translate (Offset (-w/2, w / 2 * slope_f)); Molecule *beams= new Molecule; @@ -107,12 +107,7 @@ Stem_tremolo::do_brew_molecule_p () const ? -st->get_direction () * st->note_delta_f ()/2 : 0.0; - /* - UGH. Internote fudging. - */ - dy /= internote_f; dy += st->stem_end_f (); - dy *= internote_f; beams->translate (Offset(st->hpos_f () - hpos_f ()+ whole_note_correction, dy)); } diff --git a/lily/stem.cc b/lily/stem.cc index 1edd92bc53..a6ca3d3df5 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -4,6 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996, 1997--1999 Han-Wen Nienhuys + Jan Nieuwenhuizen TODO: This is way too hairy */ @@ -19,12 +20,12 @@ #include "beam.hh" #include "rest.hh" #include "group-interface.hh" +#include "cross-staff.hh" +#include "staff-symbol-referencer.hh" Stem::Stem () { beams_i_drul_[LEFT] = beams_i_drul_[RIGHT] = -1; - yextent_drul_[DOWN] = yextent_drul_[UP] = 0; - flag_i_ = 2; } Interval_t @@ -46,43 +47,38 @@ Stem::head_positions () const Interval_t r; for (int i =0; i < head_l_arr.size (); i++) { - int p = (int)head_l_arr[i]->position_f (); + Staff_symbol_referencer_interface si (head_l_arr[i]); + int p = (int)si.position_f (); r[BIGGER] = r[BIGGER] >? p; r[SMALLER] = r[SMALLER] balltype_i_; + return first_head ()->balltype_i (); } Note_head* @@ -135,7 +130,7 @@ Stem::add_head (Rhythmic_head *n) bool Stem::invisible_b () const { - return !(first_head () && first_head()->balltype_i_ >= 1); + return !(first_head () && first_head()->balltype_i () >= 1); } int @@ -158,8 +153,6 @@ Stem::get_default_dir () const return Direction (int(paper_l ()->get_var ("stem_default_neutral_direction"))); } - - void Stem::set_default_stemlen () { @@ -187,10 +180,10 @@ Stem::set_default_stemlen () if (((int)chord_start_f ()) && (get_direction () != get_default_dir ())) length_f -= shorten_f; - - if (flag_i_ >= 5) + + if (flag_i () >= 5) length_f += 2.0; - if (flag_i_ >= 6) + if (flag_i () >= 6) length_f += 1.0; set_stemend ((get_direction () > 0) ? head_positions()[BIGGER] + length_f: @@ -201,6 +194,13 @@ Stem::set_default_stemlen () set_stemend (0); } +int +Stem::flag_i () const +{ + SCM s = get_elt_property ("duration-log"); + return (gh_number_p (s)) ? gh_scm2int (s) : 2; +} + //xxx void Stem::set_default_extents () @@ -230,10 +230,11 @@ Stem::set_noteheads () head_l_arr.top ()->set_elt_property ("extremal", SCM_BOOL_T); int parity=1; - int lastpos = int (beginhead->position_f ()); + int lastpos = int (Staff_symbol_referencer_interface (beginhead).position_f ()); for (int i=1; i < head_l_arr.size (); i ++) { - int dy =abs (lastpos- (int)head_l_arr[i]->position_f ()); + Real p = Staff_symbol_referencer_interface (head_l_arr[i]).position_f (); + int dy =abs (lastpos- (int)p); if (dy <= 1) { @@ -243,14 +244,14 @@ Stem::set_noteheads () } else parity = 1; - lastpos = int (head_l_arr[i]->position_f ()); + lastpos = int (p); } } void Stem::do_pre_processing () { - if (yextent_drul_[DOWN]== yextent_drul_[UP]) + if (yextent_.empty_b ()) set_default_extents (); set_noteheads (); @@ -305,7 +306,7 @@ Stem::flag () const char c = (get_direction () == UP) ? 'u' : 'd'; Molecule m = lookup_l ()->afm_find (String ("flags-") + to_str (c) + - to_str (flag_i_)); + to_str (flag_i ())); if (!style.empty_b ()) m.add_molecule(lookup_l ()->afm_find (String ("flags-") + to_str (c) + style)); return m; @@ -317,7 +318,7 @@ Stem::dim_callback (Dimension_cache const* c) Stem * s = dynamic_cast (c->element_l ()); Interval r (0, 0); - if (s->get_elt_property ("beam") != SCM_UNDEFINED || abs (s->flag_i_) <= 2) + if (s->get_elt_property ("beam") != SCM_UNDEFINED || abs (s->flag_i ()) <= 2) ; // TODO! else { @@ -336,8 +337,9 @@ Molecule* Stem::do_brew_molecule_p () const { Molecule *mol_p =new Molecule; - Drul_array stem_y = yextent_drul_; - Real dy = staff_line_leading_f ()/2.0; + Interval stem_y = yextent_; + Real dy = staff_symbol_referencer_interface (this) + .staff_line_leading_f ()/2.0; Real head_wid = 0; if (first_head ()) @@ -353,7 +355,7 @@ Stem::do_brew_molecule_p () const } if (get_elt_property ("beam") == SCM_UNDEFINED - && abs (flag_i_) > 2) + && abs (flag_i ()) > 2) { Molecule fl = flag (); fl.translate_axis(stem_y[get_direction ()]*dy, Y_AXIS); @@ -398,3 +400,104 @@ Stem::beam_l ()const SCM b= get_elt_property ("beam"); return dynamic_cast (unsmob_element (b)); } + + +Stem_info +Stem::calc_stem_info () const +{ + assert (beam_l ()); + + SCM bd = get_elt_property ("beam-dir"); + Real internote_f + = staff_symbol_referencer_interface (this).staff_line_leading_f ()/2; + + Direction beam_dir; + Stem_info info; + + if (isdir_b (bd)) + { + beam_dir = to_dir (bd); + } + else + { + programming_error ("Beam direction not set."); + beam_dir = UP; // GURAUGRNAGURAGU! urg ! + } + + Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->multiplicity_i_); + Real beam_f = gh_scm2double (beam_l ()->get_elt_property ("beam-thickness")); + + info.idealy_f_ = chord_start_f (); + + // for simplicity, we calculate as if dir == UP + info.idealy_f_ *= beam_dir; + + bool grace_b = get_elt_property ("grace") != SCM_UNDEFINED; + bool no_extend_b = get_elt_property ("no-stem-extend") != SCM_UNDEFINED; + + int stem_max = (int)rint(paper_l ()->get_var ("stem_max")); + String type_str = grace_b ? "grace_" : ""; + Real min_stem_f = paper_l ()->get_var (type_str + "minimum_stem_length" + + to_str (beam_l ()->multiplicity_i_ get_var (type_str + "stem_length" + + to_str (beam_l ()->multiplicity_i_ multiplicity_i_) + { + info.idealy_f_ += beam_f; + info.idealy_f_ += (beam_l ()->multiplicity_i_ - 1) * interbeam_f; + } + info.miny_f_ = info.idealy_f_; + info.maxy_f_ = INT_MAX; + + info.idealy_f_ += stem_f; + info.miny_f_ += min_stem_f; + + /* + lowest beam of (UP) beam must never be lower than second staffline + + Hmm, reference (Wanske?) + + Although this (additional) rule is probably correct, + I expect that highest beam (UP) should also never be lower + than middle staffline, just as normal stems. + + */ + if (!grace_b && !no_extend_b) + { + //highest beam of (UP) beam must never be lower than middle staffline + info.miny_f_ = info.miny_f_ >? 0; + //lowest beam of (UP) beam must never be lower than second staffline + info.miny_f_ = info.miny_f_ >? (- 2 * internote_f - beam_f + + (beam_l ()->multiplicity_i_ > 0) * beam_f + interbeam_f * (beam_l ()->multiplicity_i_ - 1)); + } + } + else + /* knee */ + { + info.idealy_f_ -= beam_f; + info.maxy_f_ = info.idealy_f_; + info.miny_f_ = -INT_MAX; + + info.idealy_f_ -= stem_f; + info.maxy_f_ -= min_stem_f; + } + + info.idealy_f_ = info.maxy_f_ ? info.idealy_f_; + + Real interstaff_f = calc_interstaff_dist (this, beam_l ()); + info.idealy_f_ += interstaff_f * beam_dir; + + SCM s = get_elt_property ("shorten"); + if (s != SCM_UNDEFINED) + info.idealy_f_ -= gh_double2scm (s); + info.miny_f_ += interstaff_f * beam_dir; + info.maxy_f_ += interstaff_f * beam_dir; + + return info; +} + diff --git a/lily/tie.cc b/lily/tie.cc index 6959854d0f..f7ea46e801 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -11,10 +11,7 @@ #include "note-head.hh" #include "paper-column.hh" #include "debug.hh" -#include "group-interface.hh" - - - +#include "staff-symbol-referencer.hh" void Tie::set_head (Direction d, Note_head * head_l) @@ -22,7 +19,7 @@ Tie::set_head (Direction d, Note_head * head_l) assert (!head (d)); if (d == LEFT) gh_set_car_x (get_elt_property ("heads"), head_l->self_scm_ ); - else if (d == LEFT) + else if (d == RIGHT) gh_set_cdr_x (get_elt_property ("heads"), head_l->self_scm_ ); set_bounds (d, head_l); @@ -51,8 +48,10 @@ Tie::head (Direction d) const Direction Tie::get_default_dir () const { - int m = int (head (LEFT)->position_f () - + head (RIGHT)->position_f ()) /2; + Real p1 = Staff_symbol_referencer_interface (head (LEFT)).position_f () ; + Real p2 = Staff_symbol_referencer_interface (head (RIGHT)).position_f () ; + + int m = int (p1 + p2); /* If dir is not determined: inverse of stem: down @@ -84,7 +83,14 @@ Tie::do_add_processing() void Tie::do_post_processing() { - assert (head (LEFT) || head (RIGHT)); + if (!head (LEFT) && !head (RIGHT)) + { + programming_error ("Tie without heads."); + set_elt_property ("transparent", SCM_BOOL_T); + set_empty (X_AXIS); + set_empty (Y_AXIS); + return; + } Real interline_f = paper_l ()->get_var ("interline"); Real internote_f = interline_f / 2; @@ -167,8 +173,10 @@ Tie::do_post_processing() for smal slurs */ - Real ypos = head (LEFT) ? head (LEFT)->position_f () - : head (RIGHT)->position_f (); + + Real ypos = head (LEFT) + ? Staff_symbol_referencer_interface (head (LEFT)).position_f () + : Staff_symbol_referencer_interface (head (RIGHT)).position_f () ; Real y_f = internote_f * ypos; int ypos_i = int (ypos); diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index 48935c674c..7f047f908e 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -58,15 +58,8 @@ Vertical_align_engraver::do_removal_processing() bool Vertical_align_engraver::qualifies_b (Score_element_info i) const { -#if 0 - Translator * t = i.origin_trans_l_arr_[0]; -#endif int sz = i.origin_trans_l_arr_.size() ; -#if 0 - return (sz == 1 && dynamic_cast (t)) - || (sz == 2 && dynamic_cast (t)); -#endif Axis_group_element * elt = dynamic_cast (i.elem_l_); diff --git a/ly/params.ly b/ly/params.ly index 4e60c76a01..bbeba93841 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -29,7 +29,7 @@ stem_max = 3.0; %{ Specify length of stems for notes in the staff that don't have beams. - Measured in staff positions. + Measured in staff positions. %} stem_length0 = 7.; stem_length1 = 5.; @@ -63,7 +63,7 @@ grace_stem_length3 = \stem_length3 * \grace_factor; % only used for beams minimum_stem_length0 = 0.0 ; % not used -minimum_stem_length1 = 3. ; +minimum_stem_length1 = 3.; minimum_stem_length2 = 2.5; minimum_stem_length3 = 2.0; -- 2.39.5