2 balloon.cc -- implement Balloon
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "text-interface.hh"
11 #include "line-interface.hh"
13 #include "font-interface.hh"
14 #include "lily-guile.hh"
15 #include "output-def.hh"
18 class Balloon_interface
21 DECLARE_SCHEME_CALLBACK (print, (SCM));
22 DECLARE_GROB_INTERFACE ();
25 MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1);
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);
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 (),
51 Stencil *text_stil = unsmob_stencil (stencil);
54 for (int i = X_AXIS; i < NO_AXES; i++)
57 z1[a] = b[a].linear_combination (sign (off[a]));
58 text_stil->align_to (a, -sign (off[a]));
63 fr.add_stencil (Line_interface::line (me, z1, z2));
65 text_stil->translate (z2);
66 fr.add_stencil (*text_stil);
69 return fr.smobbed_copy ();
72 ADD_INTERFACE (Balloon_interface,
73 "A collection of routines to put text balloons around an"