X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Falign-interface.cc;h=e52e8f69ff7c1891609d153ce0e2025097a5469d;hb=87eedcd59f4082cb0841528ad5bc82cb1d1191e3;hp=89d2648ae21400a4f889895ce7786e5d0b2b9ea8;hpb=66adac8fa4ba5126100ff8748a2576c6983637c5;p=lilypond.git diff --git a/lily/align-interface.cc b/lily/align-interface.cc index 89d2648ae2..e52e8f69ff 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2000--2006 Han-Wen Nienhuys + (c) 2000--2007 Han-Wen Nienhuys */ #include "align-interface.hh" @@ -16,6 +16,7 @@ #include "international.hh" #include "system.hh" #include "warn.hh" +#include "paper-column.hh" /* TODO: for vertical spacing, should also include a rod & spring @@ -146,8 +147,17 @@ get_skylines (Grob *me, vector child_refpoints; for (vsize i = 0; i < elements->size (); i++) { - extract_grob_set ((*elements)[i], "elements", child_elts); - Grob *child_common = common_refpoint_of_array (child_elts, (*elements)[i], other_axis (a)); + Grob *elt = (*elements)[i]; + Grob *child_common = unsmob_grob ((a == Y_AXIS) + ? elt->get_object ("X-common") + : elt->get_object ("Y-common")); + + if (!child_common) + { + extract_grob_set (elt, "elements", child_elts); + child_common = common_refpoint_of_array (child_elts, elt, other_axis (a)); + } + child_refpoints.push_back (child_common); } Grob *common_refpoint = common_refpoint_of_array (child_refpoints, me, other_axis (a)); @@ -297,6 +307,27 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a) all_grobs[j]->translate_axis (translates[j], a); } +/* After we have already determined the y-offsets of our children, we may still + want to stretch them a little. */ +void +Align_interface::stretch (Grob *me, Real amount, Axis a) +{ + extract_grob_set (me, "elements", elts); + Real non_empty_elts = 0.0; + for (vsize i = 0; i < elts.size (); i++) + non_empty_elts += !elts[i]->extent (me, a).is_empty (); + + Real offset = 0.0; + Direction dir = robust_scm2dir (me->get_property ("stacking-dir"), DOWN); + for (vsize i = 0; i < elts.size (); i++) + { + elts[i]->translate_axis (dir * offset, a); + if (!elts[i]->extent (me, a).is_empty ()) + offset += amount / non_empty_elts; + } + me->flush_extent_cache (Y_AXIS); +} + Real Align_interface::get_pure_child_y_translation (Grob *me, Grob *ch, int start, int end) { @@ -366,6 +397,31 @@ Align_interface::set_ordered (Grob *me) ga->set_ordered (true); } +MAKE_SCHEME_CALLBACK (Align_interface, calc_max_stretch, 1) +SCM +Align_interface::calc_max_stretch (SCM smob) +{ + Grob *me = unsmob_grob (smob); + Spanner *spanner_me = dynamic_cast (me); + Real ret = 0; + + if (spanner_me) + { + Paper_column *left = dynamic_cast (spanner_me->get_bound (LEFT)); + Real height = me->extent (me, Y_AXIS).length (); + SCM line_break_details = left->get_property ("line-break-system-details"); + SCM fixed_offsets = scm_assq (ly_symbol2scm ("alignment-offsets"), + line_break_details); + + /* if there are fixed offsets, we refuse to stretch */ + if (fixed_offsets != SCM_BOOL_F) + ret = 0; + else + ret = height * height / 80.0; /* why this, exactly? -- jneem */ + } + return scm_from_double (ret); +} + /* Find Y-axis parent of G that has a #'forced-distance property. This has the effect of finding the piano-staff given an object in that