From 54f2d107d43119034e1a5d7a34cb38f7cb029a84 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 23 Feb 2008 20:25:58 -0600 Subject: [PATCH] Clean up trimming extremes. --- Region.C | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Region.C b/Region.C index 9f718a2..bad8649 100644 --- a/Region.C +++ b/Region.C @@ -113,9 +113,12 @@ Region::trim ( enum trim_e t, int X ) long td = timeline->x_to_ts( d ); - if ( td < 0 && _start < 0 - td ) + if ( td < 0 && _start < 0 - td ) td = 0 - _start; + if ( _start + td >= _end ) + td = (_end - _start) - timeline->x_to_ts( 1 ); + _start += td; _offset += td; break; @@ -128,7 +131,12 @@ Region::trim ( enum trim_e t, int X ) long td = timeline->x_to_ts( d ); - _end -= td; + printf( "%li %li\n", td, _end - _start ); + + if ( td >= 0 && _end - _start < td ) + _end = _start + timeline->x_to_ts( 1 ); + else + _end -= td; break; }