X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgrob.cc;h=d5dcf6794dd90233209e94d924972f8fe5612815;hb=91f7915b2a66ab9381c2a8d650f14707c60036d1;hp=435a6faff3a92447ad67c637678a89129f5a09dd;hpb=658c44d32fe6406c472152875346d63211c7bae2;p=lilypond.git diff --git a/lily/grob.cc b/lily/grob.cc index 435a6faff3..d5dcf6794d 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -38,6 +38,7 @@ #include "system.hh" #include "unpure-pure-container.hh" #include "warn.hh" +#include "lily-imports.hh" Grob * @@ -127,7 +128,7 @@ Grob::get_stencil () const return 0; SCM stil = get_property ("stencil"); - return Stencil::unsmob (stil); + return unsmob (stil); } Stencil @@ -136,20 +137,41 @@ Grob::get_print_stencil () const SCM stil = get_property ("stencil"); Stencil retval; - if (Stencil *m = Stencil::unsmob (stil)) + if (Stencil *m = unsmob (stil)) { retval = *m; bool transparent = to_boolean (get_property ("transparent")); + /* Process whiteout before color and grob-cause to prevent colored */ + /* whiteout background and larger file sizes with \pointAndClickOn. */ + /* A grob has to be visible, otherwise the whiteout property has no effect. */ + /* Calls the scheme procedure stencil-whiteout in scm/stencils.scm */ + if (!transparent && (scm_is_number (get_property("whiteout")) + || to_boolean (get_property ("whiteout")))) + { + Real thickness = robust_scm2double (get_property("whiteout"), 3.0) + * layout ()->get_dimension (ly_symbol2scm ("line-thickness")); + retval = *unsmob + (Lily::stencil_whiteout (retval.smobbed_copy (), + scm_from_double (thickness))); + } + + /* Calls the scheme procedure stencil-whiteout-box in scm/stencils.scm */ + if (!transparent && to_boolean (get_property ("whiteout-box"))) + { + retval = *unsmob + (Lily::stencil_whiteout_box (retval.smobbed_copy ())); + } + if (transparent) retval = Stencil (m->extent_box (), SCM_EOL); else { - SCM expr = m->expr (); - expr = scm_list_3 (ly_symbol2scm ("grob-cause"), - self_scm (), expr); + SCM expr = scm_list_3 (ly_symbol2scm ("grob-cause"), + self_scm (), + retval.expr ()); - retval = Stencil (m->extent_box (), expr); + retval = Stencil (retval.extent_box (), expr); } SCM rot = get_property ("rotation"); @@ -173,17 +195,6 @@ Grob::get_print_stencil () const retval = Stencil (retval.extent_box (), expr); } - /* process whiteout */ - /* a grob has to be visible, otherwise the whiteout property has no effect */ - if (!transparent && to_boolean (get_property ("whiteout"))) - { - /* Call the scheme procedure stencil-whiteout in scm/stencils.scm */ - /* to add a round-filled-box stencil to the stencil list */ - retval - = *Stencil::unsmob (scm_call_1 (ly_lily_module_constant ("stencil-whiteout"), - retval.smobbed_copy ())); - } - SCM id = get_property ("id"); if (scm_is_string (id)) { @@ -478,7 +489,7 @@ Grob::extent (Grob *refp, Axis a) const if(!isinf (offset)) real_ext.translate(offset); else - this->warning(_f ("ignored infinite %s-offset", + warning(_f ("ignored infinite %s-offset", a == X_AXIS ? "X" : "Y")); return real_ext; @@ -720,13 +731,13 @@ void Grob::programming_error (const string &s) const { SCM cause = self_scm (); - while (Grob *g = Grob::unsmob (cause)) + while (Grob *g = unsmob (cause)) cause = g->get_property ("cause"); /* ES TODO: cause can't be Music*/ - if (Music *m = Music::unsmob (cause)) + if (Music *m = unsmob (cause)) m->origin ()->programming_error (s); - else if (Stream_event *ev = Stream_event::unsmob (cause)) + else if (Stream_event *ev = unsmob (cause)) ev->origin ()->programming_error (s); else ::programming_error (s); @@ -736,13 +747,13 @@ void Grob::warning (const string &s) const { SCM cause = self_scm (); - while (Grob *g = Grob::unsmob (cause)) + while (Grob *g = unsmob (cause)) cause = g->get_property ("cause"); /* ES TODO: cause can't be Music*/ - if (Music *m = Music::unsmob (cause)) + if (Music *m = unsmob (cause)) m->origin ()->warning (s); - else if (Stream_event *ev = Stream_event::unsmob (cause)) + else if (Stream_event *ev = unsmob (cause)) ev->origin ()->warning (s); else ::warning (s); @@ -754,7 +765,7 @@ Grob::name () const SCM meta = get_property ("meta"); SCM nm = scm_assq (ly_symbol2scm ("name"), meta); nm = (scm_is_pair (nm)) ? scm_cdr (nm) : SCM_EOL; - return scm_is_symbol (nm) ? ly_symbol2string (nm) : this->class_name (); + return scm_is_symbol (nm) ? ly_symbol2string (nm) : class_name (); } ADD_INTERFACE (Grob, @@ -828,6 +839,7 @@ ADD_INTERFACE (Grob, "transparent " "vertical-skylines " "whiteout " + "whiteout-box " ); /**************************************************************** @@ -848,7 +860,7 @@ MAKE_SCHEME_CALLBACK (Grob, stencil_height, 1); SCM Grob::stencil_height (SCM smob) { - Grob *me = Grob::unsmob (smob); + Grob *me = unsmob (smob); return grob_stencil_extent (me, Y_AXIS); } @@ -856,8 +868,8 @@ MAKE_SCHEME_CALLBACK (Grob, pure_stencil_height, 3); SCM Grob::pure_stencil_height (SCM smob, SCM /* beg */, SCM /* end */) { - Grob *me = Grob::unsmob (smob); - if (Stencil::is_smob (me->get_property_data ("stencil"))) + Grob *me = unsmob (smob); + if (unsmob (me->get_property_data ("stencil"))) return grob_stencil_extent (me, Y_AXIS); return ly_interval2scm (Interval ()); @@ -868,7 +880,7 @@ MAKE_SCHEME_CALLBACK (Grob, y_parent_positioning, 1); SCM Grob::y_parent_positioning (SCM smob) { - Grob *me = Grob::unsmob (smob); + Grob *me = unsmob (smob); Grob *par = me->get_parent (Y_AXIS); if (par) (void) par->get_property ("positioning-done"); @@ -880,7 +892,7 @@ MAKE_SCHEME_CALLBACK (Grob, x_parent_positioning, 1); SCM Grob::x_parent_positioning (SCM smob) { - Grob *me = Grob::unsmob (smob); + Grob *me = unsmob (smob); Grob *par = me->get_parent (X_AXIS); if (par) @@ -893,7 +905,7 @@ MAKE_SCHEME_CALLBACK (Grob, stencil_width, 1); SCM Grob::stencil_width (SCM smob) { - Grob *me = Grob::unsmob (smob); + Grob *me = unsmob (smob); return grob_stencil_extent (me, X_AXIS); } @@ -901,7 +913,7 @@ Grob * common_refpoint_of_list (SCM elist, Grob *common, Axis a) { for (; scm_is_pair (elist); elist = scm_cdr (elist)) - if (Grob *s = Grob::unsmob (scm_car (elist))) + if (Grob *s = unsmob (scm_car (elist))) { if (common) common = common->common_refpoint (s, a);