T: adjust meter count to available inputs
This commit is contained in:
parent
d5dc58fc3f
commit
8d7cd9f7a8
@ -535,7 +535,7 @@ ARDOUR_UI::livetrax_setup_windows ()
|
||||
|
||||
/* meter display */
|
||||
|
||||
livetrax_meters = manage (new LiveTraxMeters (48));
|
||||
livetrax_meters = manage (new LiveTraxMeters);
|
||||
livetrax_meters->show_all ();
|
||||
// livetrax_meter_bar.set_border_width (4);
|
||||
livetrax_meter_bar.pack_start (*livetrax_meters, true, true, 0);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "widgets/fastmeter.h"
|
||||
|
||||
#include "gui_thread.h"
|
||||
#include "livetrax_meters.h"
|
||||
#include "ui_config.h"
|
||||
|
||||
@ -11,35 +12,53 @@ using namespace ArdourWidgets;
|
||||
|
||||
#define PX_SCALE(px) std::max ((float)px, rintf ((float)px* UIConfiguration::instance ().get_ui_scale ()))
|
||||
|
||||
LiveTraxMeters::LiveTraxMeters (size_t initial_cnt)
|
||||
LiveTraxMeters::LiveTraxMeters ()
|
||||
{
|
||||
set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER);
|
||||
|
||||
resize (initial_cnt);
|
||||
_meter_box.set_border_width (PX_SCALE (10));
|
||||
_meter_box.set_spacing (PX_SCALE (10));
|
||||
add (_meter_box);
|
||||
|
||||
meter_box.set_border_width (PX_SCALE (10));
|
||||
meter_box.set_spacing (PX_SCALE (10));
|
||||
add (meter_box);
|
||||
|
||||
fast_screen_update_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &LiveTraxMeters::update_meters), 40, GDK_PRIORITY_REDRAW + 10);
|
||||
AudioEngine::instance ()->Running.connect (_engine_connections, invalidator (*this), boost::bind (&LiveTraxMeters::start_updating, this), gui_context ());
|
||||
AudioEngine::instance ()->Stopped.connect (_engine_connections, invalidator (*this), boost::bind (&LiveTraxMeters::stop_updating, this), gui_context ());
|
||||
AudioEngine::instance ()->Halted.connect (_engine_connections, invalidator (*this), boost::bind (&LiveTraxMeters::stop_updating, this), gui_context ());
|
||||
|
||||
if (ARDOUR::AudioEngine::instance ()->running ()) {
|
||||
start_updating ();
|
||||
}
|
||||
}
|
||||
|
||||
LiveTraxMeters::~LiveTraxMeters ()
|
||||
{
|
||||
fast_screen_update_connection.disconnect ();
|
||||
}
|
||||
|
||||
void
|
||||
LiveTraxMeters::start_updating ()
|
||||
{
|
||||
resize (AudioEngine::instance ()->audio_input_ports ().size ());
|
||||
_fast_screen_update_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &LiveTraxMeters::update_meters), 40, GDK_PRIORITY_REDRAW + 10);
|
||||
}
|
||||
|
||||
void
|
||||
LiveTraxMeters::stop_updating ()
|
||||
{
|
||||
_fast_screen_update_connection.disconnect ();
|
||||
resize (0);
|
||||
}
|
||||
|
||||
void
|
||||
LiveTraxMeters::resize (size_t sz)
|
||||
{
|
||||
size_t old = meters.size();
|
||||
size_t old = _meters.size();
|
||||
|
||||
while (old > sz) {
|
||||
/* Widgets are all managed so this should delete them as they
|
||||
are removed.
|
||||
*/
|
||||
meter_box.remove (*widgets[old - 1]);
|
||||
meters.pop_back ();
|
||||
_meter_box.remove (*_widgets[old - 1]);
|
||||
_meters.pop_back ();
|
||||
_widgets.pop_back ();
|
||||
old--;
|
||||
}
|
||||
|
||||
@ -76,7 +95,7 @@ LiveTraxMeters::resize (size_t sz)
|
||||
|
||||
for (size_t i = old; i < sz; ++i) {
|
||||
|
||||
meters.push_back (manage (new FastMeter (10 /* (uint32_t)floor (UIConfiguration::instance ().get_meter_hold ()) */,
|
||||
_meters.push_back (manage (new FastMeter (10 /* (uint32_t)floor (UIConfiguration::instance ().get_meter_hold ()) */,
|
||||
8, FastMeter::Vertical, PX_SCALE (64),
|
||||
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9],
|
||||
b[0], b[1], b[2], b[3],
|
||||
@ -87,15 +106,18 @@ LiveTraxMeters::resize (size_t sz)
|
||||
char buf[16];
|
||||
snprintf (buf, sizeof (buf), "%zu", i+1);
|
||||
Gtk::Label* l = manage (new Gtk::Label (buf));
|
||||
vb->pack_start (*meters.back(), true, true);
|
||||
vb->pack_start (*_meters.back(), true, true);
|
||||
vb->pack_start (*l, false, false, PX_SCALE(3));
|
||||
|
||||
widgets.push_back (vb);
|
||||
_widgets.push_back (vb);
|
||||
|
||||
meter_box.pack_start (*vb, false, false, 0);
|
||||
_meter_box.pack_start (*vb, false, false, 0);
|
||||
}
|
||||
|
||||
meter_box.show_all ();
|
||||
_meter_box.show_all ();
|
||||
if (get_parent ()) {
|
||||
queue_resize ();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -106,10 +128,10 @@ LiveTraxMeters::update_meters ()
|
||||
size_t n = 0;
|
||||
|
||||
for (auto const & p : aip) {
|
||||
if (n >= meters.size()) {
|
||||
if (n >= _meters.size()) {
|
||||
break;
|
||||
}
|
||||
meters[n]->set (p.second.meter->level, p.second.meter->peak);
|
||||
_meters[n]->set (p.second.meter->level, p.second.meter->peak);
|
||||
++n;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
|
||||
#include "pbd/signals.h"
|
||||
|
||||
namespace Gtk {
|
||||
class Label;
|
||||
}
|
||||
@ -16,20 +18,21 @@ namespace ArdourWidgets {
|
||||
|
||||
class LiveTraxMeters : public Gtk::ScrolledWindow
|
||||
{
|
||||
public:
|
||||
LiveTraxMeters (size_t initial_cnt);
|
||||
public:
|
||||
LiveTraxMeters ();
|
||||
~LiveTraxMeters ();
|
||||
|
||||
private:
|
||||
void start_updating ();
|
||||
void stop_updating ();
|
||||
bool update_meters ();
|
||||
void resize (size_t);
|
||||
|
||||
private:
|
||||
Gtk::HBox meter_box;
|
||||
Gtk::HBox global_hbox;
|
||||
std::vector<Gtk::Widget*> widgets;
|
||||
std::vector<ArdourWidgets::FastMeter*> meters;
|
||||
sigc::connection fast_screen_update_connection;
|
||||
|
||||
bool update_meters ();
|
||||
Gtk::HBox _meter_box;
|
||||
std::vector<Gtk::Widget*> _widgets;
|
||||
std::vector<ArdourWidgets::FastMeter*> _meters;
|
||||
PBD::ScopedConnectionList _engine_connections;
|
||||
sigc::connection _fast_screen_update_connection;
|
||||
};
|
||||
|
||||
#endif /* __ardour_gtk_livetrax_meters_h__ */
|
||||
|
Loading…
Reference in New Issue
Block a user