2013-06-23 10:05:52 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2012 Paul Davis
|
|
|
|
Author: 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef WAF_BUILD
|
|
|
|
#include "gtk2ardour-config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <sigc++/bind.h>
|
|
|
|
|
|
|
|
#include <gtkmm/accelmap.h>
|
|
|
|
|
|
|
|
#include <glibmm/threads.h>
|
|
|
|
|
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
#include <gtkmm2ext/window_title.h>
|
|
|
|
|
|
|
|
#include "ardour/debug.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/route_group.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
|
2013-06-28 15:00:17 -04:00
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
#include "meterbridge.h"
|
|
|
|
|
2013-07-05 14:58:23 -04:00
|
|
|
#include "keyboard.h"
|
2013-06-23 10:05:52 -04:00
|
|
|
#include "monitor_section.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "route_sorter.h"
|
|
|
|
#include "actions.h"
|
|
|
|
#include "gui_thread.h"
|
2013-07-05 16:18:04 -04:00
|
|
|
#include "global_signals.h"
|
|
|
|
#include "meter_patterns.h"
|
2013-06-23 10:05:52 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Glib;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
using namespace std;
|
2013-07-15 09:04:20 -04:00
|
|
|
using namespace ArdourMeter;
|
2013-06-23 10:05:52 -04:00
|
|
|
|
|
|
|
using PBD::atoi;
|
|
|
|
|
|
|
|
Meterbridge* Meterbridge::_instance = 0;
|
|
|
|
|
|
|
|
Meterbridge*
|
|
|
|
Meterbridge::instance ()
|
|
|
|
{
|
|
|
|
if (!_instance) {
|
|
|
|
_instance = new Meterbridge;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
|
2013-06-23 10:14:39 -04:00
|
|
|
/* copy from gtk2_ardour/mixer_ui.cc -- TODO consolidate
|
|
|
|
* used by Meterbridge::set_session() below
|
|
|
|
*/
|
|
|
|
struct SignalOrderRouteSorter {
|
|
|
|
bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
|
|
|
|
if (a->is_master() || a->is_monitor()) {
|
|
|
|
/* "a" is a special route (master, monitor, etc), and comes
|
|
|
|
* last in the mixer ordering
|
|
|
|
*/
|
|
|
|
return false;
|
|
|
|
} else if (b->is_master() || b->is_monitor()) {
|
|
|
|
/* everything comes before b */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return a->order_key (MixerSort) < b->order_key (MixerSort);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
Meterbridge::Meterbridge ()
|
|
|
|
: Window (Gtk::WINDOW_TOPLEVEL)
|
|
|
|
, VisibilityTracker (*((Gtk::Window*) this))
|
|
|
|
, _visible (false)
|
2013-06-28 16:48:43 -04:00
|
|
|
, _show_busses (false)
|
2013-07-23 07:30:23 -04:00
|
|
|
, metrics_left (1, MeterPeak)
|
|
|
|
, metrics_right (2, MeterPeak)
|
2013-07-05 06:30:26 -04:00
|
|
|
, cur_max_width (-1)
|
2013-06-23 10:05:52 -04:00
|
|
|
{
|
|
|
|
set_name ("Meter Bridge");
|
|
|
|
|
2013-07-05 00:34:58 -04:00
|
|
|
m_width = default_width;
|
|
|
|
m_height = default_height;
|
|
|
|
m_root_x = 1;
|
|
|
|
m_root_y = 1;
|
|
|
|
|
2013-06-26 09:10:26 -04:00
|
|
|
update_title ();
|
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
set_wmclass (X_("ardour_mixer"), PROGRAM_NAME);
|
|
|
|
|
2013-06-26 03:42:39 -04:00
|
|
|
Gdk::Geometry geom;
|
|
|
|
geom.max_width = 1<<16;
|
2013-07-05 06:30:26 -04:00
|
|
|
geom.max_height = max_height;
|
2013-07-09 20:42:29 -04:00
|
|
|
geom.height_inc = 16;
|
|
|
|
geom.width_inc = 1;
|
|
|
|
set_geometry_hints(*((Gtk::Window*) this), geom, Gdk::HINT_MAX_SIZE | Gdk::HINT_RESIZE_INC);
|
2013-06-26 03:42:39 -04:00
|
|
|
|
2013-07-03 15:50:54 -04:00
|
|
|
set_keep_above (true);
|
|
|
|
set_border_width (0);
|
|
|
|
|
2013-07-05 02:47:23 -04:00
|
|
|
metrics_vpacker_left.pack_start (metrics_left, true, true);
|
|
|
|
metrics_vpacker_left.pack_start (metrics_spacer_left, false, false);
|
|
|
|
metrics_spacer_left.set_size_request(-1, 0);
|
|
|
|
metrics_spacer_left.set_spacing(0);
|
2013-07-02 16:56:35 -04:00
|
|
|
|
2013-07-05 02:47:23 -04:00
|
|
|
metrics_vpacker_right.pack_start (metrics_right, true, true);
|
|
|
|
metrics_vpacker_right.pack_start (metrics_spacer_right, false, false);
|
|
|
|
metrics_spacer_right.set_size_request(-1, 0);
|
|
|
|
metrics_spacer_right.set_spacing(0);
|
2013-07-02 16:56:35 -04:00
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
signal_delete_event().connect (sigc::mem_fun (*this, &Meterbridge::hide_window));
|
|
|
|
signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
|
2013-06-23 10:14:39 -04:00
|
|
|
Route::SyncOrderKeys.connect (*this, invalidator (*this), boost::bind (&Meterbridge::sync_order_keys, this, _1), gui_context());
|
2013-06-23 10:05:52 -04:00
|
|
|
MeterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Meterbridge::remove_strip, this, _1), gui_context());
|
2013-07-23 07:30:23 -04:00
|
|
|
MeterStrip::MetricChanged.connect (*this, invalidator (*this), boost::bind(&Meterbridge::resync_order, this), gui_context());
|
2013-07-23 19:39:16 -04:00
|
|
|
MeterStrip::ConfigurationChanged.connect (*this, invalidator (*this), boost::bind(&Meterbridge::queue_resize, this), gui_context());
|
2013-06-23 10:05:52 -04:00
|
|
|
|
2013-07-05 02:47:23 -04:00
|
|
|
/* work around ScrolledWindowViewport alignment mess Part one */
|
|
|
|
Gtk::HBox * yspc = manage (new Gtk::HBox());
|
|
|
|
yspc->set_size_request(-1, 1);
|
|
|
|
Gtk::VBox * xspc = manage (new Gtk::VBox());
|
|
|
|
xspc->pack_start(meterarea, true, true);
|
|
|
|
xspc->pack_start(*yspc, false, false);
|
|
|
|
yspc->show();
|
|
|
|
xspc->show();
|
|
|
|
|
|
|
|
meterarea.set_spacing(0);
|
|
|
|
scroller.set_shadow_type(Gtk::SHADOW_NONE);
|
|
|
|
scroller.set_border_width(0);
|
|
|
|
scroller.add (*xspc);
|
2013-06-23 10:05:52 -04:00
|
|
|
scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER);
|
2013-07-05 02:47:23 -04:00
|
|
|
|
|
|
|
global_hpacker.pack_start (metrics_vpacker_left, false, false);
|
|
|
|
global_hpacker.pack_start (scroller, true, true);
|
|
|
|
global_hpacker.pack_start (metrics_vpacker_right, false, false);
|
|
|
|
|
|
|
|
global_vpacker.pack_start (global_hpacker, true, true);
|
2013-06-23 10:05:52 -04:00
|
|
|
add (global_vpacker);
|
|
|
|
|
2013-07-05 02:47:23 -04:00
|
|
|
metrics_left.show();
|
|
|
|
metrics_right.show();
|
|
|
|
|
|
|
|
metrics_vpacker_left.show();
|
|
|
|
metrics_spacer_left.show();
|
|
|
|
metrics_vpacker_right.show();
|
|
|
|
metrics_spacer_right.show();
|
|
|
|
|
|
|
|
meterarea.show();
|
2013-06-23 10:05:52 -04:00
|
|
|
global_vpacker.show();
|
2013-07-05 02:47:23 -04:00
|
|
|
global_hpacker.show();
|
2013-06-23 10:05:52 -04:00
|
|
|
scroller.show();
|
2013-07-05 02:47:23 -04:00
|
|
|
|
|
|
|
/* the return of the ScrolledWindowViewport mess:
|
|
|
|
* remove shadow from scrollWindow's viewport
|
|
|
|
* see http://www.mail-archive.com/gtkmm-list@gnome.org/msg03509.html
|
|
|
|
*/
|
|
|
|
Gtk::Viewport* viewport = (Gtk::Viewport*) scroller.get_child();
|
|
|
|
viewport->set_shadow_type(Gtk::SHADOW_NONE);
|
2013-07-05 04:42:58 -04:00
|
|
|
viewport->set_border_width(0);
|
2013-07-05 16:18:04 -04:00
|
|
|
|
|
|
|
UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &Meterbridge::on_theme_changed));
|
|
|
|
ColorsChanged.connect (sigc::mem_fun (*this, &Meterbridge::on_theme_changed));
|
|
|
|
DPIReset.connect (sigc::mem_fun (*this, &Meterbridge::on_theme_changed));
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Meterbridge::~Meterbridge ()
|
|
|
|
{
|
2013-07-23 07:30:23 -04:00
|
|
|
while (_metrics.size() > 0) {
|
|
|
|
delete (_metrics.back());
|
|
|
|
_metrics.pop_back();
|
|
|
|
}
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::show_window ()
|
|
|
|
{
|
|
|
|
present();
|
|
|
|
if (!_visible) {
|
|
|
|
set_window_pos_and_size ();
|
|
|
|
}
|
|
|
|
_visible = true;
|
|
|
|
}
|
|
|
|
|
2013-06-26 09:10:26 -04:00
|
|
|
/* code duplicated from gtk2_ardour/mixer_ui.cc Mixer_UI::update_title() */
|
|
|
|
void
|
|
|
|
Meterbridge::update_title ()
|
|
|
|
{
|
|
|
|
if (_session) {
|
|
|
|
string n;
|
|
|
|
|
|
|
|
if (_session->snap_name() != _session->name()) {
|
|
|
|
n = _session->snap_name ();
|
|
|
|
} else {
|
|
|
|
n = _session->name ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_session->dirty ()) {
|
|
|
|
n = "*" + n;
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowTitle title (n);
|
|
|
|
title += S_("Window|Meterbridge");
|
|
|
|
title += Glib::get_application_name ();
|
|
|
|
set_title (title.get_string());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
WindowTitle title (S_("Window|Meterbridge"));
|
|
|
|
title += Glib::get_application_name ();
|
|
|
|
set_title (title.get_string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
void
|
|
|
|
Meterbridge::set_window_pos_and_size ()
|
|
|
|
{
|
|
|
|
resize (m_width, m_height);
|
2013-07-05 00:34:58 -04:00
|
|
|
if (m_root_x >= 0 && m_root_y >= 0) {
|
|
|
|
move (m_root_x, m_root_y);
|
|
|
|
}
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::get_window_pos_and_size ()
|
|
|
|
{
|
|
|
|
get_position(m_root_x, m_root_y);
|
|
|
|
get_size(m_width, m_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Meterbridge::hide_window (GdkEventAny *ev)
|
|
|
|
{
|
2013-07-05 16:35:26 -04:00
|
|
|
if (!_visible) return 0;
|
2013-06-23 10:05:52 -04:00
|
|
|
get_window_pos_and_size();
|
|
|
|
_visible = false;
|
|
|
|
return just_hide_it(ev, static_cast<Gtk::Window *>(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Meterbridge::on_key_press_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return forward_key_press (ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Meterbridge::on_key_release_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
/* don't forward releases */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-05 14:58:23 -04:00
|
|
|
bool
|
|
|
|
Meterbridge::on_scroll_event (GdkEventScroll* ev)
|
|
|
|
{
|
|
|
|
switch (ev->direction) {
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
scroll_left ();
|
|
|
|
return true;
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
if (ev->state & Keyboard::TertiaryModifier) {
|
|
|
|
scroll_left ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
scroll_right ();
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
if (ev->state & Keyboard::TertiaryModifier) {
|
|
|
|
scroll_right ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::scroll_left ()
|
|
|
|
{
|
2013-07-13 08:58:23 -04:00
|
|
|
if (!scroller.get_hscrollbar()) return;
|
2013-07-05 14:58:23 -04:00
|
|
|
Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
|
|
|
|
/* stupid GTK: can't rely on clamping across versions */
|
|
|
|
scroller.get_hscrollbar()->set_value (max (adj->get_lower(), adj->get_value() - adj->get_step_increment()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::scroll_right ()
|
|
|
|
{
|
2013-07-13 08:58:23 -04:00
|
|
|
if (!scroller.get_hscrollbar()) return;
|
2013-07-05 14:58:23 -04:00
|
|
|
Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
|
|
|
|
/* stupid GTK: can't rely on clamping across versions */
|
|
|
|
scroller.get_hscrollbar()->set_value (min (adj->get_upper(), adj->get_value() + adj->get_step_increment()));
|
|
|
|
}
|
|
|
|
|
2013-07-05 02:47:23 -04:00
|
|
|
void
|
|
|
|
Meterbridge::on_size_request (Gtk::Requisition* r)
|
|
|
|
{
|
2013-07-14 05:34:31 -04:00
|
|
|
meter_clear_pattern_cache(3);
|
2013-07-05 02:47:23 -04:00
|
|
|
Gtk::Window::on_size_request(r);
|
2013-07-05 06:30:26 -04:00
|
|
|
|
|
|
|
Gdk::Geometry geom;
|
2013-07-23 19:39:16 -04:00
|
|
|
Gtk::Requisition mr = meterarea.size_request();
|
2013-07-24 09:26:40 -04:00
|
|
|
|
2013-07-23 19:39:16 -04:00
|
|
|
geom.max_width = mr.width + metrics_left.get_width() + metrics_right.get_width();
|
2013-07-05 06:30:26 -04:00
|
|
|
geom.max_height = max_height;
|
|
|
|
|
2013-07-24 09:26:40 -04:00
|
|
|
const Gtk::Scrollbar * hsc = scroller.get_hscrollbar();
|
|
|
|
Glib::RefPtr<Gdk::Screen> screen = get_screen ();
|
|
|
|
Gdk::Rectangle monitor_rect;
|
|
|
|
screen->get_monitor_geometry (0, monitor_rect);
|
|
|
|
const int scr_w = monitor_rect.get_width() - 44;
|
|
|
|
|
|
|
|
if (cur_max_width < geom.max_width
|
|
|
|
&& cur_max_width < scr_w
|
|
|
|
&& !(scroller.get_hscrollbar_visible() && hsc)) {
|
|
|
|
int h = r->height;
|
|
|
|
*r = Gtk::Requisition();
|
|
|
|
r->width = geom.max_width;
|
|
|
|
r->height = h;
|
|
|
|
}
|
|
|
|
|
2013-07-05 06:30:26 -04:00
|
|
|
if (cur_max_width != geom.max_width) {
|
|
|
|
cur_max_width = geom.max_width;
|
2013-07-09 20:42:29 -04:00
|
|
|
geom.height_inc = 16;
|
|
|
|
geom.width_inc = 1;
|
|
|
|
set_geometry_hints(*((Gtk::Window*) this), geom, Gdk::HINT_MAX_SIZE | Gdk::HINT_RESIZE_INC);
|
2013-07-05 06:30:26 -04:00
|
|
|
}
|
2013-07-05 02:47:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::on_size_allocate (Gtk::Allocation& a)
|
|
|
|
{
|
|
|
|
const Gtk::Scrollbar * hsc = scroller.get_hscrollbar();
|
|
|
|
|
|
|
|
if (scroller.get_hscrollbar_visible() && hsc) {
|
2013-07-05 04:42:58 -04:00
|
|
|
gint scrollbar_spacing;
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (scroller.gobj()),
|
|
|
|
"scrollbar-spacing", &scrollbar_spacing, NULL);
|
|
|
|
const int h = hsc->get_height() + scrollbar_spacing + 1;
|
2013-07-05 02:47:23 -04:00
|
|
|
metrics_spacer_left.set_size_request(-1, h);
|
|
|
|
metrics_spacer_right.set_size_request(-1, h);
|
|
|
|
} else {
|
|
|
|
metrics_spacer_left.set_size_request(-1, 0);
|
|
|
|
metrics_spacer_right.set_size_request(-1, 0);
|
|
|
|
}
|
|
|
|
Gtk::Window::on_size_allocate(a);
|
|
|
|
}
|
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
void
|
|
|
|
Meterbridge::set_session (Session* s)
|
|
|
|
{
|
|
|
|
SessionHandlePtr::set_session (s);
|
|
|
|
|
|
|
|
if (!_session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-08 17:56:03 -04:00
|
|
|
metrics_left.set_session(s);
|
|
|
|
metrics_right.set_session(s);
|
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
XMLNode* node = _session->instant_xml(X_("Meterbridge"));
|
|
|
|
if (node) {
|
|
|
|
set_state (*node);
|
|
|
|
}
|
|
|
|
|
2013-06-26 09:10:26 -04:00
|
|
|
update_title ();
|
2013-07-05 14:55:55 -04:00
|
|
|
_show_busses = _session->config.get_show_busses_on_meterbridge();
|
|
|
|
_show_master = _session->config.get_show_master_on_meterbridge();
|
|
|
|
_show_midi = _session->config.get_show_midi_on_meterbridge();
|
2013-06-26 09:10:26 -04:00
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
SignalOrderRouteSorter sorter;
|
|
|
|
boost::shared_ptr<RouteList> routes = _session->get_routes();
|
|
|
|
|
|
|
|
RouteList copy(*routes);
|
|
|
|
copy.sort(sorter);
|
|
|
|
add_strips(copy);
|
|
|
|
|
|
|
|
_session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::add_strips, this, _1), gui_context());
|
2013-06-26 09:10:26 -04:00
|
|
|
_session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::update_title, this), gui_context());
|
|
|
|
_session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Meterbridge::update_title, this), gui_context());
|
2013-06-28 16:48:43 -04:00
|
|
|
_session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&Meterbridge::parameter_changed, this, _1), gui_context());
|
2013-07-05 16:18:04 -04:00
|
|
|
Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&Meterbridge::parameter_changed, this, _1), gui_context());
|
2013-06-23 10:05:52 -04:00
|
|
|
|
|
|
|
if (_visible) {
|
|
|
|
show_window();
|
|
|
|
ActionManager::check_toggleaction ("<Actions>/Common/toggle-meterbridge");
|
|
|
|
}
|
|
|
|
start_updating ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::session_going_away ()
|
|
|
|
{
|
|
|
|
ENSURE_GUI_THREAD (*this, &Meterbridge::session_going_away);
|
|
|
|
|
2013-07-06 16:48:43 -04:00
|
|
|
for (list<MeterBridgeStrip>::iterator i = strips.begin(); i != strips.end(); ++i) {
|
|
|
|
delete ((*i).s);
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
strips.clear ();
|
|
|
|
stop_updating ();
|
|
|
|
|
|
|
|
SessionHandlePtr::session_going_away ();
|
|
|
|
|
|
|
|
_session = 0;
|
2013-06-26 09:10:26 -04:00
|
|
|
update_title ();
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Meterbridge::set_state (const XMLNode& node)
|
|
|
|
{
|
|
|
|
const XMLProperty* prop;
|
|
|
|
XMLNode* geometry;
|
|
|
|
|
|
|
|
m_width = default_width;
|
|
|
|
m_height = default_height;
|
|
|
|
m_root_x = 1;
|
|
|
|
m_root_y = 1;
|
|
|
|
|
|
|
|
if ((geometry = find_named_node (node, "geometry")) != 0) {
|
|
|
|
|
|
|
|
XMLProperty* prop;
|
|
|
|
|
|
|
|
if ((prop = geometry->property("x_size")) == 0) {
|
|
|
|
prop = geometry->property ("x-size");
|
|
|
|
}
|
|
|
|
if (prop) {
|
|
|
|
m_width = atoi(prop->value());
|
|
|
|
}
|
|
|
|
if ((prop = geometry->property("y_size")) == 0) {
|
|
|
|
prop = geometry->property ("y-size");
|
|
|
|
}
|
|
|
|
if (prop) {
|
|
|
|
m_height = atoi(prop->value());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((prop = geometry->property ("x_pos")) == 0) {
|
|
|
|
prop = geometry->property ("x-pos");
|
|
|
|
}
|
|
|
|
if (prop) {
|
|
|
|
m_root_x = atoi (prop->value());
|
|
|
|
|
|
|
|
}
|
|
|
|
if ((prop = geometry->property ("y_pos")) == 0) {
|
|
|
|
prop = geometry->property ("y-pos");
|
|
|
|
}
|
|
|
|
if (prop) {
|
|
|
|
m_root_y = atoi (prop->value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_window_pos_and_size ();
|
|
|
|
|
|
|
|
if ((prop = node.property ("show-meterbridge"))) {
|
|
|
|
if (string_is_affirmative (prop->value())) {
|
|
|
|
_visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLNode&
|
|
|
|
Meterbridge::get_state (void)
|
|
|
|
{
|
2013-07-09 13:48:15 -04:00
|
|
|
char buf[32];
|
2013-06-23 10:05:52 -04:00
|
|
|
XMLNode* node = new XMLNode ("Meterbridge");
|
|
|
|
|
2013-07-09 13:48:15 -04:00
|
|
|
if (is_realized() && _visible) {
|
2013-06-23 10:05:52 -04:00
|
|
|
get_window_pos_and_size ();
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:48:15 -04:00
|
|
|
XMLNode* geometry = new XMLNode ("geometry");
|
|
|
|
snprintf(buf, sizeof(buf), "%d", m_width);
|
|
|
|
geometry->add_property(X_("x_size"), string(buf));
|
|
|
|
snprintf(buf, sizeof(buf), "%d", m_height);
|
|
|
|
geometry->add_property(X_("y_size"), string(buf));
|
|
|
|
snprintf(buf, sizeof(buf), "%d", m_root_x);
|
|
|
|
geometry->add_property(X_("x_pos"), string(buf));
|
|
|
|
snprintf(buf, sizeof(buf), "%d", m_root_y);
|
|
|
|
geometry->add_property(X_("y_pos"), string(buf));
|
|
|
|
node->add_child_nocopy (*geometry);
|
|
|
|
|
2013-06-23 10:05:52 -04:00
|
|
|
node->add_property ("show-meterbridge", _visible ? "yes" : "no");
|
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gint
|
|
|
|
Meterbridge::start_updating ()
|
|
|
|
{
|
|
|
|
fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &Meterbridge::fast_update_strips));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
Meterbridge::stop_updating ()
|
|
|
|
{
|
|
|
|
fast_screen_update_connection.disconnect();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::fast_update_strips ()
|
|
|
|
{
|
|
|
|
if (!is_mapped () || !_session) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-06 16:48:43 -04:00
|
|
|
for (list<MeterBridgeStrip>::iterator i = strips.begin(); i != strips.end(); ++i) {
|
|
|
|
if (!(*i).visible) continue;
|
|
|
|
(*i).s->fast_update ();
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::add_strips (RouteList& routes)
|
|
|
|
{
|
|
|
|
MeterStrip* strip;
|
|
|
|
for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
|
|
|
|
boost::shared_ptr<Route> route = (*x);
|
|
|
|
if (route->is_auditioner()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (route->is_monitor()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-02 16:56:35 -04:00
|
|
|
strip = new MeterStrip (_session, route);
|
2013-07-06 16:48:43 -04:00
|
|
|
strips.push_back (MeterBridgeStrip(strip));
|
2013-07-05 14:55:55 -04:00
|
|
|
route->active_changed.connect (*this, invalidator (*this), boost::bind (&Meterbridge::resync_order, this), gui_context ());
|
2013-06-23 10:05:52 -04:00
|
|
|
|
2013-07-05 02:47:23 -04:00
|
|
|
meterarea.pack_start (*strip, false, false);
|
2013-06-23 10:05:52 -04:00
|
|
|
strip->show();
|
|
|
|
}
|
2013-06-23 10:14:39 -04:00
|
|
|
|
2013-07-06 16:48:43 -04:00
|
|
|
resync_order();
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::remove_strip (MeterStrip* strip)
|
|
|
|
{
|
|
|
|
if (_session && _session->deletion_in_progress()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-06 16:48:43 -04:00
|
|
|
list<MeterBridgeStrip>::iterator i;
|
|
|
|
for (list<MeterBridgeStrip>::iterator i = strips.begin(); i != strips.end(); ++i) {
|
|
|
|
if ( (*i).s == strip) {
|
|
|
|
strips.erase (i);
|
|
|
|
break;
|
|
|
|
}
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-06-23 10:14:39 -04:00
|
|
|
Meterbridge::sync_order_keys (RouteSortOrderKey src)
|
2013-06-23 10:05:52 -04:00
|
|
|
{
|
2013-07-07 05:58:27 -04:00
|
|
|
Glib::Threads::Mutex::Lock lm (_resync_mutex);
|
|
|
|
|
2013-06-23 10:14:39 -04:00
|
|
|
MeterOrderRouteSorter sorter;
|
2013-07-07 05:58:27 -04:00
|
|
|
strips.sort(sorter);
|
2013-06-23 10:14:39 -04:00
|
|
|
|
|
|
|
int pos = 0;
|
2013-07-08 10:24:17 -04:00
|
|
|
int vis = 0;
|
2013-07-27 21:31:34 -04:00
|
|
|
MeterStrip * last = 0;
|
2013-07-02 16:56:35 -04:00
|
|
|
|
2013-07-23 07:30:23 -04:00
|
|
|
unsigned int metrics = 0;
|
|
|
|
MeterType lmt = MeterPeak;
|
|
|
|
bool have_midi = false;
|
|
|
|
metrics_left.set_metric_mode(1, lmt);
|
|
|
|
|
2013-07-07 05:58:27 -04:00
|
|
|
for (list<MeterBridgeStrip>::iterator i = strips.begin(); i != strips.end(); ++i) {
|
2013-06-28 16:48:43 -04:00
|
|
|
|
2013-07-06 16:48:43 -04:00
|
|
|
if (! (*i).s->route()->active()) {
|
|
|
|
(*i).s->hide();
|
|
|
|
(*i).visible = false;
|
2013-06-28 15:00:17 -04:00
|
|
|
}
|
2013-07-06 16:48:43 -04:00
|
|
|
else if ((*i).s->route()->is_master()) {
|
2013-07-05 14:55:55 -04:00
|
|
|
if (_show_master) {
|
2013-07-06 16:48:43 -04:00
|
|
|
(*i).s->show();
|
|
|
|
(*i).visible = true;
|
2013-07-08 10:24:17 -04:00
|
|
|
vis++;
|
2013-07-05 14:55:55 -04:00
|
|
|
} else {
|
2013-07-06 16:48:43 -04:00
|
|
|
(*i).s->hide();
|
|
|
|
(*i).visible = false;
|
2013-07-05 14:55:55 -04:00
|
|
|
}
|
2013-06-28 16:48:43 -04:00
|
|
|
}
|
2013-07-06 16:48:43 -04:00
|
|
|
else if (boost::dynamic_pointer_cast<AudioTrack>((*i).s->route()) == 0
|
|
|
|
&& boost::dynamic_pointer_cast<MidiTrack>((*i).s->route()) == 0
|
2013-06-28 16:48:43 -04:00
|
|
|
) {
|
|
|
|
/* non-master bus */
|
|
|
|
if (_show_busses) {
|
2013-07-06 16:48:43 -04:00
|
|
|
(*i).s->show();
|
|
|
|
(*i).visible = true;
|
2013-07-08 10:24:17 -04:00
|
|
|
vis++;
|
2013-06-28 16:48:43 -04:00
|
|
|
} else {
|
2013-07-06 16:48:43 -04:00
|
|
|
(*i).s->hide();
|
|
|
|
(*i).visible = false;
|
2013-06-28 16:48:43 -04:00
|
|
|
}
|
|
|
|
}
|
2013-07-06 16:48:43 -04:00
|
|
|
else if (boost::dynamic_pointer_cast<MidiTrack>((*i).s->route())) {
|
2013-07-05 14:55:55 -04:00
|
|
|
if (_show_midi) {
|
2013-07-06 16:48:43 -04:00
|
|
|
(*i).s->show();
|
|
|
|
(*i).visible = true;
|
2013-07-08 10:24:17 -04:00
|
|
|
vis++;
|
2013-07-05 14:55:55 -04:00
|
|
|
} else {
|
2013-07-06 16:48:43 -04:00
|
|
|
(*i).s->hide();
|
|
|
|
(*i).visible = false;
|
2013-07-05 14:55:55 -04:00
|
|
|
}
|
|
|
|
}
|
2013-06-28 16:48:43 -04:00
|
|
|
else {
|
2013-07-06 16:48:43 -04:00
|
|
|
(*i).s->show();
|
|
|
|
(*i).visible = true;
|
2013-07-08 10:24:17 -04:00
|
|
|
vis++;
|
2013-06-28 16:48:43 -04:00
|
|
|
}
|
2013-07-23 07:30:23 -04:00
|
|
|
|
2013-07-27 21:31:34 -04:00
|
|
|
(*i).s->set_tick_bar(0);
|
|
|
|
|
2013-07-23 07:30:23 -04:00
|
|
|
MeterType nmt = (*i).s->meter_type();
|
|
|
|
if (nmt == MeterKrms) nmt = MeterPeak; // identical metrics
|
2013-07-27 21:31:34 -04:00
|
|
|
if (pos == 0) {
|
|
|
|
(*i).s->set_tick_bar(1);
|
|
|
|
}
|
2013-07-23 07:30:23 -04:00
|
|
|
|
|
|
|
if ((*i).visible && nmt != lmt && pos == 0) {
|
|
|
|
lmt = nmt;
|
|
|
|
metrics_left.set_metric_mode(1, lmt);
|
|
|
|
} else if ((*i).visible && nmt != lmt) {
|
|
|
|
|
2013-07-27 21:31:34 -04:00
|
|
|
if (last) {
|
|
|
|
last->set_tick_bar(last->get_tick_bar() | 2);
|
|
|
|
}
|
|
|
|
(*i).s->set_tick_bar((*i).s->get_tick_bar() | 1);
|
|
|
|
|
2013-07-23 07:30:23 -04:00
|
|
|
if (_metrics.size() <= metrics) {
|
|
|
|
_metrics.push_back(new MeterStrip(have_midi ? 2 : 3, lmt));
|
|
|
|
meterarea.pack_start (*_metrics[metrics], false, false);
|
|
|
|
_metrics[metrics]->set_session(_session);
|
|
|
|
_metrics[metrics]->show();
|
|
|
|
} else {
|
|
|
|
_metrics[metrics]->set_metric_mode(have_midi ? 2 : 3, lmt);
|
|
|
|
}
|
|
|
|
meterarea.reorder_child(*_metrics[metrics], pos++);
|
|
|
|
metrics++;
|
|
|
|
|
|
|
|
lmt = nmt;
|
|
|
|
|
|
|
|
if (_metrics.size() <= metrics) {
|
|
|
|
_metrics.push_back(new MeterStrip(1, lmt));
|
|
|
|
meterarea.pack_start (*_metrics[metrics], false, false);
|
|
|
|
_metrics[metrics]->set_session(_session);
|
|
|
|
_metrics[metrics]->show();
|
|
|
|
} else {
|
|
|
|
_metrics[metrics]->set_metric_mode(1, lmt);
|
|
|
|
}
|
|
|
|
meterarea.reorder_child(*_metrics[metrics], pos++);
|
|
|
|
metrics++;
|
|
|
|
have_midi = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*i).visible && (*i).s->has_midi()) {
|
|
|
|
have_midi = true;
|
|
|
|
}
|
|
|
|
|
2013-07-06 16:48:43 -04:00
|
|
|
meterarea.reorder_child(*((*i).s), pos++);
|
2013-07-27 21:31:34 -04:00
|
|
|
if ((*i).visible) {
|
|
|
|
last = (*i).s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (last) {
|
|
|
|
last->set_tick_bar(last->get_tick_bar() | 2);
|
2013-06-23 10:14:39 -04:00
|
|
|
}
|
2013-07-23 07:30:23 -04:00
|
|
|
|
|
|
|
metrics_right.set_metric_mode(have_midi ? 2 : 3, lmt);
|
|
|
|
|
|
|
|
while (_metrics.size() > metrics) {
|
|
|
|
meterarea.remove(*_metrics.back());
|
|
|
|
delete (_metrics.back());
|
|
|
|
_metrics.pop_back();
|
|
|
|
}
|
2013-07-24 05:57:11 -04:00
|
|
|
queue_resize();
|
2013-06-23 10:05:52 -04:00
|
|
|
}
|
2013-06-28 16:48:43 -04:00
|
|
|
|
2013-07-05 14:55:55 -04:00
|
|
|
void
|
2013-07-06 16:48:43 -04:00
|
|
|
Meterbridge::resync_order()
|
2013-07-05 14:55:55 -04:00
|
|
|
{
|
|
|
|
sync_order_keys(MixerSort);
|
|
|
|
}
|
|
|
|
|
2013-06-28 16:48:43 -04:00
|
|
|
void
|
|
|
|
Meterbridge::parameter_changed (std::string const & p)
|
|
|
|
{
|
2013-07-05 14:55:55 -04:00
|
|
|
if (p == "show-busses-on-meterbridge") {
|
|
|
|
_show_busses = _session->config.get_show_busses_on_meterbridge();
|
2013-07-06 16:48:43 -04:00
|
|
|
resync_order();
|
2013-07-05 14:55:55 -04:00
|
|
|
}
|
|
|
|
else if (p == "show-master-on-meterbridge") {
|
|
|
|
_show_master = _session->config.get_show_master_on_meterbridge();
|
2013-07-06 16:48:43 -04:00
|
|
|
resync_order();
|
2013-07-05 14:55:55 -04:00
|
|
|
}
|
|
|
|
else if (p == "show-midi-on-meterbridge") {
|
|
|
|
_show_midi = _session->config.get_show_midi_on_meterbridge();
|
2013-07-06 16:48:43 -04:00
|
|
|
resync_order();
|
2013-06-28 16:48:43 -04:00
|
|
|
}
|
2013-07-05 16:18:04 -04:00
|
|
|
else if (p == "meter-line-up-level") {
|
|
|
|
meter_clear_pattern_cache();
|
|
|
|
}
|
2013-07-08 17:56:03 -04:00
|
|
|
else if (p == "show-rec-on-meterbridge") {
|
|
|
|
scroller.queue_resize();
|
|
|
|
}
|
|
|
|
else if (p == "show-mute-on-meterbridge") {
|
|
|
|
scroller.queue_resize();
|
|
|
|
}
|
|
|
|
else if (p == "show-solo-on-meterbridge") {
|
|
|
|
scroller.queue_resize();
|
|
|
|
}
|
2013-07-08 21:22:13 -04:00
|
|
|
else if (p == "show-name-on-meterbridge") {
|
|
|
|
scroller.queue_resize();
|
|
|
|
}
|
2013-07-05 16:18:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Meterbridge::on_theme_changed ()
|
|
|
|
{
|
|
|
|
meter_clear_pattern_cache();
|
2013-06-28 16:48:43 -04:00
|
|
|
}
|