13
0

move rate_as_string() from EngineControl to utils.cc

This commit is contained in:
Paul Davis 2013-09-23 21:35:17 -04:00
parent 884789bfad
commit cff174b541
4 changed files with 16 additions and 13 deletions

View File

@ -48,6 +48,7 @@
#include "ardour_ui.h" #include "ardour_ui.h"
#include "engine_dialog.h" #include "engine_dialog.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "utils.h"
#include "i18n.h" #include "i18n.h"
using namespace std; using namespace std;
@ -800,18 +801,6 @@ EngineControl::device_changed ()
push_state_to_backend (false); push_state_to_backend (false);
} }
string
EngineControl::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;
}
string string
EngineControl::bufsize_as_string (uint32_t sz) EngineControl::bufsize_as_string (uint32_t sz)
{ {

View File

@ -122,7 +122,6 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
void setup_midi_tab_for_jack (); void setup_midi_tab_for_jack ();
void refresh_midi_display (); void refresh_midi_display ();
std::string rate_as_string (float);
std::string bufsize_as_string (uint32_t); std::string bufsize_as_string (uint32_t);
float get_rate() const; float get_rate() const;

View File

@ -28,6 +28,7 @@
#include <clocale> #include <clocale>
#include <cstring> #include <cstring>
#include <cctype> #include <cctype>
#include <cmath>
#include <fstream> #include <fstream>
#include <list> #include <list>
#include <sys/stat.h> #include <sys/stat.h>
@ -860,3 +861,15 @@ unique_random_color (list<Gdk::Color>& used_colors)
/* XXX need throttle here to make sure we don't spin for ever */ /* 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;
}

View File

@ -86,4 +86,6 @@ std::string escape_angled_brackets (std::string const &);
Gdk::Color unique_random_color (std::list<Gdk::Color> &); Gdk::Color unique_random_color (std::list<Gdk::Color> &);
std::string rate_as_string (float r);
#endif /* __ardour_gtk_utils_h__ */ #endif /* __ardour_gtk_utils_h__ */