X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Finclude%2Finterval.tcc;h=2f002a7e008e24e438d306299268e2aeb8290013;hb=17d3559fc93cd3b2cc2afbc240abbe11874373c6;hp=5cd938fd0853fc14d9a68e85c7e8b9d2c4b2807b;hpb=e18531db1f79fb685fbd16d6a2a67bf4b6c09915;p=lilypond.git diff --git a/flower/include/interval.tcc b/flower/include/interval.tcc index 5cd938fd08..2f002a7e00 100644 --- a/flower/include/interval.tcc +++ b/flower/include/interval.tcc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1996--2010 Han-Wen Nienhuys + Copyright (C) 1996--2011 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -107,6 +107,31 @@ Interval_t::unite (Interval_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 +void +Interval_t::unite_disjoint (Interval_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 +Interval_t +Interval_t::union_disjoint (Interval_t h, T padding, Direction d) const +{ + Interval_t iv = *this; + iv.unite_disjoint (h, padding, d); + return iv; +} + template void Interval_t::intersect (Interval_t h)