X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fballoon.cc;h=5252e88077a441977a5e6927943d85e788bd8e1f;hb=c1a0e9792fcd6a23573ded6e19a37ead6b782b32;hp=560a2f667586ec4ca0eb2fd51067f9a0bb98d8b4;hpb=75eebcb49e52d296b1da3e1074e0825d2c780db4;p=lilypond.git diff --git a/lily/balloon.cc b/lily/balloon.cc index 560a2f6675..5252e88077 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2004--2006 Han-Wen Nienhuys + (c) 2004--2007 Han-Wen Nienhuys */ #include "text-interface.hh" @@ -19,7 +19,7 @@ class Balloon_interface { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob *); + DECLARE_GROB_INTERFACE (); }; MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1); @@ -28,42 +28,33 @@ Balloon_interface::print (SCM smob) { Grob *me = unsmob_grob (smob); - SCM stil = me->get_property ("original-stencil"); - if (!unsmob_stencil (stil)) - return stil; + Grob *p = me->get_parent (X_AXIS); + + Offset off (me->relative_coordinate (p, X_AXIS), + me->relative_coordinate (p, Y_AXIS)); - SCM scm_off = me->get_property ("balloon-text-offset"); + Box b (p->extent (p, X_AXIS), + p->extent (p, Y_AXIS)); - if (!is_number_pair (scm_off)) - return stil; - - Offset off = ly_scm2offset (scm_off); - Stencil *s = unsmob_stencil (stil); - Box orig_extent = s->extent_box (); - Box box_extent = orig_extent; - - Real w = robust_scm2double (me->get_property ("balloon-padding"), .1); - box_extent.widen (w, w); + Real padding = robust_scm2double (me->get_property ("padding"), .1); + b.widen (padding, padding); // FIXME - Stencil fr = Lookup::frame (box_extent, 0.1, 0.05); - - fr.add_stencil (*s); + Stencil fr = Lookup::frame (b, 0.1, 0.05); - SCM bt = me->get_property ("balloon-text"); + SCM bt = me->get_property ("text"); SCM chain = Font_interface::text_font_alist_chain (me); - chain = scm_cons (me->get_property ("balloon-text-props"), chain); - SCM text = Text_interface::interpret_markup (me->layout ()->self_scm (), + SCM stencil = Text_interface::interpret_markup (me->layout ()->self_scm (), chain, bt); - Stencil *text_stil = unsmob_stencil (text); + Stencil *text_stil = unsmob_stencil (stencil); Offset z1; for (int i = X_AXIS; i < NO_AXES; i++) { Axis a ((Axis)i); - z1[a] = box_extent [a].linear_combination (sign (off[a])); + z1[a] = b[a].linear_combination (sign (off[a])); text_stil->align_to (a, -sign (off[a])); } @@ -74,17 +65,16 @@ Balloon_interface::print (SCM smob) text_stil->translate (z2); fr.add_stencil (*text_stil); - fr = Stencil (orig_extent, fr.expr ()); + fr.translate (-off); return fr.smobbed_copy (); } -ADD_INTERFACE (Balloon_interface, "text-balloon-interface", - "A collection of routines to put text balloons around an object.", +ADD_INTERFACE (Balloon_interface, + "A collection of routines to put text balloons around an" + " object.", /* properties */ - "balloon-padding " - "balloon-text-props " - "balloon-text-offset " - "balloon-text " - "original-stencil "); + "padding " + "text " + );