X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbreak-align-item.cc;h=fece9623638a366ece716b272ac0eff6fb333185;hb=d9b43b93f2c885409bafdb157138158f65cc49aa;hp=36f536ba0fd4d2313b312feff9d9c26ae6e2abbf;hpb=94189ec2b8da6d7e89dc619c646a927adead9b19;p=lilypond.git diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index 36f536ba0f..fece962363 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -3,12 +3,12 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2001 Han-Wen Nienhuys + (c) 1997--2002 Han-Wen Nienhuys */ #include -#include +#include // isinf #include "side-position-interface.hh" #include "axis-group-interface.hh" @@ -21,7 +21,7 @@ #include "group-interface.hh" #include "align-interface.hh" -MAKE_SCHEME_CALLBACK(Break_align_interface,before_line_breaking,1); +MAKE_SCHEME_CALLBACK (Break_align_interface,before_line_breaking,1); SCM Break_align_interface::before_line_breaking (SCM smob) @@ -30,7 +30,7 @@ Break_align_interface::before_line_breaking (SCM smob) do_alignment (me); return SCM_UNSPECIFIED; } -MAKE_SCHEME_CALLBACK(Break_align_interface,alignment_callback,2); +MAKE_SCHEME_CALLBACK (Break_align_interface,alignment_callback,2); SCM Break_align_interface::alignment_callback (SCM element_smob, SCM axis) @@ -39,7 +39,7 @@ Break_align_interface::alignment_callback (SCM element_smob, SCM axis) Axis a = (Axis) gh_scm2int (axis); assert (a == X_AXIS); - Grob *par = me->parent_l (a); + Grob *par = me->get_parent (a); if (par && !to_boolean (par->get_grob_property ("break-alignment-done")))\ { par->set_grob_property ("break-alignment-done", SCM_BOOL_T); @@ -49,7 +49,7 @@ Break_align_interface::alignment_callback (SCM element_smob, SCM axis) return gh_double2scm (0); } -MAKE_SCHEME_CALLBACK(Break_align_interface,self_align_callback,2); +MAKE_SCHEME_CALLBACK (Break_align_interface,self_align_callback,2); SCM Break_align_interface::self_align_callback (SCM element_smob, SCM axis) { @@ -58,13 +58,18 @@ Break_align_interface::self_align_callback (SCM element_smob, SCM axis) assert (a == X_AXIS); Item* item = dynamic_cast (me); - Direction bsd = item->break_status_dir(); + Direction bsd = item->break_status_dir (); if (bsd == LEFT) { me->set_grob_property ("self-alignment-X", gh_int2scm (RIGHT)); } - return Side_position::aligned_on_self (element_smob, axis); + /* + Force break alignment itself to be done first, in the case + */ + + + return Side_position_interface::aligned_on_self (element_smob, axis); } void @@ -81,13 +86,13 @@ Break_align_interface::do_alignment (Grob *me) Link_array elems; Link_array all_elems - = Pointer_group_interface__extract_elements (me, (Grob*)0, + = Pointer_group_interface__extract_grobs (me, (Grob*)0, "elements"); - for (int i=0; i < all_elems.size(); i++) + for (int i=0; i < all_elems.size (); i++) { - Interval y = all_elems[i]->extent(all_elems[i], X_AXIS); - if (!y.empty_b()) + Interval y = all_elems[i]->extent (all_elems[i], X_AXIS); + if (!y.empty_b ()) elems.push (dynamic_cast (all_elems[i])); } @@ -117,41 +122,41 @@ Break_align_interface::do_alignment (Grob *me) next_origin = ly_symbol2scm ("begin-of-note"); SCM alist = me->get_grob_property ("space-alist"); - SCM e = scm_assoc (scm_listify (current_origin, + SCM e = scm_assoc (scm_list_n (current_origin, next_origin, SCM_UNDEFINED), alist); SCM extra_space; if (e != SCM_BOOL_F) { - extra_space = gh_cdr (e); + extra_space = ly_cdr (e); } else { warning (_f ("unknown spacing pair `%s', `%s'", ly_symbol2string (current_origin), ly_symbol2string (next_origin))); - extra_space = scm_listify (ly_symbol2scm ("minimum-space"), gh_double2scm (0.0), SCM_UNDEFINED); + extra_space = scm_list_n (ly_symbol2scm ("minimum-space"), gh_double2scm (0.0), SCM_UNDEFINED); } - SCM symbol = gh_car (extra_space); - Real spc = gh_scm2double (gh_cadr(extra_space)); + SCM symbol = ly_car (extra_space); + Real spc = gh_scm2double (ly_cadr (extra_space)); - dists.push(spc); + dists.push (spc); symbol_list = gh_cons (symbol, symbol_list); current_origin = next_origin; } // skip the first sym. - symbol_list = gh_cdr (scm_reverse (symbol_list)); - for (int i=0; i set_grob_property (gh_car (symbol_list), - scm_cons (gh_double2scm (0), + elems[i]->internal_set_grob_property (ly_car (symbol_list), + scm_cons (gh_double2scm (0), gh_double2scm (dists[i+1]))); - symbol_list = gh_cdr (symbol_list); + symbol_list = ly_cdr (symbol_list); } @@ -165,11 +170,16 @@ Break_align_interface::do_alignment (Grob *me) scm_set_car_x (first_pair, gh_double2scm (-dists[0])); elems[0]->set_grob_property ("minimum-space", first_pair); + Direction bsd = item->break_status_dir (); + if (bsd == LEFT) + { + me->set_grob_property ("self-alignment-X", gh_int2scm (RIGHT)); + } /* Force callbacks for alignment to be called */ - Align_interface::align_to_extents (me, X_AXIS); + Align_interface::align_elements_to_extents (me, X_AXIS); Real pre_space = elems[0]->relative_coordinate (column, X_AXIS); @@ -188,21 +198,44 @@ Break_align_interface::do_alignment (Grob *me) Real stretch_distance =0.; - if (gh_car (symbol_list) == ly_symbol2scm ("extra-space")) + if (ly_car (symbol_list) == ly_symbol2scm ("extra-space")) { spring_len += dists.top (); stretch_distance = dists.top (); } - else if (gh_car (symbol_list) == ly_symbol2scm ("minimum-space")) + else if (ly_car (symbol_list) == ly_symbol2scm ("minimum-space")) { spring_len = spring_len >? dists.top (); stretch_distance = spring_len; } + /* Hint the spacing engine how much space to put in. The pairs are in the format of an interval (ie. CAR < CDR). + */ + /* + UGH UGH UGH + + This is a side effect, and there is no guarantee that this info is + computed at a "sane" moment. + + (just spent some time tracking a bug that was caused by this info + being written halfway: + + self_alignment_callback (*) + -> child->relative_coordinate (self) + -> break_alignment + -> child->relative_coordinate (column) + + the last call incorporates the value that should've been computed + in (*), but--of course-- is not yet. + + The result is that an offsets of align_elements_to_extents () are + not compensated for, and spring_len is completely off. + + */ column->set_grob_property ("extra-space", scm_cons (gh_double2scm (pre_space),