]> git.donarmstrong.com Git - lilypond.git/blob - lily/tuplet-number.cc
Grand fixcc.py run on all .hh .cc files.
[lilypond.git] / lily / tuplet-number.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6
7   LilyPond is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "tuplet-bracket.hh"
22 #include "moment.hh"
23 #include "paper-column.hh"
24 #include "text-interface.hh"
25 #include "spanner.hh"
26 #include "lookup.hh"
27
28 struct Tuplet_number
29 {
30   DECLARE_SCHEME_CALLBACK (print, (SCM));
31   DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
32   DECLARE_GROB_INTERFACE ();
33 };
34
35 MAKE_SCHEME_CALLBACK (Tuplet_number, print, 1);
36 SCM
37 Tuplet_number::print (SCM smob)
38 {
39   Spanner *me = unsmob_spanner (smob);
40   Spanner *tuplet = unsmob_spanner (me->get_object ("bracket"));
41
42   if (!tuplet || !tuplet->is_live ())
43     {
44       me->suicide ();
45       return SCM_EOL;
46     }
47
48   SCM stc_scm = Text_interface::print (smob);
49   Stencil *stc = unsmob_stencil (stc_scm);
50
51   stc->align_to (X_AXIS, CENTER);
52   stc->align_to (Y_AXIS, CENTER);
53
54   SCM cpoints = tuplet->get_property ("control-points");
55   Drul_array<Offset> points;
56   if (scm_is_pair (cpoints))
57     {
58       points[LEFT] = ly_scm2offset (scm_car (cpoints));
59       points[RIGHT] = ly_scm2offset (scm_cadr (cpoints));
60     }
61   else
62     {
63       programming_error ("wrong type for control-points");
64     }
65   stc->translate ((points[RIGHT] + points[LEFT]) / 2);
66
67   return stc_scm;
68 }
69
70 MAKE_SCHEME_CALLBACK (Tuplet_number, calc_cross_staff, 1)
71 SCM
72 Tuplet_number::calc_cross_staff (SCM smob)
73 {
74   Grob *me = unsmob_grob (smob);
75   return unsmob_grob (me->get_object ("bracket"))->get_property ("cross-staff");
76 }
77
78 ADD_INTERFACE (Tuplet_number,
79                "The number for a bracket.",
80
81                /* properties */
82                "avoid-slur "    // UGH.
83                "bracket "
84                "direction "
85               );
86