]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/skyline.cc
Fixes annotate spacing (issue 3169)
[lilypond.git] / lily / skyline.cc
index 1d6e4d5e78e81c2efb24b88a54ddae297035e4fa..bf95fe35418153ce65237a415a29c4d4553ecde0 100644 (file)
@@ -213,6 +213,7 @@ Skyline::normalize ()
 {
   bool last_empty = false;
   list<Building>::iterator i;
+
   for (i = buildings_.begin (); i != buildings_.end (); i++)
     {
       if (last_empty && i->y_intercept_ == -infinity_f)
@@ -330,11 +331,13 @@ single_skyline (Building b, list<Building> *const ret)
 {
   if (b.end_ > b.start_ + EPS)
     {
-      ret->push_back (Building (-infinity_f, -infinity_f,
-                                -infinity_f, b.start_));
+      if (b.start_ != -infinity_f)
+        ret->push_back (Building (-infinity_f, -infinity_f,
+                                  -infinity_f, b.start_));
       ret->push_back (b);
-      ret->push_back (Building (b.end_, -infinity_f,
-                                -infinity_f, infinity_f));
+      if (b.end_ != infinity_f)
+        ret->push_back (Building (b.end_, -infinity_f,
+                                  -infinity_f, infinity_f));
     }
   else
     {
@@ -553,6 +556,7 @@ Skyline::Skyline (Box const &b, Axis horizon_axis, Direction sky)
   sky_ = sky;
   Building front (b, horizon_axis, sky);
   single_skyline (front, &buildings_);
+  normalize ();
 }
 
 void
@@ -766,6 +770,12 @@ Skyline::max_height () const
   return sky_ * ret;
 }
 
+Direction
+Skyline::direction () const
+{
+  return sky_;
+}
+
 Real
 Skyline::left () const
 {
@@ -922,3 +932,12 @@ Skyline::get_height (SCM skyline_scm, SCM x_scm)
   Real x = robust_scm2double (x_scm, 0.0);
   return scm_from_double (Skyline::unsmob (skyline_scm)->height (x));
 }
+
+LY_DEFINE (ly_skyline_empty_p, "ly:skyline-empty?",
+           1, 0, 0, (SCM sky),
+           "Return whether @var{sky} is empty.")
+{
+  Skyline *s = Skyline::unsmob (sky);
+  LY_ASSERT_SMOB (Skyline, sky, 1);
+  return scm_from_bool (s->is_empty ());
+}