X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhorizontal-bracket.cc;h=b453985b091b6ef31c7ff16f3b6f5110597d6232;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=7f3c839e9121bb261c2487e57ab7c007e0c5d58e;hpb=08560a1b8076630c4fc6cb9b902614d8b74fd6fc;p=lilypond.git diff --git a/lily/horizontal-bracket.cc b/lily/horizontal-bracket.cc index 7f3c839e91..b453985b09 100644 --- a/lily/horizontal-bracket.cc +++ b/lily/horizontal-bracket.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2002--2012 Han-Wen Nienhuys + Copyright (C) 2002--2015 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,91 +19,18 @@ #include "horizontal-bracket.hh" -#include "lookup.hh" -#include "side-position-interface.hh" +#include "bracket.hh" +#include "stencil.hh" #include "pointer-group-interface.hh" #include "directional-element-interface.hh" -#include "output-def.hh" -#include "staff-symbol-referencer.hh" -#include "tuplet-bracket.hh" -#include "axis-group-interface.hh" #include "spanner.hh" #include "item.hh" -Stencil -Horizontal_bracket::make_bracket (Grob *me, - Real length, - Axis a, Direction dir) -{ - Drul_array edge_height = robust_scm2interval (me->get_property ("edge-height"), - Interval (1.0, 1.0)); - Drul_array flare = robust_scm2interval (me->get_property ("bracket-flare"), - Interval (0, 0)); - Drul_array shorten = robust_scm2interval (me->get_property ("shorten-pair"), - Interval (0, 0)); - - // Make sure that it points in the correct direction: - scale_drul (&edge_height, Real (-dir)); - - Interval empty; - Offset start; - start[a] = length; - - Drul_array connect_to_other - = robust_scm2booldrul (me->get_property ("connect-to-neighbor"), - Drul_array (false, false)); - - Direction d = LEFT; - do - { - if (connect_to_other[d]) - { - edge_height[d] = 0.0; - flare[d] = 0.0; - shorten[d] = 0.0; - } - } - while (flip (&d) != LEFT); - - /* - ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. - */ - return Tuplet_bracket::make_bracket (me, other_axis (a), start, - edge_height, empty, flare, shorten); -} - -Stencil -Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint, - vector grobs, - Axis a, Direction dir) -{ - Grob *common = common_refpoint_of_array (grobs, refpoint, a); - Interval ext = Axis_group_interface::relative_group_extent (grobs, common, a); - - if (ext.is_empty ()) - { - me->programming_error ("Can't enclose empty extents with bracket"); - return Stencil (); - } - else - { - Stencil b = make_bracket (me, ext.length (), a, dir); - b.translate_axis (ext[LEFT] - refpoint->relative_coordinate (common, a), a); - - return b; - } -} - -/* - TODO: - - Support texts on the brackets? -*/ MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1); SCM Horizontal_bracket::print (SCM smob) { - Spanner *me = unsmob_spanner (smob); + Spanner *me = unsmob (smob); extract_grob_set (me, "columns", gs); vector enclosed = gs; @@ -113,16 +40,15 @@ Horizontal_bracket::print (SCM smob) return SCM_EOL; } - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *b = me->get_bound (d); if (b->break_status_dir ()) enclosed.push_back (b); } - while (flip (&d) != LEFT); - Stencil b = make_enclosing_bracket (me, me, enclosed, X_AXIS, get_grob_direction (me)); + Stencil b = Bracket::make_enclosing_bracket (me, me, enclosed, X_AXIS, + get_grob_direction (me)); return b.smobbed_copy (); } @@ -131,6 +57,7 @@ ADD_INTERFACE (Horizontal_bracket, /* properties */ "bracket-flare " + "bracket-text " "columns " "edge-height " "shorten-pair "