X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgrob.cc;h=d5dcf6794dd90233209e94d924972f8fe5612815;hb=c7acad264e49f23e333dd66a0e1d50005c630068;hp=90a7dbac20a9e5ec98793c5432603d8c82883a01;hpb=f4abbfff5f0d985a457e15586dbcc3ae473b0dee;p=lilypond.git diff --git a/lily/grob.cc b/lily/grob.cc index 90a7dbac20..d5dcf6794d 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1997--2014 Han-Wen Nienhuys + Copyright (C) 1997--2015 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 @@ -38,8 +38,8 @@ #include "system.hh" #include "unpure-pure-container.hh" #include "warn.hh" +#include "lily-imports.hh" -#include "ly-smobs.icc" Grob * Grob::clone () const @@ -51,7 +51,6 @@ Grob::Grob (SCM basicprops) { /* FIXME: default should be no callback. */ - self_scm_ = SCM_EOL; layout_ = 0; original_ = 0; interfaces_ = SCM_EOL; @@ -77,26 +76,26 @@ Grob::Grob (SCM basicprops) } } - if (get_property_data ("X-extent") == SCM_EOL) + if (scm_is_null (get_property_data ("X-extent"))) set_property ("X-extent", Grob::stencil_width_proc); - if (get_property_data ("Y-extent") == SCM_EOL) + if (scm_is_null (get_property_data ("Y-extent"))) set_property ("Y-extent", - ly_make_unpure_pure_container (Grob::stencil_height_proc, - Grob::pure_stencil_height_proc)); - if (get_property_data ("vertical-skylines") == SCM_EOL) + Unpure_pure_container::make_smob (Grob::stencil_height_proc, + Grob::pure_stencil_height_proc)); + if (scm_is_null (get_property_data ("vertical-skylines"))) set_property ("vertical-skylines", - ly_make_unpure_pure_container (Grob::simple_vertical_skylines_from_extents_proc, - Grob::pure_simple_vertical_skylines_from_extents_proc)); - if (get_property_data ("horizontal-skylines") == SCM_EOL) + Unpure_pure_container::make_smob (Grob::simple_vertical_skylines_from_extents_proc, + Grob::pure_simple_vertical_skylines_from_extents_proc)); + if (scm_is_null (get_property_data ("horizontal-skylines"))) set_property ("horizontal-skylines", - ly_make_unpure_pure_container (Grob::simple_horizontal_skylines_from_extents_proc, - Grob::pure_simple_horizontal_skylines_from_extents_proc)); + Unpure_pure_container::make_smob (Grob::simple_horizontal_skylines_from_extents_proc, + Grob::pure_simple_horizontal_skylines_from_extents_proc)); } Grob::Grob (Grob const &s) + : Smob () { original_ = (Grob *) & s; - self_scm_ = SCM_EOL; immutable_property_alist_ = s.immutable_property_alist_; mutable_property_alist_ = SCM_EOL; @@ -129,7 +128,7 @@ Grob::get_stencil () const return 0; SCM stil = get_property ("stencil"); - return Stencil::unsmob (stil); + return unsmob (stil); } Stencil @@ -138,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"); @@ -175,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)) { @@ -406,7 +415,7 @@ Grob::get_offset (Axis a) const UGH: can't fold next 2 statements together. Apparently GCC thinks dim_cache_[a].offset_ is unaliased. */ - Real off = robust_scm2double (internal_get_property (sym), 0.0); + Real off = robust_scm2double (get_property (sym), 0.0); if (me->dim_cache_[a].offset_) { *me->dim_cache_[a].offset_ += off; @@ -461,20 +470,15 @@ Grob::extent (Grob *refp, Axis a) const /* Order is significant: ?-extent may trigger suicide. */ - SCM ext_sym - = (a == X_AXIS) - ? ly_symbol2scm ("X-extent") - : ly_symbol2scm ("Y-extent"); - - SCM ext = internal_get_property (ext_sym); + SCM ext = (a == X_AXIS) + ? get_property ("X-extent") + : get_property ("Y-extent"); if (is_number_pair (ext)) real_ext.unite (ly_scm2interval (ext)); - SCM min_ext_sym - = (a == X_AXIS) - ? ly_symbol2scm ("minimum-X-extent") - : ly_symbol2scm ("minimum-Y-extent"); - SCM min_ext = internal_get_property (min_ext_sym); + SCM min_ext = (a == X_AXIS) + ? get_property ("minimum-X-extent") + : get_property ("minimum-Y-extent"); if (is_number_pair (min_ext)) real_ext.unite (ly_scm2interval (min_ext)); @@ -485,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; @@ -727,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); @@ -743,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); @@ -761,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, @@ -825,6 +829,7 @@ ADD_INTERFACE (Grob, "meta " "minimum-X-extent " "minimum-Y-extent " + "parenthesis-friends " "pure-Y-offset-in-progress " "rotation " "skyline-horizontal-padding " @@ -834,6 +839,7 @@ ADD_INTERFACE (Grob, "transparent " "vertical-skylines " "whiteout " + "whiteout-box " ); /**************************************************************** @@ -854,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); } @@ -862,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::unsmob (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 ()); @@ -874,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"); @@ -886,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) @@ -899,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); } @@ -907,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);