X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fseparation-item.cc;h=0a053065bdbffbcb74fc712c46871e75ddc4552a;hb=051d7e7cbdbbe5f5337ab2b477b0bd1e72eedd04;hp=8a777a0df9aadf51563972e725b7ff022fc77953;hpb=94189ec2b8da6d7e89dc619c646a927adead9b19;p=lilypond.git diff --git a/lily/separation-item.cc b/lily/separation-item.cc index 8a777a0df9..0a053065bd 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -1,50 +1,104 @@ /* - single-malt-grouping-item.cc -- implement Separation_item + separation-item.cc -- implement Separation_item source file of the GNU LilyPond music typesetter - (c) 1998--2001 Han-Wen Nienhuys + (c) 1998--2002 Han-Wen Nienhuys */ #include "separation-item.hh" #include "paper-column.hh" -#include "debug.hh" +#include "warn.hh" #include "group-interface.hh" +#include "accidental-placement.hh" void -Separation_item::set_interface (Grob*s) +Separation_item::add_item (Grob*s,Item* i) { - s->set_extent_callback (SCM_EOL, X_AXIS); - s->set_extent_callback (SCM_EOL, Y_AXIS); + assert (i); + Pointer_group_interface::add_grob (s, ly_symbol2scm ("elements"),i); + s->add_dependency (i); } void -Separation_item::add_item (Grob*s,Item* i) +Separation_item::add_conditional_item (Grob* me , Grob *e) { - assert (i); - Pointer_group_interface::add_element (s,"elements",i); - s->add_dependency (i); + 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::my_width (Grob *me) +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)) + { + SCM elt = ly_car (s); + if (!unsmob_grob (elt)) + continue; + + Item *il = unsmob_item (elt); + if (pc != il->get_column ()) + { + /* this shouldn't happen, but let's continue anyway. */ + programming_error (_ ("Separation_item: I've been drinking too much")); + continue; /*UGH UGH*/ + } + + if (to_boolean (il->get_grob_property ("no-spacing-rods"))) + { + continue; + } + + if (Accidental_placement::has_interface (il)) + { + w.unite (Accidental_placement::get_relevant_accidental_extent (il, pc, 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; + } + return w; +} + +Interval +Separation_item::width (Grob *me) +{ + SCM sw = me->get_grob_property ("X-extent"); + if (ly_number_pair_p (sw)) + { + return ly_scm2interval (sw); + } + + Item *item = dynamic_cast (me); + Paper_column * pc = item->get_column (); Interval w; - for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s); s = ly_cdr (s)) { - SCM elt = gh_car (s); + SCM elt = ly_car (s); if (!unsmob_grob (elt)) continue; - Item *il = dynamic_cast (unsmob_grob (elt)); - if (pc != il->column_l ()) + Item *il = unsmob_item (elt); + if (pc != il->get_column ()) { /* this shouldn't happen, but let's continue anyway. */ - programming_error (_("Separation_item: I've been drinking too much")); + programming_error (_ ("Separation_item: I've been drinking too much")); continue; /*UGH UGH*/ } @@ -56,13 +110,35 @@ Separation_item::my_width (Grob *me) Interval iv (il->extent (pc, X_AXIS)); if (!iv.empty_b ()) { - w.unite (iv); + w.unite (iv); } } + SCM pad = me->get_grob_property ("padding"); + + if (gh_number_p (pad)) + { + w[RIGHT] += gh_scm2double (pad)/2; + w[LEFT] -= gh_scm2double (pad)/2; + } + + + me->set_grob_property ("X-extent", ly_interval2scm (w)); + + return w; // add this->offset_ ? this-> relative_coordinate ()? } + + +ADD_INTERFACE (Separation_item,"separation-item-interface", + "Item that computes widths to generate spacing rods. + +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 +", + "X-extent conditional-elements elements");