X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fballoon.cc;h=d323121b3e1f1e5bde93b465a6dfb9e1d328664a;hb=9578677bb2b3929964e8cc2c906df5c98b8a50c4;hp=672fb95a4d2e9212d8548617d56124a0495fc637;hpb=82a9add4f1d4790bddb79459d5f63b01b3e7cc97;p=lilypond.git diff --git a/lily/balloon.cc b/lily/balloon.cc index 672fb95a4d..d323121b3e 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2004--2011 Han-Wen Nienhuys + Copyright (C) 2004--2012 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,6 @@ #include "output-def.hh" #include "misc.hh" #include "spanner.hh" -#include "international.hh" class Balloon_interface { @@ -35,6 +34,8 @@ public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (print_spanner, (SCM)); DECLARE_GROB_INTERFACE (); + + static SCM internal_balloon_print (Grob *me, Grob *p, Offset off); }; MAKE_SCHEME_CALLBACK (Balloon_interface, print, 1); @@ -43,83 +44,52 @@ Balloon_interface::print (SCM smob) { Grob *me = unsmob_grob (smob); - Grob *p = me->get_parent (X_AXIS); - - Offset off (me->relative_coordinate (p, X_AXIS), - me->relative_coordinate (p, Y_AXIS)); + if (Item *item = dynamic_cast (me)) + if (!Item::break_visible (item)) + return SCM_EOL; - Box b (p->extent (p, X_AXIS), - p->extent (p, Y_AXIS)); + Grob *p = me->get_parent (X_AXIS); - Real padding = robust_scm2double (me->get_property ("padding"), .1); - b.widen (padding, padding); + Offset off (me->relative_coordinate (p, X_AXIS), + me->relative_coordinate (p, Y_AXIS)); - // FIXME - Stencil fr; - if (to_boolean (me->get_property ("annotation-balloon"))) - fr = Lookup::frame (b, 0.1, 0.05); + return internal_balloon_print (me, p, off); +} - SCM bt = me->get_property ("text"); - SCM chain = Font_interface::text_font_alist_chain (me); +MAKE_SCHEME_CALLBACK (Balloon_interface, print_spanner, 1); +SCM +Balloon_interface::print_spanner (SCM smob) +{ + Spanner *me = unsmob_spanner (smob); + Spanner *orig = dynamic_cast (me->original ()); - SCM stencil = Text_interface::interpret_markup (me->layout ()->self_scm (), - chain, bt); + if (orig) + { + Direction spanner_placement = robust_scm2dir (me->get_property ("spanner-placement"), LEFT); - Stencil *text_stil = unsmob_stencil (stencil); + Spanner *wanted = (spanner_placement != RIGHT) + ? orig->broken_intos_[0] + : orig->broken_intos_.back (); - Offset z1; - for (int i = X_AXIS; i < NO_AXES; i++) - { - Axis a ((Axis)i); - z1[a] = b[a].linear_combination (sign (off[a])); - text_stil->align_to (a, -sign (off[a])); + if (me != wanted) + return SCM_EOL; } - Offset z2 = z1 + off; - - if (to_boolean (me->get_property ("annotation-line"))) - fr.add_stencil (Line_interface::line (me, z1, z2)); + Spanner *p = dynamic_cast (me->get_parent (Y_AXIS)); - text_stil->translate (z2); - fr.add_stencil (*text_stil); + if (!p) + return SCM_EOL; - fr.translate (-off); - return fr.smobbed_copy (); + Offset off (me->relative_coordinate (me->get_bound (LEFT), X_AXIS), + me->relative_coordinate (p, Y_AXIS)); + return internal_balloon_print (me, p, off); } -// ugh...code dup...hopefully can be consolidated w/ above one day -MAKE_SCHEME_CALLBACK (Balloon_interface, print_spanner, 1); SCM -Balloon_interface::print_spanner (SCM smob) +Balloon_interface::internal_balloon_print (Grob *me, Grob *p, Offset off) { - Spanner *me = unsmob_spanner (smob); - Spanner *parent = unsmob_spanner (me->get_property ("parent-spanner")); - Spanner *p; - message (_f ("foo %d", robust_scm2int (me->get_property ("spanner-to-annotate"), 0))); - message (_f ("bar %d", robust_scm2int (me->broken_intos_[0]->get_property ("spanner-to-annotate"), 0))); - if (parent->broken_intos_.size () == 0) - p = parent; - else - p = parent->broken_intos_[robust_scm2int (me->get_property ("spanner-to-annotate"), 0) % parent->broken_intos_.size ()]; - - - Drul_array bounds; - Direction d = LEFT; - - do - { - bounds[d] = me->get_bound (d); - } - while (flip (&d) != LEFT); - - Grob *commonx = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); - - Offset off (me->relative_coordinate (commonx, X_AXIS), - me->relative_coordinate (p, Y_AXIS)); - Box b (p->extent (p, X_AXIS), - p->extent (p, Y_AXIS)); - + p->extent (p, Y_AXIS)); Real padding = robust_scm2double (me->get_property ("padding"), .1); b.widen (padding, padding); @@ -130,13 +100,12 @@ Balloon_interface::print_spanner (SCM smob) 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); - + chain, bt); Stencil *text_stil = unsmob_stencil (stencil); Offset z1; + for (int i = X_AXIS; i < NO_AXES; i++) { Axis a ((Axis)i); @@ -157,14 +126,14 @@ Balloon_interface::print_spanner (SCM smob) } ADD_INTERFACE (Balloon_interface, - "A collection of routines to put text balloons around an" - " object.", - - /* properties */ - "annotation-balloon " - "annotation-line " - "padding " - "spanner-to-annotate " - "text " - ); + "A collection of routines to put text balloons around an" + " object.", + + /* properties */ + "annotation-balloon " + "annotation-line " + "padding " + "spanner-placement " + "text " + );