From fa22689b704ab2dd06c98dcbc1d33b6f4418a4c0 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Fri, 16 Feb 2018 09:35:44 -0600 Subject: Consistently use Gauge to avoid the overloaded term Indicator. --- gtk2_ardour/ardour_ui.cc | 28 ++++----- gtk2_ardour/ardour_ui.h | 13 ++-- gtk2_ardour/ardour_ui_ed.cc | 12 ++-- gtk2_ardour/disk_io_gauge.cc | 78 +++++++++++++++++++++++ gtk2_ardour/disk_io_gauge.h | 44 +++++++++++++ gtk2_ardour/disk_io_indicator.cc | 78 ----------------------- gtk2_ardour/disk_io_indicator.h | 44 ------------- gtk2_ardour/disk_space_gauge.cc | 99 +++++++++++++++++++++++++++++ gtk2_ardour/disk_space_gauge.h | 43 +++++++++++++ gtk2_ardour/disk_space_indicator.cc | 99 ----------------------------- gtk2_ardour/disk_space_indicator.h | 43 ------------- gtk2_ardour/dsp_load_gauge.cc | 121 ++++++++++++++++++++++++++++++++++++ gtk2_ardour/dsp_load_gauge.h | 50 +++++++++++++++ gtk2_ardour/dsp_load_indicator.cc | 121 ------------------------------------ gtk2_ardour/dsp_load_indicator.h | 50 --------------- gtk2_ardour/wscript | 6 +- 16 files changed, 463 insertions(+), 466 deletions(-) create mode 100644 gtk2_ardour/disk_io_gauge.cc create mode 100644 gtk2_ardour/disk_io_gauge.h delete mode 100644 gtk2_ardour/disk_io_indicator.cc delete mode 100644 gtk2_ardour/disk_io_indicator.h create mode 100644 gtk2_ardour/disk_space_gauge.cc create mode 100644 gtk2_ardour/disk_space_gauge.h delete mode 100644 gtk2_ardour/disk_space_indicator.cc delete mode 100644 gtk2_ardour/disk_space_indicator.h create mode 100644 gtk2_ardour/dsp_load_gauge.cc create mode 100644 gtk2_ardour/dsp_load_gauge.h delete mode 100644 gtk2_ardour/dsp_load_indicator.cc delete mode 100644 gtk2_ardour/dsp_load_indicator.h diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 74a2f24854..9e6fd093b4 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -1684,9 +1684,9 @@ ARDOUR_UI::update_xrun_count () if (_session) { const unsigned int x = _session->get_xrun_count (); - dsp_load_indicator.set_xrun_count (x); + dsp_load_gauge.set_xrun_count (x); } else { - dsp_load_indicator.set_xrun_count (UINT_MAX); + dsp_load_gauge.set_xrun_count (UINT_MAX); } } @@ -1698,7 +1698,7 @@ ARDOUR_UI::update_cpu_load () */ double const c = AudioEngine::instance()->get_dsp_load (); - dsp_load_indicator.set_dsp_load (c); + dsp_load_gauge.set_dsp_load (c); } void @@ -1720,7 +1720,7 @@ ARDOUR_UI::update_buffer_load () uint32_t const playback = _session ? _session->playback_load () : 100; uint32_t const capture = _session ? _session->capture_load () : 100; uint32_t max_load = std::min ( playback, capture ); - disk_io_indicator.set_disk_io(max_load); + disk_io_gauge.set_disk_io(max_load); } void @@ -1736,7 +1736,7 @@ void ARDOUR_UI::update_disk_space() { if (_session == 0) { - disk_space_indicator.set_available_disk_sec (-1); + disk_space_gauge.set_available_disk_sec (-1); return; } @@ -1745,15 +1745,15 @@ ARDOUR_UI::update_disk_space() if (fr == 0) { /* skip update - no SR available */ - disk_space_indicator.set_available_disk_sec (-1); + disk_space_gauge.set_available_disk_sec (-1); return; } if (!opt_samples) { /* Available space is unknown */ - disk_space_indicator.set_available_disk_sec (-1); + disk_space_gauge.set_available_disk_sec (-1); } else if (opt_samples.get_value_or (0) == max_samplecnt) { - disk_space_indicator.set_available_disk_sec (max_samplecnt); + disk_space_gauge.set_available_disk_sec (max_samplecnt); } else { rec_enabled_streams = 0; _session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams, false); @@ -1764,11 +1764,7 @@ ARDOUR_UI::update_disk_space() samples /= rec_enabled_streams; } - int hrs; - int mins; - int secs; - - disk_space_indicator.set_available_disk_sec (samples / (float)fr); + disk_space_gauge.set_available_disk_sec (samples / (float)fr); } } @@ -2583,8 +2579,8 @@ ARDOUR_UI::blink_handler (bool blink_on) audition_blink (blink_on); feedback_blink (blink_on); - dsp_load_indicator.blink(blink_on); - disk_space_indicator.blink(blink_on); + dsp_load_gauge.blink(blink_on); + disk_space_gauge.blink(blink_on); } void @@ -4873,7 +4869,7 @@ ARDOUR_UI::xrun_handler (samplepos_t where) ENSURE_GUI_THREAD (*this, &ARDOUR_UI::xrun_handler, where) if (_session && _session->actively_recording()) { - dsp_load_indicator.set_xrun_while_recording(); + dsp_load_gauge.set_xrun_while_recording(); } if (_session && Config->get_create_xrun_marker() && _session->actively_recording()) { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 99aa0e2503..a22bb8352e 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -74,9 +74,9 @@ #include "add_route_dialog.h" #include "ardour_dialog.h" #include "ardour_window.h" -#include "dsp_load_indicator.h" -#include "disk_space_indicator.h" -#include "disk_io_indicator.h" +#include "dsp_load_gauge.h" +#include "disk_space_gauge.h" +#include "disk_io_gauge.h" #include "editing.h" #include "enums.h" #include "mini_timeline.h" @@ -491,9 +491,10 @@ private: ShuttleControl shuttle_box; MiniTimeline mini_timeline; TimeInfoBox* time_info_box; - DspLoadIndicator dsp_load_indicator; - DiskIoIndicator disk_io_indicator; - DiskSpaceIndicator disk_space_indicator; + + DspLoadGauge dsp_load_gauge; + DiskIoGauge disk_io_gauge; + DiskSpaceGauge disk_space_gauge; ArdourWidgets::ArdourVSpacer meterbox_spacer; ArdourWidgets::ArdourVSpacer meterbox_spacer2; diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 2fae71b4ea..67a3f0b589 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -696,10 +696,10 @@ ARDOUR_UI::build_menu_bar () hbox->pack_end (error_alert_button, false, false, 2); - hbox->pack_end (dsp_load_indicator, false, false, 4); + hbox->pack_end (dsp_load_gauge, false, false, 4); - hbox->pack_end (disk_space_indicator, false, false, 4); - hbox->pack_end (disk_io_indicator, false, false, 4); + hbox->pack_end (disk_space_gauge, false, false, 4); + hbox->pack_end (disk_io_gauge, false, false, 4); hbox->pack_end (sample_rate_label, false, false, 4); hbox->pack_end (timecode_format_label, false, false, 4); hbox->pack_end (format_label, false, false, 4); @@ -715,10 +715,10 @@ ARDOUR_UI::build_menu_bar () // OSX provides its own wallclock, thank you very much _status_bar_visibility.add (&wall_clock_label, X_("WallClock"), _("Wall Clock"), true); #endif - _status_bar_visibility.add (&disk_space_indicator, X_("Disk"), _("Disk Space"), !Profile->get_small_screen()); - _status_bar_visibility.add (&dsp_load_indicator, X_("DSP"), _("DSP"), true); + _status_bar_visibility.add (&disk_space_gauge, X_("Disk"), _("Disk Space"), !Profile->get_small_screen()); + _status_bar_visibility.add (&dsp_load_gauge, X_("DSP"), _("DSP"), true); _status_bar_visibility.add (&peak_thread_work_label,X_("Peakfile"), _("Active Peak-file Work"), false); - _status_bar_visibility.add (&disk_io_indicator, X_("Buffers"), _("Buffers"), true); + _status_bar_visibility.add (&disk_io_gauge, X_("Buffers"), _("Buffers"), true); _status_bar_visibility.add (&sample_rate_label, X_("Audio"), _("Audio"), true); _status_bar_visibility.add (&timecode_format_label, X_("TCFormat"), _("Timecode Format"), true); _status_bar_visibility.add (&format_label, X_("Format"), _("File Format"), true); diff --git a/gtk2_ardour/disk_io_gauge.cc b/gtk2_ardour/disk_io_gauge.cc new file mode 100644 index 0000000000..79ccccd9f7 --- /dev/null +++ b/gtk2_ardour/disk_io_gauge.cc @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2017 Robin Gareus + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "ardour_ui.h" +#include "disk_io_gauge.h" + +#include "ardour/audioengine.h" + +#include "pbd/i18n.h" + +#define PADDING 3 + +DiskIoGauge::DiskIoGauge () + : ArdourGauge ("00.0%") + , _disk_io (0) +{ +} + +void +DiskIoGauge::set_disk_io (const double load) +{ + if (load == _disk_io) { + return; + } + _disk_io = load; + + char buf[64]; + snprintf (buf, sizeof (buf), "Dsk: %.1f%%", _disk_io); + update (std::string (buf)); +} + +float +DiskIoGauge::level () const { + return (_disk_io / 100.f); +} + +bool +DiskIoGauge::alert () const +{ + return false; +} + +ArdourGauge::Status +DiskIoGauge::indicator () const +{ + if (_disk_io < 50) { + return ArdourGauge::Level_CRIT; + } else if (_disk_io < 75) { + return ArdourGauge::Level_WARN; + } else { + return ArdourGauge::Level_OK; + } +} + +std::string +DiskIoGauge::tooltip_text () +{ + char buf[64]; + + snprintf (buf, sizeof (buf), _("Disk I/O cache: %.1f"), _disk_io); + + return buf; +} diff --git a/gtk2_ardour/disk_io_gauge.h b/gtk2_ardour/disk_io_gauge.h new file mode 100644 index 0000000000..f06f610097 --- /dev/null +++ b/gtk2_ardour/disk_io_gauge.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2017 Robin Gareus + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __gtkardour_disk_io_gauge_h__ +#define __gtkardour_disk_io_gauge_h__ + +#include + +#include "ardour_gauge.h" + +class DiskIoGauge : public ArdourGauge +{ +public: + DiskIoGauge (); + + void set_disk_io (const double load); + +protected: + bool alert () const; + ArdourGauge::Status indicator () const; + float level () const; + std::string tooltip_text (); + +private: + + float _disk_io; +}; + +#endif diff --git a/gtk2_ardour/disk_io_indicator.cc b/gtk2_ardour/disk_io_indicator.cc deleted file mode 100644 index 3b8c6161a5..0000000000 --- a/gtk2_ardour/disk_io_indicator.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "ardour_ui.h" -#include "disk_io_indicator.h" - -#include "ardour/audioengine.h" - -#include "pbd/i18n.h" - -#define PADDING 3 - -DiskIoIndicator::DiskIoIndicator () - : ArdourGauge ("00.0%") - , _disk_io (0) -{ -} - -void -DiskIoIndicator::set_disk_io (const double load) -{ - if (load == _disk_io) { - return; - } - _disk_io = load; - - char buf[64]; - snprintf (buf, sizeof (buf), "Dsk: %.1f%%", _disk_io); - update (std::string (buf)); -} - -float -DiskIoIndicator::level () const { - return (_disk_io / 100.f); -} - -bool -DiskIoIndicator::alert () const -{ - return false; -} - -ArdourGauge::Status -DiskIoIndicator::indicator () const -{ - if (_disk_io < 50) { - return ArdourGauge::Level_CRIT; - } else if (_disk_io < 75) { - return ArdourGauge::Level_WARN; - } else { - return ArdourGauge::Level_OK; - } -} - -std::string -DiskIoIndicator::tooltip_text () -{ - char buf[64]; - - snprintf (buf, sizeof (buf), _("Disk I/O cache: %.1f"), _disk_io); - - return buf; -} diff --git a/gtk2_ardour/disk_io_indicator.h b/gtk2_ardour/disk_io_indicator.h deleted file mode 100644 index f2b10cd90a..0000000000 --- a/gtk2_ardour/disk_io_indicator.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __gtkardour_disk_io_indicator_h__ -#define __gtkardour_disk_io_indicator_h__ - -#include - -#include "ardour_gauge.h" - -class DiskIoIndicator : public ArdourGauge -{ -public: - DiskIoIndicator (); - - void set_disk_io (const double load); - -protected: - bool alert () const; - ArdourGauge::Status indicator () const; - float level () const; - std::string tooltip_text (); - -private: - - float _disk_io; -}; - -#endif diff --git a/gtk2_ardour/disk_space_gauge.cc b/gtk2_ardour/disk_space_gauge.cc new file mode 100644 index 0000000000..9c5d735b8d --- /dev/null +++ b/gtk2_ardour/disk_space_gauge.cc @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2017 Robin Gareus + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "ardour_ui.h" +#include "dsp_load_gauge.h" + +#include "pbd/i18n.h" + +#define PADDING 3 + +DiskSpaceGauge::DiskSpaceGauge () + : ArdourGauge (">24h") + , _sec (-1) +{ +} + +void +DiskSpaceGauge::set_available_disk_sec (float sec) +{ + if (_sec == sec) { + return; + } + _sec = sec; + + if (sec < 0) { + update (_("N/A")); + return; + } + + char buf[64]; + if (_sec > 86400) { + update (_("Rec: >24h")); + return; + } else if (_sec > 32400 /* 9 hours */) { + snprintf (buf, sizeof (buf), "Rec: %.0fh", _sec / 3600.f); + } else if (_sec > 5940 /* 99 mins */) { + snprintf (buf, sizeof (buf), "Rec: %.1fh", _sec / 3600.f); + } else { + snprintf (buf, sizeof (buf), "Rec: %.0fm", _sec / 60.f); + } + update (std::string (buf)); +} + +float +DiskSpaceGauge::level () const { + static const float lm = 6.f * 3600.f; + if (_sec < 0) return 0; + if (_sec > lm) return 1.0; + return _sec / lm; +} + +bool +DiskSpaceGauge::alert () const +{ + return _sec >=0 && _sec < 60.f * 10.f; +} + +ArdourGauge::Status +DiskSpaceGauge::indicator () const +{ + if (_sec > 3600.f) { + return ArdourGauge::Level_OK; + } else if (_sec > 1800.f) { + return ArdourGauge::Level_WARN; + } + return ArdourGauge::Level_CRIT; +} + +std::string +DiskSpaceGauge::tooltip_text () +{ + if (_sec < 0) { + return _("Unkown"); + } + + int sec = floor (_sec); + char buf[64]; + int hrs = sec / 3600; + int mins = (sec / 60) % 60; + int secs = sec % 60; + + snprintf (buf, sizeof(buf), _("%02dh:%02dm:%02ds"), hrs, mins, secs); + return _("Available capture disk-space: ") + std::string (buf); +} diff --git a/gtk2_ardour/disk_space_gauge.h b/gtk2_ardour/disk_space_gauge.h new file mode 100644 index 0000000000..1b92708f2b --- /dev/null +++ b/gtk2_ardour/disk_space_gauge.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2017 Robin Gareus + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __gtkardour_disk_space_gauge_h__ +#define __gtkardour_disk_space_gauge_h__ + +#include + +#include "ardour_gauge.h" + +class DiskSpaceGauge : public ArdourGauge +{ +public: + DiskSpaceGauge (); + + void set_available_disk_sec (float); + +protected: + bool alert () const; + ArdourGauge::Status indicator () const; + float level () const; + std::string tooltip_text (); + +private: + float _sec; +}; + +#endif diff --git a/gtk2_ardour/disk_space_indicator.cc b/gtk2_ardour/disk_space_indicator.cc deleted file mode 100644 index acdfa56d74..0000000000 --- a/gtk2_ardour/disk_space_indicator.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "ardour_ui.h" -#include "dsp_load_indicator.h" - -#include "pbd/i18n.h" - -#define PADDING 3 - -DiskSpaceIndicator::DiskSpaceIndicator () - : ArdourGauge (">24h") - , _sec (-1) -{ -} - -void -DiskSpaceIndicator::set_available_disk_sec (float sec) -{ - if (_sec == sec) { - return; - } - _sec = sec; - - if (sec < 0) { - update (_("N/A")); - return; - } - - char buf[64]; - if (_sec > 86400) { - update (_("Rec: >24h")); - return; - } else if (_sec > 32400 /* 9 hours */) { - snprintf (buf, sizeof (buf), "Rec: %.0fh", _sec / 3600.f); - } else if (_sec > 5940 /* 99 mins */) { - snprintf (buf, sizeof (buf), "Rec: %.1fh", _sec / 3600.f); - } else { - snprintf (buf, sizeof (buf), "Rec: %.0fm", _sec / 60.f); - } - update (std::string (buf)); -} - -float -DiskSpaceIndicator::level () const { - static const float lm = 6.f * 3600.f; - if (_sec < 0) return 0; - if (_sec > lm) return 1.0; - return _sec / lm; -} - -bool -DiskSpaceIndicator::alert () const -{ - return _sec >=0 && _sec < 60.f * 10.f; -} - -ArdourGauge::Status -DiskSpaceIndicator::indicator () const -{ - if (_sec > 3600.f) { - return ArdourGauge::Level_OK; - } else if (_sec > 1800.f) { - return ArdourGauge::Level_WARN; - } - return ArdourGauge::Level_CRIT; -} - -std::string -DiskSpaceIndicator::tooltip_text () -{ - if (_sec < 0) { - return _("Unkown"); - } - - int sec = floor (_sec); - char buf[64]; - int hrs = sec / 3600; - int mins = (sec / 60) % 60; - int secs = sec % 60; - - snprintf (buf, sizeof(buf), _("%02dh:%02dm:%02ds"), hrs, mins, secs); - return _("Available capture disk-space: ") + std::string (buf); -} diff --git a/gtk2_ardour/disk_space_indicator.h b/gtk2_ardour/disk_space_indicator.h deleted file mode 100644 index e4a46f9c83..0000000000 --- a/gtk2_ardour/disk_space_indicator.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __gtkardour_disk_space_indicator_h__ -#define __gtkardour_disk_space_indicator_h__ - -#include - -#include "ardour_gauge.h" - -class DiskSpaceIndicator : public ArdourGauge -{ -public: - DiskSpaceIndicator (); - - void set_available_disk_sec (float); - -protected: - bool alert () const; - ArdourGauge::Status indicator () const; - float level () const; - std::string tooltip_text (); - -private: - float _sec; -}; - -#endif diff --git a/gtk2_ardour/dsp_load_gauge.cc b/gtk2_ardour/dsp_load_gauge.cc new file mode 100644 index 0000000000..46ff15400b --- /dev/null +++ b/gtk2_ardour/dsp_load_gauge.cc @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2017 Robin Gareus + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "ardour_ui.h" +#include "dsp_load_gauge.h" + +#include "ardour/audioengine.h" + +#include "pbd/i18n.h" + +#define PADDING 3 + +DspLoadGauge::DspLoadGauge () + : ArdourGauge ("00.0%") + , _dsp_load (0) + , _xrun_count (0) + , _xrun_while_recording (false) +{ +} + +void +DspLoadGauge::set_xrun_count (const unsigned int xruns) +{ + if (xruns == _xrun_count) { + return; + } + _xrun_count = xruns; + update (); +} + +void +DspLoadGauge::set_dsp_load (const double load) +{ + if (load == _dsp_load) { + return; + } + _dsp_load = load; + + char buf[64]; + if (_xrun_count > 0) { + snprintf (buf, sizeof (buf), "DSP: %.1f%% (%d)", _dsp_load, _xrun_count); + } else { + snprintf (buf, sizeof (buf), "DSP: %.1f%%", _dsp_load); + } + update (std::string (buf)); +} + +float +DspLoadGauge::level () const { + return (100.0-_dsp_load) / 100.f; +} + +bool +DspLoadGauge::alert () const +{ + bool ret = false; + + //xrun while recording + ret |= _xrun_while_recording; + + //engine OFF + ret |= !ARDOUR::AudioEngine::instance()->running(); + + return ret; +} + +ArdourGauge::Status +DspLoadGauge::indicator () const +{ + if (_dsp_load > 90) { + return ArdourGauge::Level_CRIT; + } else if (_dsp_load > 80) { + return ArdourGauge::Level_WARN; + } else { + return ArdourGauge::Level_OK; + } +} + +std::string +DspLoadGauge::tooltip_text () +{ + char buf[64]; + + //xruns + if (_xrun_count == UINT_MAX) { + snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: ?\nClick to clear xruns."), _dsp_load); + } else if (_xrun_count > 9999) { + snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: >10k\nClick to clear xruns."), _dsp_load); + } else { + snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: %u\nClick to clear xruns."), _dsp_load, _xrun_count); + } + + return buf; +} + +bool +DspLoadGauge::on_button_release_event (GdkEventButton *ev) +{ + ARDOUR::Session* s = ARDOUR_UI::instance ()->the_session (); + if (s) { + s->reset_xrun_count (); + _xrun_while_recording = false; + queue_draw(); + } + return true; +} diff --git a/gtk2_ardour/dsp_load_gauge.h b/gtk2_ardour/dsp_load_gauge.h new file mode 100644 index 0000000000..166093a2c7 --- /dev/null +++ b/gtk2_ardour/dsp_load_gauge.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2017 Robin Gareus + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __gtkardour_dsp_load_gauge_h__ +#define __gtkardour_dsp_load_gauge_h__ + +#include + +#include "ardour_gauge.h" + +class DspLoadGauge : public ArdourGauge +{ +public: + DspLoadGauge (); + + void set_xrun_count (const unsigned int xruns); + void set_dsp_load (const double load); + + void set_xrun_while_recording () {_xrun_while_recording = true;} + +protected: + bool alert () const; + ArdourGauge::Status indicator () const; + float level () const; + std::string tooltip_text (); + +private: + bool on_button_release_event (GdkEventButton*); + + float _dsp_load; + unsigned int _xrun_count; + bool _xrun_while_recording; +}; + +#endif diff --git a/gtk2_ardour/dsp_load_indicator.cc b/gtk2_ardour/dsp_load_indicator.cc deleted file mode 100644 index 8e50d21771..0000000000 --- a/gtk2_ardour/dsp_load_indicator.cc +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "ardour_ui.h" -#include "dsp_load_indicator.h" - -#include "ardour/audioengine.h" - -#include "pbd/i18n.h" - -#define PADDING 3 - -DspLoadIndicator::DspLoadIndicator () - : ArdourGauge ("00.0%") - , _dsp_load (0) - , _xrun_count (0) - , _xrun_while_recording (false) -{ -} - -void -DspLoadIndicator::set_xrun_count (const unsigned int xruns) -{ - if (xruns == _xrun_count) { - return; - } - _xrun_count = xruns; - update (); -} - -void -DspLoadIndicator::set_dsp_load (const double load) -{ - if (load == _dsp_load) { - return; - } - _dsp_load = load; - - char buf[64]; - if (_xrun_count > 0) { - snprintf (buf, sizeof (buf), "DSP: %.1f%% (%d)", _dsp_load, _xrun_count); - } else { - snprintf (buf, sizeof (buf), "DSP: %.1f%%", _dsp_load); - } - update (std::string (buf)); -} - -float -DspLoadIndicator::level () const { - return (100.0-_dsp_load) / 100.f; -} - -bool -DspLoadIndicator::alert () const -{ - bool ret = false; - - //xrun while recording - ret |= _xrun_while_recording; - - //engine OFF - ret |= !ARDOUR::AudioEngine::instance()->running(); - - return ret; -} - -ArdourGauge::Status -DspLoadIndicator::indicator () const -{ - if (_dsp_load > 90) { - return ArdourGauge::Level_CRIT; - } else if (_dsp_load > 80) { - return ArdourGauge::Level_WARN; - } else { - return ArdourGauge::Level_OK; - } -} - -std::string -DspLoadIndicator::tooltip_text () -{ - char buf[64]; - - //xruns - if (_xrun_count == UINT_MAX) { - snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: ?\nClick to clear xruns."), _dsp_load); - } else if (_xrun_count > 9999) { - snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: >10k\nClick to clear xruns."), _dsp_load); - } else { - snprintf (buf, sizeof (buf), _("DSP: %.1f%% X: %u\nClick to clear xruns."), _dsp_load, _xrun_count); - } - - return buf; -} - -bool -DspLoadIndicator::on_button_release_event (GdkEventButton *ev) -{ - ARDOUR::Session* s = ARDOUR_UI::instance ()->the_session (); - if (s) { - s->reset_xrun_count (); - _xrun_while_recording = false; - queue_draw(); - } - return true; -} diff --git a/gtk2_ardour/dsp_load_indicator.h b/gtk2_ardour/dsp_load_indicator.h deleted file mode 100644 index d350d5680d..0000000000 --- a/gtk2_ardour/dsp_load_indicator.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __gtkardour_dsp_load_indicator_h__ -#define __gtkardour_dsp_load_indicator_h__ - -#include - -#include "ardour_gauge.h" - -class DspLoadIndicator : public ArdourGauge -{ -public: - DspLoadIndicator (); - - void set_xrun_count (const unsigned int xruns); - void set_dsp_load (const double load); - - void set_xrun_while_recording () {_xrun_while_recording = true;} - -protected: - bool alert () const; - ArdourGauge::Status indicator () const; - float level () const; - std::string tooltip_text (); - -private: - bool on_button_release_event (GdkEventButton*); - - float _dsp_load; - unsigned int _xrun_count; - bool _xrun_while_recording; -}; - -#endif diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 4857ebd89e..857e7a33c2 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -65,10 +65,10 @@ gtk2_ardour_sources = [ 'cursor_context.cc', 'curvetest.cc', 'debug.cc', - 'disk_space_indicator.cc', + 'disk_space_gauge.cc', 'duplicate_routes_dialog.cc', - 'disk_io_indicator.cc', - 'dsp_load_indicator.cc', + 'disk_io_gauge.cc', + 'dsp_load_gauge.cc', 'edit_note_dialog.cc', 'editing.cc', 'editor.cc', -- cgit v1.2.3