]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/grob.cc
Doc-es: update Web/introduction, NEWS.
[lilypond.git] / lily / grob.cc
index 57d06515eed6032d1a08cd3c6d3445167ac8e008..4c54cbc508a318938b50ef5258ce012ff2f381f2 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
 #include "grob.hh"
 
 #include <cstring>
+#include <set>
 
 #include "align-interface.hh"
 #include "axis-group-interface.hh"
@@ -79,6 +80,10 @@ Grob::Grob (SCM basicprops)
     set_property ("X-extent", Grob::stencil_width_proc);
   if (get_property_data ("Y-extent") == SCM_EOL)
     set_property ("Y-extent", Grob::stencil_height_proc);
+  if (get_property_data ("vertical-skylines") == SCM_EOL)
+    set_property ("vertical-skylines", Grob::simple_vertical_skylines_from_extents_proc);
+  if (get_property_data ("horizontal-skylines") == SCM_EOL)
+    set_property ("horizontal-skylines", Grob::simple_horizontal_skylines_from_extents_proc);
 }
 
 Grob::Grob (Grob const &s)
@@ -170,6 +175,17 @@ Grob::get_print_stencil () const
             = *unsmob_stencil (scm_call_1 (ly_lily_module_constant ("stencil-whiteout"),
                                            retval.smobbed_copy ()));
         }
+
+      SCM id = get_property ("id");
+      if (scm_is_string (id))
+        {
+          SCM expr = scm_list_3 (ly_symbol2scm ("id"),
+                                 id,
+                                 retval.expr ());
+
+          retval = Stencil (retval.extent_box (), expr);
+        }
+
     }
 
   return retval;
@@ -455,7 +471,12 @@ Grob::extent (Grob *refp, Axis a) const
       ((Grob *)this)->dim_cache_[a].extent_ = new Interval (real_ext);
     }
 
-  real_ext.translate (offset);
+  // We never want nan, so we avoid shifting infinite values.
+    if(!isinf (offset))
+      real_ext.translate(offset);
+    else
+      this->warning(_f ("ignored infinite %s-offset",
+                        a == X_AXIS ? "X" : "Y"));
 
   return real_ext;
 }
@@ -464,6 +485,9 @@ Interval
 Grob::pure_height (Grob *refp, int start, int end)
 {
   SCM iv_scm = get_pure_property ("Y-extent", start, end);
+  // TODO: Why is this Interval (0,0)
+  // Shouldn't it just be an empty interval?
+  // 0,0 puts an arbitrary point at 0,0 which will influence spacing
   Interval iv = robust_scm2interval (iv_scm, Interval (0, 0));
   Real offset = pure_relative_y_coordinate (refp, start, end);
 
@@ -784,10 +808,11 @@ ADD_INTERFACE (Grob,
                "cause "
                "color "
                "cross-staff "
-               "extra-X-extent "
-               "extra-Y-extent "
+               "id "
                "extra-offset "
+               "footnote-music "
                "forced-spacing "
+               "horizontal-skylines "
                "interfaces "
                "layer "
                "meta "
@@ -798,10 +823,12 @@ ADD_INTERFACE (Grob,
                "outside-staff-priority "
                "pure-Y-offset-in-progress "
                "rotation "
+               "skyline-horizontal-padding "
                "springs-and-rods "
                "staff-symbol "
                "stencil "
                "transparent "
+               "vertical-skylines "
                "whiteout "
               );
 
@@ -887,6 +914,20 @@ common_refpoint_of_array (vector<Grob *> const &arr, Grob *common, Axis a)
   return common;
 }
 
+Grob *
+common_refpoint_of_array (set<Grob *> const &arr, Grob *common, Axis a)
+{
+  set<Grob *>::iterator it;
+
+  for (it = arr.begin (); it != arr.end (); it++)
+    if (common)
+      common = common->common_refpoint (*it, a);
+    else
+      common = *it;
+
+  return common;
+}
+
 Interval
 robust_relative_extent (Grob *me, Grob *refpoint, Axis a)
 {