X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fballoon.cc;h=5409bd52d556a1cf6ba6864c401293cbd94a9a80;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=6c29895f4b56a12b08039a6e7d37aaaf3da556db;hpb=402045837e7134cdf90d1fcf31768c62227a4936;p=lilypond.git diff --git a/lily/balloon.cc b/lily/balloon.cc index 6c29895f4b..5409bd52d5 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -1,94 +1,80 @@ /* - balloon.cc -- implement Balloon objects - */ + balloon.cc -- implement Balloon -#include "text-item.hh" + source file of the GNU LilyPond music typesetter + + (c) 2004--2008 Han-Wen Nienhuys +*/ + +#include "text-interface.hh" #include "grob.hh" #include "line-interface.hh" #include "lookup.hh" #include "font-interface.hh" -#include "stencil.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*); + DECLARE_GROB_INTERFACE (); }; MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1); SCM -Balloon_interface::print (SCM smob) +Balloon_interface::print (SCM smob) { - Grob *me= unsmob_grob (smob); - - SCM cb = me->get_grob_property ("balloon-original-callback"); - SCM scm_mol = SCM_EOL; - - if (gh_procedure_p (cb)) - { - scm_mol = scm_call_1 (cb, smob); - } - - if (!unsmob_stencil (scm_mol)) - return scm_mol; - - SCM scm_off = me->get_grob_property ("balloon-text-offset"); - - if (!is_number_pair (scm_off)) - return scm_mol; - - Offset off = ly_scm2offset (scm_off); - Stencil * m = unsmob_stencil (scm_mol); - Box orig_extent = m->extent_box (); - Box box_extent = orig_extent; + Grob *me = unsmob_grob (smob); - Real w = robust_scm2double (me->get_grob_property ("balloon-padding"), .1); - box_extent.widen (w, w); + Grob *p = me->get_parent (X_AXIS); - - Stencil fr = Lookup::frame (box_extent, 0.1, 0.05); + Offset off (me->relative_coordinate (p, X_AXIS), + me->relative_coordinate (p, Y_AXIS)); - - fr.add_stencil (*m); + Box b (p->extent (p, X_AXIS), + p->extent (p, Y_AXIS)); + Real padding = robust_scm2double (me->get_property ("padding"), .1); + b.widen (padding, padding); + // FIXME + Stencil fr = Lookup::frame (b, 0.1, 0.05); - 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 bt = me->get_property ("text"); + SCM chain = Font_interface::text_font_alist_chain (me); + SCM stencil = Text_interface::interpret_markup (me->layout ()->self_scm (), + chain, bt); - SCM text = Text_item::interpret_markup (me->get_paper ()->self_scm (), chain, bt); + Stencil *text_stil = unsmob_stencil (stencil); - - Stencil *text_mol = unsmob_stencil (text); - 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])); - text_mol->align_to (a, -sign (off[a])); + Axis a ((Axis)i); + z1[a] = b[a].linear_combination (sign (off[a])); + text_stil->align_to (a, -sign (off[a])); } Offset z2 = z1 + off; - + fr.add_stencil (Line_interface::line (me, z1, z2)); - text_mol->translate (z2); - fr.add_stencil (*text_mol); - - fr = Stencil (orig_extent, fr.get_expr ()); + text_stil->translate (z2); + fr.add_stencil (*text_stil); + + fr.translate (-off); return fr.smobbed_copy (); } -ADD_INTERFACE (Balloon_interface,"text-balloon-interface", - "comic books.", - "balloon-padding balloon-text-props balloon-text-offset balloon-text balloon-original-callback"); +ADD_INTERFACE (Balloon_interface, + "A collection of routines to put text balloons around an" + " object.", + + /* properties */ + "padding " + "text " + );