X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fseparation-item.cc;h=34f3855ebc3d0e16433570f1e8e0b290ac1b64fb;hb=557c7f26f0c62bca9eb620a782e6a8e5bef9103e;hp=f85866f4c8320d503dcec25bc210fc97af2b9024;hpb=ce62ceaa3f635693b541a97de1eced86fab4c0f7;p=lilypond.git diff --git a/lily/separation-item.cc b/lily/separation-item.cc index f85866f4c8..34f3855ebc 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1998--2002 Han-Wen Nienhuys + (c) 1998--2004 Han-Wen Nienhuys */ @@ -27,13 +27,17 @@ Separation_item::add_conditional_item (Grob* me , Grob *e) Pointer_group_interface::add_grob (me, ly_symbol2scm ("conditional-elements"), e); } +/* + Return the width of ME given that we are considering the object on + the LEFT. + */ Interval Separation_item::conditional_width (Grob * me, Grob * left) { Interval w = width (me); - + Item *item = dynamic_cast (me); - Paper_column * pc = item->column_l (); + Paper_column * pc = item->get_column (); for (SCM s = me->get_grob_property ("conditional-elements"); gh_pair_p (s); s = ly_cdr (s)) @@ -43,7 +47,7 @@ Separation_item::conditional_width (Grob * me, Grob * left) continue; Item *il = unsmob_item (elt); - if (pc != il->column_l ()) + if (pc != il->get_column ()) { /* this shouldn't happen, but let's continue anyway. */ programming_error (_ ("Separation_item: I've been drinking too much")); @@ -63,25 +67,21 @@ Separation_item::conditional_width (Grob * me, Grob * left) SCM pad = me->get_grob_property ("padding"); - if (gh_number_p (pad)) - { - w[RIGHT] += gh_scm2double (pad)/2; - w[LEFT] -= gh_scm2double (pad)/2; - } + w.widen (robust_scm2double (pad, 0.0)); return w; } Interval Separation_item::width (Grob *me) { - SCM sw = me->get_grob_property ("extent-X"); - if (ly_number_pair_p (sw)) + SCM sw = me->get_grob_property ("X-extent"); + if (is_number_pair (sw)) { return ly_scm2interval (sw); } Item *item = dynamic_cast (me); - Paper_column * pc = item->column_l (); + Paper_column * pc = item->get_column (); Interval w; for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s); s = ly_cdr (s)) @@ -91,7 +91,7 @@ Separation_item::width (Grob *me) continue; Item *il = unsmob_item (elt); - if (pc != il->column_l ()) + if (pc != il->get_column ()) { /* this shouldn't happen, but let's continue anyway. */ programming_error (_ ("Separation_item: I've been drinking too much")); @@ -104,7 +104,7 @@ Separation_item::width (Grob *me) } Interval iv (il->extent (pc, X_AXIS)); - if (!iv.empty_b ()) + if (!iv.is_empty ()) { w.unite (iv); } @@ -112,18 +112,54 @@ Separation_item::width (Grob *me) SCM pad = me->get_grob_property ("padding"); - if (gh_number_p (pad)) - { - w[RIGHT] += gh_scm2double (pad)/2; - w[LEFT] -= gh_scm2double (pad)/2; - } - + w.widen (robust_scm2double (pad, 0.0)); - me->set_grob_property ("extent-X", ly_interval2scm (w)); - + me->set_grob_property ("X-extent", ly_interval2scm (w)); return w; - // add this->offset_ ? this-> relative_coordinate ()? +} + +Interval +Separation_item::relative_width (Grob * me, Grob * common) +{ + Interval iv = width (me); + + return dynamic_cast(me)->get_column ()->relative_coordinate (common, X_AXIS) + iv ; +} + + +/* + Try to find the break-aligned symbol in SEPARATION_ITEM that is + sticking out at direction D. The x size is put in LAST_EXT +*/ +Grob* +Separation_item::extremal_break_aligned_grob (Grob *separation_item, Direction d, + Interval * last_ext) +{ + Grob *col = dynamic_cast (separation_item)->get_column (); + last_ext->set_empty (); + Grob *last_grob = 0; + for (SCM s = separation_item->get_grob_property ("elements"); + gh_pair_p (s); s = gh_cdr (s)) + { + Grob * break_item = unsmob_grob (gh_car (s)); + + if (!gh_symbol_p (break_item->get_grob_property ("break-align-symbol"))) + continue; + + Interval ext = break_item->extent (col, X_AXIS); + + if (ext.is_empty ()) + continue; + if (!last_grob + || (last_grob && d * (ext[d]- (*last_ext)[d]) > 0) ) + { + *last_ext = ext; + last_grob = break_item; + } + } + + return last_grob; } @@ -131,10 +167,9 @@ Separation_item::width (Grob *me) ADD_INTERFACE (Separation_item,"separation-item-interface", - "Item that computes widths to generate spacing rods. + "Item that computes widths to generate spacing rods. " + "This is done in concert with @ref{separation-spanner-interface}." + + , -Calc dimensions for the Separating_group_spanner; this has to be -an item to get dependencies correct. It can't be an grob_group -since these usually are in a different X_group -", - "extent-X conditional-elements elements"); + "padding X-extent conditional-elements elements");