X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftuplet-number.cc;h=69e97afef04b6435e1494c28019405d580102c2f;hb=9e484cffc04d14eab77cb8fd8ead727892310b60;hp=d04e8f3aadfd4d1f934a5846e142dd483f6d8330;hpb=75eebcb49e52d296b1da3e1074e0825d2c780db4;p=lilypond.git diff --git a/lily/tuplet-number.cc b/lily/tuplet-number.cc index d04e8f3aad..69e97afef0 100644 --- a/lily/tuplet-number.cc +++ b/lily/tuplet-number.cc @@ -1,52 +1,101 @@ /* - tuplet-number.cc -- implement Tuplet_number + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2012 Han-Wen Nienhuys - (c) 2005--2006 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 "tuplet-bracket.hh" +#include "moment.hh" +#include "paper-column.hh" #include "text-interface.hh" #include "spanner.hh" #include "lookup.hh" struct Tuplet_number { - DECLARE_SCHEME_CALLBACK(print, (SCM)); - static bool has_interface (Grob *); + DECLARE_SCHEME_CALLBACK (print, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_x_offset, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_y_offset, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); + DECLARE_GROB_INTERFACE (); + + static Real calc_offset (Spanner *me, Axis a); }; - -MAKE_SCHEME_CALLBACK(Tuplet_number, print, 1); -SCM +MAKE_SCHEME_CALLBACK (Tuplet_number, print, 1); +SCM Tuplet_number::print (SCM smob) { - Stencil *stc = unsmob_stencil (Text_interface::print (smob)); + Spanner *me = unsmob_spanner (smob); + Spanner *tuplet = unsmob_spanner (me->get_object ("bracket")); + + if (!tuplet || !tuplet->is_live ()) + { + me->suicide (); + return SCM_EOL; + } + + SCM stc_scm = Text_interface::print (smob); + Stencil *stc = unsmob_stencil (stc_scm); stc->align_to (X_AXIS, CENTER); stc->align_to (Y_AXIS, CENTER); - Spanner *me = unsmob_spanner (smob); - Spanner *tuplet = unsmob_spanner (me->get_object ("bracket")); - SCM cpoints = tuplet->get_property ("control-points"); - Drul_array points; - points[LEFT] = ly_scm2offset (scm_car (cpoints)); - points[RIGHT] = ly_scm2offset (scm_cadr (cpoints)); - - stc->translate ((points[RIGHT] + points[LEFT]) / 2); - return stc->smobbed_copy (); } +MAKE_SCHEME_CALLBACK (Tuplet_number, calc_x_offset, 1); +SCM +Tuplet_number::calc_x_offset (SCM smob) +{ + Spanner *me = unsmob_spanner (smob); + Spanner *tuplet = unsmob_spanner (me->get_object ("bracket")); + + Interval x_positions = robust_scm2interval (tuplet->get_property ("X-positions"), Interval (0.0, 0.0)); + + return scm_from_double (x_positions.center ()); +} + +MAKE_SCHEME_CALLBACK (Tuplet_number, calc_y_offset, 1); +SCM +Tuplet_number::calc_y_offset (SCM smob) +{ + + Spanner *me = unsmob_spanner (smob); + Spanner *tuplet = unsmob_spanner (me->get_object ("bracket")); + + Drul_array positions = robust_scm2drul (tuplet->get_property ("positions"), Drul_array (0.0, 0.0)); + return scm_from_double ((positions[LEFT] + positions[RIGHT]) / 2.0); +} + +MAKE_SCHEME_CALLBACK (Tuplet_number, calc_cross_staff, 1) +SCM +Tuplet_number::calc_cross_staff (SCM smob) +{ + Grob *me = unsmob_grob (smob); + return unsmob_grob (me->get_object ("bracket"))->get_property ("cross-staff"); +} ADD_INTERFACE (Tuplet_number, - "tuplet-number-interface", - "The number for a bracket. " - , + "The number for a bracket.", - /* properties */ - "avoid-slur " // UGH. - "bracket "); + /* properties */ + "avoid-slur " // UGH. + "bracket " + "direction " + );