X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fottava-bracket.cc;h=25de958243775ffacffb8bb1aa37597c0e9a2e29;hb=ca20eaa74e7e762c0611de26cc2267909ae27e02;hp=efbac77ea030ec3ab9747d73917a85b246d676a0;hpb=b1323f33e9aa4b9eea05eefb8755c907d4d762d4;p=lilypond.git diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc index efbac77ea0..25de958243 100644 --- a/lily/ottava-bracket.cc +++ b/lily/ottava-bracket.cc @@ -3,24 +3,23 @@ source file of the GNU LilyPond music typesetter - (c) 2004 Han-Wen Nienhuys + (c) 2004--2005 Han-Wen Nienhuys */ -#include "stencil.hh" #include "text-item.hh" -#include "text-spanner.hh" #include "line-spanner.hh" #include "spanner.hh" #include "font-interface.hh" #include "dimensions.hh" -#include "paper-def.hh" +#include "output-def.hh" #include "warn.hh" #include "paper-column.hh" #include "staff-symbol-referencer.hh" #include "note-column.hh" #include "directional-element-interface.hh" #include "tuplet-bracket.hh" +#include "rhythmic-head.hh" struct Ottava_bracket { @@ -31,26 +30,21 @@ struct Ottava_bracket /* TODO: the string for ottava shoudl depend on the available space, ie. - Long: 15ma Short: 15ma Empty: 15 8va 8va 8 8va bassa 8ba 8 */ - MAKE_SCHEME_CALLBACK (Ottava_bracket, print, 1); SCM Ottava_bracket::print (SCM smob) { Spanner*me = dynamic_cast (unsmob_grob (smob)); - - Interval span_points; Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS); - Paper_def * paper = me->get_paper(); - + Output_def * layout = me->get_layout (); Drul_array broken; Direction d = LEFT; @@ -61,20 +55,28 @@ Ottava_bracket::print (SCM smob) if (Note_column::has_interface (b)) { - common = common_refpoint_of_list (b->get_property ("heads"), common, X_AXIS); + SCM heads = b->get_property ("note-heads"); + common = common_refpoint_of_list (heads, common, X_AXIS); + for (SCM s = heads; scm_is_pair (s); s = scm_cdr (s)) + { + Grob * h = unsmob_grob (scm_car (s)); + Grob * dots = Rhythmic_head::get_dots (h); + if (dots) + common = dots->common_refpoint (common, X_AXIS); + } } } while (flip (&d) != LEFT); - SCM properties = Font_interface::font_alist_chain (me); + SCM properties = Font_interface::text_font_alist_chain (me); SCM markup = me->get_property ("text"); Stencil text; - if (Text_item::markup_p (markup)) - text = *unsmob_stencil (Text_item::interpret_markup (paper->self_scm (), properties, markup)); + if (Text_interface::markup_p (markup)) + text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, markup)); Drul_array shorten = robust_scm2interval (me->get_property ("shorten-pair"), - Interval (0,0)); + Interval (0, 0)); /* @@ -88,17 +90,32 @@ Ottava_bracket::print (SCM smob) Interval ext; if (Note_column::has_interface (b)) { - for (SCM s = b->get_property ("note-heads"); gh_pair_p (s); s =gh_cdr (s)) - ext.unite (unsmob_grob (gh_car (s))->extent (common, X_AXIS)); + for (SCM s = b->get_property ("note-heads"); scm_is_pair (s); s = scm_cdr (s)) + { + Grob * h = unsmob_grob (scm_car (s)); + ext.unite (h->extent (common, X_AXIS)); + Grob * dots = Rhythmic_head::get_dots (h); + + if (dots && d == RIGHT) + { + ext.unite (dots->extent (common, X_AXIS)); + } + } } - - if (ext.is_empty ()) - ext = Interval (0,0); - span_points[d] = (broken [d]) ? b->extent (common, X_AXIS)[-d] : ext[d]; + if (ext.is_empty ()) + { + ext = robust_relative_extent (b, common, X_AXIS); + } if (broken[d]) - shorten [d] = 0.0; + { + span_points[d] = b->extent (common, X_AXIS)[RIGHT]; + shorten[d] = 0.; + } + + else + span_points[d] = ext[d]; } while (flip (&d) != LEFT); @@ -121,7 +138,7 @@ Ottava_bracket::print (SCM smob) Drul_array flare = robust_scm2interval (me->get_property ("bracket-flare"), - Interval (0,0)); + Interval (0, 0)); @@ -131,11 +148,12 @@ Ottava_bracket::print (SCM smob) edge_height[RIGHT] = 0.0; Stencil b; + Interval empty; if (!bracket_span_points.is_empty () && bracket_span_points.length () > 0.001) b = Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (bracket_span_points.length (), 0), edge_height, - 0.0, + empty, flare, shorten); /* @@ -154,8 +172,8 @@ Ottava_bracket::print (SCM smob) */ b = Stencil (Box (b.extent (X_AXIS), - Interval (0.1,0.1)), - b.get_expr ()); + Interval (0.1, 0.1)), + b.expr ()); b.translate_axis (bracket_span_points[LEFT], X_AXIS); text.translate_axis (span_points[LEFT], X_AXIS);