X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Ftime.cpp;h=ea59b8e1ddae4696ec5abfe8c2d5b299d2ca0640;hb=756c0d29ac1742f231e6615f9a577e574e35a4af;hp=255359b730eb22d6740a087d6b7c838a6573aec5;hpb=a4f8d89f6d124bfa872551bf5ef8d2d3f6e37da3;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/time.cpp b/synfig-core/trunk/src/synfig/time.cpp index 255359b..ea59b8e 100644 --- a/synfig-core/trunk/src/synfig/time.cpp +++ b/synfig-core/trunk/src/synfig/time.cpp @@ -6,7 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2007 Chris Moore +** Copyright (c) 2007, 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -101,7 +101,7 @@ Time::Time(const String &str_, float fps): int read; float amount; - // Now try to read it in the letter-abreviated format + // Now try to read it in the letter-abbreviated format while(pos1) { int frame; frame=round_to_int(time*fps); @@ -209,34 +209,44 @@ Time::get_string(float fps, Time::Format format)const if(format<=FORMAT_FULL || hour) { - ret+=strprintf(format<=FORMAT_NOSPACES?"%dh":"%dh ",hour); + ret+=strprintf("%dh",hour); started = true; } if(format<=FORMAT_FULL || minute) { - ret+=strprintf(format<=FORMAT_NOSPACES?"%dm":"%dm ",minute); + if (!(format<=FORMAT_NOSPACES) && started) + ret += " "; + + ret += strprintf("%dm", minute); started = true; } - if(fps) + if(fps && fps>1) { int second; float frame; second=time;time-=second; frame=time*fps; + if(format<=FORMAT_FULL || second) { - ret+=strprintf(format<=FORMAT_NOSPACES?"%ds":"%ds ",(int)second); + if (!(format<=FORMAT_NOSPACES) && started) + ret += " "; + + ret += strprintf("%ds", (int)second); started = true; } if(format<=FORMAT_FULL || frame || !started) { - if(abs(frame-floor(frame)>=epsilon_())) - ret+=strprintf("%0.3ff",frame); + if (!(format<=FORMAT_NOSPACES) && started) + ret += " "; + + if(abs(frame-floor(frame) >= epsilon_())) + ret += strprintf("%0.3ff", frame); else - ret+=strprintf("%0.0ff",frame); + ret += strprintf("%0.0ff", frame); } } else @@ -245,13 +255,17 @@ Time::get_string(float fps, Time::Format format)const second=time; if(format<=FORMAT_FULL || second || !started) { + if (!(format<=FORMAT_NOSPACES) && started) + ret += " "; + if(abs(second-floor(second))>=epsilon_()) { String seconds(strprintf("%0.8f",second)); // skip trailing zeros int count = 0; - for (String::reverse_iterator i = seconds.rbegin(); (*i) == '0'; i++) + String::reverse_iterator i = seconds.rbegin(); + for ( ; (*i) == '0'; i++) count++; // if we removed too many, go back one place, leaving one zero