From: Han-Wen Nienhuys Date: Sun, 5 Dec 1999 22:08:54 +0000 (+0100) Subject: patch::: 1.3.9.hwn2 X-Git-Tag: release/1.3.10~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9bc467a994787949def91708bf3bd50d088db982;p=lilypond.git patch::: 1.3.9.hwn2 pl 9.hwn1 - abstracting Staff_symbol_referencer to an interface. - quantised_position for staccato dots. - standchen fixes - junk Score_element::do_{width,height}: set callbacks directly. - merge Score_element, Graphical_element - merge Axis_group_element, Graphical_axis_group - junk pointer fields from * Single_malt_grouping_item * Separating_group_spanner * Stem_tremolo * Hara_kiri_vertical_group_spanner * Stem * Axis_group_element * Align_element * Beam ********** --- diff --git a/CHANGES b/CHANGES index dcf9175885..bcb9d4b971 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,22 @@ +pl 9.hwn1 + - abstracting Staff_symbol_referencer to an interface. + - quantised_position for staccato dots. + - standchen fixes + - junk Score_element::do_{width,height}: set callbacks directly. + - merge Score_element, Graphical_element + - merge Axis_group_element, Graphical_axis_group + - junk pointer fields from + * Single_malt_grouping_item + * Separating_group_spanner + * Stem_tremolo + * Hara_kiri_vertical_group_spanner + * Stem + * Axis_group_element + * Align_element + * Beam + +********** + pl 8.hwn2 - staff-support for Crescendi. - padding for accidentals. @@ -7,10 +26,9 @@ pl 8.hwn1 - note-head-side - naming Staff_sidify -> Side_position_interface - - *********** -pl7.mb1 + +pl 7.mb1 - bf: timeSignatureStyle works again pl 7.hwn1 diff --git a/VERSION b/VERSION index 9c66264a28..fe652d9364 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=9 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=hwn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/staccato-pos.sly b/input/test/staccato-pos.sly index 31bcd80900..aed9dc91de 100644 --- a/input/test/staccato-pos.sly +++ b/input/test/staccato-pos.sly @@ -1,3 +1,3 @@ -\stemup + e''4-. f-. d-. c,-. b-. c'''-. d-. diff --git a/lily/align-element.cc b/lily/align-element.cc index 9ccc1538d6..2297ddd017 100644 --- a/lily/align-element.cc +++ b/lily/align-element.cc @@ -13,63 +13,6 @@ #include "hash-table-iter.hh" #include "dimension-cache.hh" -struct Align_element_content { - Graphical_element * elem_l_; - int priority_i_; - - static int compare (Align_element_content const &h1, - Align_element_content const &h2) - { - return h1.priority_i_ - h2.priority_i_; - } - Align_element_content (Graphical_element *elem_l, int p) - { - priority_i_ = p; - elem_l_ = elem_l; - } - Align_element_content () { - elem_l_ = 0; - priority_i_ = 0; - } -}; - - - -void -Align_element::add_element (Score_element*el_l) -{ - int p = elem_l_arr_.size (); - add_element_priority (el_l, p); -} - -void -Align_element::add_element_priority (Score_element *el, int p) -{ - assert (! contains_b (el)); - Axis_group_element::add_element (el); - priority_i_hash_[el] = p; - add_dependency (el); -} - -void -Align_element::do_substitute_element_pointer (Score_element*o, - Score_element*n) -{ - Axis_group_element :: do_substitute_element_pointer (o,n); - if (o == center_l_) - { - center_l_ = n; - } - if (priority_i_hash_.elem_b (o)) - { - priority_i_hash_[n] = priority_i_hash_[o]; - /* - Huh? It seems the old pointers are still used. Why? - */ - // priority_i_hash_.remove (o); - } -} - void Align_element::do_post_processing() { @@ -90,12 +33,13 @@ Align_element::do_side_processing () Array dims; Link_array elems; - for (int i=0; i < elem_l_arr_.size(); i++) + Link_array all_elts (elem_l_arr ()); + for (int i=0; i < elem_l_arr ().size(); i++) { - Interval y = elem_l_arr_[i]->extent(axis ()) + elem_l_arr_[i]->relative_coordinate (this, axis ()); + Interval y = all_elts[i]->extent(axis ()) + all_elts[i]->relative_coordinate (this, axis ()); if (!y.empty_b()) { - Score_element *e =dynamic_cast(elem_l_arr_[i]); + Score_element *e =dynamic_cast(all_elts[i]); // todo: fucks up if item both in Halign & Valign. SCM min_dims = e->remove_elt_property ("minimum-space"); @@ -119,6 +63,10 @@ Align_element::do_side_processing () Real where_f=0; Real center_f = 0.0; + SCM scenter = get_elt_property ("center-element"); + Score_element *center_elt = (SMOB_IS_TYPE_B(Score_element,scenter)) + ? SMOB_TO_TYPE(Score_element,scenter) : 0; + for (int i=0 ; i < elems.size(); i++) { Real dy = - stacking_dir_ * dims[i][-stacking_dir_]; @@ -133,7 +81,7 @@ Align_element::do_side_processing () if (!i && align_dir_ == LEFT) center_f = where_f; - else if (align_dir_ == CENTER && elems[i] == center_l_) + else if (align_dir_ == CENTER && elems[i] == center_elt) center_f = where_f; where_f += stacking_dir_ * dy; @@ -144,7 +92,7 @@ Align_element::do_side_processing () where_f += dims.top ()[stacking_dir_]; if (align_dir_ == RIGHT) center_f = where_f; - else if (align_dir_ == CENTER && !center_l_) + else if (align_dir_ == CENTER && !center_elt) center_f = where_f / 2; if (center_f) @@ -159,8 +107,21 @@ Align_element::Align_element() threshold_interval_ = Interval (0, Interval::infinity ()); stacking_dir_ = DOWN; align_dir_ = CENTER; - center_l_ =0; - priority_i_hash_.hash_func_ = pointer_hash; +} + +int +Align_element::get_count (Score_element*s)const +{ + SCM e = get_elt_property ("elements"); + int c =0; + while (gh_pair_p (e)) + { + if (gh_car (e) == s->self_scm_) + break; + c++; + e = gh_cdr (e); + } + return c; } Axis @@ -176,62 +137,7 @@ Align_element::set_axis (Axis a) } -bool -Align_element::contains_b (Score_element const *e) const -{ - return elem_l_arr_.find_l (e); -} - -void -Align_element::sort_elements () -{ - Array content; - for (int i =0; i < elem_l_arr_.size(); i++) - { - Score_element * e = dynamic_cast (elem_l_arr_[i]); - assert (priority_i_hash_.elem_b (e)); - int p = priority_i_hash_[e]; - content.push (Align_element_content (e, p)); - } - content.sort (Align_element_content::compare); - - elem_l_arr_.clear(); - priority_i_hash_.clear(); - - for (int i =0; i < content.size(); i++) - { - elem_l_arr_.push (content[i].elem_l_); - } -} -void -Align_element::do_print () const -{ -#ifndef NPRINT - DEBUG_OUT << "contains: "; - for (int i=0 ; i < elem_l_arr_.size(); i++) - DEBUG_OUT << classname (elem_l_arr_[i]) << ", "; -#endif -} -Score_element* -Align_element::get_elt_by_priority (int p) const -{ - for (Hash_table_iter i(priority_i_hash_); i.ok (); i++) - { - if (i.val () == p) - return i.key(); - } - return 0; -} -int -Align_element::get_priority (Score_element const * e) const -{ - Score_element * nonconst = (Score_element*) e; - if ( priority_i_hash_.elem_b (nonconst)) - return priority_i_hash_[nonconst]; - else - return elem_l_arr_.find_i (nonconst); -} diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index bbba952ad2..6e1e805b3d 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -207,7 +207,7 @@ Auto_beam_engraver::create_beam_p () /* watch out for stem tremolos and abbreviation beams */ - if ((*stem_l_arr_p_)[i]->beam_l_) + if ((*stem_l_arr_p_)[i]->beam_l ()) { return 0; } @@ -334,7 +334,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info) return; } - if (stem_l->beam_l_) + if (stem_l->beam_l ()) { if (stem_l_arr_p_) junk_beam (); diff --git a/lily/axis-group-element.cc b/lily/axis-group-element.cc index c14b5186e5..306d9d481b 100644 --- a/lily/axis-group-element.cc +++ b/lily/axis-group-element.cc @@ -7,7 +7,7 @@ */ #include "axis-group-element.hh" -#include "graphical-axis-group.hh" +#include "axis-group-element.hh" #include "dimension-cache.hh" Link_array @@ -24,8 +24,11 @@ Axis_group_element::elem_l_arr () const ugh. I know */ Link_array r; - for (int i=0; i < elem_l_arr_.size (); i++) - r.push (dynamic_cast(elem_l_arr_[i])); + for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) + { + SCM e=gh_car (s); + r.push (dynamic_cast(SMOB_TO_TYPE (Score_element, e))); + } return r; } @@ -36,7 +39,6 @@ Axis_group_element::get_children () Link_array childs; Link_array elems = elem_l_arr (); - elems.concat (extra_elems_ ); for (int i=0; i < elems.size (); i++) { Score_element* e = elems[i]; @@ -49,69 +51,48 @@ Axis_group_element::get_children () return childs; } -void -Axis_group_element::do_print() const -{ - Graphical_axis_group::do_print(); -} - Axis_group_element::Axis_group_element() { + axes_[0] = (Axis)-1 ; + axes_[1] = (Axis)-1 ; + + set_elt_property ("elements", SCM_EOL); set_elt_property ("transparent", SCM_BOOL_T); } void Axis_group_element::set_axes (Axis a1, Axis a2) { - Graphical_axis_group::set_axes (a1,a2); - set_empty (a1 != X_AXIS && a2 != X_AXIS, X_AXIS); - set_empty (a1 != Y_AXIS && a2 != Y_AXIS, Y_AXIS); -} - - -void -Axis_group_element::do_substitute_element_pointer (Score_element*o, - Score_element*n) -{ - int i; - Graphical_element * go = o; - Graphical_element * gn = n; + axes_[0] = a1 ; + axes_[1] = a2 ; + if (a1 != X_AXIS && a2 != X_AXIS) + set_empty (X_AXIS); + if (a1 != Y_AXIS && a2 != Y_AXIS) + set_empty (Y_AXIS); - while ((i = elem_l_arr_.find_i (go))>=0) - elem_l_arr_.substitute (go,gn); - - extra_elems_.substitute (o, n); + dim_cache_[a1]->set_callback(extent_callback); + dim_cache_[a2]->set_callback (extent_callback); } Interval -Axis_group_element::extra_extent (Axis a )const +Axis_group_element::extent_callback (Dimension_cache const *c) { - Interval g; - Axis_group_element* urg = (Axis_group_element*)this; - urg->purge_extra (); // Yeah yeah, const correctness. - for (int i=0; i < extra_elems_.size (); i++) + Axis a = c->axis (); + Axis_group_element * me + = dynamic_cast (c->element_l ()); + + Interval r; + for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) { - Interval ge = extra_elems_[i]->relative_coordinate (this, a) - + extra_elems_[i]->extent (a); - g.unite (ge); - } - return g; -} + SCM e=gh_car (s); + Score_element * se = dynamic_cast(SMOB_TO_TYPE (Score_element, e)); -Interval -Axis_group_element::do_height () const -{ - Interval gag = Graphical_axis_group::extent (Y_AXIS); - gag.unite (extra_extent (Y_AXIS)); - return gag; -} + Interval dims = se->extent (a); + if (!dims.empty_b ()) + r.unite (dims + se->relative_coordinate (me, a)); + } -Interval -Axis_group_element::do_width () const -{ - Interval gag = Graphical_axis_group::extent (X_AXIS); - gag.unite (extra_extent (X_AXIS)); - return gag; + return r; } @@ -121,49 +102,31 @@ Axis_group_element::do_width () const void Axis_group_element::add_extra_element (Score_element *e) { - Link_array se; - while (e && e != this) - { - se.push (e); - e = dynamic_cast (e->parent_l (Y_AXIS)); - } - - if (1) // e == this) - { - for (int i=0; i < se.size( ); i++) - { - extra_elems_.push (se[i]); - add_dependency (se[i]); - se[i]->set_elt_property (("Axis_group_element::add_extra_element"), SCM_BOOL_T); // UGH GUH. - } - - } + add_element (e); } -/* - UGH GUH - */ + void -Axis_group_element::purge_extra () +Axis_group_element::add_element (Score_element *e) { - for (int i=0; i < extra_elems_.size ();) + used_b_ =true; + e->used_b_ = true; + + for (int i = 0; i < 2; i++) { - Score_element *e = extra_elems_[i]; - while (e && e != this) - { - e = dynamic_cast (e->parent_l (Y_AXIS)); - } - if (e != this) - extra_elems_.del (i); - else - i++; + 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); } -Interval -Axis_group_element::extent (Axis a) const -{ - return Graphical_element::extent (a); -} - + + + + + diff --git a/lily/axis-group-item.cc b/lily/axis-group-item.cc index 5068ecd099..fdbcf9cf29 100644 --- a/lily/axis-group-item.cc +++ b/lily/axis-group-item.cc @@ -10,20 +10,10 @@ -void -Axis_group_item::OK() const -{ - Link_array elems = elem_l_arr (); - for (int i=0; i < elems.size(); i++) - { - Item * it_l = dynamic_cast (elems[i]); - assert (it_l); - } -} - void Axis_group_item::do_breakable_col_processing() { +#if 0 if (!breakable_b ()) // ugh should merge with Item code return; @@ -45,12 +35,7 @@ Axis_group_item::do_breakable_col_processing() } while (flip(&j)!=LEFT); } +#endif Item::do_breakable_col_processing(); } -void -Axis_group_item::do_print() const -{ - Axis_group_element::do_print(); - Item::do_print (); -} diff --git a/lily/axis-group-spanner.cc b/lily/axis-group-spanner.cc index 991cf10853..7af3118a11 100644 --- a/lily/axis-group-spanner.cc +++ b/lily/axis-group-spanner.cc @@ -18,6 +18,7 @@ void Axis_group_spanner::do_break_processing_if_unbroken() { +#if 0 Link_array elems = elem_l_arr (); Line_of_score *my_line = line_l(); for (int i=0; i < elems.size(); i++) @@ -46,11 +47,13 @@ Axis_group_spanner::do_break_processing_if_unbroken() } } +#endif } void Axis_group_spanner::do_break_processing() { + Spanner::do_break_processing (); bool breaking_self_b = ! Spanner::line_l(); if (!breaking_self_b) @@ -60,6 +63,7 @@ Axis_group_spanner::do_break_processing() return; } +#if 0 break_into_pieces (); Link_array loose_elems = elem_l_arr (); @@ -134,7 +138,8 @@ Axis_group_spanner::do_break_processing() else { broken_item->set_elt_property ("transparent", SCM_BOOL_T); - broken_item->set_empty (true); + broken_item->set_empty (X_AXIS); // UGH. + broken_item->set_empty (Y_AXIS); } } @@ -153,20 +158,9 @@ Axis_group_spanner::do_break_processing() } Spanner::do_break_processing(); +#endif } -void -Axis_group_spanner::do_print() const -{ - Axis_group_element::do_print(); - - Spanner::do_print (); -} -Interval -Axis_group_spanner::do_width () const -{ - return Spanner::do_width (); -} diff --git a/lily/bar.cc b/lily/bar.cc index ad6fb103f4..04214d4068 100644 --- a/lily/bar.cc +++ b/lily/bar.cc @@ -85,7 +85,7 @@ Bar::do_pre_processing () } if (type_str_ =="") - set_empty (true, X_AXIS); + set_empty (X_AXIS); } diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index e98ab84552..1d1a70addf 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -152,7 +152,7 @@ Beam_engraver::acknowledge_element (Score_element_info info) if (beam_p_) { Stem* stem_l = dynamic_cast (info.elem_l_); - if (!stem_l || stem_l->beam_l_) + if (!stem_l || stem_l->beam_l ()) return; diff --git a/lily/beam.cc b/lily/beam.cc index c489e8f6e7..10e1355d02 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -35,33 +35,45 @@ needs what, and what information should be available when. #include "stem.hh" #include "paper-def.hh" #include "lookup.hh" +#include "group-interface.hh" Beam::Beam () { + Group_interface g (this, "stems"); + g.set_interface (); + slope_f_ = 0; left_y_ = 0; multiple_i_ = 0; } +/* + TODO: Fix this class. This is wildly inefficient. + */ +Stem * +Beam::stem (int i)const +{ + return Group_interface__extract_elements ((Beam*) this, (Stem*) 0, "stems")[i]; +} + +int +Beam::stem_count ()const +{ + Group_interface gi (this); + return gi.count (); +} + + void Beam::add_stem (Stem*s) { -#if 0 - /* - should figure out why this didn't work. - - --hwn. - */ - if (!stems_.size ()) - { - set_parent (s, Y_AXIS); - } -#endif - stems_.push (s); + Group_interface gi (this); + gi.add_element (s); + s->add_dependency (this); - assert (!s->beam_l_); - s->beam_l_ = this; + assert (!s->beam_l ()); + s->set_elt_property ("beam", self_scm_); if (!spanned_drul_[LEFT]) set_bounds (LEFT,s); @@ -89,12 +101,12 @@ Beam::do_brew_molecule_p () const if (!sinfo_.size ()) return mol_p; - Real x0 = stems_[0]->hpos_f (); - for (int j=0; j hpos_f (); + for (int j=0; j 0)? stems_[j-1] : 0; - Stem * next = (j < stems_.size ()-1) ? stems_[j+1] :0; + Stem *i = stem (j); + Stem * prev = (j > 0)? stem (j-1) : 0; + Stem * next = (j < stem_count ()-1) ? stem (j+1) :0; Molecule sb = stem_beams (i, next, prev); Real x = i->hpos_f ()-x0; @@ -127,16 +139,16 @@ Beam::auto_knee (SCM gap, bool interstaff_b) { bool knee = false; int knee_y = 0; - Real internote_f = stems_[0]->staff_line_leading_f ()/2; + 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 < stems_.size (); i++) + 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)(stems_[i-1]->chord_start_f () / internote_f) + int l_y = (int)(stem (i-1)->chord_start_f () / internote_f) + (int)sinfo_[i-1].interstaff_f_; - int r_y = (int)(stems_[i]->chord_start_f () / internote_f) + int r_y = (int)(stem (i)->chord_start_f () / internote_f) + (int)sinfo_[i].interstaff_f_; int gap_i = r_y - l_y; @@ -154,12 +166,12 @@ Beam::auto_knee (SCM gap, bool interstaff_b) } if (knee) { - for (int i=0; i < stems_.size (); i++) + for (int i=0; i < stem_count (); i++) { - int y = (int)(stems_[i]->chord_start_f () / internote_f) + int y = (int)(stem (i)->chord_start_f () / internote_f) + (int)sinfo_[i].interstaff_f_; - stems_[i]->set_direction ( y < knee_y ? UP : DOWN); - stems_[i]->set_elt_property ("dir-forced", SCM_BOOL_T); + stem (i)->set_direction ( y < knee_y ? UP : DOWN); + stem (i)->set_elt_property ("dir-forced", SCM_BOOL_T); } } return knee; @@ -200,7 +212,7 @@ Beam::do_print () const void Beam::do_post_processing () { - if (stems_.size () < 2) + if (stem_count () < 2) { warning (_ ("beam with less than two stems")); set_elt_property ("transparent", SCM_BOOL_T); @@ -228,20 +240,15 @@ Beam::do_post_processing () set_stemlens (); } -void -Beam::do_substitute_element_pointer (Score_element*o,Score_element*n) -{ - if (Stem * os = dynamic_cast (o)) - stems_.substitute (os, - dynamic_cast (n)); -} +#if 0 Interval Beam::do_width () const { - return Interval (stems_[0]->hpos_f (), + return Interval (stem (0)->hpos_f (), stems_.top ()->hpos_f ()); } +#endif Direction Beam::get_default_dir () const @@ -252,9 +259,9 @@ Beam::get_default_dir () const count[UP] = count[DOWN] = 0; Direction d = DOWN; - for (int i=0; i get_direction () ? (1 + d * s->get_direction ())/2 : s->get_center_distance ((Direction)-d); @@ -313,9 +320,9 @@ void Beam::set_direction (Direction d) { Directional_spanner::set_direction (d); - for (int i=0; i set_elt_property ("beam-dir", gh_int2scm (d)); SCM force = s->remove_elt_property ("dir-forced"); @@ -390,16 +397,16 @@ Beam::check_stemlengths_f (bool set_b) void Beam::set_steminfo () { - if(!stems_.size ()) + if(!stem_count ()) return; assert (multiple_i_); int total_count_i = 0; int forced_count_i = 0; - for (int i=0; i < stems_.size (); i++) + for (int i=0; i < stem_count (); i++) { - Stem *s = stems_[i]; + Stem *s = stem (i); s->set_default_extents (); if (s->invisible_b ()) @@ -416,9 +423,9 @@ Beam::set_steminfo () + to_str (multiple_i_ hpos_f () - stems_[0]->hpos_f (); + Real dx_f = stem (stem_count () -1)->hpos_f () - stem (0)->hpos_f (); // urg, these y internote-y-dimensions - Real internote_f = stems_[0]->staff_line_leading_f ()/2; + 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; @@ -518,12 +525,12 @@ Beam::quantise_dy () if (q == ly_symbol2scm ("none")) return; - Real interline_f = stems_[0]->staff_line_leading_f (); + Real interline_f = stem (0)->staff_line_leading_f (); Real internote_f = interline_f / 2; Real staffline_f = paper_l ()->get_var ("stafflinethickness"); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));; - Real dx_f = stems_.top ()->hpos_f () - stems_[0]->hpos_f (); + Real dx_f = stem (stem_count () -1 )->hpos_f () - stem (0)->hpos_f (); // dim(y) = internote; so slope = (y/internote)/x Real dy_f = dx_f * abs (slope_f_ * internote_f); @@ -571,7 +578,7 @@ Beam::quantise_left_y (bool extend_b) hang straddle sit inter hang */ - Real space = stems_[0]->staff_line_leading_f (); + Real space = stem (0)->staff_line_leading_f (); Real internote_f = space /2; Real staffline_f = paper_l ()->get_var ("stafflinethickness"); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));; @@ -599,7 +606,7 @@ Beam::quantise_left_y (bool extend_b) // dim(left_y_) = internote Real dy_f = get_direction () * left_y_ * internote_f; - Real beamdx_f = stems_.top ()->hpos_f () - stems_[0]->hpos_f (); + Real beamdx_f = stem (stem_count () -1)->hpos_f () - stem (0)->hpos_f (); Real beamdy_f = beamdx_f * slope_f_ * internote_f; Array allowed_position; @@ -659,12 +666,12 @@ void Beam::set_beaming (Beaming_info_list *beaming) { Direction d = LEFT; - for (int i=0; i < stems_.size (); i++) + for (int i=0; i < stem_count (); i++) { do { - if (stems_[i]->beams_i_drul_[d] < 0) - stems_[i]->beams_i_drul_[d] = beaming->infos_.elem (i).beams_i_drul_[d]; + if (stem (i)->beams_i_drul_[d] < 0) + stem (i)->beams_i_drul_[d] = beaming->infos_.elem (i).beams_i_drul_[d]; } while (flip (&d) != LEFT); } @@ -674,18 +681,21 @@ Beam::set_beaming (Beaming_info_list *beaming) void Beam::do_add_processing () { - for (int i=0; i < stems_.size () ; i++) + for (int i=0; i < stem_count () ; i++) { Direction d = LEFT; do { - multiple_i_ = multiple_i_ >? stems_[i]->beams_i_drul_[d]; + multiple_i_ = multiple_i_ >? stem (i)->beams_i_drul_[d]; } while ((flip (&d)) != LEFT); } - if (stems_.size ()) + /* + Why? + */ + if (stem_count ()) { - stems_[0]->beams_i_drul_[LEFT] =0; - stems_.top()->beams_i_drul_[RIGHT] =0; + stem (0)->beams_i_drul_[LEFT] =0; + stem (stem_count () -1)->beams_i_drul_[RIGHT] =0; } } diff --git a/lily/bow.cc b/lily/bow.cc index 6033cfe926..ca967f0ee3 100644 --- a/lily/bow.cc +++ b/lily/bow.cc @@ -6,6 +6,7 @@ (c) 1997--1999 Han-Wen Nienhuys Jan Nieuwenhuizen */ +#include "dimension-cache.hh" #include "bow.hh" #include "debug.hh" @@ -51,13 +52,14 @@ Bow::center () const Ugh. Control points are too crude measures. */ Interval -Bow::do_height () const +Bow::dim_callback (Dimension_cache const* c) { Interval iv; - Array c (get_controls()); - for (int i=0; i < c.size (); i++) + Bow * b = dynamic_cast (c->element_l ()); + Array p (b->get_controls()); + for (int i=0; i < p.size (); i++) { - Real y = c[i][Y_AXIS]; + Real y = p[i][Y_AXIS]; iv.unite (Interval (y,y)); } return iv; @@ -92,7 +94,7 @@ Bow::get_encompass_offset_arr () const { Array offset_arr; offset_arr.push (Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT])); - offset_arr.push (Offset (do_width ().length () + dx_f_drul_[RIGHT], + offset_arr.push (Offset (spanner_length () + dx_f_drul_[RIGHT], dy_f_drul_[RIGHT])); return offset_arr; diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index 1d6c6cb891..e4c518834c 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -29,7 +29,7 @@ Break_align_item::do_pre_processing() align_dir_ = RIGHT; flip (&align_dir_); - sort_elements (); + Real interline= paper_l ()->get_var ("interline"); Link_array elems; diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index 452fda6c67..2ec5e9c569 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -11,6 +11,7 @@ /* CLEAN ME UP. */ + #include #include "bar.hh" #include "clef-engraver.hh" diff --git a/lily/clef-item.cc b/lily/clef-item.cc index 32a7d93273..838d06a808 100644 --- a/lily/clef-item.cc +++ b/lily/clef-item.cc @@ -15,6 +15,7 @@ #include "text-item.hh" #include "paper-score.hh" #include "dimension-cache.hh" +#include "staff-side.hh" void Clef_item::do_pre_processing() @@ -30,7 +31,7 @@ Clef_item::do_pre_processing() if (style == "transparent") { set_elt_property ("transparent", SCM_BOOL_T); - set_empty (true, X_AXIS); + set_empty (X_AXIS); } } @@ -53,22 +54,21 @@ Clef_item::do_add_processing () Text_item *g =0; SCM octave_dir = remove_elt_property ("octave-dir"); - if (octave_dir != SCM_UNDEFINED) + if (isdir_b (octave_dir)) { - Direction d = Direction (gh_scm2int (octave_dir)); g = new Text_item; + Side_position_interface spi (g); + spi.set_axis (Y_AXIS); + pscore_l_->typeset_element (g); g->text_str_ = "8"; g->set_elt_property ("style", gh_str02scm ("italic")); g->set_parent (this, Y_AXIS); g->set_parent (this, X_AXIS); - + g->set_elt_property ("direction", octave_dir); + add_dependency (g); // just to be sure. - - Real r = do_height ()[d] - g->extent (Y_AXIS)[-d]; - g->dim_cache_[Y_AXIS]->set_offset (r); - SCM my_vis = get_elt_property ("visibility-lambda"); if (my_vis != SCM_UNDEFINED) g->set_elt_property ("visibility-lambda", my_vis); diff --git a/lily/cross-staff.cc b/lily/cross-staff.cc index 47300e660d..ca44c30e9d 100644 --- a/lily/cross-staff.cc +++ b/lily/cross-staff.cc @@ -8,7 +8,7 @@ Real calc_interstaff_dist (Item const *item, Spanner const *span) { Real interstaff = 0.0; - Graphical_element *common = item->common_refpoint (span, Y_AXIS); + Score_element *common = item->common_refpoint (span, Y_AXIS); Align_element * align = dynamic_cast (common); if (align && align->axis() == Y_AXIS) { @@ -18,18 +18,18 @@ calc_interstaff_dist (Item const *item, Spanner const *span) interstaff = align->threshold_interval_[MIN]; - Graphical_element const * span_refpoint = span; + Score_element const * span_refpoint = span; while (span_refpoint->parent_l (Y_AXIS) != common) span_refpoint = span_refpoint->parent_l (Y_AXIS); - Graphical_element const * note_refpoint = item; + Score_element const * note_refpoint = item; while (note_refpoint->parent_l (Y_AXIS) != common) note_refpoint = note_refpoint->parent_l (Y_AXIS); int span_prio = - align->get_priority ((Score_element*) dynamic_cast (span_refpoint)); + align->get_count ((Score_element*) dynamic_cast (span_refpoint)); int item_prio = - align->get_priority ((Score_element*) dynamic_cast (note_refpoint)); + align->get_count ((Score_element*) dynamic_cast (note_refpoint)); /* our staff is lower -> interstaff *= -1 diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index b7cf04207a..aacf58aadc 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -8,17 +8,18 @@ #include "dimension-cache.hh" #include "parray.hh" -#include "graphical-element.hh" +#include "score-element.hh" + Dimension_cache::Dimension_cache (Dimension_cache const &d) { init(); callback_l_ = d.callback_l_; - empty_b_ = d.empty_b_; basic_offset_ = d.basic_offset_; extra_offset_ = d.extra_offset_; off_valid_b_ = d.off_valid_b_; off_callbacks_ = d.off_callbacks_; + parent_l_ = d.parent_l_; } Dimension_cache::Dimension_cache () @@ -38,7 +39,6 @@ Dimension_cache::init() dim_.set_empty (); parent_l_ =0; valid_b_ = false; - empty_b_ = false; off_valid_b_ = false; } @@ -127,38 +127,29 @@ Dimension_cache::common_refpoint (Dimension_cache const* s) const return (Dimension_cache*) common; } - - -void -Dimension_cache::set_empty (bool b) +Interval +Dimension_cache::point_dimension_callback (Dimension_cache const* ) { - if (empty_b_ != b) - { - empty_b_ = b; - if (!empty_b_) - invalidate (); - } -} + return Interval (0,0); +} Interval Dimension_cache::get_dim () const { Interval r; - if (empty_b_) + Dimension_cache *nc = ((Dimension_cache*)this); + if (!callback_l_) { - r.set_empty (); - return r; + nc->dim_.set_empty (); } - - if (!valid_b_) + else if (!valid_b_) { - Dimension_cache *nc = ((Dimension_cache*)this); + nc->dim_= (*callback_l_ ) (nc); nc->valid_b_ = true; } r=dim_; - return r; } diff --git a/lily/directional-spanner.cc b/lily/directional-spanner.cc index 1ef4574bd9..eb6b471fc6 100644 --- a/lily/directional-spanner.cc +++ b/lily/directional-spanner.cc @@ -1,4 +1,5 @@ #include "directional-spanner.hh" +#include "offset.hh" Direction Directional_spanner::get_default_dir() const @@ -13,7 +14,7 @@ Directional_spanner::do_pre_processing() set_direction (get_default_dir()); } - +#if 0 Offset Directional_spanner::center () const { @@ -21,3 +22,4 @@ Directional_spanner::center () const Offset o (w/2, 0); return o; } +#endif diff --git a/lily/dots.cc b/lily/dots.cc index 8eda51a6d2..6fc996328c 100644 --- a/lily/dots.cc +++ b/lily/dots.cc @@ -22,7 +22,8 @@ Dots::do_post_processing () if (!dots_i_) { set_elt_property ("transparent", SCM_BOOL_T); - set_empty (true, X_AXIS, Y_AXIS); + set_empty (X_AXIS); + set_empty (Y_AXIS); } else { diff --git a/lily/extender-spanner.cc b/lily/extender-spanner.cc index 513011d5c0..b9f4f487b5 100644 --- a/lily/extender-spanner.cc +++ b/lily/extender-spanner.cc @@ -10,7 +10,8 @@ TODO: too complicated implementation. Why the dx_drul?. */ - +# +#include "dimension-cache.hh" #include "box.hh" #include "debug.hh" #include "lookup.hh" @@ -23,16 +24,11 @@ Extender_spanner::Extender_spanner () : Directional_spanner () { dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0; + dim_cache_[Y_AXIS]->set_callback (Dimension_cache::point_dimension_callback); } -Offset -Extender_spanner::center () const -{ - Real dx = extent (X_AXIS).length (); - return Offset (dx / 2, 0); -} Molecule* Extender_spanner::do_brew_molecule_p () const @@ -51,11 +47,7 @@ Extender_spanner::do_brew_molecule_p () const return mol_p; } -Interval -Extender_spanner::do_height () const -{ - return Interval (0,0); -} + void Extender_spanner::do_post_processing () diff --git a/lily/gdb.cc b/lily/gdb.cc index 0df1e5085a..9404eb1c69 100644 --- a/lily/gdb.cc +++ b/lily/gdb.cc @@ -3,12 +3,12 @@ // thanks to GDBs wonderful casting abilities, we need these: Item* -to_item (Graphical_element* g) +to_item (Score_element* g) { return dynamic_cast(g); } Spanner* -to_spanner (Graphical_element*g) +to_spanner (Score_element*g) { return dynamic_cast(g); } diff --git a/lily/grace-position-engraver.cc b/lily/grace-position-engraver.cc index d45ea19b34..172f26968f 100644 --- a/lily/grace-position-engraver.cc +++ b/lily/grace-position-engraver.cc @@ -82,15 +82,15 @@ Grace_position_engraver::do_pre_move_processing () */ if (align_l_ && !align_l_->supported_b ()) { - Graphical_element * elt = align_l_->parent_l (X_AXIS); + Score_element * elt = align_l_->parent_l (X_AXIS); if (elt) return; warning (_("Unattached grace notes. Attaching to last musical column.")); Axis_group_element * ae = dynamic_cast (elt); - if (ae) + /* if (ae) ae->remove_element (align_l_); - else if (elt) + else if (elt)*/ align_l_->set_parent (0, X_AXIS); last_musical_col_l_->add_element (align_l_); } diff --git a/lily/graphical-axis-group.cc b/lily/graphical-axis-group.cc index e0cfcaf1ef..e69de29bb2 100644 --- a/lily/graphical-axis-group.cc +++ b/lily/graphical-axis-group.cc @@ -1,130 +0,0 @@ -/* - axis-group.cc -- implement Graphical_axis_group - - source file of the GNU LilyPond music typesetter - - (c) 1997--1999 Han-Wen Nienhuys -*/ - -#include "dimension-cache.hh" -#include "interval.hh" -#include "graphical-axis-group.hh" -#include "axis-group-element.hh" -#include "graphical-element.hh" -#include "debug.hh" - -/** don't copy anything: an element can only be in one - Graphical_axis_group at one time. */ -Graphical_axis_group::Graphical_axis_group(Graphical_axis_group const&s) -{ - axes_[0] = s.axes_[0]; - axes_[1] = s.axes_[1]; - ordered_b_ = s.ordered_b_; -} - -bool -Graphical_axis_group::contains_b (Graphical_element const *e) const -{ - return elem_l_arr_.find_l (e); -} - -Interval -Graphical_axis_group::extent (Axis axis) const -{ - Interval r; - for (int i=0; i < elem_l_arr_.size(); i++) - { - r.unite (elem_l_arr_[i]->extent (axis) - + elem_l_arr_[i]->relative_coordinate (this, axis) - ); - } - return r; -} - -void -Graphical_axis_group::add_element (Graphical_element*e, Axis a1 , Axis a2) -{ - used_b_ =true; - e->used_b_ = true; - - Axis as[2] = { - (a1 == NO_AXES) ? axes_[0] : a1, - (a2 == NO_AXES) ? axes_[1] : a2, - }; - - - - for (int i = 0; i < 2; i++) - { - if (e->parent_l (as[i])) - continue; - - e->set_parent (this, as[i]); - - // e->dim_cache_[as[i]]->dependencies_l_arr_.push (dim_cache_[as[i]]); - } - assert (e->parent_l(Y_AXIS) == this || e->parent_l (X_AXIS) == this); - elem_l_arr_.push (e); -} - - -/** - ugr. duplication of functionality with remove_all () - */ -void -Graphical_axis_group::remove_element (Graphical_element*e) -{ - assert (contains_b (e)); - if (ordered_b_) - elem_l_arr_.substitute (e,0); - else - elem_l_arr_.unordered_substitute (e,0); - - do_remove (e); -} - -void -Graphical_axis_group::do_remove (Graphical_element *e) -{ - for (int i=0; i< 2; i++) - { - Axis a=axes_[i]; - if (e->parent_l (a) != this) - continue; - e->set_parent (0, a); - // e->dim_cache_[a]->dependencies_l_arr_.clear (); - } -} - -void -Graphical_axis_group::remove_all () -{ - for (int i=0; i < elem_l_arr_.size(); i++) - do_remove (elem_l_arr_[i]); - - elem_l_arr_.clear (); -} - - -void -Graphical_axis_group::do_print() const -{ -#ifndef NPRINT - for (int i=0; i < elem_l_arr_.size(); i++) - DEBUG_OUT << classname(elem_l_arr_[i]) << " "; -#endif -} - -Graphical_axis_group::Graphical_axis_group () -{ - ordered_b_ = false; - axes_[0] = (Axis)-1 ; - axes_[1] = (Axis)-1 ; -} - -void -Graphical_axis_group::set_axes (Axis a1, Axis a2) -{ - axes_[0] = a1 ; - axes_[1] = a2 ; -} diff --git a/lily/graphical-element.cc b/lily/graphical-element.cc index 21a256bc3f..e69de29bb2 100644 --- a/lily/graphical-element.cc +++ b/lily/graphical-element.cc @@ -1,156 +0,0 @@ -/* - graphical-element.cc -- implement Graphical_element - - source file of the GNU LilyPond music typesetter - - (c) 1997--1999 Han-Wen Nienhuys -*/ - -#include "dimension-cache.hh" -#include "graphical-element.hh" -#include "graphical-axis-group.hh" -#include "debug.hh" - -Graphical_element::Graphical_element () -{ - dim_cache_[X_AXIS] = new Dimension_cache; - dim_cache_[Y_AXIS] = new Dimension_cache; - used_b_ = false; - init (); -} - -Graphical_element::Graphical_element (Graphical_element const &s) -{ - dim_cache_[X_AXIS] = new Dimension_cache (*s.dim_cache_[X_AXIS]); - dim_cache_[Y_AXIS] = new Dimension_cache (*s.dim_cache_[Y_AXIS]); - - used_b_ = true; - init (); -} - -void -Graphical_element::init () -{ - dim_cache_[X_AXIS]->elt_l_ = dim_cache_[Y_AXIS]->elt_l_ = this; -} - - -void -Graphical_element::translate_axis (Real y, Axis a) -{ - dim_cache_[a]->translate (y); -} - -Real -Graphical_element::relative_coordinate (Graphical_element const*e, Axis a) const -{ - return dim_cache_[a]->relative_coordinate (e ? e->dim_cache_[a] : 0); -} - -Graphical_element * -Graphical_element::common_refpoint (Graphical_element const* s, Axis a) const -{ - Dimension_cache *dim = dim_cache_[a]->common_refpoint (s->dim_cache_[a]); - if (!dim) - programming_error ("No common reference point"); - return dim ? dim->element_l () : 0; -} - -void -Graphical_element::translate (Offset offset) -{ - translate_axis (offset[Y_AXIS], Y_AXIS); - translate_axis (offset[X_AXIS], X_AXIS); -} - - -void -Graphical_element::set_empty (bool b, Axis a1, Axis a2) -{ - if (a1 != NO_AXES) - dim_cache_[a1]->set_empty (b); - if (a2 != NO_AXES) - dim_cache_[a2]->set_empty (b); -} - -/** - Return true if empty in both A1 direction and A2 dir. - */ -bool -Graphical_element::empty_b (Axis a) -{ - return dim_cache_[a]->empty_b (); -} - -Interval -Graphical_element::extent (Axis a) const -{ - Dimension_cache const * d = dim_cache_[a]; - - if (d->empty_b ()) - return Interval (); - - return d->get_dim (); -} - - -void -Graphical_element::do_print () const -{ -#ifndef NPRINT - DEBUG_OUT << '\n'; -#endif -} - -void -Graphical_element::invalidate_cache (Axis a) -{ - dim_cache_[a]->invalidate (); -} - -Graphical_element* -Graphical_element::parent_l (Axis a) const -{ - Dimension_cache*d= dim_cache_[a]->parent_l_; - return d ? d->elt_l_ : 0; -} - -Graphical_element::~Graphical_element () -{ - delete dim_cache_[X_AXIS]; - delete dim_cache_[Y_AXIS]; -} - -Graphical_element * -Graphical_element::common_refpoint (Link_array gs, Axis a) const -{ - Dimension_cache * common = dim_cache_[a]; - for (int i=0; i < gs.size (); i++) - { - common = common->common_refpoint (gs[i]->dim_cache_[a]); - } - - return common->element_l (); -} - -char const * -Graphical_element::name () const -{ - return classname (this); -} - -void -Graphical_element::print () const -{ -#ifndef NPRINT - DEBUG_OUT << classname (this) << "{\n"; - do_print (); - DEBUG_OUT << "}\n"; -#endif -} - -void -Graphical_element::set_parent (Graphical_element *g, Axis a) -{ - dim_cache_[a]->parent_l_ = g ? g->dim_cache_[a]: 0; -} diff --git a/lily/group-interface.cc b/lily/group-interface.cc new file mode 100644 index 0000000000..b91d50e936 --- /dev/null +++ b/lily/group-interface.cc @@ -0,0 +1,53 @@ +/* + group-interface.cc -- implement Group_interface + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ +#include "group-interface.hh" +#include "score-element.hh" + +Group_interface::Group_interface (Score_element* e) +{ + elt_l_ = e; + name_ = "elements"; +} + + +Group_interface::Group_interface (Score_element *e, String s) +{ + elt_l_ =e; + name_ = s; +} +bool +Group_interface::supports_interface_b () +{ + SCM el = elt_l_->get_elt_property (name_); + + return el == SCM_EOL || gh_pair_p (el); +} + + +void +Group_interface::add_element (Score_element*p) +{ + elt_l_->set_elt_property (name_, + gh_cons (p->self_scm_, elt_l_->get_elt_property (name_))); +} + +int +Group_interface::count () +{ + return scm_ilength (elt_l_->get_elt_property ("name")); +} + +void +Group_interface::set_interface () +{ + if (!supports_interface_b ()) + { + elt_l_->set_elt_property (name_, SCM_EOL); + } +} diff --git a/lily/hara-kiri-vertical-group-spanner.cc b/lily/hara-kiri-vertical-group-spanner.cc index 9ea5c23de1..99293896de 100644 --- a/lily/hara-kiri-vertical-group-spanner.cc +++ b/lily/hara-kiri-vertical-group-spanner.cc @@ -14,6 +14,7 @@ Hara_kiri_group_spanner::Hara_kiri_group_spanner() { + set_elt_property ("items-worth-living", SCM_EOL); set_axes(Y_AXIS,Y_AXIS); } @@ -21,13 +22,16 @@ void Hara_kiri_group_spanner::add_interesting_item (Item* n) { add_dependency (n); - interesting_items_.push (n); + set_elt_property ("items-worth-living", + gh_cons (n->self_scm_, + get_elt_property ("items-worth-living"))); } void Hara_kiri_group_spanner::do_post_processing () { - if (!interesting_items_.empty ()) + SCM worth = get_elt_property ("items-worth-living"); + if (worth != SCM_EOL && worth != SCM_UNDEFINED) return; Link_array childs = get_children (); @@ -38,24 +42,13 @@ Hara_kiri_group_spanner::do_post_processing () if ( line_l () != s->line_l ()) programming_error ("Killing other children too"); s->set_elt_property ("transparent", SCM_BOOL_T); - s->set_empty (true, X_AXIS, Y_AXIS); + s->set_empty (X_AXIS); + s->set_empty (Y_AXIS); } - set_empty (true); -} - -void -Hara_kiri_group_spanner::do_substitute_element_pointer (Score_element*o, Score_element*n) -{ - Axis_group_spanner::do_substitute_element_pointer (o,n); - if (Item *it = dynamic_cast (o)) - interesting_items_.substitute (it, dynamic_cast (n)); + set_empty (X_AXIS); + set_empty (Y_AXIS); } -void -Hara_kiri_group_spanner::do_print () const -{ - Axis_group_spanner::do_print (); -} diff --git a/lily/hyphen-spanner.cc b/lily/hyphen-spanner.cc index 5d2fa9598e..411ab3670d 100644 --- a/lily/hyphen-spanner.cc +++ b/lily/hyphen-spanner.cc @@ -20,20 +20,14 @@ #include "paper-column.hh" #include "paper-def.hh" #include "hyphen-spanner.hh" +#include "dimension-cache.hh" Hyphen_spanner::Hyphen_spanner () : Directional_spanner () { dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0; -} - -// UGH - is this even used? -Offset -Hyphen_spanner::center () const -{ - Real dx = extent (X_AXIS).length (); - return Offset (dx / 2, 0); + dim_cache_[Y_AXIS]->set_callback (Dimension_cache::point_dimension_callback); } Molecule* @@ -61,11 +55,6 @@ Hyphen_spanner::do_brew_molecule_p () const return mol_p; } -Interval -Hyphen_spanner::do_height () const -{ - return Interval (0,0); -} void Hyphen_spanner::do_post_processing () diff --git a/lily/include/align-element.hh b/lily/include/align-element.hh index ff8dddf6f6..f97b7c6162 100644 --- a/lily/include/align-element.hh +++ b/lily/include/align-element.hh @@ -24,12 +24,6 @@ document usage of this. */ class Align_element : public virtual Axis_group_element { - - /* - ugh. JUNKME - - */ - Hash_table priority_i_hash_; public: Interval threshold_interval_ ; @@ -49,20 +43,11 @@ public: Direction align_dir_; Axis axis () const; - Score_element * center_l_; Align_element (); void set_axis (Axis); - void add_element (Score_element*); - void add_element_priority (Score_element*, int); - bool contains_b (Score_element const*) const; - - Score_element *get_elt_by_priority (int) const; - int get_priority (Score_element const*) const; + int get_count (Score_element*)const; protected: - void sort_elements (); - virtual void do_print() const; - virtual void do_substitute_element_pointer (Score_element*,Score_element*); virtual void do_post_processing() ; virtual void do_pre_processing (); virtual void do_side_processing (); diff --git a/lily/include/axis-group-element.hh b/lily/include/axis-group-element.hh index ab81872b52..d2ea0b96ea 100644 --- a/lily/include/axis-group-element.hh +++ b/lily/include/axis-group-element.hh @@ -11,37 +11,42 @@ #define AXIS_GROUP_ELEMENT_HH #include "score-element.hh" -#include "graphical-axis-group.hh" + /** Treat a group of elements a unity in either or both axis sense . This is a wrapper around Axis_group_administration */ -class Axis_group_element : public virtual Score_element, - public virtual Graphical_axis_group +class Axis_group_element : public virtual Score_element { Link_array extra_elems_; -protected: - virtual void do_print() const; - virtual Link_array get_extra_dependencies() const; + /// modify fields of E for removal. + void do_remove (Score_element*e); void purge_extra (); - virtual void do_substitute_element_pointer (Score_element*,Score_element*); + + +protected: + virtual Link_array get_extra_dependencies() const; virtual Link_array elem_l_arr() const; + static Interval extent_callback (Dimension_cache const*); - virtual Interval do_height () const; - virtual Interval do_width () const; Interval extra_extent (Axis a) const; - - public: - /** - Override Graphical_axis_group::extent: make sure that - Graphical_element::extent() is used as the public entry point. */ - Interval extent (Axis a) const; + // keep array in order. + bool ordered_b_; + Link_array elem_l_arr_; + 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 @@ -51,9 +56,9 @@ public: Axis_group_element (); - virtual void set_axes (Axis,Axis); + void set_axes (Axis,Axis); - virtual Link_array get_children (); + Link_array get_children (); }; #endif // AXIS_GROUP_ELEMENT_HH diff --git a/lily/include/axis-group-item.hh b/lily/include/axis-group-item.hh index b3701a1534..8f59c298a2 100644 --- a/lily/include/axis-group-item.hh +++ b/lily/include/axis-group-item.hh @@ -21,8 +21,6 @@ class Axis_group_item : public virtual Axis_group_element, public virtual Item { protected: virtual void do_breakable_col_processing(); - void OK() const; - virtual void do_print() const; public: VIRTUAL_COPY_CONS(Score_element); }; diff --git a/lily/include/axis-group-spanner.hh b/lily/include/axis-group-spanner.hh index 0de8cc51ef..f81b7354c7 100644 --- a/lily/include/axis-group-spanner.hh +++ b/lily/include/axis-group-spanner.hh @@ -22,9 +22,6 @@ class Axis_group_spanner : public virtual Axis_group_element, void do_break_processing_if_unbroken(); protected: virtual void do_break_processing(); - virtual void do_print() const; - virtual Interval do_width () const; - public: VIRTUAL_COPY_CONS(Score_element); }; diff --git a/lily/include/beam.hh b/lily/include/beam.hh index de68f6f99c..cfcc305e65 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -28,14 +28,10 @@ slope_quantisation: 'none, 'normal or 'traditional */ class Beam : public Directional_spanner { public: - /** - The beams should be prevented to conflict with the stafflines, - especially at small slopes. - */ - enum Quantisation { NONE, NORMAL, TRADITIONAL }; - enum Dir_algorithm { /* DOWN=-1, UP=1, */ MAJORITY=2, MEAN, MEDIAN }; - - Link_array stems_; + + int stem_count ()const; + Stem * stem (int )const; + /** the slope of the beam in (staffpositions) per (X-dimension, in PT). UGH. standardise this for once and for all. @@ -61,7 +57,6 @@ public: VIRTUAL_COPY_CONS(Score_element); protected: - virtual Interval do_width () const; Offset center () const; Direction get_default_dir () const; void set_direction (Direction); @@ -71,7 +66,6 @@ protected: virtual void do_pre_processing (); virtual void do_post_processing (); - virtual void do_substitute_element_pointer (Score_element*, Score_element*); virtual void do_add_processing (); virtual void do_print() const; virtual Molecule*do_brew_molecule_p () const; diff --git a/lily/include/bow.hh b/lily/include/bow.hh index 58f7d5fb2c..da2e7a3f1d 100644 --- a/lily/include/bow.hh +++ b/lily/include/bow.hh @@ -33,7 +33,7 @@ protected: // virtual Interval do_width () const; Array get_controls () const; virtual Array get_encompass_offset_arr () const; - virtual Interval do_height () const; + static Interval dim_callback (Dimension_cache const*); Drul_array curve_extent_drul () const; Drul_array dy_f_drul_; diff --git a/lily/include/dimension-cache.hh b/lily/include/dimension-cache.hh index fc23932284..0a61bc2d74 100644 --- a/lily/include/dimension-cache.hh +++ b/lily/include/dimension-cache.hh @@ -25,10 +25,6 @@ typedef Real (*Offset_cache_callback)(Dimension_cache const *); class Dimension_cache { bool valid_b_; - /** Is this element dimensionless?. - This is private to guarantee correctness of the cache - */ - bool empty_b_; Interval dim_; /** The offset wrt. to the center of #parent_l_# @@ -36,18 +32,19 @@ class Dimension_cache Real extra_offset_; Real basic_offset_; - bool off_valid_b_; - - Graphical_element *elt_l_; - Dim_cache_callback callback_l_; - friend class Graphical_element; + Score_element *elt_l_; + friend class Score_element; void init (); public: Array off_callbacks_; - + /** + What to call to find extent. Nil means empty. + */ + Dim_cache_callback callback_l_; + static Interval point_dimension_callback (Dimension_cache const* ); Axis axis () const; Real get_offset () const; void set_callback (Dim_cache_callback); @@ -56,7 +53,7 @@ public: void set_offset_callback (Offset_cache_callback); Dimension_cache * parent_l_; - Graphical_element *element_l () const { return elt_l_; } + Score_element *element_l () const { return elt_l_; } void invalidate (); void invalidate_dependencies (); @@ -81,7 +78,7 @@ public: void set_offset (Real); bool valid_b () const { return valid_b_; } - bool empty_b() const { return empty_b_; } + bool empty_b() const; Interval get_dim () const; }; diff --git a/lily/include/directional-spanner.hh b/lily/include/directional-spanner.hh index e268b20b92..779a5ed9f4 100644 --- a/lily/include/directional-spanner.hh +++ b/lily/include/directional-spanner.hh @@ -17,7 +17,7 @@ class Directional_spanner : public Spanner, public Directional_element { public: /// offset of "center" relative to left-column/0-pos of staff - virtual Offset center() const; + // virtual Offset center() const; virtual Direction get_default_dir() const; VIRTUAL_COPY_CONS(Score_element); protected: diff --git a/lily/include/extender-spanner.hh b/lily/include/extender-spanner.hh index 3da4095ebf..e0268198e8 100644 --- a/lily/include/extender-spanner.hh +++ b/lily/include/extender-spanner.hh @@ -30,14 +30,11 @@ class Extender_spanner : public Directional_spanner { public: -Extender_spanner (); - Offset center () const; + Extender_spanner (); void set_textitem (Direction, Item*); protected: virtual Molecule* do_brew_molecule_p () const; - Interval do_height () const; - void do_post_processing (); VIRTUAL_COPY_CONS (Score_element); diff --git a/lily/include/graphical-axis-group.hh b/lily/include/graphical-axis-group.hh index 539f8d95e4..e69de29bb2 100644 --- a/lily/include/graphical-axis-group.hh +++ b/lily/include/graphical-axis-group.hh @@ -1,46 +0,0 @@ -/* - axis-group-administration.hh -- declare Graphical_axis_group - - source file of the GNU LilyPond music typesetter - - (c) 1997--1999 Han-Wen Nienhuys -*/ - - -#ifndef GRAPHICAL_AXIS_GROUP_HH -#define GRAPHICAL_AXIS_GROUP_HH - - -#include "parray.hh" -#include "axes.hh" -#include "real.hh" -#include "lily-proto.hh" -#include "graphical-element.hh" - -/** - Treat a group of graphical elements as an aggegrate. - */ -class Graphical_axis_group : public virtual Graphical_element { -private: - - /// modify fields of E for removal. - void do_remove (Graphical_element*e); -public: - // keep array in order. - bool ordered_b_; - Link_array elem_l_arr_; - Axis axes_[2]; - - Interval extent (Axis) const; - virtual void do_print() const; - Graphical_axis_group(Graphical_axis_group const&s); - Graphical_axis_group (); - virtual void set_axes (Axis,Axis); - void remove_all (); - - bool contains_b (Graphical_element const *) const; - void add_element (Graphical_element*, Axis = NO_AXES, Axis = NO_AXES); - void remove_element (Graphical_element*); -}; - -#endif // Graphical_axis_group_HH diff --git a/lily/include/graphical-element.hh b/lily/include/graphical-element.hh index eeb2582688..eab17f40b7 100644 --- a/lily/include/graphical-element.hh +++ b/lily/include/graphical-element.hh @@ -14,59 +14,13 @@ #include "lily-proto.hh" #include "interval.hh" #include "virtual-methods.hh" +#error + /** The 2d geometric aspects of a score-element. */ class Graphical_element { - void init (); -public: - Dimension_cache *dim_cache_[NO_AXES]; - - /** - Set this if anyone points to me, or if I point to anyone. - */ - bool used_b_; - - char const * name () const; - /** - Set empty in direction a1 and a2. If an argument is NO_AXES, it is ignored. - */ - void set_empty (bool b, Axis a1 = NO_AXES, Axis a2 = NO_AXES); - bool empty_b (Axis a1); - Graphical_element (); - Graphical_element (Graphical_element const&); - virtual ~Graphical_element (); - - void invalidate_cache (Axis); - Interval extent (Axis) const; - - /** - translate the symbol. - */ - void translate (Offset); - /** - translate in one direction - */ - - void translate_axis (Real, Axis); - - Real relative_coordinate (Graphical_element const* refp, Axis) const; - /** - Find the group-element which has both #this# and #s# - */ - Graphical_element*common_refpoint (Graphical_element const* s, Axis a) const; - Graphical_element*common_refpoint (Link_array elems, Axis a) const; - - /** - Set the parent refpoint of THIS to E - */ - void set_parent (Graphical_element* e, Axis); - - Graphical_element *parent_l (Axis a) const; - - virtual void do_print () const; - virtual void print () const; }; #endif // GRAPHICAL_ELEMENT_HH diff --git a/lily/include/group-interface.hh b/lily/include/group-interface.hh new file mode 100644 index 0000000000..06c20b10a3 --- /dev/null +++ b/lily/include/group-interface.hh @@ -0,0 +1,57 @@ +/* + group-interface.hh -- declare Group_interface + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ + +#ifndef GROUP_INTERFACE_HH +#define GROUP_INTERFACE_HH + +#include "lily-proto.hh" +#include "string.hh" +#include "lily-guile.hh" +#include "smobs.hh" + +struct Group_interface +{ + Score_element * elt_l_; + String name_; +public: + Group_interface (Score_element*); + Group_interface (Score_element*, String); + int count (); + bool supports_interface_b (); + void set_interface (); + void add_element (Score_element*); +}; + +/* + template + Link_array Group_interface__extract_elements (T *, String name); +*/ +template +Link_array +Group_interface__extract_elements (Score_element *elt, T *, String name) +{ + Link_array arr; + + for (SCM s = elt->get_elt_property (name); gh_pair_p (s); s = gh_cdr (s)) + { + SCM e = gh_car (s); + assert (SMOB_IS_TYPE_B(Score_element,e)); + Score_element* se = SMOB_TO_TYPE(Score_element, e); + arr.push (dynamic_cast (se)); + } + + arr.reverse (); + return arr; +} + + + + +#endif /* GROUP_INTERFACE_HH */ + diff --git a/lily/include/hara-kiri-vertical-group-spanner.hh b/lily/include/hara-kiri-vertical-group-spanner.hh index 7479e90b29..a6245449dd 100644 --- a/lily/include/hara-kiri-vertical-group-spanner.hh +++ b/lily/include/hara-kiri-vertical-group-spanner.hh @@ -25,11 +25,6 @@ public: void add_interesting_item (Item* n); protected: VIRTUAL_COPY_CONS(Score_element); - - virtual void do_substitute_element_pointer (Score_element*, Score_element*); - virtual void do_print ()const; - - Link_array interesting_items_; }; diff --git a/lily/include/hyphen-spanner.hh b/lily/include/hyphen-spanner.hh index e1316252c9..d7a15b6c00 100644 --- a/lily/include/hyphen-spanner.hh +++ b/lily/include/hyphen-spanner.hh @@ -22,7 +22,6 @@ class Hyphen_spanner : public Directional_spanner { public: Hyphen_spanner (); - Offset center () const; void set_textitem (Direction, Item*); protected: diff --git a/lily/include/item.hh b/lily/include/item.hh index be7d981d66..1c6135d999 100644 --- a/lily/include/item.hh +++ b/lily/include/item.hh @@ -46,6 +46,7 @@ public: /// I am really to be broken? bool breakable_b () const; + bool broken_b () const; bool broken_original_b () const; Direction break_status_dir () const; @@ -65,8 +66,7 @@ public: protected: virtual void do_breakable_col_processing(); virtual void handle_prebroken_dependencies(); - virtual void do_print() const; - virtual void handle_prebroken_dependents (); + //virtual void handle_prebroken_dependents (); void copy_breakable_items(); }; diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 0970b575dd..fae4e4d398 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -95,8 +95,6 @@ struct Font_metric; struct General_script_def; struct Global_translator; struct Grace_align_item; -struct Graphical_axis_group; -struct Graphical_element; struct Hara_kiri_group_spanner; struct Hara_kiri_line_group_engraver; struct Head_column; diff --git a/lily/include/line-of-score.hh b/lily/include/line-of-score.hh index 6d0bfa6634..a6b937a13f 100644 --- a/lily/include/line-of-score.hh +++ b/lily/include/line-of-score.hh @@ -15,7 +15,6 @@ class Line_of_score : public Axis_group_spanner, public Super_element { public: - Link_array cols_; int rank_i_; Line_of_score(); @@ -23,15 +22,14 @@ public: /// is #c# contained in #*this#? bool contains_b (Paper_column const *c) const; - Line_of_score * set_breaking (Array const&, int j); static int compare (Line_of_score* const &,Line_of_score* const &); - void output_all (bool last_line); + void break_into_pieces (Array const&); + void output_lines (); + void output_line (bool last_line); void add_column (Paper_column*); protected: - virtual void do_substitute_element_pointer (Score_element*, Score_element*); - virtual Link_array get_extra_dependencies () const; virtual void do_print() const; VIRTUAL_COPY_CONS(Score_element); }; diff --git a/lily/include/note-head.hh b/lily/include/note-head.hh index 3becb11874..308ff1c1eb 100644 --- a/lily/include/note-head.hh +++ b/lily/include/note-head.hh @@ -25,7 +25,7 @@ protected: Molecule make_molecule () const; - virtual Interval do_width () const; + static Interval dim_callback (Dimension_cache const*); virtual void do_pre_processing(); virtual Molecule* do_brew_molecule_p() const; }; diff --git a/lily/include/paper-score.hh b/lily/include/paper-score.hh index 7fad9b8b32..3d33f133bc 100644 --- a/lily/include/paper-score.hh +++ b/lily/include/paper-score.hh @@ -28,6 +28,9 @@ public: Paper_def *paper_l_; /// the columns, ordered left to right + /* + UGH. MOVE INTO LINE_OF_SCORE ?! + */ Link_array col_l_arr_; Paper_outputter *outputter_l_; @@ -35,6 +38,8 @@ public: Paper_score (); + void fixup_refpoints (); + /// add to bottom of pcols void add_column (Paper_column*); diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index 2f770ba431..ed4bc4ba8d 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -9,8 +9,8 @@ #include "parray.hh" #include "virtual-methods.hh" -#include "graphical-element.hh" #include "lily-guile.hh" +#include "lily-proto.hh" #include "smobs.hh" typedef void (Score_element::*Score_element_method_pointer) (void); @@ -34,7 +34,7 @@ Boolean (true iff defined) transparent -- do not calc. output */ -class Score_element : public virtual Graphical_element { +class Score_element { /** properties specific for this element. Destructor will not call scm_unprotect, so as to allow more flexible GC arrangements. The @@ -116,9 +116,7 @@ protected: int dependency_size () const; virtual void output_processing (); - virtual Interval do_height () const; - virtual Interval do_width () const; - + static Interval molecule_extent (Dimension_cache const*); /// do printing of derived info. virtual void do_print () const; @@ -138,37 +136,58 @@ protected: virtual void do_substitute_element_pointer (Score_element * , Score_element *); virtual void do_break_processing (); - virtual void handle_broken_dependencies (); - virtual void handle_prebroken_dependencies (); - virtual void handle_prebroken_dependents (); - virtual void handle_broken_dependents (); + virtual Link_array get_extra_dependencies () const; static Interval dim_cache_callback (Dimension_cache const*); public: + virtual void handle_broken_dependencies (); + virtual void handle_prebroken_dependencies (); + DECLARE_SMOBS; -}; + void init (); + +public: + Dimension_cache *dim_cache_[NO_AXES]; + + /** + Set this if anyone points to me, or if I point to anyone. + */ + bool used_b_; + + char const * name () const; + /** + Set empty in direction A. + */ + void set_empty (Axis a); + bool empty_b (Axis a) const; + void invalidate_cache (Axis); + Interval extent (Axis) const; + + /** + translate in one direction + */ + + void translate_axis (Real, Axis); + + Real relative_coordinate (Score_element const* refp, Axis) const; + /** + Find the group-element which has both #this# and #s# + */ + Score_element*common_refpoint (Score_element const* s, Axis a) const; + Score_element*common_refpoint (Link_array elems, Axis a) const; + + /** + Set the parent refpoint of THIS to E + */ + void set_parent (Score_element* e, Axis); + + Score_element *parent_l (Axis a) const; + void fixup_refpoint (); +}; -template -void -substitute_element_array (Link_array &arr, Line_of_score * to) -{ - Link_array newarr; - for (int i =0; i < arr.size (); i++) - { - T * t = arr[i]; - if (t->line_l () != to) - { - t = dynamic_cast (t->find_broken_piece (to)); - } - - if (t) - newarr.push (t); - } - arr = newarr; -} diff --git a/lily/include/separating-group-spanner.hh b/lily/include/separating-group-spanner.hh index 5f4f7e9d02..059a3ae7c8 100644 --- a/lily/include/separating-group-spanner.hh +++ b/lily/include/separating-group-spanner.hh @@ -12,21 +12,14 @@ #include "spanner.hh" - class Separating_group_spanner : public Spanner { - Link_array spacing_unit_l_arr_; public: - /** - extra space to add after postbreak. (FIXME). - */ - Real padding_f_ ; - Separating_group_spanner (); void add_spacing_unit (Single_malt_grouping_item*); + Separating_group_spanner(); protected: VIRTUAL_COPY_CONS(Score_element); virtual Array get_rods () const; - virtual void do_substitute_element_pointer (Score_element*,Score_element*); }; #endif /* SEPARATING_GROUP_SPANNER_HH */ diff --git a/lily/include/single-malt-grouping-item.hh b/lily/include/single-malt-grouping-item.hh index 2eb025b047..27477b05bd 100644 --- a/lily/include/single-malt-grouping-item.hh +++ b/lily/include/single-malt-grouping-item.hh @@ -21,16 +21,12 @@ class Single_malt_grouping_item : public Item { VIRTUAL_COPY_CONS(Score_element); - Link_array item_l_arr_; public: Single_malt_grouping_item (); Interval my_width () const; void add_item (Item*); - -protected: - virtual void do_substitute_element_pointer (Score_element*, Score_element*); - virtual void do_print () const; }; + #endif /* SINGLE_MALT_GROUPING_ITEM_HH */ diff --git a/lily/include/spacing-spanner.hh b/lily/include/spacing-spanner.hh index 0b8b10586a..fb249675c3 100644 --- a/lily/include/spacing-spanner.hh +++ b/lily/include/spacing-spanner.hh @@ -16,10 +16,10 @@ class Spacing_spanner : public Spanner { public: Spacing_spanner (); + VIRTUAL_COPY_CONS(Score_element); - Score_column *scol (int) const; - Array do_measure (int,int) const; - int col_count () const; + Array do_measure (Link_array) const; + protected: virtual Array get_springs () const; diff --git a/lily/include/span-bar.hh b/lily/include/span-bar.hh index 9290b5ae35..dad0191da4 100644 --- a/lily/include/span-bar.hh +++ b/lily/include/span-bar.hh @@ -34,10 +34,11 @@ public: protected: void evaluate_empty (); - virtual Interval do_width() const; + static Interval width_callback(Dimension_cache const*) ; + static Interval height_callback(Dimension_cache const*) ; + virtual void do_pre_processing(); virtual void do_post_processing(); - virtual Interval do_height () const; virtual void do_substitute_element_pointer (Score_element*,Score_element*); virtual Molecule * do_brew_molecule_p() const; }; diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index 3392804666..08c7f361f3 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -44,6 +44,7 @@ public: Spanner (); Spanner (Spanner const &); bool broken_b () const; + void do_break (); static int compare (Spanner * const &,Spanner * const &); virtual Array get_rods () const; @@ -62,10 +63,9 @@ protected: friend Axis_group_spanner; // UGH virtual void do_space_processing (); - void handle_broken_dependents (); + // void handle_broken_dependents (); virtual void do_break_processing (); - virtual Interval do_width () const; - virtual void do_print () const; + Real spanner_length () const; virtual Line_of_score*line_l () const; }; #endif diff --git a/lily/include/staff-side.hh b/lily/include/staff-side.hh index 690cf1d3bc..42c1e00289 100644 --- a/lily/include/staff-side.hh +++ b/lily/include/staff-side.hh @@ -24,8 +24,9 @@ public: 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; diff --git a/lily/include/staff-symbol-referencer.hh b/lily/include/staff-symbol-referencer.hh index f90fe8c1e3..e5f6751a75 100644 --- a/lily/include/staff-symbol-referencer.hh +++ b/lily/include/staff-symbol-referencer.hh @@ -19,28 +19,19 @@ */ class Staff_symbol_referencer : public virtual Score_element { - Real position_f_; - -protected: - Staff_symbol * staff_symbol_l_; - public: Staff_symbol_referencer (); void set_position (Real); - - void set_staff_symbol (Staff_symbol*); + static Real callback (Dimension_cache const*); + /** Leading are the lead strips between the sticks (lines) of typeface. ie. leading is vertical space. - */ Real staff_line_leading_f () const; Staff_symbol * staff_symbol_l () const; int lines_i () const; - virtual void do_substitute_element_pointer (Score_element*,Score_element*); - virtual void do_pre_processing (); - virtual Real position_f () const; - + Real position_f () const; }; #endif /* STAFF_SYMBOL_REFERENCER_HH */ diff --git a/lily/include/staff-symbol.hh b/lily/include/staff-symbol.hh index c15a1df10b..afe679d65b 100644 --- a/lily/include/staff-symbol.hh +++ b/lily/include/staff-symbol.hh @@ -26,7 +26,6 @@ public: int steps_i() const; protected: VIRTUAL_COPY_CONS(Score_element); - virtual Interval do_height () const; virtual Molecule* do_brew_molecule_p() const; virtual void do_print() const; }; diff --git a/lily/include/stem-tremolo.hh b/lily/include/stem-tremolo.hh index 617f2ed604..ef23aadfde 100644 --- a/lily/include/stem-tremolo.hh +++ b/lily/include/stem-tremolo.hh @@ -14,13 +14,12 @@ class Stem_tremolo : public Item { - Stem * stem_l_; protected: + Stem * stem_l () const; virtual void do_print () const; virtual Molecule *do_brew_molecule_p () const; - virtual void do_substitute_element_pointer (Score_element*, Score_element*); - virtual Interval do_width () const; - virtual void do_pre_processing (); + + static Interval dim_callback (Dimension_cache const*); public: int abbrev_flags_i_; Stem_tremolo (); diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 411848696b..9fad0e51db 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -63,7 +63,7 @@ public: don't print flag when in beam. our beam, for aligning abbrev flags */ - Beam* beam_l_; + Beam* beam_l () const; Drul_array beams_i_drul_; Stem (); @@ -100,7 +100,7 @@ protected: Molecule flag () const; virtual void do_substitute_element_pointer (Score_element*,Score_element*); virtual void do_pre_processing(); - virtual Interval do_width() const; + static Interval dim_callback (Dimension_cache const*); virtual Molecule* do_brew_molecule_p() const; void set_spacing_hints () ; diff --git a/lily/include/volta-spanner.hh b/lily/include/volta-spanner.hh index 636acf03bb..e3f30af740 100644 --- a/lily/include/volta-spanner.hh +++ b/lily/include/volta-spanner.hh @@ -32,7 +32,7 @@ protected: VIRTUAL_COPY_CONS (Score_element); virtual void do_add_processing (); - virtual Interval do_height () const; + static Interval dim_callback (Dimension_cache const*); virtual void do_post_processing (); virtual void do_substitute_element_pointer (Score_element*,Score_element*); }; diff --git a/lily/item.cc b/lily/item.cc index eba020f52b..283010a4bd 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -5,8 +5,8 @@ (c) 1997--1999 Han-Wen Nienhuys */ -#include "dimension-cache.hh" +#include "dimension-cache.hh" #include "paper-score.hh" #include "debug.hh" #include "item.hh" @@ -29,12 +29,6 @@ Item::breakable_b () const return (i) ? i->breakable_b () : get_elt_property( "breakable") != SCM_UNDEFINED; } -void -Item::do_print() const -{ -} - - Real Item::hpos_f() const { @@ -44,7 +38,7 @@ Item::hpos_f() const Line_of_score * Item::line_l() const { - Graphical_element *g = parent_l (X_AXIS); + Score_element *g = parent_l (X_AXIS); if (!g) return 0; return dynamic_cast (g)-> line_l (); @@ -54,10 +48,6 @@ Item::line_l() const void Item::copy_breakable_items() { - if (broken_to_drul_[LEFT] || broken_to_drul_[RIGHT] - || !breakable_b ()) - return ; - Drul_array new_copies; Direction i=LEFT; do @@ -76,7 +66,6 @@ Item::copy_breakable_items() broken_to_drul_[i]->try_visibility_lambda(); } while (flip(&i) != LEFT); - try_visibility_lambda (); } void @@ -91,32 +80,49 @@ Item::try_visibility_lambda () int empty = gh_scm2bool (gh_cdr (result)); if (empty) - set_empty (true, X_AXIS, Y_AXIS); + { + set_empty (X_AXIS); + set_empty ( Y_AXIS); + } if (trans) set_elt_property ("transparent", SCM_BOOL_T); } } +bool +Item::broken_b () const +{ + return broken_to_drul_[LEFT] || broken_to_drul_[RIGHT]; +} + void Item::do_break () { - copy_breakable_items(); - handle_prebroken_dependencies(); + if (broken_b ()) + return; + + if (breakable_b ()) + { + copy_breakable_items(); + handle_prebroken_dependencies(); - /* + /* Otherwise the broken items won't be pre_process()'ed. */ - add_dependency (broken_to_drul_[LEFT]); - add_dependency (broken_to_drul_[RIGHT]); + + if (broken_to_drul_[LEFT]) + { + add_dependency (broken_to_drul_[LEFT]); + add_dependency (broken_to_drul_[RIGHT]); + } + } + try_visibility_lambda (); // ugh. } void Item::do_breakable_col_processing() { - if (breakable_b ()) - do_break (); - else - try_visibility_lambda (); + do_break (); } Score_element* @@ -124,10 +130,14 @@ Item::find_broken_piece (Line_of_score*l) const { if (line_l() == l) return (Item*)(this); - else if (broken_to_drul_[LEFT] && broken_to_drul_[LEFT]->line_l() == l) - return broken_to_drul_[LEFT]; - else if (broken_to_drul_[RIGHT] && broken_to_drul_[RIGHT]->line_l() == l) - return broken_to_drul_[RIGHT]; + + Direction d = LEFT; + do { + Score_element *s = find_broken_piece (d); + if (s && s->line_l () == l) + return s; + } + while (flip (&d) != LEFT); return 0; } @@ -135,10 +145,14 @@ Item::find_broken_piece (Line_of_score*l) const Item* Item::find_broken_piece (Direction d) const { + Item * me = (Item *) (this); if (!d) - return (Item *) (this); // ugh - else - return dynamic_cast (broken_to_drul_[d]); + return me; + else + { + me->do_break (); + return dynamic_cast (broken_to_drul_[d]); + } } void @@ -174,7 +188,7 @@ Item::Item (Item const &s) broken_to_drul_[LEFT] = broken_to_drul_[RIGHT] =0; } - +#if 0 void Item::handle_prebroken_dependents () { @@ -213,6 +227,7 @@ Item::handle_prebroken_dependents () while ((flip (&d))!=LEFT); } } +#endif Direction Item::break_status_dir () const diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 6e7d4f9eec..20abc957b4 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -93,19 +93,10 @@ ly_parse_scm (char const* s, int* n) /* scm_m_quote doesn't use any env, but needs one for a good signature in GUILE. */ -// apparently env arg is ignored. SCM ly_quote_scm (SCM s) { -#if 0 - /* - This internal quote symbol breaks list->string and display, - and thus scm output. - */ - return scm_m_quote (scm_cons2 (SCM_EOL, s, SCM_EOL) ,SCM_EOL); -#else return gh_list (ly_symbol2scm ("quote"), s, SCM_UNDEFINED); -#endif } @@ -121,14 +112,6 @@ ly_symbol2string (SCM s) return String((Byte*)SCM_CHARS (s), (int) SCM_LENGTH(s)); } -#if 0 -SCM -ly_set_x (String name, SCM val) -{ - return scm_sysintern ((char*)name.ch_C(), val); - -} -#endif /** Read a file, and shove it down GUILE. GUILE also has file read @@ -288,3 +271,5 @@ to_dir (SCM s) { return (Direction) gh_scm2int (s); } + + diff --git a/lily/line-of-score.cc b/lily/line-of-score.cc index b648ea10c5..8d004831cd 100644 --- a/lily/line-of-score.cc +++ b/lily/line-of-score.cc @@ -12,47 +12,65 @@ #include "paper-column.hh" #include "paper-score.hh" #include "warn.hh" +#include "main.hh" +#include "debug.hh" Line_of_score::Line_of_score() { set_axes (Y_AXIS,X_AXIS); } -bool -Line_of_score::contains_b (Paper_column const* c) const + + +void +Line_of_score::output_lines () { - return cols_.find_l ((Paper_column*)(c)); + for (int i=0; i < broken_into_l_arr_.size (); i++) + { + Line_of_score *line_l = dynamic_cast (broken_into_l_arr_[i]); + + *mlog << '[' << flush; + line_l->post_processing (); + *mlog << i << flush; + line_l->output_line (i + 1 == broken_into_l_arr_.size ()); + *mlog << ']' << flush; + } } // const? -Line_of_score* -Line_of_score::set_breaking (Array const &breaking, int j) +void +Line_of_score::break_into_pieces (Array const &breaking) { - const Link_array &curline (breaking[j].cols_); - const Array &config (breaking[j].config_); - Line_of_score *line_l=0; + for (int i=0; i < breaking.size (); i++) + { + Line_of_score *line_l = dynamic_cast (clone()); + line_l->rank_i_ = i; + Link_array c (breaking[i].cols_); + pscore_l_->typeset_element (line_l); + line_l->set_bounds(LEFT,c[0]); + line_l->set_bounds(RIGHT,c.top ()); + for (int j=0; j < c.size(); j++) + { + c[i]->translate_axis (breaking[i].config_[j],X_AXIS); + c[i]->line_l_ = line_l; + } + + broken_into_l_arr_.push (line_l); + } - line_l = dynamic_cast (clone()); - line_l->rank_i_ = j; - - line_l->cols_ = curline; - line_l->set_bounds(LEFT,curline[0]); - line_l->set_bounds(RIGHT,curline.top()); - - for (int i=0; i < curline.size(); i++) + for (int i=0; i < broken_into_l_arr_.size (); i++) { - curline[i]->translate_axis (config[i],X_AXIS); - curline[i]->line_l_ = dynamic_cast (line_l); + broken_into_l_arr_[i]->handle_broken_dependencies (); } - broken_into_l_arr_.push (line_l); - return line_l; + handle_broken_dependencies (); } void Line_of_score::add_column (Paper_column*p) { - cols_.push (p); + set_elt_property ("columns", + gh_cons (p->self_scm_, get_elt_property ("columns"))); add_element (p); } @@ -63,28 +81,12 @@ Line_of_score::do_print() const Axis_group_spanner::do_print (); } -Link_array -Line_of_score::get_extra_dependencies () const -{ - Link_array r (Axis_group_spanner::get_extra_dependencies ()); - for (int i=0; i < cols_.size (); i++) - r.push (cols_[i]); - return r; -} - -void -Line_of_score::do_substitute_element_pointer (Score_element*o, Score_element*n) -{ - if (Paper_column *p = dynamic_cast(o)) - cols_.substitute (p, dynamic_cast(n)); -} - void -Line_of_score::output_all (bool last_line) +Line_of_score::output_line (bool last_line) { Interval i(extent(Y_AXIS)); if (i.empty_b()) - warning (_ ("Huh? Empty Line_of_score?")); + programming_error ("Huh? Empty Line_of_score?"); else translate_axis (- i[MAX], Y_AXIS); diff --git a/lily/note-column.cc b/lily/note-column.cc index 0f8bd3bc38..844ad7701a 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -157,13 +157,13 @@ Note_column::do_post_processing () if (!stem_l_ || !rest_b ()) return; - Beam * b = stem_l_->beam_l_; - if (!b || !b->stems_.size ()) + Beam * b = stem_l_->beam_l (); + if (!b || !b->stem_count ()) return; /* ugh. Should be done by beam. */ Direction d = stem_l_->get_direction (); - Real beamy = (stem_l_->hpos_f () - b->stems_[0]->hpos_f ()) * b->slope_f_ + b->left_y_; + Real beamy = (stem_l_->hpos_f () - b->stem(0)->hpos_f ()) * b->slope_f_ + b->left_y_; Real staff_space = rest_l_arr_[0]->staff_line_leading_f (); Real rest_dim = extent (Y_AXIS)[d]*2.0 /staff_space ; diff --git a/lily/note-head.cc b/lily/note-head.cc index f8e9195607..4a631d0515 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -14,15 +14,25 @@ #include "molecule.hh" #include "musical-request.hh" #include "stem.hh" +#include "dimension-cache.hh" void Note_head::flip_around_stem (Direction d) { - translate_axis (do_width ().length () * d, X_AXIS); + Real l= make_molecule ().dim_[X_AXIS].length (); + translate_axis (l * d, X_AXIS); +} + +Interval +Note_head::dim_callback (Dimension_cache const * c) +{ + Note_head* n = dynamic_cast (c->element_l ()); + return n->make_molecule ().dim_[X_AXIS]; } Note_head::Note_head () { + dim_cache_[X_AXIS]->callback_l_ = dim_callback; } void @@ -56,14 +66,7 @@ Note_head::compare (Note_head *const &a, Note_head * const &b) return sign(a->position_f () - b->position_f ()); } -/** - Don't account for ledgerlines in the width. - */ -Interval -Note_head::do_width () const -{ - return make_molecule ().dim_[X_AXIS]; -} + Molecule Note_head::make_molecule () const diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 7c5e0c2684..1b2f4caa8f 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -132,11 +132,14 @@ Paper_column::column_l () const } /* - ugh. + ugh. JUNKME */ void Paper_column::preprocess () { + /* + JUNKME + */ minimal_dists_arr_drul_[LEFT].sort (Column_rod::compare); minimal_dists_arr_drul_[RIGHT].sort (Column_rod::compare); spring_arr_drul_[LEFT].sort (Column_spring::compare); diff --git a/lily/paper-score.cc b/lily/paper-score.cc index e51b01cef3..4a78ff3fb3 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -114,13 +114,14 @@ Paper_score::process () print (); *mlog << _ ("Preprocessing elements...") << " " << flush; line_l_->breakable_col_processing (); + fixup_refpoints (); line_l_->pre_processing (); *mlog << '\n' << _ ("Calculating column positions...") << " " << flush; line_l_->space_processing (); Array breaking = calc_breaking (); - + line_l_->break_into_pieces (breaking); outputter_l_ = new Paper_outputter ; outputter_l_->output_header (); @@ -154,30 +155,10 @@ Paper_score::process () */ SCM before_output = outputter_l_->last_cons_; - Link_array lines; - for (int i=0; i < breaking.size (); i++) - { - Line_of_score *line_l = line_l_->set_breaking (breaking, i); - lines.push (line_l); - if (line_l != line_l_) - typeset_element (line_l); - } + fixup_refpoints (); + line_l_->output_lines (); - *mlog << "\n"; - *mlog << _ ("Line ... "); - line_l_->break_processing (); - for (int i=0; i < lines.size (); i++) - { - *mlog << '[' << flush; - - Line_of_score *line_l = lines[i]; - - line_l->post_processing (); - *mlog << i << flush; - line_l->output_all (i + 1 == lines.size ()); - *mlog << ']' << flush; - } SCM font_names = ly_quote_scm (all_fonts_global_p->font_descriptions ()); gh_set_cdr_x (before_output, @@ -222,3 +203,18 @@ Paper_score::broken_col_range (Item const*l, Item const*r) const return ret; } + + +void +Paper_score::fixup_refpoints () +{ + for (SCM s = element_smob_list_; gh_pair_p (s); s = gh_cdr (s)) + { + SCM e = gh_car (s); + if (SMOB_IS_TYPE_B(Score_element, e)) + { + Score_element * se = SMOB_TO_TYPE (Score_element,e ); + se->fixup_refpoint (); + } + } +} diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 52c0149bce..0b065747bb 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -138,6 +138,7 @@ Rest_collision::do_substitute_element_pointer (Score_element*o,Score_element*n) Rest_collision::Rest_collision() { set_elt_property ("transparent", SCM_BOOL_T); - set_empty (true, X_AXIS, Y_AXIS); + set_empty (X_AXIS); + set_empty (Y_AXIS); } diff --git a/lily/score-element.cc b/lily/score-element.cc index b87027a0c8..e8b5154c81 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -25,23 +25,20 @@ #include "paper-outputter.hh" #include "dimension-cache.hh" #include "staff-side.hh" - -Interval -Score_element::dim_cache_callback (Dimension_cache const*c) -{ - Score_element * e =dynamic_cast (c->element_l()); - if(e->dim_cache_[X_AXIS] == c) - return e->do_width (); - else - return e->do_height (); -} +#include "item.hh" Score_element::Score_element() { output_p_ =0; - dim_cache_[X_AXIS]->set_callback (dim_cache_callback); - dim_cache_[Y_AXIS]->set_callback (dim_cache_callback); + dim_cache_[X_AXIS] = new Dimension_cache; + dim_cache_[Y_AXIS] = new Dimension_cache; + dim_cache_[X_AXIS]->elt_l_ = dim_cache_[Y_AXIS]->elt_l_ = this; + + used_b_ = false; + + dim_cache_[X_AXIS]->set_callback (molecule_extent); + dim_cache_[Y_AXIS]->set_callback (molecule_extent); used_b_ = false; pscore_l_=0; lookup_l_ =0; @@ -53,9 +50,25 @@ Score_element::Score_element() smobify_self (); } +SCM ly_deep_copy (SCM); + +SCM +ly_deep_copy (SCM l) +{ + if (gh_pair_p (l)) + { + return gh_cons (ly_deep_copy (gh_car (l)), ly_deep_copy (gh_cdr (l))); + } + else + return l; +} + + Score_element::Score_element (Score_element const&s) - : Graphical_element (s) { + dim_cache_[X_AXIS] = new Dimension_cache (*s.dim_cache_[X_AXIS]); + dim_cache_[Y_AXIS] = new Dimension_cache (*s.dim_cache_[Y_AXIS]); + dim_cache_[X_AXIS]->elt_l_ = dim_cache_[Y_AXIS]->elt_l_ = this; self_scm_ = SCM_EOL; used_b_ = true; @@ -64,7 +77,7 @@ Score_element::Score_element (Score_element const&s) /* should protect because smobify_self () might trigger GC. */ - element_property_alist_ = scm_protect_object (scm_list_copy (s.element_property_alist_)); + 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_; @@ -72,6 +85,8 @@ Score_element::Score_element (Score_element const&s) pscore_l_ = s.pscore_l_; smobify_self (); + + } Score_element::~Score_element() @@ -79,6 +94,9 @@ Score_element::~Score_element() assert (!output_p_); assert (status_i_ >=0); status_i_ = -1; + + delete dim_cache_[X_AXIS]; + delete dim_cache_[Y_AXIS]; } Score_element* @@ -139,42 +157,27 @@ Score_element::set_elt_property (String k, SCM v) } Interval -Score_element::do_width() const +Score_element::molecule_extent(Dimension_cache const *c) { - Interval r; - - Molecule*m = output_p_ ? output_p_ : do_brew_molecule_p(); - r = m->extent().x (); - - if (!output_p_) - delete m; - - return r; + Score_element *s = dynamic_cast(c->element_l()); + Molecule*m = s->do_brew_molecule_p(); + return m->extent()[c->axis ()]; } -Interval -Score_element::do_height() const -{ - Interval r; - Molecule*m = output_p_ ? output_p_ : do_brew_molecule_p(); - r = m->extent().y (); - if (!output_p_) - delete m; - - return r; -} void Score_element::print() const { #ifndef NPRINT DEBUG_OUT << classname(this) << "{\n"; + + 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 "; - Graphical_element::do_print (); do_print(); DEBUG_OUT << "}\n"; @@ -330,7 +333,9 @@ Score_element::do_substitute_element_pointer (Score_element*,Score_element*) Molecule* Score_element::do_brew_molecule_p() const { - Molecule a (lookup_l ()->fill (Box (Interval (0,0), Interval (0,0)))); + Interval emp; + emp.set_empty (); + Molecule a (lookup_l ()->fill (Box (emp,emp))); return new Molecule (a); } @@ -372,7 +377,9 @@ Score_element::handle_broken_smobs (SCM s, SCM criterion) { Score_element *sc = SMOB_TO_TYPE (Score_element, s); - if (gh_number_p (criterion)) + if (criterion == SCM_UNDEFINED) + return SCM_UNDEFINED; + else if (gh_number_p (criterion)) { Item * i = dynamic_cast (sc); Direction d = to_dir (criterion); @@ -387,12 +394,14 @@ Score_element::handle_broken_smobs (SCM s, SCM criterion) Score_element * ln = SMOB_TO_TYPE (Score_element, criterion); Line_of_score * line = dynamic_cast (ln); Score_element * br =0; - if (sc->line_l () != line) + Line_of_score * dep_line = sc->line_l (); + if (dep_line != line) { br = sc->find_broken_piece (line); return (br) ? br->self_scm_ : SCM_UNDEFINED; } - + if (!dep_line) + return SCM_UNDEFINED; } } else if (gh_pair_p (s)) @@ -402,6 +411,9 @@ 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) + return gh_cdr (s); } return s; } @@ -410,11 +422,11 @@ void Score_element::handle_broken_dependencies() { Line_of_score *line = line_l(); + element_property_alist_ = handle_broken_smobs (element_property_alist_, + line ? line->self_scm_ : SCM_UNDEFINED); if (!line) return; - element_property_alist_ = handle_broken_smobs (element_property_alist_, - line->self_scm_); Link_array new_deps; @@ -431,7 +443,6 @@ Score_element::handle_broken_dependencies() new_deps.push (elt); } dependency_arr_ = new_deps; - } @@ -479,6 +490,7 @@ Score_element::handle_prebroken_dependencies() substitute_dependency (old_arr[i], new_arr[i]); } +#if 0 void Score_element::handle_prebroken_dependents() { @@ -488,6 +500,7 @@ void Score_element::handle_broken_dependents() { } +#endif @@ -509,8 +522,6 @@ Score_element::do_print () const { } - - Score_element* Score_element::find_broken_piece (Line_of_score*) const { @@ -535,8 +546,23 @@ Score_element::print_smob (SCM s, SCM port, scm_print_state *) scm_puts ("#name (), port); - scm_puts ("properties = ", port); - scm_display (sc->element_property_alist_, port); +#if 0 + for (SCM s = sc->element_property_alist_; gh_pair_p (s); s = gh_cdr (s)) + { + scm_display (gh_caar(s), port); + SCM val = gh_cdar(s); + if (SMOB_IS_TYPE_B (Score_element, val)) + { + scm_puts ("#<:", port); + scm_puts ((SMOB_TO_TYPE(Score_element,val))->name(), port); + scm_puts (">", port); + } + else + scm_display (val, port); + } +#endif + // scm_puts (" properties = ", port); + // scm_display (sc->element_property_alist_, port); scm_puts (" >", port); return 1; } @@ -555,3 +581,121 @@ Score_element::equal_p (SCM a, SCM b) return SCM_CDR(a) == SCM_CDR(b) ? SCM_BOOL_T : SCM_BOOL_F; } +void +Score_element::translate_axis (Real y, Axis a) +{ + dim_cache_[a]->translate (y); +} + +Real +Score_element::relative_coordinate (Score_element const*e, Axis a) const +{ + return dim_cache_[a]->relative_coordinate (e ? e->dim_cache_[a] : 0); +} + +Score_element * +Score_element::common_refpoint (Score_element const* s, Axis a) const +{ + Dimension_cache *dim = dim_cache_[a]->common_refpoint (s->dim_cache_[a]); + if (!dim) + programming_error ("No common reference point"); + return dim ? dim->element_l () : 0; +} + +void +Score_element::set_empty (Axis a) +{ + dim_cache_[a]->callback_l_ =0; +} + +bool +Score_element::empty_b (Axis a)const +{ + return !dim_cache_[a]->callback_l_; +} + +Interval +Score_element::extent (Axis a) const +{ + Dimension_cache const * d = dim_cache_[a]; + + return d->get_dim (); +} + + + + +/* + JUNKME + */ +void +Score_element::invalidate_cache (Axis a) +{ + dim_cache_[a]->invalidate (); +} + +Score_element* +Score_element::parent_l (Axis a) const +{ + Dimension_cache*d= dim_cache_[a]->parent_l_; + return d ? d->elt_l_ : 0; +} + +Score_element * +Score_element::common_refpoint (Link_array gs, Axis a) const +{ + Dimension_cache * common = dim_cache_[a]; + for (int i=0; i < gs.size (); i++) + { + common = common->common_refpoint (gs[i]->dim_cache_[a]); + } + + return common->element_l (); +} + +char const * +Score_element::name () const +{ + return classname (this); +} + + +void +Score_element::set_parent (Score_element *g, Axis a) +{ + dim_cache_[a]->parent_l_ = g ? g->dim_cache_[a]: 0; +} + +void +Score_element::fixup_refpoint () +{ + for (int a = X_AXIS; a < NO_AXES; a ++) + { + Axis ax = (Axis)a; + Score_element * par = parent_l (ax); + + if (!par) + continue; + + if (par->line_l () != line_l ()) + { + Score_element * newpar = par->find_broken_piece (line_l ()); + set_parent (newpar, ax); + } + + if (Item * i = dynamic_cast (this)) + { + Item *pari = dynamic_cast (par); + + if (pari && i) + { + Direction my_dir = i->break_status_dir () ; + if (my_dir!= pari->break_status_dir()) + { + Item *newpar = pari->find_broken_piece (my_dir); + set_parent (newpar, ax); + } + } + } + } +} diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index a959550a77..cde149793f 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -84,6 +84,9 @@ Script_engraver::do_process_requests() if (!follow_staff && ! xaxis) p->set_elt_property ("staff-support", SCM_BOOL_T); + if (!xaxis && follow_staff) + stafy.set_quantised (Y_AXIS); + p->set_elt_property ("script-priority", priority); script_p_arr_.push (p); diff --git a/lily/script.cc b/lily/script.cc index f523de37bb..430b03acfe 100644 --- a/lily/script.cc +++ b/lily/script.cc @@ -1,5 +1,5 @@ /* - script.cc -- implement Script + script.cc -- implement Script source file of the GNU LilyPond music typesetter @@ -44,7 +44,7 @@ Script::do_pre_processing () /* center my self on the note head. */ - Graphical_element * e = parent_l(X_AXIS); + Score_element * e = parent_l(X_AXIS); translate_axis (e->extent (X_AXIS).center (), X_AXIS); } diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index a07381b615..4da73f8dbc 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -37,20 +37,27 @@ Separating_group_spanner::get_rods () const { Array a; - for (int i=0; i < spacing_unit_l_arr_.size () -1; i++) + for (SCM s = get_elt_property ("elements"); gh_pair_p (s) && gh_pair_p (gh_cdr (s)); s = gh_cdr (s)) { - Single_malt_grouping_item *l =spacing_unit_l_arr_[i]; + SCM elt = gh_car (s); + if (!SMOB_IS_TYPE_B(Score_element, elt)) + continue; + + SCM next_elt = gh_cadr (s); + if (!SMOB_IS_TYPE_B(Score_element, next_elt)) + continue; + + Single_malt_grouping_item *l = dynamic_cast (SMOB_TO_TYPE(Score_element, elt)); Single_malt_grouping_item *lb = dynamic_cast(l->find_broken_piece (RIGHT)); - Single_malt_grouping_item *r = spacing_unit_l_arr_[i+1]; + Single_malt_grouping_item *r = dynamic_cast (SMOB_TO_TYPE(Score_element, next_elt)); Single_malt_grouping_item *rb = dynamic_cast(r->find_broken_piece (LEFT)); - a.push (make_rod(spacing_unit_l_arr_[i], spacing_unit_l_arr_[i+1])); + a.push (make_rod(l, r)); if (lb) { Rod rod(make_rod (lb, r)); - rod.distance_f_ += padding_f_; a.push (rod); } @@ -62,7 +69,6 @@ Separating_group_spanner::get_rods () const if (lb && rb) { Rod rod(make_rod (lb, rb)); - rod.distance_f_ += padding_f_; a.push (rod); } } @@ -73,22 +79,14 @@ Separating_group_spanner::get_rods () const void Separating_group_spanner::add_spacing_unit (Single_malt_grouping_item*i) { - spacing_unit_l_arr_.push (i); + set_elt_property ("elements", + gh_cons (i->self_scm_, + get_elt_property ("elements"))); add_dependency (i); } -void -Separating_group_spanner::do_substitute_element_pointer (Score_element*o, - Score_element*n) -{ - if (dynamic_cast (o)) - { - Single_malt_grouping_item*ns = dynamic_cast (n); - spacing_unit_l_arr_.substitute (dynamic_cast (o), ns); - } -} -Separating_group_spanner::Separating_group_spanner() +Separating_group_spanner::Separating_group_spanner () { - padding_f_ =0.0; + set_elt_property ("elements", SCM_EOL); } diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index b48a0e7689..b2ae354ab9 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -31,16 +31,6 @@ Separating_line_group_engraver::do_creation_processing () void Separating_line_group_engraver::do_removal_processing () { - SCM sz (get_property ("postBreakPadding", 0)); - if (gh_number_p(sz)) - { - sep_span_p_->padding_f_ = Real(sz); - } - else - { - sep_span_p_->padding_f_ = paper_l ()->get_realvar (ly_symbol2scm ("postBreakPadding")); - } - sep_span_p_->set_bounds (RIGHT, get_staff_info ().command_pcol_l ()); typeset_element (sep_span_p_); sep_span_p_ =0; diff --git a/lily/single-malt-grouping-item.cc b/lily/single-malt-grouping-item.cc index 39fcd793aa..4a9a9d929e 100644 --- a/lily/single-malt-grouping-item.cc +++ b/lily/single-malt-grouping-item.cc @@ -14,9 +14,11 @@ Single_malt_grouping_item ::Single_malt_grouping_item() { set_elt_property ("transparent", SCM_BOOL_T); + set_elt_property ("elements", SCM_EOL); // this is weird! , but needed! - set_empty (true, X_AXIS, Y_AXIS); + set_empty (X_AXIS); + set_empty ( Y_AXIS); } @@ -24,7 +26,10 @@ void Single_malt_grouping_item::add_item (Item* i) { assert (i); - item_l_arr_.push (i); + set_elt_property ("elements", + gh_cons (i->self_scm_, + get_elt_property ("elements"))); + add_dependency (i); } @@ -33,9 +38,16 @@ Single_malt_grouping_item::my_width () const { Paper_column * pc = column_l (); Interval w; - for (int i=0; i < item_l_arr_.size (); i++) + + for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) { - Item *il = item_l_arr_[i]; + SCM elt = gh_car (s); + if (!SMOB_IS_TYPE_B(Score_element, elt)) + continue; + + + + Item *il = dynamic_cast (SMOB_TO_TYPE (Score_element, elt)); if (pc != il->column_l ()) { /* this shouldn't happen, but let's continue anyway. */ @@ -57,25 +69,3 @@ Single_malt_grouping_item::my_width () const -void -Single_malt_grouping_item::do_substitute_element_pointer (Score_element*o, - Score_element*n) -{ - if (dynamic_cast (o)) - { - item_l_arr_.unordered_substitute (dynamic_cast (o), - dynamic_cast (n)); - } -} - -void -Single_malt_grouping_item::do_print () const -{ -#ifndef NDEBUG - for (int i=0; i < item_l_arr_.size (); i++) - { - DEBUG_OUT << classname (item_l_arr_[i]) << ", "; - } -#endif -} - diff --git a/lily/slur.cc b/lily/slur.cc index ae96ed9771..45e74b09df 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -181,7 +181,7 @@ Slur::do_post_processing () if ((stem_l->extent (Y_AXIS).empty_b () || !((stem_l->get_direction () == get_direction ()) && (get_direction () != d))) && !((get_direction () == stem_l->get_direction ()) - && stem_l->beam_l_ && (stem_l->beams_i_drul_[-d] >= 1))) + && stem_l->beam_l () && (stem_l->beams_i_drul_[-d] >= 1))) { dx_f_drul_[d] = spanned_drul_[d]->extent (X_AXIS).length () / 2; dx_f_drul_[d] -= d * x_gap_f; @@ -207,7 +207,7 @@ Slur::do_post_processing () /* side attached to beamed stem */ - if (stem_l->beam_l_ && (stem_l->beams_i_drul_[-d] >= 1)) + if (stem_l->beam_l () && (stem_l->beams_i_drul_[-d] >= 1)) { dy_f_drul_[d] = stem_l->extent (Y_AXIS)[get_direction ()]; dy_f_drul_[d] += get_direction () * 2 * y_gap_f; @@ -292,7 +292,7 @@ Slur::do_post_processing () Real dy_f = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT]; if (!fix_broken_b) dy_f -= interstaff_f; - Real dx_f = do_width ().length () + dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]; + Real dx_f = spanner_length ()+ dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]; /* Avoid too steep slurs. @@ -491,7 +491,7 @@ Slur::get_encompass_offset_arr () const offset_arr.push (o - origin); } - offset_arr.push (Offset (do_width ().length () + dx_f_drul_[RIGHT], + offset_arr.push (Offset (spanner_length ()+ dx_f_drul_[RIGHT], dy_f_drul_[RIGHT])); return offset_arr; diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index ece98451f7..69632b2af8 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -17,21 +17,11 @@ Spacing_spanner::Spacing_spanner () { + set_empty (X_AXIS); + set_empty (Y_AXIS); set_elt_property ("transparent", SCM_BOOL_T); } -int -Spacing_spanner::col_count () const -{ - return pscore_l_->line_l_->cols_.size (); -} - -Score_column * -Spacing_spanner::scol (int i)const -{ - return dynamic_cast (pscore_l_->line_l_->cols_[i]); -} - /* cut 'n paste from spring-spacer.cc @@ -48,31 +38,31 @@ Spacing_spanner::scol (int i)const */ Array -Spacing_spanner::do_measure (int col1, int col2) const +Spacing_spanner::do_measure (Link_array cols) const { - for (int i =col1; i < col2; i++) + for (int i =0 ; i < cols.size (); i++) { - scol (i)->preprocess (); - scol (i)->print (); + cols[i]->preprocess (); + cols[i]->print (); } Moment shortest; shortest.set_infinite (1); - for (int i =col1; i < col2; i++) + for (int i =0 ; i < cols.size (); i++) { - if (scol(i)->musical_b ()) + if (cols[i]->musical_b ()) { - shortest = shortest shortest_starter_mom_; + shortest = shortest shortest_starter_mom_; } } Array meas_springs; Real non_musical_space_strength = paper_l ()->get_var ("breakable_column_space_strength"); - for (int i= col1; i < col2; i++) + for (int i= 0; i < cols.size (); i++) { - Item * l = scol(i); - Item * r = scol(i+1); + Item * l = cols[i]; + Item * r = cols[i+1]; Item * lb = l->find_broken_piece (RIGHT); Item * rb = r->find_broken_piece (LEFT); @@ -99,7 +89,8 @@ Spacing_spanner::do_measure (int col1, int col2) const { left_distance = gh_scm2double (gh_cdr (hint)); } - else if (!lc->musical_b() && i+1 < col_count()) + // 2nd condition should be (i+1 < col_count()), ie. not the last column in score. FIXME + else if (!lc->musical_b() && i+1 < cols.size ()) { left_distance= default_bar_spacing (lc,rc,shortest); } @@ -295,13 +286,20 @@ Array Spacing_spanner::get_springs () const { Array springs; - int last_break =0; - for (int i=1; i < col_count (); i++) + + SCM last_col = pscore_l_->line_l_->get_elt_property ("columns"); + Link_array measure; + for (SCM s = last_col; gh_pair_p (s); s = gh_cdr (s)) { - if (scol (i)->breakable_b ()) + SCM elt = gh_car (s); + Score_column* sc = dynamic_cast (SMOB_TO_TYPE (Score_column, elt)); + measure.push (sc); + if (sc->breakable_b ()) { - springs.concat (do_measure (last_break, i)); - last_break = i; + measure.reverse (); + springs.concat (do_measure (measure)); + measure.clear (); + measure.push (sc); } } return springs; diff --git a/lily/span-bar.cc b/lily/span-bar.cc index fe85a4e6b6..34c9f39ea1 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -29,9 +29,10 @@ Span_bar::do_substitute_element_pointer (Score_element*o, Score_element*n) Interval -Span_bar::do_width () const +Span_bar::width_callback (Dimension_cache const * c) { - Molecule m = lookup_l ()->bar (type_str_, 40 PT, paper_l ()); + Span_bar* s= dynamic_cast (c->element_l ()); + Molecule m = s->lookup_l ()->bar (s->type_str_, 40 PT, s->paper_l ()); return m.extent (X_AXIS); } @@ -43,7 +44,7 @@ Span_bar::do_pre_processing () evaluate_empty (); - set_empty (false, Y_AXIS); // a hack to make mark scripts work. + // set_empty (false, Y_AXIS); // a hack to make mark scripts work. } void @@ -61,13 +62,14 @@ Span_bar::evaluate_empty () if (spanning_l_arr_.size () < 1) { set_elt_property ("transparent", SCM_BOOL_T); - set_empty (true, X_AXIS, Y_AXIS); - + set_empty (X_AXIS); + set_empty (Y_AXIS); } if (type_str_.empty_b ()) { set_elt_property ("transparent", SCM_BOOL_T); - set_empty (true); + set_empty (X_AXIS); + set_empty (Y_AXIS); } else if (type_str_ == "|:") { @@ -90,7 +92,7 @@ Span_bar::get_spanned_interval () const for (int i=0; i < spanning_l_arr_.size (); i++) { - Graphical_element*common = common_refpoint (spanning_l_arr_[i], Y_AXIS); + Score_element*common = common_refpoint (spanning_l_arr_[i], Y_AXIS); Real y = spanning_l_arr_[i]->relative_coordinate (common, Y_AXIS) - relative_coordinate (common, Y_AXIS); @@ -100,9 +102,10 @@ Span_bar::get_spanned_interval () const } Interval -Span_bar::do_height () const +Span_bar::height_callback (Dimension_cache const *c) { - return get_spanned_interval (); + Span_bar * s= dynamic_cast (c->element_l ()); + return s->get_spanned_interval (); } Molecule* @@ -126,5 +129,7 @@ Span_bar::do_brew_molecule_p () const Span_bar::Span_bar () { type_str_ = ""; + dim_cache_[X_AXIS]->set_callback (width_callback); + dim_cache_[Y_AXIS]->set_callback (height_callback); } diff --git a/lily/span-score-bar-engraver.cc b/lily/span-score-bar-engraver.cc index 770aa4c4c5..e4efbe0ec0 100644 --- a/lily/span-score-bar-engraver.cc +++ b/lily/span-score-bar-engraver.cc @@ -32,7 +32,7 @@ Span_bar* Piano_bar_engraver::get_span_bar_p () const { Span_bar *s= new Span_bar; - s->set_empty (true, X_AXIS); + s->set_empty (X_AXIS); s->type_str_ = "brace"; return s; } @@ -41,7 +41,7 @@ Span_bar* Staff_group_bar_engraver::get_span_bar_p () const { Span_bar *s= new Span_bar; - s->set_empty (true, X_AXIS); + s->set_empty (X_AXIS); s->type_str_ = "bracket"; return s; } diff --git a/lily/spanner.cc b/lily/spanner.cc index 5aa48681d4..9aeaaab407 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -16,24 +16,12 @@ #include "score-column.hh" #include "line-of-score.hh" -void -Spanner::do_print() const -{ -#ifndef NPRINT - DEBUG_OUT << "Between " << classname (spanned_drul_[LEFT]) - << " and " << classname (spanned_drul_[RIGHT]) << '\n'; - - if (broken_b ()) - DEBUG_OUT << "Broken in " << to_str (broken_into_l_arr_.size ()) << " pieces"; -#endif -} - void Spanner::break_into_pieces () { - if (broken_b ()) - return; - + if (line_l () || broken_b ()) + return; + Item * left = spanned_drul_[LEFT]; Item * right = spanned_drul_[RIGHT]; @@ -80,13 +68,13 @@ Spanner::break_into_pieces () void Spanner::set_my_columns() { - Direction i = (Direction)1; + Direction i = (Direction) LEFT; do { if (!spanned_drul_[i]->line_l()) - set_bounds(i,spanned_drul_[i]->find_broken_piece((Direction)-i)); + set_bounds(i,spanned_drul_[i]->find_broken_piece((Direction) -i)); } - while (flip(&i) != 1); + while (flip(&i) != LEFT); } void @@ -106,18 +94,18 @@ Spanner::set_bounds(Direction d, Item*i) set_parent (i, X_AXIS); } - if (spanned_drul_[Direction(-d)] == spanned_drul_[d] + if (spanned_drul_[Direction(-d)] == spanned_drul_[d] && i) warning (_f ("Spanner `%s' has equal left and right spanpoints", classname (this))); } + + void Spanner::do_break_processing() { - if (!line_l()) - break_into_pieces (); - else - handle_broken_dependencies(); + break_into_pieces (); + handle_broken_dependencies(); } Spanner::Spanner () @@ -133,8 +121,8 @@ Spanner::Spanner (Spanner const &s) } -Interval -Spanner::do_width() const +Real +Spanner::spanner_length() const { Real l = spanned_drul_[LEFT]->relative_coordinate (0, X_AXIS); Real r = spanned_drul_[RIGHT]->relative_coordinate (0, X_AXIS); @@ -142,7 +130,7 @@ Spanner::do_width() const if (r< l) warning (_ ("spanner with negative length")); - return Interval (0, r-l); + return r-l; } Line_of_score * @@ -159,22 +147,17 @@ Spanner::line_l() const Score_element* Spanner::find_broken_piece (Line_of_score*l) const { + Spanner* me = (Spanner*) this; + break_into_pieces (); + int idx = binsearch_link_array (broken_into_l_arr_, (Spanner*)l, Spanner::compare); + if (idx < 0) return 0; else return broken_into_l_arr_ [idx]; } -/* - for (int i=0; i < broken_into_l_arr_.size (); i++) - { - if (broken_into_l_arr_[i]->line_l () == l) - return broken_into_l_arr_[i]; - } - return 0; -*/ - int Spanner::compare (Spanner * const &p1, Spanner * const &p2) @@ -218,6 +201,7 @@ Spanner::do_space_processing () } } +#if 0 /* UGH. */ @@ -239,6 +223,7 @@ Spanner::handle_broken_dependents () programming_error ("Spanner y -refpoint lost."); } } +#endif /* If this is a broken spanner, return the amount the left end is to be @@ -254,7 +239,8 @@ Spanner::get_broken_left_end_align () const Score_column *sc = dynamic_cast (spanned_drul_[LEFT]->column_l()); // Relevant only if left span point is first column in line - if(sc != NULL && sc->line_l ()->cols_.find_i (sc) == 0) + 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. diff --git a/lily/staff-side.cc b/lily/staff-side.cc index bea519b2dd..20440aa923 100644 --- a/lily/staff-side.cc +++ b/lily/staff-side.cc @@ -39,7 +39,7 @@ Side_position_interface::get_direction () const Direction relative_dir = UP; SCM reldir = elt_l_->get_elt_property ("side-relative-direction"); // should use a lambda. - if (isdir_b (d)) + if (isdir_b (reldir)) { relative_dir = to_dir (reldir); } @@ -65,7 +65,7 @@ Side_position_interface::side_position (Dimension_cache const * c) Interval dim; Axis axis = c->axis (); - Graphical_element *common = me->parent_l (axis); + Score_element *common = me->parent_l (axis); SCM support = me->get_elt_property ("side-support"); for (SCM s = support; s != SCM_EOL; s = gh_cdr (s)) { @@ -135,55 +135,62 @@ Side_position_interface::self_alignment (Dimension_cache const *c) Real -Side_position_interface::aligned_side (Dimension_cache const *c) +directed_round (Real f, Direction d ) +{ + if (d < 0) + return floor (f); + else + return ceil (f); +} + +Real +Side_position_interface::quantised_position (Dimension_cache const *c) { Score_element * me = dynamic_cast (c->element_l ()); Side_position_interface s(me); Direction d = s.get_direction (); - Axis ax = c->axis (); - Real o = side_position (c); - - Interval iv = me->extent (ax); - if (!iv.empty_b ()) + Staff_symbol_referencer *ref = dynamic_cast (me); + if (ref) { - o += - iv[-d]; + Real p = ref->position_f (); + Real rp = directed_round (d, p); - SCM pad = me->get_elt_property ("padding"); - if (gh_number_p (pad)) - o += d *gh_scm2double (pad) ; + int ip = int (p); + if (!(ip % 2)) + { + ip += d; + rp += d; + } + + return (rp - p) * ref->staff_line_leading_f (); } - return o; + return 0.0; } -#if 0 - -/* - need cascading off callbacks for this. - */ -Side_position_interface::quantised_side (Dimension_cache const *c) +Real +Side_position_interface::aligned_side (Dimension_cache const *c) { Score_element * me = dynamic_cast (c->element_l ()); Side_position_interface s(me); Direction d = s.get_direction (); Axis ax = c->axis (); Real o = side_position (c); - Staff_symbol_referencer * st = dynamic_cast (me); - if (st && ax == Y_AXIS) + Interval iv = me->extent (ax); + + if (!iv.empty_b ()) { - st->translate_axis (o, Y_AXIS); - st->set_position (); + o += - iv[-d]; - st->lines_i (); - st->quantise_to_next_line (d); - st->translate_axis (o, -Y_AXIS); + SCM pad = me->get_elt_property ("padding"); + if (gh_number_p (pad)) + o += d *gh_scm2double (pad) ; } - return o; } -#endif - + + void @@ -193,11 +200,20 @@ Side_position_interface::set_axis (Axis a) if (elt_l_->get_elt_property ("side-support") == SCM_UNDEFINED) elt_l_->set_elt_property ("side-support" ,SCM_EOL); - Axis other = Axis ((a +1)%2); elt_l_->dim_cache_[a]->off_callbacks_.push (aligned_side); } +void +Side_position_interface::set_quantised (Axis a) +{ + Dimension_cache * c = elt_l_->dim_cache_[a]; + for (int i=0; i < c->off_callbacks_.size (); i++) + if (c->off_callbacks_[i] == aligned_side) + c->off_callbacks_[i] = side_position ; + c->off_callbacks_.push (quantised_position); +} + Axis Side_position_interface::get_axis () const { diff --git a/lily/staff-sym-engraver.cc b/lily/staff-sym-engraver.cc index 695d109999..369df2928f 100644 --- a/lily/staff-sym-engraver.cc +++ b/lily/staff-sym-engraver.cc @@ -58,11 +58,9 @@ Staff_symbol_engraver::do_removal_processing() void Staff_symbol_engraver::acknowledge_element (Score_element_info s) { - if (Staff_symbol_referencer * st = dynamic_cast (s.elem_l_)) - { - st->set_staff_symbol (span_p_); - } - + 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)) { diff --git a/lily/staff-sym.cc b/lily/staff-sym.cc index 7ab14e91ba..2bc87b2321 100644 --- a/lily/staff-sym.cc +++ b/lily/staff-sym.cc @@ -29,18 +29,11 @@ Staff_symbol::do_print() const #endif } -Interval -Staff_symbol::do_height() const -{ - Interval i =Interval (0, staff_line_leading_f_ * (no_lines_i_-1)); - i += - i.center (); - return i; -} Molecule* Staff_symbol::do_brew_molecule_p() const { - Graphical_element * common + Score_element * common = spanned_drul_[LEFT]->common_refpoint (spanned_drul_[RIGHT], X_AXIS); #if 0 diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index 22b29af539..d07dbea01a 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -15,58 +15,55 @@ Staff_symbol_referencer::Staff_symbol_referencer () { - staff_symbol_l_ =0; - position_f_ =0; + set_elt_property ("staff-position", gh_double2scm (0.0)); + dim_cache_[Y_AXIS]->off_callbacks_.push (callback); } -void -Staff_symbol_referencer::do_substitute_element_pointer (Score_element *o, - Score_element*n) -{ - if (staff_symbol_l_ == o) - { - staff_symbol_l_ = dynamic_cast (n); - } -} int Staff_symbol_referencer::lines_i () const { - return (staff_symbol_l_) ? staff_symbol_l_->no_lines_i_ : 5; -} - -void -Staff_symbol_referencer::set_staff_symbol (Staff_symbol*s) -{ - staff_symbol_l_ =s; - add_dependency (s); + Staff_symbol *st = staff_symbol_l (); + return st ? st->no_lines_i_ : 5; } Staff_symbol* Staff_symbol_referencer::staff_symbol_l () const { - return staff_symbol_l_; + SCM st = get_elt_property ("staff-symbol"); + if (SMOB_IS_TYPE_B (Score_element, st)) + return dynamic_cast (SMOB_TO_TYPE (Score_element,st)); + else + return 0; } Real Staff_symbol_referencer::staff_line_leading_f () const { - if (staff_symbol_l_) - return staff_symbol_l_->staff_line_leading_f_; + Staff_symbol * st = staff_symbol_l (); + if (st) + return st->staff_line_leading_f_; else if (pscore_l_ && paper_l ()) paper_l ()->get_var ("interline"); return 0.0; } + Real Staff_symbol_referencer::position_f () const { - Real p = position_f_; - if (staff_symbol_l_ ) + Real p =0.0; + SCM pos = get_elt_property ("staff-position"); + if (gh_number_p (pos)) + p = gh_scm2double (pos); + + Staff_symbol * st = staff_symbol_l (); + if (st) { - Graphical_element * c = common_refpoint (staff_symbol_l_, Y_AXIS); - Real y = relative_coordinate (c, Y_AXIS) - staff_symbol_l_->relative_coordinate (c, Y_AXIS); + Score_element * c = common_refpoint (st, Y_AXIS); + Real y = relative_coordinate (c, Y_AXIS) + - st->relative_coordinate (c, Y_AXIS); p += 2.0 * y / staff_line_leading_f (); } @@ -78,23 +75,38 @@ Staff_symbol_referencer::position_f () const /* should use offset callback! */ -void -Staff_symbol_referencer::do_pre_processing () +Real +Staff_symbol_referencer::callback (Dimension_cache const * c) { - translate_axis (position_f_ * staff_line_leading_f () /2.0, Y_AXIS); - position_f_ =0; + Score_element * sc = dynamic_cast (c->element_l ()); + Staff_symbol_referencer * ref = dynamic_cast (sc); + SCM pos = sc->get_elt_property ("staff-position"); + Real off =0.0; + if (gh_number_p (pos)) + { + off = gh_scm2double (pos) * ref->staff_line_leading_f () /2.0; + } + sc->set_elt_property ("staff-position", gh_double2scm (0.0)); + + return off; } void Staff_symbol_referencer::set_position (Real p) { - Real halfspace = staff_line_leading_f ()* 0.5; + Real halfspace = staff_line_leading_f ()* 0.5; translate_axis (- halfspace * position_f (), Y_AXIS); - if (staff_symbol_l_) + Staff_symbol *st = staff_symbol_l (); + if (st) translate_axis (halfspace * p, Y_AXIS); else - position_f_ = p; + { + // SCM pos = get_elt_property ("staff-position"); + set_elt_property ("staff-position", + gh_double2scm (p)); + // gh_double2scm (p + gh_scm2double (pos))); + } } diff --git a/lily/stem-info.cc b/lily/stem-info.cc index 6269efb796..ee0faf9721 100644 --- a/lily/stem-info.cc +++ b/lily/stem-info.cc @@ -29,13 +29,13 @@ Stem_info::Stem_info () GURG UGRGINRG INA UG R - JUNKME -> This should be in Beam + JUNKME -> this should set elt properties of STEM. */ Stem_info::Stem_info (Stem*s, int mult) { mult_i_ =mult; stem_l_ = s; - Beam* beam_l = stem_l_->beam_l_; + Beam* beam_l = stem_l_->beam_l (); x_ = stem_l_->hpos_f (); set_direction (stem_l_->get_direction ()); diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index bbc4b0b50a..24f1405b5b 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -14,10 +14,11 @@ #include "lookup.hh" #include "stem.hh" #include "offset.hh" +#include "dimension-cache.hh" Stem_tremolo::Stem_tremolo () { - stem_l_ = 0; + set_elt_property ("stem", SCM_EOL); abbrev_flags_i_ = 1; } @@ -27,31 +28,41 @@ Stem_tremolo::do_print () const DEBUG_OUT << "abbrev_flags_i_ " << abbrev_flags_i_; } -Interval -Stem_tremolo::do_width () const +Stem * +Stem_tremolo::stem_l ()const { - Real space = stem_l_->staff_line_leading_f (); - return Interval (-space, space); + SCM s = get_elt_property ("stem"); + if (SMOB_IS_TYPE_B (Score_element, s)) + { + return dynamic_cast (SMOB_TO_TYPE (Score_element,s)); + } + else + return 0; } -void -Stem_tremolo::do_pre_processing () +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 (); + return Interval (-space, space); } + Molecule* Stem_tremolo::do_brew_molecule_p () const { + Stem * st = stem_l (); int mult =0; - if (Beam * b = stem_l_->beam_l_) + if (Beam * b = st->beam_l ()) { - Stem_info i = b->get_stem_info (stem_l_); + Stem_info i = b->get_stem_info (st); mult = i.mult_i_; } Real interbeam_f = paper_l ()->interbeam_f (mult); Real w = gh_scm2double (get_elt_property ("beam-width")); - Real space = stem_l_->staff_line_leading_f (); + Real space = st->staff_line_leading_f (); Real internote_f = space/2; Real beam_f = gh_scm2double (get_elt_property ("beam-thickness")); @@ -59,10 +70,10 @@ Stem_tremolo::do_brew_molecule_p () const int beams_i = 0; Real slope_f = internote_f / 4 / internote_f; // HUH? - if (stem_l_ && stem_l_->beam_l_) { - slope_f = stem_l_->beam_l_->slope_f_; + if (st && st->beam_l ()) { + slope_f = st->beam_l ()->slope_f_; // ugh, rather calc from Stem_tremolo_req - beams_i = stem_l_->beams_i_drul_[RIGHT] >? stem_l_->beams_i_drul_[LEFT]; + beams_i = st->beams_i_drul_[RIGHT] >? st->beams_i_drul_[LEFT]; } Real sl = slope_f * internote_f; @@ -78,35 +89,35 @@ Stem_tremolo::do_brew_molecule_p () const } beams->translate_axis (-beams->extent ()[Y_AXIS].center (), Y_AXIS); - if (stem_l_) + if (st) { - if (stem_l_->beam_l_) + if (st->beam_l ()) { - beams->translate (Offset(stem_l_->hpos_f () - hpos_f (), - stem_l_->stem_end_f () * internote_f - - stem_l_->beam_l_->get_direction () * beams_i * interbeam_f)); + beams->translate (Offset(st->hpos_f () - hpos_f (), + st->stem_end_f () * internote_f - + st->beam_l ()->get_direction () * beams_i * interbeam_f)); } else { /* Beams should intersect one beamthickness below staff end */ - Real dy = - beams->extent ()[Y_AXIS].length () / 2 * stem_l_->get_direction (); + Real dy = - beams->extent ()[Y_AXIS].length () / 2 * st->get_direction (); /* uhg. Should use relative coords and placement */ - Real whole_note_correction = (stem_l_ && stem_l_->invisible_b( )) - ? -stem_l_->get_direction () * stem_l_->note_delta_f ()/2 + Real whole_note_correction = (st && st->invisible_b( )) + ? -st->get_direction () * st->note_delta_f ()/2 : 0.0; /* UGH. Internote fudging. */ dy /= internote_f; - dy += stem_l_->stem_end_f (); + dy += st->stem_end_f (); dy *= internote_f; - beams->translate (Offset(stem_l_->hpos_f () - hpos_f ()+ + beams->translate (Offset(st->hpos_f () - hpos_f ()+ whole_note_correction, dy)); } @@ -119,18 +130,11 @@ Stem_tremolo::do_brew_molecule_p () const return beams; } -void -Stem_tremolo::do_substitute_element_pointer (Score_element*o, Score_element*n) -{ - if (stem_l_ == o) - stem_l_ = dynamic_cast (n); -} - void Stem_tremolo::set_stem (Stem *s) { - stem_l_ = s; + set_elt_property ("stem", s->self_scm_); add_dependency (s); } diff --git a/lily/stem.cc b/lily/stem.cc index 2975f3321a..74ac9349ae 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -7,7 +7,7 @@ TODO: This is way too hairy */ - +#include "dimension-cache.hh" #include "stem.hh" #include "debug.hh" #include "paper-def.hh" @@ -24,7 +24,6 @@ Stem::Stem () beams_i_drul_[LEFT] = beams_i_drul_[RIGHT] = -1; yextent_drul_[DOWN] = yextent_drul_[UP] = 0; flag_i_ = 2; - beam_l_ = 0; } Interval_t @@ -55,8 +54,6 @@ Stem::do_print () const { #ifndef NPRINT DEBUG_OUT << "flag "<< flag_i_; - if (beam_l_) - DEBUG_OUT << "beamed"; #endif } @@ -238,8 +235,11 @@ Stem::do_pre_processing () if (invisible_b ()) { set_elt_property ("transparent", SCM_BOOL_T); + set_empty (Y_AXIS); + set_empty (X_AXIS); } - set_empty (invisible_b (), X_AXIS, Y_AXIS); + + set_spacing_hints (); } @@ -290,15 +290,17 @@ Stem::flag () const } Interval -Stem::do_width () const +Stem::dim_callback (Dimension_cache const* c) { + Stem * s = dynamic_cast (c->element_l ()); + Interval r (0, 0); - if (beam_l_ || abs (flag_i_) <= 2) + if (s->get_elt_property ("beam") != SCM_UNDEFINED || abs (s->flag_i_) <= 2) ; // TODO! else { - r = flag ().dim_.x (); - r += note_delta_f (); + r = s->flag ().dim_.x (); + r += s->note_delta_f (); } return r; } @@ -328,7 +330,8 @@ Stem::do_brew_molecule_p () const mol_p->add_molecule (ss); } - if (!beam_l_ && abs (flag_i_) > 2) + if (get_elt_property ("beam") == SCM_UNDEFINED + && abs (flag_i_) > 2) { Molecule fl = flag (); fl.translate_axis(stem_y[get_direction ()]*dy, Y_AXIS); @@ -373,11 +376,14 @@ Stem::do_substitute_element_pointer (Score_element*o,Score_element*n) head_l_arr_.substitute (h, dynamic_cast(n)); if (Rest *r=dynamic_cast (o)) rest_l_arr_.substitute (r, dynamic_cast(n)); - if (Beam* b = dynamic_cast (o)) - { - if (b == beam_l_) - beam_l_ = dynamic_cast (n); - } - Staff_symbol_referencer::do_substitute_element_pointer (o,n); } +Beam* +Stem::beam_l ()const +{ + SCM b= get_elt_property ("beam"); + if (SMOB_IS_TYPE_B(Score_element, b)) + return dynamic_cast (SMOB_TO_TYPE(Score_element,b)); + else + return 0; +} diff --git a/lily/super-element.cc b/lily/super-element.cc index 90f8d49700..dee963dedd 100644 --- a/lily/super-element.cc +++ b/lily/super-element.cc @@ -53,7 +53,7 @@ void Super_element::breakable_col_processing () { calculate_dependencies (PREBROKEN, PREBROKEN, &Score_element::do_breakable_col_processing); - calculate_dependencies (PREBROKEN_SECOND, PREBROKEN_SECOND, &Score_element::handle_prebroken_dependents); + // calculate_dependencies (PREBROKEN_SECOND, PREBROKEN_SECOND, &Score_element::handle_prebroken_dependents); } void @@ -65,8 +65,8 @@ Super_element::break_processing () void Super_element::post_processing () { - calculate_dependencies (BROKEN_SECOND, BROKEN_SECOND, - &Score_element::handle_broken_dependents); + // calculate_dependencies (BROKEN_SECOND, BROKEN_SECOND, + // &Score_element::handle_broken_dependents); calculate_dependencies (POSTCALCED, POSTCALCING, &Score_element::do_post_processing); } diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index 718845c755..40646392ed 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -104,7 +104,7 @@ Text_engraver::do_process_requests () SCM empty = get_property ("textEmptyDimension", 0); if (gh_boolean_p (empty) && gh_scm2bool (empty)) { - text->set_empty (true, X_AXIS); + text->set_empty (X_AXIS); } announce_element (Score_element_info (text, r)); diff --git a/lily/tuplet-spanner.cc b/lily/tuplet-spanner.cc index 0c3646f6ff..7fed879b85 100644 --- a/lily/tuplet-spanner.cc +++ b/lily/tuplet-spanner.cc @@ -21,6 +21,9 @@ Tuplet_spanner::Tuplet_spanner () { + /* + -> GUILE + */ parallel_beam_b_ = false; } diff --git a/lily/volta-spanner.cc b/lily/volta-spanner.cc index 9e06d74c69..f1e641b782 100644 --- a/lily/volta-spanner.cc +++ b/lily/volta-spanner.cc @@ -17,12 +17,13 @@ #include "paper-def.hh" #include "volta-spanner.hh" #include "stem.hh" - +#include "dimension-cache.hh" #include "pointer.tcc" Volta_spanner::Volta_spanner () { last_b_ = false; + dim_cache_ [Y_AXIS]->set_callback (dim_callback); } Molecule* @@ -82,11 +83,8 @@ Volta_spanner::do_add_processing () set_bounds (RIGHT, bar_arr_.top ()); } } - -Interval -Volta_spanner::do_height () const -{ - /* + +/* Originally the following comment existed here "in most cases, it's a lot better not no have height...", but problems existed with collision between volta spanner @@ -94,8 +92,12 @@ Volta_spanner::do_height () const height is now being returned. Additional space should still be added elsewhere so lyrics from above staff do not sit on volta spanner. (Roy R. Rankin) - */ - Real h = paper_l()->get_var ("volta_spanner_height") * 2.; +*/ +Interval +Volta_spanner::dim_callback (Dimension_cache const *c) +{ + Volta_spanner * v = dynamic_cast (c->element_l ()); + Real h = v->paper_l()->get_var ("volta_spanner_height") * 2.; return Interval (0., h); } diff --git a/ly/params.ly b/ly/params.ly index 61ac19f2dc..4e60c76a01 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -96,10 +96,13 @@ grace_forced_stem_shorten3 = \grace_forced_stem_shorten2; % * MEDIAN : mean centre distance weighted per note % -#'slope-quantisation = #'normal #'beam-dir-algorithm = #'majority %urg. #'Stem_tremolo::beam-width = 1.5 * \quartwidth ; +% The beams should be prevented to conflict with the stafflines, +% especially at small slopes. +#'slope-quantisation = #'normal + #'Clef_item::visibility-lambda = #postbreak-only-visibility diff --git a/make/toplevel.make.in b/make/toplevel.make.in index 2c2e051086..8a33b3279c 100644 --- a/make/toplevel.make.in +++ b/make/toplevel.make.in @@ -44,5 +44,5 @@ localinstall: $(LN_S) $(TEX_TFMDIR) $(datadir)/cmtfm local-WWW-clean: - $(depth)/buildscripts/out/clean-fonts + $(SHELL) $(depth)/buildscripts/clean-fonts.sh diff --git a/mutopia/F.Schubert/standchen.ly b/mutopia/F.Schubert/standchen.ly index c9e18e1f5d..e37947d68b 100644 --- a/mutopia/F.Schubert/standchen.ly +++ b/mutopia/F.Schubert/standchen.ly @@ -44,7 +44,7 @@ Note: Original key F. \version "1.3.4"; vocalVerse = \notes\relative c''{ - \property Voice.dynamicDirection=1 + \property Voice.dynamicDirection=\up \times 2/3 { [ g8( )as] g } c4. g8 | \times 2/3 { [ f8( )g] f } c'4 f,8 r | g4.-> f8 \times 2/3 { [ f( )es] d } | @@ -73,7 +73,7 @@ vocalVerse = \notes\relative c''{ } vocalThrough = \notes\relative c{ - \property Voice.dynamicDirection=1 + \property Voice.dynamicDirection=\up g''8. g16 b8. b16 d8. d16 | c4 b r | g4. b8 d8. c16 | @@ -176,7 +176,7 @@ trebleVerseOne = \notes\relative c{ } trebleEentje = \notes \relative c'{ - \context Voice=one \property Voice.verticalDirection = 0 + \context Voice=one \property Voice.verticalDirection = \center | ( c> <)f16 )as> | | @@ -190,7 +190,7 @@ trebleEentje = \notes \relative c'{ } trebleThrough = \notes \relative c'{ - \context Voice=one \property Voice.verticalDirection = 0 + \context Voice=one \property Voice.verticalDirection = \center | %61 R2. | @@ -348,8 +348,8 @@ lyricStaff = \context Lyrics = lyric< vocals = \notes{ \clef treble; % certainly no auto-beaming for vocals - \property Voice.noAutoBeaming = "1" - \property Staff.automaticMelismata=1 + \property Voice.noAutoBeaming = ##t + \property Staff.automaticMelismata= ##t \property Voice.dynamicDirection = \up \skip 4 * 12; @@ -367,7 +367,7 @@ vocalStaff = \context Staff = vocal< treble = { \clef treble; - \property Voice.beamAutoBegin=0 + \property Voice.beamAutoBegin= #(make-moment 0 1) \trebleIntro \trebleVerseOne \trebleEentje