]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/interval.tcc
resolve merge
[lilypond.git] / flower / include / interval.tcc
index faf9f3db028fc4643b1c38903cbb8a417a597f35..2f002a7e008e24e438d306299268e2aeb8290013 100644 (file)
@@ -1,9 +1,20 @@
 /*
-  interval.tcc -- implement Interval_t
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the Flower Library
+  Copyright (C) 1996--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 1996--2009 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
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #ifndef INTERVAL_TCC
@@ -96,6 +107,31 @@ Interval_t<T>::unite (Interval_t<T> h)
   at (RIGHT) = max (h.at (RIGHT), at (RIGHT));
 }
 
+/* Unites h and this interval, but in such a way
+   that h will lie in a particular direction from this
+   interval, with a minimum amount of space in between.
+   (That is, h will be translated before we unite, if
+   that is necessary to prevent overlap. */
+template<class T>
+void
+Interval_t<T>::unite_disjoint (Interval_t<T> h, T padding, Direction d)
+{
+  T dir = d;
+  T translation = dir * (at (d) + dir * padding - h.at (-d));
+  if (translation > (T) 0)
+    h.translate (translation);
+  unite (h);
+}
+
+template<class T>
+Interval_t<T>
+Interval_t<T>::union_disjoint (Interval_t<T> h, T padding, Direction d) const
+{
+  Interval_t<T> iv = *this;
+  iv.unite_disjoint (h, padding, d);
+  return iv;
+}
+
 template<class T>
 void
 Interval_t<T>::intersect (Interval_t<T> h)