From: David Kastrup Date: Sat, 27 Apr 2013 12:39:34 +0000 (+0200) Subject: Make Box::is_empty more selective and create an axis-specific variant X-Git-Tag: release/2.17.19-1~5^2~22 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0b9c108e213a6caeb4b40e1306b18700ae608fd4;p=lilypond.git Make Box::is_empty more selective and create an axis-specific variant 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. --- diff --git a/lily/box.cc b/lily/box.cc index bc0a975ed0..f91069b766 100644 --- a/lily/box.cc +++ b/lily/box.cc @@ -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) diff --git a/lily/include/box.hh b/lily/include/box.hh index 63224f2f88..b0f8994311 100644 --- a/lily/include/box.hh +++ b/lily/include/box.hh @@ -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;