2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002 Paul Davis
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ardour/session.h>
|
|
|
|
#include <ardour/session_route.h>
|
2006-06-14 17:17:32 -04:00
|
|
|
#include <ardour/audio_diskstream.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/audio_track.h>
|
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "meter_bridge.h"
|
|
|
|
#include "meter_bridge_strip.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#define FRAME_SHADOW_STYLE Gtk::SHADOW_IN
|
2005-09-25 14:42:24 -04:00
|
|
|
#define FRAME_NAME "BaseFrame"
|
|
|
|
|
|
|
|
MeterBridge::MeterBridge ()
|
2005-11-12 22:53:51 -05:00
|
|
|
: ArdourDialog ("meter bridge"),
|
|
|
|
hadjustment (0.0, 0.0, 0.0),
|
|
|
|
vadjustment (0.0, 0.0, 0.0),
|
|
|
|
meter_viewport (hadjustment, vadjustment)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
meter_base.set_name ("MeterBase");
|
|
|
|
meter_frame.set_shadow_type (FRAME_SHADOW_STYLE);
|
|
|
|
meter_frame.set_name (FRAME_NAME);
|
|
|
|
meter_frame.add (meter_base);
|
|
|
|
|
|
|
|
upper_metering_box.set_name ("AboveMeterZone");
|
|
|
|
lower_metering_box.set_name ("BelowMeterZone");
|
|
|
|
|
|
|
|
metering_vbox.set_spacing (5);
|
|
|
|
metering_vbox.set_border_width (10);
|
|
|
|
metering_vbox.pack_start (upper_metering_box, false, false);
|
|
|
|
metering_vbox.pack_start (meter_frame, false, false);
|
|
|
|
metering_vbox.pack_start (lower_metering_box, false, false);
|
|
|
|
|
|
|
|
metering_hbox.pack_start (metering_vbox, false, false);
|
|
|
|
|
|
|
|
meter_scroll_base.set_name ("MeterScrollBase");
|
|
|
|
meter_scroll_base.add (metering_hbox);
|
|
|
|
|
|
|
|
meter_viewport.add (meter_scroll_base);
|
2005-10-09 01:03:29 -04:00
|
|
|
meter_viewport.set_shadow_type (Gtk::SHADOW_NONE);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
meter_scroller.add (meter_viewport);
|
|
|
|
meter_scroller.set_name ("MeterBridgeWindow");
|
2005-09-25 16:33:00 -04:00
|
|
|
meter_scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
2005-09-25 14:42:24 -04:00
|
|
|
meter_scroller.set_border_width (5);
|
|
|
|
|
|
|
|
add (meter_scroller);
|
2005-09-25 16:33:00 -04:00
|
|
|
add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
|
2005-09-25 14:42:24 -04:00
|
|
|
set_name ("MeterBridgeWindow");
|
|
|
|
set_title (_("ardour: meter bridge"));
|
|
|
|
set_wmclass (_("ardour_meter_bridge"), "Ardour");
|
|
|
|
// set_policy (false, false, false); // no user resizing of any kind
|
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Gtk::Window*>(this)));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
metering = false;
|
|
|
|
|
|
|
|
/* don't show: this window doesn't come up by default */
|
|
|
|
}
|
|
|
|
|
|
|
|
MeterBridge::~MeterBridge ()
|
|
|
|
{
|
|
|
|
stop_metering ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::set_session (Session *s)
|
|
|
|
{
|
|
|
|
ArdourDialog::set_session (s);
|
|
|
|
|
|
|
|
if (session) {
|
|
|
|
// XXX this stuff has to be fixed if we ever use this code again
|
|
|
|
// (refs vs. ptrs)
|
|
|
|
// session->foreach_route (this, &MeterBridge::add_route);
|
2005-09-25 17:19:23 -04:00
|
|
|
session->RouteAdded.connect (mem_fun(*this, &MeterBridge::add_route));
|
|
|
|
session->going_away.connect (mem_fun(*this, &MeterBridge::session_gone));
|
2005-09-25 14:42:24 -04:00
|
|
|
start_metering ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::session_gone ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(mem_fun(*this, &MeterBridge::session_gone));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
stop_metering ();
|
|
|
|
hide_all ();
|
|
|
|
|
|
|
|
list<MeterBridgeStrip *>::iterator i;
|
|
|
|
|
|
|
|
for (i = meters.begin(); i != meters.end(); ++i) {
|
|
|
|
|
|
|
|
upper_metering_box.remove ((*i)->above_box());
|
|
|
|
meter_base.remove ((*i)->meter_widget());
|
|
|
|
lower_metering_box.remove ((*i)->below_box());
|
|
|
|
|
|
|
|
// delete (*i);
|
|
|
|
}
|
|
|
|
|
|
|
|
meters.clear ();
|
|
|
|
|
|
|
|
ArdourDialog::session_gone();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::add_route (ARDOUR::Route* route)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &MeterBridge::add_route), route));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
uint32_t n;
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
if (!session || route->hidden() || dynamic_cast<AudioTrack*>(route) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
n = meters.size();
|
|
|
|
snprintf (buf, sizeof (buf), "%u", n+1);
|
|
|
|
|
|
|
|
MeterBridgeStrip *meter = new MeterBridgeStrip (session->engine(),
|
|
|
|
*session,
|
|
|
|
*route,
|
|
|
|
buf,
|
|
|
|
session->over_length_long,
|
|
|
|
session->over_length_short,
|
|
|
|
200);
|
|
|
|
|
|
|
|
#define packing_factor 30
|
|
|
|
|
|
|
|
upper_metering_box.put (meter->above_box(), n * packing_factor, 0);
|
|
|
|
|
|
|
|
meter_base.put (meter->meter_widget(), (n * packing_factor) + (meter->meter_width()/2), 0);
|
|
|
|
lower_metering_box.put (meter->below_box(), n * packing_factor, 0);
|
|
|
|
|
|
|
|
meter->above_box().show_all ();
|
|
|
|
meter->meter_widget().show ();
|
|
|
|
meter->below_box().show_all ();
|
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
route->GoingAway.connect (bind (mem_fun(*this, &MeterBridge::remove_route), route));
|
2005-09-25 14:42:24 -04:00
|
|
|
meters.insert (meters.begin(), meter);
|
|
|
|
|
|
|
|
set_default_size (30 + ((n+1) * packing_factor), 315);
|
|
|
|
|
|
|
|
meter->set_meter_on(true);
|
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
session->going_away.connect (mem_fun(*this, &MeterBridge::session_gone));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::remove_route (Route* route)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &MeterBridge::remove_route), route));
|
2005-09-25 14:42:24 -04:00
|
|
|
list<MeterBridgeStrip *>::iterator i;
|
|
|
|
|
|
|
|
for (i = meters.begin(); i != meters.end(); ++i) {
|
|
|
|
if (&((*i)->route()) == route) {
|
|
|
|
delete *i;
|
|
|
|
meters.erase (i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::clear_all_meters ()
|
|
|
|
{
|
|
|
|
list<MeterBridgeStrip *>::iterator i;
|
|
|
|
|
|
|
|
for (i = meters.begin(); i != meters.end(); ++i) {
|
|
|
|
(*i)->clear_meter ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::update ()
|
|
|
|
{
|
|
|
|
list<MeterBridgeStrip *>::iterator i;
|
|
|
|
|
|
|
|
for (i = meters.begin(); i != meters.end(); ++i) {
|
|
|
|
(*i)->update ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::start_metering ()
|
|
|
|
{
|
|
|
|
list<MeterBridgeStrip *>::iterator i;
|
|
|
|
|
|
|
|
for (i = meters.begin(); i != meters.end(); ++i) {
|
|
|
|
(*i)->set_meter_on (true);
|
|
|
|
}
|
|
|
|
metering_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
|
2005-09-25 17:19:23 -04:00
|
|
|
(mem_fun(*this, &MeterBridge::update));
|
2005-09-25 14:42:24 -04:00
|
|
|
metering = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::stop_metering ()
|
|
|
|
{
|
|
|
|
list<MeterBridgeStrip *>::iterator i;
|
|
|
|
|
|
|
|
for (i = meters.begin(); i != meters.end(); ++i) {
|
|
|
|
(*i)->set_meter_on (false);
|
|
|
|
}
|
|
|
|
metering_connection.disconnect();
|
|
|
|
metering = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MeterBridge::toggle_metering ()
|
|
|
|
{
|
|
|
|
if (!metering) {
|
|
|
|
start_metering ();
|
|
|
|
} else {
|
|
|
|
stop_metering ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
void
|
|
|
|
MeterBridge::on_map ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
start_metering ();
|
2005-11-12 22:53:51 -05:00
|
|
|
return Window::on_map ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-12 22:53:51 -05:00
|
|
|
void
|
|
|
|
MeterBridge::on_unmap ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
stop_metering ();
|
2005-11-12 22:53:51 -05:00
|
|
|
return Window::on_unmap ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|