+
+wxString
+time_to_timecode (DCPTime t, double fps)
+{
+ double w = t.seconds ();
+ int const h = (w / 3600);
+ w -= h * 3600;
+ int const m = (w / 60);
+ w -= m * 60;
+ int const s = floor (w);
+ w -= s;
+ int const f = lrint (w * fps);
+ return wxString::Format (wxT("%02d:%02d:%02d.%02d"), h, m, s, f);
+}
+
+void
+setup_audio_channels_choice (wxChoice* choice, int minimum)
+{
+ vector<pair<string, string> > items;
+ for (int i = minimum; i <= 16; i += 2) {
+ if (i == 2) {
+ items.push_back (make_pair (wx_to_std (_("2 - stereo")), locale_convert<string> (i)));
+ } else if (i == 4) {
+ items.push_back (make_pair (wx_to_std (_("4 - L/C/R/Lfe")), locale_convert<string> (i)));
+ } else if (i == 6) {
+ items.push_back (make_pair (wx_to_std (_("6 - 5.1")), locale_convert<string> (i)));
+ } else if (i == 8) {
+ items.push_back (make_pair (wx_to_std (_("8 - 5.1/HI/VI")), locale_convert<string> (i)));
+ } else if (i == 12) {
+ items.push_back (make_pair (wx_to_std (_("12 - 7.1/HI/VI")), locale_convert<string> (i)));
+ } else {
+ items.push_back (make_pair (locale_convert<string> (i), locale_convert<string> (i)));
+ }
+ }
+
+ checked_set (choice, items);
+}
+
+wxSplashScreen *
+maybe_show_splash ()
+{
+ wxSplashScreen* splash = 0;
+ try {
+ if (!Config::have_existing ("config.xml")) {
+ wxBitmap bitmap;
+ boost::filesystem::path p = shared_path () / "splash.png";
+ if (bitmap.LoadFile (std_to_wx (p.string ()), wxBITMAP_TYPE_PNG)) {
+ splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1);
+ wxYield ();
+ }
+ }
+ } catch (boost::filesystem::filesystem_error& e) {
+ /* Maybe we couldn't find the splash image; never mind */
+ }
+
+ return splash;
+}
+
+optional<boost::filesystem::path>
+path_from_file_dialog (wxFileDialog* dialog, string extension)
+{
+ boost::filesystem::path p(wx_to_std(dialog->GetPath()));
+ p.replace_extension(extension);
+ if (boost::filesystem::is_regular_file(p) && !confirm_dialog(dialog, wxString::Format(_("A file named %s already exists. Do you want to replace it?"), std_to_wx(p.filename().string())))) {
+ return optional<boost::filesystem::path>();
+ }
+ return p;
+}
+
+double
+calculate_mark_interval (double mark_interval)
+{
+ if (mark_interval > 5) {
+ mark_interval -= lrint (mark_interval) % 5;
+ }
+ if (mark_interval > 10) {
+ mark_interval -= lrint (mark_interval) % 10;
+ }
+ if (mark_interval > 60) {
+ mark_interval -= lrint (mark_interval) % 60;
+ }
+ if (mark_interval > 3600) {
+ mark_interval -= lrint (mark_interval) % 3600;
+ }
+
+ if (mark_interval < 1) {
+ mark_interval = 1;
+ }
+
+ return mark_interval;
+}