]> git.donarmstrong.com Git - lilypond.git/commitdiff
Make Box::is_empty more selective and create an axis-specific variant
authorDavid Kastrup <dak@gnu.org>
Sat, 27 Apr 2013 12:39:34 +0000 (14:39 +0200)
committerDavid Kastrup <dak@gnu.org>
Sun, 26 May 2013 00:33:02 +0000 (02:33 +0200)
Boxes are not really "empty" just because they show negative
advancement on some axis.  A box is empty if its original dimensions
of (+inf . -inf) are still unchanged for both axes.  And boxes can
make an impact in one axis but not another (pretty much the definition
of spacing), so is_empty can take an axis as argument now.

lily/box.cc
lily/include/box.hh

index bc0a975ed0d3d91b0be837f5810af3fb8b991795..f91069b7663d56feb9c51603ed0199c16e6f9216 100644 (file)
@@ -54,8 +54,16 @@ Box::set_empty ()
 bool
 Box::is_empty () const
 {
-  return interval_a_[X_AXIS].is_empty ()
-         || interval_a_[Y_AXIS].is_empty ();
+  return is_empty (X_AXIS) && is_empty (Y_AXIS);
+}
+
+bool
+Box::is_empty (Axis a) const
+{
+  Interval empty;
+  empty.set_empty ();
+  return interval_a_[a][LEFT] == empty[LEFT]
+    && interval_a_[a][RIGHT] == empty[RIGHT];
 }
 
 Box::Box (Interval ix, Interval iy)
index 63224f2f880debeb58567524dfb7dac51e1ae6a4..b0f899431188bf4d653ac448afbb6e074efdd6fa 100644 (file)
@@ -22,6 +22,7 @@ public:
   Interval &operator [] (Axis a);
   Real area () const;
   bool is_empty () const;
+  bool is_empty (Axis a) const;
 
   Offset center () const;