Browse Source

Format waveform duration in a nicer way

tags/1.0.0
xenakios 7 years ago
parent
commit
a589f133d2
2 changed files with 20 additions and 1 deletions
  1. +19
    -0
      Source/PS_Source/globals.h
  2. +1
    -1
      Source/PluginEditor.cpp

+ 19
- 0
Source/PS_Source/globals.h View File

@@ -206,3 +206,22 @@ inline void callGUI(T* ap, F&& f, bool async)
MessageManager::callAsync([ed, f]() { f(ed); }); 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;
}

+ 1
- 1
Source/PluginEditor.cpp View File

@@ -496,7 +496,7 @@ void WaveformComponent::paint(Graphics & g)
} }
g.setColour(Colours::aqua.darker()); g.setColour(Colours::aqua.darker());
g.drawText(GetFileCallback().getFileName(), 2, m_topmargin + 2, getWidth(), 20, Justification::topLeft); 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() void WaveformComponent::timerCallback()


Loading…
Cancel
Save