X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbreak-align-item.cc;h=c4b6963bbcbfeb359ea169c6b45e9dfd3ba12f50;hb=d26be70e8f3942df6f13e25a7f79321b9b98d1a8;hp=cf7cc9a649512b5caf90cdfafe9f83ee4d1e9d85;hpb=86f02d911398a55f8b6bfa8e1d843b96856c031b;p=lilypond.git diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index cf7cc9a649..c4b6963bbc 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -6,6 +6,7 @@ (c) 1997--1999 Han-Wen Nienhuys */ +#include "dimension-cache.hh" #include "lily-guile.hh" #include "break-align-item.hh" #include "dimensions.hh" @@ -13,12 +14,9 @@ #include "paper-def.hh" #include "paper-column.hh" - /* Handle spacing for prefatory matter. - - TODO: rewrite this. It is kludgy */ @@ -31,15 +29,17 @@ Break_align_item::do_pre_processing() align_dir_ = RIGHT; flip (&align_dir_); - sort_elements (); - Real interline= paper_l ()->get_realvar (interline_scm_sym); + + Real interline= paper_l ()->get_var ("interline"); Link_array elems; - for (int i=0; i < elem_l_arr_.size(); i++) + Link_array all_elems (elem_l_arr ()); + + for (int i=0; i < all_elems.size(); i++) { - Interval y = elem_l_arr_[i]->extent(axis ()); + Interval y = all_elems[i]->extent(axis ()); if (!y.empty_b()) - elems.push (dynamic_cast (elem_l_arr_[i])); + elems.push (dynamic_cast (all_elems[i])); } if (!elems.size ()) @@ -47,7 +47,7 @@ Break_align_item::do_pre_processing() SCM symbol_list = SCM_EOL; Array dists; - SCM current_origin = gh_str02scm (""); + SCM current_origin = ly_str02scm (""); for (int i=0; i <= elems.size (); i++) { Score_element *next_elt = i < elems.size () @@ -58,17 +58,17 @@ Break_align_item::do_pre_processing() if (next_elt) { - next_origin = next_elt->get_elt_property (origin_scm_sym); + next_origin = next_elt->get_elt_property ("origin"); next_origin = - (next_origin == SCM_BOOL_F) - ? gh_str02scm ("") - : SCM_CDR (next_origin); + (next_origin == SCM_UNDEFINED) + ? ly_str02scm ("") + : next_origin; } else - next_origin = gh_str02scm ("begin-of-note"); + next_origin = ly_str02scm ("begin-of-note"); SCM extra_space - = scm_eval (scm_listify (ly_symbol ("break-align-spacer"), + = scm_eval (scm_listify (ly_symbol2scm ("break-align-spacer"), current_origin, next_origin, SCM_UNDEFINED)); SCM symbol = SCM_CAR (extra_space); Real spc = gh_scm2double (SCM_CADR(extra_space)); @@ -84,7 +84,8 @@ Break_align_item::do_pre_processing() symbol_list = SCM_CDR (scm_reverse (symbol_list)); for (int i=0; i set_elt_property (SCM_CAR (symbol_list), + String sym_str = ly_scm2string (SCM_CAR (symbol_list)); + elems[i]->set_elt_property (sym_str, scm_cons (gh_double2scm (0), gh_double2scm (dists[i+1]))); @@ -93,31 +94,31 @@ Break_align_item::do_pre_processing() // urg - SCM first_pair = elems[0]->get_elt_property (minimum_space_scm_sym); - if (first_pair == SCM_BOOL_F) + SCM first_pair = elems[0]->get_elt_property ("minimum-space"); + if (first_pair == SCM_UNDEFINED) first_pair = gh_cons (gh_double2scm (0.0), gh_double2scm (0.0)); else - first_pair = SCM_CDR (first_pair); + first_pair = first_pair; scm_set_car_x (first_pair, gh_double2scm (-dists[0])); - elems[0]->set_elt_property (minimum_space_scm_sym, first_pair); + elems[0]->set_elt_property ("minimum-space", first_pair); Axis_align_item::do_pre_processing(); Real pre_space = elems[0]->extent (X_AXIS)[LEFT] - + elems[0]->relative_coordinate (column_l ()->dim_cache_[X_AXIS], X_AXIS); + + elems[0]->relative_coordinate (column_l (), X_AXIS); Real spring_len = elems.top ()->extent (X_AXIS)[RIGHT] - + elems.top ()->relative_coordinate (column_l ()->dim_cache_[X_AXIS], X_AXIS); + + elems.top ()->relative_coordinate (column_l (), X_AXIS); Real stretch_distance =0.; - if (SCM_CAR (symbol_list) == extra_space_scm_sym) + if (SCM_CAR (symbol_list) == ly_symbol2scm ("extra-space")) { spring_len += dists.top (); stretch_distance = dists.top (); } - else if (SCM_CAR (symbol_list) == minimum_space_scm_sym) + else if (SCM_CAR (symbol_list) == ly_symbol2scm ("minimum-space")) { spring_len = spring_len >? dists.top (); stretch_distance = spring_len; @@ -129,58 +130,18 @@ Break_align_item::do_pre_processing() The pairs are in the format of an interval (ie. CAR < CDR). */ - column_l ()->set_elt_property (extra_space_scm_sym, + column_l ()->set_elt_property ("extra-space", scm_cons (gh_double2scm (pre_space), gh_double2scm (spring_len))); - column_l ()->set_elt_property (stretch_distance_scm_sym, + column_l ()->set_elt_property ("stretch-distance", gh_cons (gh_double2scm (-dists[0]), gh_double2scm (stretch_distance))); } - - Break_align_item::Break_align_item () { stacking_dir_ = RIGHT; set_axis (X_AXIS); } - -void -Break_align_item::add_breakable_item (Item *it) -{ - SCM pr = it->remove_elt_property (break_priority_scm_sym); - - if (pr == SCM_BOOL_F) - return; - - int priority = gh_scm2int (SCM_CDR (pr)); - - Score_element * column_l = get_elt_by_priority (priority); - Axis_group_item * hg=0; - if (column_l) - { - hg = dynamic_cast (column_l); - } - else - { - hg = new Axis_group_item; - hg->set_axes (X_AXIS,X_AXIS); - - /* - this is quite ridiculous, but we do this anyway, to ensure that no - warning bells about missing Y refpoints go off later on. - */ - hg->dim_cache_[Y_AXIS]->parent_l_ = dim_cache_[Y_AXIS]; - hg->set_elt_property (ly_symbol("origin"), gh_str02scm (it->name())); - - pscore_l_->typeset_element (hg); - add_element_priority (hg, priority); - - if (priority == 0) - center_l_ = hg; - } - - hg->add_element (it); -}