X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_ui.cc;h=0a7542a33fc6c4ea64d6102984b4c756f39a9c57;hb=7a524285385d4581ad3f1e085629379e32f82fda;hp=979ab3504aeb0e6277d57948e2956e10267167e3;hpb=c7ed461bcfb22a83e2b2877936e81c7582c2c9e3;p=ardour.git diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 979ab3504a..0a7542a33f 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -79,6 +79,7 @@ #include "widgets/fastmeter.h" #include "widgets/prompter.h" +#include "widgets/tooltips.h" #include "ardour/ardour.h" #include "ardour/audio_backend.h" @@ -583,7 +584,6 @@ ARDOUR_UI::engine_running () } update_disk_space (); update_cpu_load (); - update_xrun_count (); update_sample_rate (AudioEngine::instance()->sample_rate()); update_timecode_format (); update_peak_thread_work (); @@ -1508,8 +1508,6 @@ void ARDOUR_UI::every_second () { update_cpu_load (); - update_xrun_count (); - update_buffer_load (); update_disk_space (); update_timecode_format (); update_peak_thread_work (); @@ -1531,8 +1529,7 @@ ARDOUR_UI::every_second () void ARDOUR_UI::every_point_one_seconds () { - // TODO get rid of this.. - // ShuttleControl is updated directly via TransportStateChange signal + if (editor) editor->build_region_boundary_cache(); } void @@ -1677,43 +1674,33 @@ ARDOUR_UI::update_format () } void -ARDOUR_UI::update_xrun_count () +ARDOUR_UI::update_cpu_load () { - char buf[64]; + const unsigned int x = _session ? _session->get_xrun_count () : 0; + double const c = AudioEngine::instance()->get_dsp_load (); - /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets - should also be changed. - */ + const char* const bg = c > 90 ? " background=\"red\"" : ""; - if (_session) { - const unsigned int x = _session->get_xrun_count (); - dsp_load_indicator.set_xrun_count (x); - if (x > 9999) { - snprintf (buf, sizeof (buf), _("X: >10K"), X_("red")); - } else { - snprintf (buf, sizeof (buf), _("X: %u"), x > 0 ? X_("red") : X_("green"), x); - } + char buf[64]; + if (x > 9999) { + snprintf (buf, sizeof (buf), "DSP: %.0f%% (>10k)", bg, c); + } else if (x > 0) { + snprintf (buf, sizeof (buf), "DSP: %.0f%% (%d)", bg, c, x); } else { - snprintf (buf, sizeof (buf), _("X: ?"), X_("yellow")); - dsp_load_indicator.set_xrun_count (UINT_MAX); + snprintf (buf, sizeof (buf), "DSP: %.0f%%", bg, c); } - xrun_label.set_markup (buf); - set_tip (xrun_label, _("Audio dropouts. Shift+click to reset")); -} -void -ARDOUR_UI::update_cpu_load () -{ - char buf[64]; + dsp_load_label.set_markup (buf); - /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets - should also be changed. - */ + if (x > 9999) { + snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: >10k\n%s"), c, _("Shift+Click to clear xruns.")); + } else if (x > 0) { + snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: %u\n%s"), c, x, _("Shift+Click to clear xruns.")); + } else { + snprintf (buf, sizeof (buf), _("DSP: %.1f%%"), c); + } - double const c = AudioEngine::instance()->get_dsp_load (); - dsp_load_indicator.set_dsp_load (c); - snprintf (buf, sizeof (buf), _("DSP: %5.1f%%"), c >= 90 ? X_("red") : X_("green"), c); - cpu_load_label.set_markup (buf); + ArdourWidgets::set_tooltip (dsp_load_label, buf); } void @@ -1730,64 +1717,68 @@ ARDOUR_UI::update_peak_thread_work () } void -ARDOUR_UI::update_buffer_load () +ARDOUR_UI::count_recenabled_streams (Route& route) { - char buf[256]; - - uint32_t const playback = _session ? _session->playback_load () : 100; - uint32_t const capture = _session ? _session->capture_load () : 100; - - /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets - should also be changed. - */ - - if (_session) { - 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 (""); + Track* track = dynamic_cast(&route); + if (track && track->rec_enable_control()->get_value()) { + rec_enabled_streams += track->n_inputs().n_total(); } } void -ARDOUR_UI::count_recenabled_streams (Route& route) +ARDOUR_UI::format_disk_space_label (float remain_sec) { - Track* track = dynamic_cast(&route); - if (track && track->rec_enable_control()->get_value()) { - rec_enabled_streams += track->n_inputs().n_total(); + if (remain_sec < 0) { + disk_space_label.set_text (_("N/A")); + ArdourWidgets::set_tooltip (disk_space_label, _("Unknown")); + return; + } + + char buf[64]; + + int sec = floor (remain_sec); + int hrs = sec / 3600; + int mins = (sec / 60) % 60; + int secs = sec % 60; + snprintf (buf, sizeof(buf), _("%02dh:%02dm:%02ds"), hrs, mins, secs); + ArdourWidgets::set_tooltip (disk_space_label, buf); + + if (remain_sec > 86400) { + disk_space_label.set_text (_("Rec: >24h")); + return; + } else if (remain_sec > 32400 /* 9 hours */) { + snprintf (buf, sizeof (buf), "Rec: %.0fh", remain_sec / 3600.f); + } else if (remain_sec > 5940 /* 99 mins */) { + snprintf (buf, sizeof (buf), "Rec: %.1fh", remain_sec / 3600.f); + } else { + snprintf (buf, sizeof (buf), "Rec: %.0fm", remain_sec / 60.f); } + disk_space_label.set_text (buf); + } void ARDOUR_UI::update_disk_space() { if (_session == 0) { + format_disk_space_label (-1); return; } boost::optional opt_samples = _session->available_capture_duration(); - char buf[64]; samplecnt_t fr = _session->sample_rate(); if (fr == 0) { /* skip update - no SR available */ + format_disk_space_label (-1); return; } if (!opt_samples) { /* Available space is unknown */ - snprintf (buf, sizeof (buf), "%s", _("Disk: Unknown")); + format_disk_space_label (-1); } else if (opt_samples.get_value_or (0) == max_samplecnt) { - snprintf (buf, sizeof (buf), "%s", _("Disk: 24hrs+")); + format_disk_space_label (max_samplecnt); } else { rec_enabled_streams = 0; _session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams, false); @@ -1798,32 +1789,9 @@ ARDOUR_UI::update_disk_space() samples /= rec_enabled_streams; } - int hrs; - int mins; - int secs; - - hrs = samples / (fr * 3600); - - if (hrs > 24) { - snprintf (buf, sizeof (buf), "%s", _("Disk: >24 hrs")); - } else { - samples -= hrs * fr * 3600; - mins = samples / (fr * 60); - samples -= mins * fr * 60; - secs = samples / fr; - - bool const low = (hrs == 0 && mins <= 30); - - snprintf ( - buf, sizeof(buf), - _("Disk: %02dh:%02dm:%02ds"), - low ? X_("red") : X_("green"), - hrs, mins, secs - ); - } + format_disk_space_label (samples / (float)fr); } - disk_space_label.set_markup (buf); } void @@ -2703,7 +2671,7 @@ ARDOUR_UI::save_session_as () MessageDialog msg (_main_window, string_compose (_("\ %1 was unable to save your session.\n\n\ -If you still wish to proceeed, please use the\n\n\ +If you still wish to proceed, please use the\n\n\ \"Don't save now\" option."), PROGRAM_NAME)); pop_back_splash(msg); msg.run (); @@ -2899,7 +2867,7 @@ ARDOUR_UI::snapshot_session (bool switch_to_it) MessageDialog msg (_main_window, string_compose (_("\ %1 was unable to save your session.\n\n\ -If you still wish to proceeed, please use the\n\n\ +If you still wish to proceed, please use the\n\n\ \"Don't save now\" option."), PROGRAM_NAME)); pop_back_splash(msg); msg.run ();