diff options
-rw-r--r-- | gtk2_ardour/ardour_gauge.cc | 129 | ||||
-rw-r--r-- | gtk2_ardour/ardour_gauge.h | 63 | ||||
-rw-r--r-- | gtk2_ardour/disk_io_gauge.cc | 90 | ||||
-rw-r--r-- | gtk2_ardour/disk_io_gauge.h | 45 | ||||
-rw-r--r-- | gtk2_ardour/disk_space_gauge.cc | 99 | ||||
-rw-r--r-- | gtk2_ardour/disk_space_gauge.h | 43 | ||||
-rw-r--r-- | gtk2_ardour/dsp_load_gauge.cc | 121 | ||||
-rw-r--r-- | gtk2_ardour/dsp_load_gauge.h | 50 | ||||
-rw-r--r-- | gtk2_ardour/wscript | 4 |
9 files changed, 0 insertions, 644 deletions
diff --git a/gtk2_ardour/ardour_gauge.cc b/gtk2_ardour/ardour_gauge.cc deleted file mode 100644 index d93d2d15d6..0000000000 --- a/gtk2_ardour/ardour_gauge.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus <robin@gareus.org> - * - * 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 "gtkmm2ext/utils.h" -#include "widgets/tooltips.h" - -#include "ardour_gauge.h" -#include "ui_config.h" - -#define PADDING 3 - -ArdourGauge::ArdourGauge (std::string const& max_text) -{ - _layout = Pango::Layout::create (get_pango_context ()); - _layout->set_text (max_text); -} - -ArdourGauge::~ArdourGauge () -{ -} - -void -ArdourGauge::on_size_request (Gtk::Requisition* req) -{ - req->width = req->height = 0; - CairoWidget::on_size_request (req); - - int w, h; - _layout->get_pixel_size (w, h); - - req->width = std::max (req->width, 100 /*std::max (20, w + PADDING) */); - req->height = std::max (req->height, std::max (12, h + PADDING)); -} - -void -ArdourGauge::update () -{ - queue_draw (); - ArdourWidgets::set_tooltip (*this, tooltip_text ()); -} - -void -ArdourGauge::update (std::string const& txt) -{ - _layout->set_text (txt); - update (); -} - -void -ArdourGauge::blink (bool onoff) -{ - _blink = onoff; - queue_draw (); -} - -void -ArdourGauge::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*) -{ - cairo_t* cr = ctx->cobj (); - Gtkmm2ext::Color bg = UIConfiguration::instance().color ("gtk_background"); - Gtkmm2ext::Color base = UIConfiguration::instance ().color ("ruler base"); - Gtkmm2ext::Color text = UIConfiguration::instance ().color ("ruler text"); - - const int width = get_width (); - const int height = get_height (); - - cairo_rectangle (cr, 0, 0, width, height); - cairo_set_source_rgba (cr, 0,0,0,1 ); - cairo_fill (cr); - - cairo_rectangle (cr, 1, 1, width-2, height-2); - Gtkmm2ext::set_source_rgba (cr, bg); - cairo_fill (cr); - - if (alert () && _blink) { - Gtkmm2ext::rounded_rectangle (cr, 1, 1, width - 2, height - 2, 1); - cairo_set_source_rgba (cr, 0.5, 0, 0, 1.0); - cairo_fill (cr); - } - - cairo_rectangle (cr, PADDING, PADDING, width - PADDING - PADDING, height - PADDING - PADDING); - cairo_clip (cr); - - const float lvl = level (); - - int bw = (width - PADDING - PADDING) * lvl; - cairo_rectangle (cr, PADDING, PADDING, bw, height-PADDING); - - switch (indicator ()) { - case Level_OK: - break; - case Level_WARN: - cairo_set_source_rgba (cr, .7, .6, 0, 1.0); - cairo_fill (cr); - break; - case Level_CRIT: - cairo_set_source_rgba (cr, .9, 0, 0, 1.0); - cairo_fill (cr); - break; - } - - int w, h; - _layout->get_pixel_size (w, h); - - cairo_save (cr); - - cairo_translate (cr, 2+PADDING, height * .5); - cairo_move_to (cr, 0, h * -.5); //vertically center the text - pango_cairo_update_layout (cr, _layout->gobj()); - Gtkmm2ext::set_source_rgba (cr, text); - pango_cairo_show_layout (cr, _layout->gobj()); - - cairo_restore (cr); -} diff --git a/gtk2_ardour/ardour_gauge.h b/gtk2_ardour/ardour_gauge.h deleted file mode 100644 index 2a12ee8ce0..0000000000 --- a/gtk2_ardour/ardour_gauge.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus <robin@gareus.org> - * - * 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_gauge_h__ -#define __gtkardour_gauge_h__ - -#include <pangomm.h> - -#include "gtkmm2ext/cairo_widget.h" - -class ArdourGauge : public CairoWidget -{ -public: - ArdourGauge (std::string const& max_text = "00.0%"); - virtual ~ArdourGauge (); - - void blink (bool onoff); - -protected: - - enum Status { - Level_OK, /* green */ - Level_WARN, /* yellow */ - Level_CRIT /* red */ - }; - - /* gauge's background, indicate alarming conditions eg. xrun */ - virtual bool alert () const { return false; } - /* guage inidicator color */ - virtual Status indicator () const = 0; - /* gauge level 0 <= level <= 1 */ - virtual float level () const = 0; - - virtual std::string tooltip_text () = 0; - - void update (); - void update (std::string const &); - -private: - void on_size_request (Gtk::Requisition*); - void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*); - - Glib::RefPtr<Pango::Layout> _layout; - - bool _blink; -}; - -#endif diff --git a/gtk2_ardour/disk_io_gauge.cc b/gtk2_ardour/disk_io_gauge.cc deleted file mode 100644 index 240cd4f079..0000000000 --- a/gtk2_ardour/disk_io_gauge.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus <robin@gareus.org> - * - * 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 (" ") - , _disk_play (0) - , _disk_capture (0) -{ -} - -void -DiskIoGauge::set_disk_io (const double play, const double capture) -{ - if (play == _disk_play && capture == _disk_capture) { - return; - } - _disk_play = 100.0-play; - _disk_capture = 100.0-capture; - - char buf[64]; - if ( _disk_play > 1.0 && _disk_play < 10.0 && _disk_capture < 2.0 ) { - snprintf (buf, sizeof (buf), "Disk: %.0f%% / 0%%", _disk_play); - } else if ( _disk_play > 1.0 && _disk_capture < 2.0 ) { - snprintf (buf, sizeof (buf), "Disk: %.0f%% / 0%%", _disk_play); - } else if ( _disk_play > 1.0 && _disk_capture > 1.0 ) { - snprintf (buf, sizeof (buf), "Disk: %.0f%% / %.0f%%", _disk_play, _disk_capture); - } else { - snprintf (buf, sizeof (buf), " "); - } - update (std::string (buf)); -} - -float -DiskIoGauge::level () const { - return min ( _disk_play / 100.f, _disk_capture / 100.f); -} - -bool -DiskIoGauge::alert () const -{ - return false; -} - -ArdourGauge::Status -DiskIoGauge::indicator () const -{ - float lvl = level(); - - if (lvl > 0.6) { - return ArdourGauge::Level_CRIT; - } else if (lvl > 0.4) { - return ArdourGauge::Level_WARN; - } else { - return ArdourGauge::Level_OK; - } -} - -std::string -DiskIoGauge::tooltip_text () -{ - char buf[128]; - - snprintf (buf, sizeof (buf), "Disk Play/Record cache: %.0f%% / %.0f%%", _disk_play, _disk_capture); - - return buf; -} diff --git a/gtk2_ardour/disk_io_gauge.h b/gtk2_ardour/disk_io_gauge.h deleted file mode 100644 index ba96833cc8..0000000000 --- a/gtk2_ardour/disk_io_gauge.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus <robin@gareus.org> - * - * 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 <pangomm.h> - -#include "ardour_gauge.h" - -class DiskIoGauge : public ArdourGauge -{ -public: - DiskIoGauge (); - - void set_disk_io (const double playback, const double capture); - -protected: - bool alert () const; - ArdourGauge::Status indicator () const; - float level () const; - std::string tooltip_text (); - -private: - - float _disk_play; - float _disk_capture; -}; - -#endif diff --git a/gtk2_ardour/disk_space_gauge.cc b/gtk2_ardour/disk_space_gauge.cc deleted file mode 100644 index acc2525b7f..0000000000 --- a/gtk2_ardour/disk_space_gauge.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus <robin@gareus.org> - * - * 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 (" ") - , _sec (12*60*60) -{ -} - -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 six_hours = 6.f * 3600.f; - if (_sec < 0) return 0.0; - if (_sec > six_hours) return 0.0; - return (1.0 - (_sec / six_hours)); -} - -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 deleted file mode 100644 index 1b92708f2b..0000000000 --- a/gtk2_ardour/disk_space_gauge.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus <robin@gareus.org> - * - * 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 <pangomm.h> - -#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/dsp_load_gauge.cc b/gtk2_ardour/dsp_load_gauge.cc deleted file mode 100644 index fc7023121f..0000000000 --- a/gtk2_ardour/dsp_load_gauge.cc +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus <robin@gareus.org> - * - * 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 (" ") - , _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 (_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 > 75) { - 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 deleted file mode 100644 index 166093a2c7..0000000000 --- a/gtk2_ardour/dsp_load_gauge.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017 Robin Gareus <robin@gareus.org> - * - * 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 <pangomm.h> - -#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/wscript b/gtk2_ardour/wscript index 857e7a33c2..ad61135d32 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -32,7 +32,6 @@ gtk2_ardour_sources = [ 'ambiguous_file_dialog.cc', 'analysis_window.cc', 'ardour_dialog.cc', - 'ardour_gauge.cc', 'ardour_http.cc', 'ardour_ui.cc', 'ardour_ui2.cc', @@ -65,10 +64,7 @@ gtk2_ardour_sources = [ 'cursor_context.cc', 'curvetest.cc', 'debug.cc', - 'disk_space_gauge.cc', 'duplicate_routes_dialog.cc', - 'disk_io_gauge.cc', - 'dsp_load_gauge.cc', 'edit_note_dialog.cc', 'editing.cc', 'editor.cc', |