dynamically adjust open-video-dialog layout depending on configuration
[ardour.git] / gtk2_ardour / utils.cc
index eb370be0dcc48087c2bc7267966cd8bf1a5135d7..a8b46f1f57853496f91d028ce831208b2e5961ae 100644 (file)
@@ -28,6 +28,7 @@
 #include <clocale>
 #include <cstring>
 #include <cctype>
+#include <cmath>
 #include <fstream>
 #include <list>
 #include <sys/stat.h>
@@ -63,6 +64,10 @@ using Gtkmm2ext::Keyboard;
 
 sigc::signal<void>  DPIReset;
 
+#ifdef PLATFORM_WINDOWS
+#define random() rand()
+#endif
+
 
 /** Add an element to a menu, settings its sensitivity.
  * @param m Menu to add to.
@@ -740,7 +745,7 @@ set_pango_fontsize ()
 
        /* FT2 rendering - used by GnomeCanvas, sigh */
 
-#ifndef WIN32
+#ifndef PLATFORM_WINDOWS
        pango_ft2_font_map_set_resolution ((PangoFT2FontMap*) pango_ft2_font_map_new(), val/1024, val/1024);
 #endif
 
@@ -843,3 +848,15 @@ unique_random_color (list<Gdk::Color>& used_colors)
                /* XXX need throttle here to make sure we don't spin for ever */
        }
 }
+
+string 
+rate_as_string (float r)
+{
+       char buf[32];
+       if (fmod (r, 1000.0f)) {
+               snprintf (buf, sizeof (buf), "%.1f kHz", r/1000.0);
+       } else {
+               snprintf (buf, sizeof (buf), "%.0f kHz", r/1000.0);
+       }
+       return buf;
+}