From: dooglus Date: Sun, 6 May 2007 22:19:03 +0000 (+0000) Subject: Don't always display the "0f" at the end of times with zero frames. I want to be... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=76bc5e374b4f97da13e0ec38f3bd47f2704f864a;p=synfig.git Don't always display the "0f" at the end of times with zero frames. I want to be able to see "1m, 2m, 3m" when I zoom out of the time track, not "1m 0f, 2m 0f, 3m 0f". Similarly with minutes and seconds. git-svn-id: http://svn.voria.com/code@482 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/time.cpp b/synfig-core/trunk/src/synfig/time.cpp index acc6bcf..eb2eef7 100644 --- a/synfig-core/trunk/src/synfig/time.cpp +++ b/synfig-core/trunk/src/synfig/time.cpp @@ -186,6 +186,7 @@ Time::get_string(float fps, Time::Format format)const hour=time/3600;time-=hour*3600; minute=time/60;time-=minute*60; + // <= is redefined, so this means "is the FORMAT_VIDEO bit set in the format?" if(format<=FORMAT_VIDEO) { int second; @@ -203,12 +204,19 @@ Time::get_string(float fps, Time::Format format)const } String ret; + bool started = false; if(format<=FORMAT_FULL || hour) + { ret+=strprintf(format<=FORMAT_NOSPACES?"%dh":"%dh ",hour); + started = true; + } - if(format<=FORMAT_FULL || hour || minute) + if(format<=FORMAT_FULL || minute) + { ret+=strprintf(format<=FORMAT_NOSPACES?"%dm":"%dm ",minute); + started = true; + } if(fps) { @@ -217,21 +225,30 @@ Time::get_string(float fps, Time::Format format)const second=time;time-=second; frame=time*fps; if(format<=FORMAT_FULL || second) + { ret+=strprintf(format<=FORMAT_NOSPACES?"%ds":"%ds ",(int)second); + started = true; + } - if(abs(frame-floor(frame)>=epsilon_())) - ret+=strprintf("%0.3ff",frame); - else - ret+=strprintf("%0.0ff",frame); + if(format<=FORMAT_FULL || frame || !started) + { + if(abs(frame-floor(frame)>=epsilon_())) + ret+=strprintf("%0.3ff",frame); + else + ret+=strprintf("%0.0ff",frame); + } } else { float second; second=time; - if(abs(second-floor(second))>=epsilon_()) - ret+=strprintf("%0.8fs",second); - else - ret+=strprintf("%0.0fs",second); + if(format<=FORMAT_FULL || second || !started) + { + if(abs(second-floor(second))>=epsilon_()) + ret+=strprintf("%0.8fs",second); + else + ret+=strprintf("%0.0fs",second); + } } return ret;