Nitpick: ly:spanner-bound grob name slur -> spanner.
[lilypond.git] / lily / balloon.cc
blob0c82fdca8e4a35e00094b0d2f2fe5870d070c726
1 /*
2 balloon.cc -- implement Balloon
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "text-interface.hh"
10 #include "grob.hh"
11 #include "line-interface.hh"
12 #include "lookup.hh"
13 #include "font-interface.hh"
14 #include "lily-guile.hh"
15 #include "output-def.hh"
16 #include "misc.hh"
18 class Balloon_interface
20 public:
21 DECLARE_SCHEME_CALLBACK (print, (SCM));
22 DECLARE_GROB_INTERFACE ();
25 MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1);
26 SCM
27 Balloon_interface::print (SCM smob)
29 Grob *me = unsmob_grob (smob);
31 Grob *p = me->get_parent (X_AXIS);
33 Offset off (me->relative_coordinate (p, X_AXIS),
34 me->relative_coordinate (p, Y_AXIS));
36 Box b (p->extent (p, X_AXIS),
37 p->extent (p, Y_AXIS));
39 Real padding = robust_scm2double (me->get_property ("padding"), .1);
40 b.widen (padding, padding);
42 // FIXME
43 Stencil fr = Lookup::frame (b, 0.1, 0.05);
45 SCM bt = me->get_property ("text");
46 SCM chain = Font_interface::text_font_alist_chain (me);
48 SCM stencil = Text_interface::interpret_markup (me->layout ()->self_scm (),
49 chain, bt);
51 Stencil *text_stil = unsmob_stencil (stencil);
53 Offset z1;
54 for (int i = X_AXIS; i < NO_AXES; i++)
56 Axis a ((Axis)i);
57 z1[a] = b[a].linear_combination (sign (off[a]));
58 text_stil->align_to (a, -sign (off[a]));
61 Offset z2 = z1 + off;
63 fr.add_stencil (Line_interface::line (me, z1, z2));
65 text_stil->translate (z2);
66 fr.add_stencil (*text_stil);
68 fr.translate (-off);
69 return fr.smobbed_copy ();
72 ADD_INTERFACE (Balloon_interface,
73 "A collection of routines to put text balloons around an"
74 " object.",
76 /* properties */
77 "padding "
78 "text "