Docs: Add new procedure for barNumberVisibility
[lilypond/mpolesky.git] / lily / tuplet-number.cc
blob117179eb112a3f9464ac3604a6e8b68c091eaadd
1 /*
2 tuplet-number.cc -- implement Tuplet_number
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
10 #include "tuplet-bracket.hh"
11 #include "moment.hh"
12 #include "paper-column.hh"
13 #include "text-interface.hh"
14 #include "spanner.hh"
15 #include "lookup.hh"
17 struct Tuplet_number
19 DECLARE_SCHEME_CALLBACK (print, (SCM));
20 DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
21 DECLARE_GROB_INTERFACE ();
25 MAKE_SCHEME_CALLBACK (Tuplet_number, print, 1);
26 SCM
27 Tuplet_number::print (SCM smob)
29 Spanner *me = unsmob_spanner (smob);
30 Spanner *tuplet = unsmob_spanner (me->get_object ("bracket"));
32 if (!tuplet || !tuplet->is_live ())
34 me->suicide ();
35 return SCM_EOL;
38 SCM stc_scm = Text_interface::print (smob);
39 Stencil *stc = unsmob_stencil (stc_scm);
41 stc->align_to (X_AXIS, CENTER);
42 stc->align_to (Y_AXIS, CENTER);
44 SCM cpoints = tuplet->get_property ("control-points");
45 Drul_array<Offset> points;
46 if (scm_is_pair (cpoints))
48 points[LEFT] = ly_scm2offset (scm_car (cpoints));
49 points[RIGHT] = ly_scm2offset (scm_cadr (cpoints));
51 else
53 programming_error ("wrong type for control-points");
55 stc->translate ((points[RIGHT] + points[LEFT]) / 2);
57 return stc_scm;
60 MAKE_SCHEME_CALLBACK (Tuplet_number, calc_cross_staff, 1)
61 SCM
62 Tuplet_number::calc_cross_staff (SCM smob)
64 Grob *me = unsmob_grob (smob);
65 return unsmob_grob (me->get_object ("bracket"))->get_property ("cross-staff");
68 ADD_INTERFACE (Tuplet_number,
69 "The number for a bracket.",
71 /* properties */
72 "avoid-slur " // UGH.
73 "bracket "