From d15d8ec40e4bb33bd5ccece63f1d8c99df782863 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 23 Oct 2011 00:15:35 +0000 Subject: [PATCH] Spruce up info bar a bit using Chris' suggestions (#4238). git-svn-id: svn://localhost/ardour2/branches/3.0@10290 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 53 +++++++++++++++++++++++--------- gtk2_ardour/ardour_ui_dialogs.cc | 1 + gtk2_ardour/ardour_ui_ed.cc | 5 +++ 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index a1bbce29ee..9d2bea5205 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -959,7 +959,7 @@ ARDOUR_UI::every_point_zero_one_seconds () void ARDOUR_UI::update_sample_rate (framecnt_t) { - char buf[32]; + char buf[64]; ENSURE_GUI_THREAD (*this, &ARDOUR_UI::update_sample_rate, ignored) @@ -972,17 +972,17 @@ ARDOUR_UI::update_sample_rate (framecnt_t) framecnt_t rate = engine->frame_rate(); if (fmod (rate, 1000.0) != 0.0) { - snprintf (buf, sizeof (buf), _("%.1f kHz / %4.1f ms"), + snprintf (buf, sizeof (buf), _("JACK: %.1f kHz / %4.1f ms"), (float) rate/1000.0f, (engine->frames_per_cycle() / (float) rate) * 1000.0f); } else { - snprintf (buf, sizeof (buf), _("%" PRId64 " kHz / %4.1f ms"), + snprintf (buf, sizeof (buf), _("JACK: %" PRId64 " kHz / %4.1f ms"), rate/1000, (engine->frames_per_cycle() / (float) rate) * 1000.0f); } } - sample_rate_label.set_text (buf); + sample_rate_label.set_markup (buf); } void @@ -994,6 +994,7 @@ ARDOUR_UI::update_format () } stringstream s; + s << "File: "; switch (_session->config.get_native_file_header_format ()) { case BWF: @@ -1033,26 +1034,41 @@ ARDOUR_UI::update_format () break; } - format_label.set_text (s.str ()); + s << ""; + + format_label.set_markup (s.str ()); } void ARDOUR_UI::update_cpu_load () { - char buf[32]; - snprintf (buf, sizeof (buf), _("DSP: %5.1f%%"), engine->get_cpu_load()); - cpu_load_label.set_text (buf); + char buf[64]; + + float const c = engine->get_cpu_load (); + snprintf (buf, sizeof (buf), _("DSP: %5.1f%%"), c >= 90 ? X_("red") : X_("green"), c_); + cpu_load_label.set_markup (buf); } void ARDOUR_UI::update_buffer_load () { - char buf[64]; + char buf[256]; + + uint32_t const playback = _session ? _session->playback_load () : 100; + uint32_t const capture = _session ? _session->capture_load () : 100; if (_session) { - snprintf (buf, sizeof (buf), _("Buffers p:%" PRIu32 "%% c:%" PRIu32 "%%"), - _session->playback_load(), _session->capture_load()); - buffer_load_label.set_text (buf); + snprintf ( + buf, sizeof (buf), + _("Buffers: p:%" PRIu32 "%% " + "c:%" PRIu32 "%%"), + playback <= 5 ? X_("red") : X_("green"), + playback, + capture <= 5 ? X_("red") : X_("green"), + capture + ); + + buffer_load_label.set_markup (buf); } else { buffer_load_label.set_text (""); } @@ -1079,7 +1095,7 @@ ARDOUR_UI::update_disk_space() framecnt_t fr = _session->frame_rate(); if (frames == max_framecnt) { - strcpy (buf, _("Disk: 24hrs+")); + snprintf (buf, sizeof (buf), _("Disk: 24hrs+")); } else { rec_enabled_streams = 0; _session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams); @@ -1098,10 +1114,17 @@ ARDOUR_UI::update_disk_space() frames -= mins * fr * 60; secs = frames / fr; - snprintf (buf, sizeof(buf), _("Disk: %02dh:%02dm:%02ds"), hrs, mins, secs); + bool const low = (hrs == 0 && mins <= 30); + + snprintf ( + buf, sizeof(buf), + _("Disk: %02dh:%02dm:%02ds"), + low ? X_("red") : X_("green"), + hrs, mins, secs + ); } - disk_space_label.set_text (buf); + disk_space_label.set_markup (buf); // An attempt to make the disk space label flash red when space has run out. diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index e3cb0c7e1a..917d76e57c 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -241,6 +241,7 @@ ARDOUR_UI::unload_session (bool hide_stuff) Blink.clear (); delete _session; + _session = 0; update_buffer_load (); diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 1379de83c8..7bfa420a36 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -529,22 +529,27 @@ ARDOUR_UI::build_menu_bar () disk_space_box.add (disk_space_label); disk_space_box.set_name ("WallClock"); disk_space_label.set_name ("WallClock"); + disk_space_label.set_use_markup (); cpu_load_box.add (cpu_load_label); cpu_load_box.set_name ("CPULoad"); cpu_load_label.set_name ("CPULoad"); + cpu_load_label.set_use_markup (); buffer_load_box.add (buffer_load_label); buffer_load_box.set_name ("BufferLoad"); buffer_load_label.set_name ("BufferLoad"); + buffer_load_label.set_use_markup (); sample_rate_box.add (sample_rate_label); sample_rate_box.set_name ("SampleRate"); sample_rate_label.set_name ("SampleRate"); + sample_rate_label.set_use_markup (); format_box.add (format_label); format_box.set_name ("Format"); format_label.set_name ("Format"); + format_label.set_use_markup (); #ifndef TOP_MENUBAR menu_hbox.pack_start (*menu_bar, false, false);