diff --git a/Source/PS_Source/globals.h b/Source/PS_Source/globals.h index 258a5d7..b139620 100644 --- a/Source/PS_Source/globals.h +++ b/Source/PS_Source/globals.h @@ -206,3 +206,22 @@ inline void callGUI(T* ap, F&& f, bool async) MessageManager::callAsync([ed, f]() { f(ed); }); } } + +inline String secondsToString(double seconds) +{ + int64_t durintseconds = seconds; + int64_t durintminutes = seconds / 60.0; + int64_t durinthours = seconds / 3600.0; + int64_t durintdays = seconds / (3600 * 24.0); + String timestring; + if (durintminutes < 1) + timestring = String(seconds, 3) + " seconds"; + if (durintminutes >= 1 && durinthours < 1) + timestring = String(durintminutes) + " mins " + String(durintseconds % 60) + " secs"; + if (durinthours >= 1 && durintdays < 1) + timestring = String(durinthours) + " hours " + String(durintminutes % 60) + " mins " + String(durintseconds % 60) + " secs"; + if (durintdays >= 1) + timestring = String(durintdays) + " days " + String(durinthours % 24) + " hours " + + String(durintminutes % 60) + " mins "; + return timestring; +} \ No newline at end of file diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 39a59f1..33d3061 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -496,7 +496,7 @@ void WaveformComponent::paint(Graphics & g) } g.setColour(Colours::aqua.darker()); g.drawText(GetFileCallback().getFileName(), 2, m_topmargin + 2, getWidth(), 20, Justification::topLeft); - g.drawText(String(thumblen, 1), getWidth() - 100, m_topmargin + 2, 100, 20, Justification::topRight); + g.drawText(secondsToString(thumblen), getWidth() - 100, m_topmargin + 2, 100, 20, Justification::topRight); } void WaveformComponent::timerCallback()