X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ffigured-bass-continuation.cc;h=283731ff80d4f22380513d39bddbd730780e9322;hb=c77189ccaa4e645850ad61779de7a4c8f3fdbc6f;hp=951807440f7b3886e76ac3e3849d40296312771d;hpb=30eb1ded55e8d8b17495b96a3741750fe34d3599;p=lilypond.git diff --git a/lily/figured-bass-continuation.cc b/lily/figured-bass-continuation.cc index 951807440f..283731ff80 100644 --- a/lily/figured-bass-continuation.cc +++ b/lily/figured-bass-continuation.cc @@ -1,14 +1,24 @@ /* - figured-bass-continuation.cc -- implement Figured_bass_continuation + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2010 Han-Wen Nienhuys - (c) 2005 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "line-interface.hh" -#include "lily-guile.hh" #include "spanner.hh" #include "output-def.hh" #include "item.hh" @@ -19,81 +29,28 @@ #include "horizontal-bracket.hh" -struct Figured_bass_bracket -{ - static bool has_interface (Grob*); - -public: - DECLARE_SCHEME_CALLBACK(print, (SCM)); -}; - - -ADD_INTERFACE(Figured_bass_bracket, - "figured-bass-bracket-interface", - "Brackets alongside bass figures.", - - /* props */ - - /* ugh: should make bracket interface. */ - "bracket-flare " - "shorten-pair " - "edge-height " - "padding " - "thickness " - "elements " - ); - -MAKE_SCHEME_CALLBACK (Figured_bass_bracket, print, 1); -SCM -Figured_bass_bracket::print (SCM grob) -{ - Grob *me = unsmob_grob (grob); - extract_grob_set (me, "elements", elements); - if (elements.is_empty ()) - { - me->suicide (); - return SCM_EOL; - } - - Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS); - Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS); - - Stencil left_br = Horizontal_bracket::make_bracket (me, me, elements, - Y_AXIS, LEFT); - Stencil right_br = Horizontal_bracket::make_bracket (me, me, elements, - Y_AXIS, RIGHT); - - xext.widen (robust_scm2double (me->get_property ("padding"), 0.25)); - left_br.translate_axis (xext[LEFT], X_AXIS); - right_br.translate_axis (xext[RIGHT], X_AXIS); - - left_br.add_stencil (right_br); - left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS); - return left_br.smobbed_copy (); -} - - struct Figured_bass_continuation { - static bool has_interface (Grob*); + DECLARE_GROB_INTERFACE (); public: - DECLARE_SCHEME_CALLBACK(print, (SCM)); - DECLARE_SCHEME_CALLBACK(center_on_figures, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (center_on_figures, (SCM)); }; -MAKE_SCHEME_CALLBACK (Figured_bass_continuation, center_on_figures, 2); +MAKE_SCHEME_CALLBACK (Figured_bass_continuation, center_on_figures, 1); SCM -Figured_bass_continuation::center_on_figures (SCM grob, SCM axis) +Figured_bass_continuation::center_on_figures (SCM grob) { Spanner *me = dynamic_cast (unsmob_grob (grob)); - (void) axis; - extract_grob_set (me, "figures", figures); + if (figures.empty ()) + return scm_from_double (0.0); Grob *common = common_refpoint_of_array (figures, me, Y_AXIS); Interval ext = Axis_group_interface::relative_group_extent (figures, common, Y_AXIS); - + if (ext.is_empty ()) + return scm_from_double (0.0); return scm_from_double (ext.center () - me->relative_coordinate (common, Y_AXIS)); } @@ -104,7 +61,7 @@ Figured_bass_continuation::print (SCM grob) Spanner *me = dynamic_cast (unsmob_grob (grob)); Real thick = - me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")) + me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")) * robust_scm2double (me->get_property ("thickness"), 1); Interval spanned; @@ -113,26 +70,33 @@ Figured_bass_continuation::print (SCM grob) X_AXIS); do { + Item *bound = me->get_bound (d); + Direction extdir = + (d == LEFT && to_boolean (bound->get_property ("implicit"))) + ? LEFT : RIGHT; + spanned[d] - = robust_relative_extent (me->get_bound (d), common, X_AXIS)[RIGHT] + = robust_relative_extent (bound, common, X_AXIS)[extdir] - me->relative_coordinate (common, X_AXIS); } while (flip (&d) != LEFT); + spanned.widen (- robust_scm2double (me->get_property ("padding"), 0.2)); - Stencil extender - = Line_interface::make_line (thick, - Offset (spanned[LEFT], 0), - Offset (spanned[RIGHT], 0)); + Stencil extender; + if (!spanned.is_empty ()) + extender = Line_interface::make_line (thick, + Offset (spanned[LEFT], 0), + Offset (spanned[RIGHT], 0)); return extender.smobbed_copy (); } -ADD_INTERFACE(Figured_bass_continuation, - "figured-bass-continuation-interface", +ADD_INTERFACE (Figured_bass_continuation, "Simple extender line between bounds.", - /* props */ + /* properties */ "thickness " + "padding " "figures " );