X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fballoon.cc;h=2a2594ee92f7be678644dcc5262d6b7afe47aad8;hb=459216bffe7aa64cd1e9f31f1fda28f90f6e9c1c;hp=9bb11b2017f8f70c4bd812b2e78e3b9d8fc42369;hpb=05fabaaf86fd44f9bd903f282bb98d343a991e40;p=lilypond.git diff --git a/lily/balloon.cc b/lily/balloon.cc index 9bb11b2017..2a2594ee92 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -1,94 +1,89 @@ /* - balloon.cc -- implement Balloon objects - */ + balloon.cc -- implement Balloon + + source file of the GNU LilyPond music typesetter + + (c) 2004--2005 Han-Wen Nienhuys +*/ #include "text-item.hh" #include "grob.hh" #include "line-interface.hh" #include "lookup.hh" #include "font-interface.hh" -#include "molecule.hh" #include "lily-guile.hh" -#include "paper-def.hh" +#include "output-def.hh" #include "misc.hh" -struct Balloon_interface +class Balloon_interface { - public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - static bool has_interface (Grob*); + static bool has_interface (Grob *); }; MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1); SCM -Balloon_interface::print (SCM smob) +Balloon_interface::print (SCM smob) { - Grob *me= unsmob_grob (smob); + Grob *me = unsmob_grob (smob); - SCM cb = me->get_grob_property ("balloon-original-callback"); - SCM scm_mol = SCM_EOL; + SCM cb = me->get_property ("balloon-original-callback"); + SCM stil = SCM_EOL; - if (gh_procedure_p (cb)) - { - scm_mol = scm_call_1 (cb, smob); - } + if (ly_c_procedure_p (cb)) + stil = scm_call_1 (cb, smob); - if (!unsmob_molecule (scm_mol)) - return scm_mol; + if (!unsmob_stencil (stil)) + return stil; - SCM scm_off = me->get_grob_property ("balloon-text-offset"); + SCM scm_off = me->get_property ("balloon-text-offset"); if (!is_number_pair (scm_off)) - return scm_mol; + return stil; Offset off = ly_scm2offset (scm_off); - Molecule * m = unsmob_molecule (scm_mol); - Box orig_extent = m->extent_box (); + Stencil *s = unsmob_stencil (stil); + Box orig_extent = s->extent_box (); Box box_extent = orig_extent; - Real w = robust_scm2double (me->get_grob_property ("balloon-padding"), .1); + Real w = robust_scm2double (me->get_property ("balloon-padding"), .1); box_extent.widen (w, w); - - - Molecule fr = Lookup::frame (box_extent, 0.1, 0.05); - - fr.add_molecule (*m); + // FIXME + Stencil fr = Lookup::frame (box_extent, 0.1, 0.05); + fr.add_stencil (*s); + SCM bt = me->get_property ("balloon-text"); + SCM chain = Font_interface::text_font_alist_chain (me); + chain = scm_cons (me->get_property ("balloon-text-props"), chain); - SCM bt = me->get_grob_property ("balloon-text"); - SCM chain = Font_interface::font_alist_chain (me); - chain = gh_cons (me->get_grob_property ("balloon-text-props"), chain); + SCM text = Text_interface::interpret_markup (me->get_layout ()->self_scm (), + chain, bt); + Stencil *text_stil = unsmob_stencil (text); - SCM text = Text_item::interpret_markup (me->get_paper ()->self_scm (), chain, bt); - - - Molecule *text_mol = unsmob_molecule (text); - Offset z1; - for (int i = X_AXIS; i < NO_AXES; i++) { - Axis a((Axis)i); + Axis a ((Axis)i); z1[a] = box_extent [a].linear_combination (sign (off[a])); - text_mol->align_to (a, -sign (off[a])); + text_stil->align_to (a, -sign (off[a])); } Offset z2 = z1 + off; - - fr.add_molecule (Line_interface::line (me, z1, z2)); - text_mol->translate (z2); - fr.add_molecule (*text_mol); - - fr = Molecule (orig_extent, fr.get_expr ()); + fr.add_stencil (Line_interface::line (me, z1, z2)); + + text_stil->translate (z2); + fr.add_stencil (*text_stil); + + fr = Stencil (orig_extent, fr.expr ()); return fr.smobbed_copy (); } -ADD_INTERFACE (Balloon_interface,"text-balloon-interface", - "comic books.", +ADD_INTERFACE (Balloon_interface, "text-balloon-interface", + "A collection of routines to put text balloons around an object.", "balloon-padding balloon-text-props balloon-text-offset balloon-text balloon-original-callback");