2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#include <ardour/io.h>
|
|
|
|
#include <ardour/dB.h>
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
#include <gtkmm2ext/stop_signal.h>
|
|
|
|
#include <gtkmm2ext/barcontroller.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <midi++/manager.h>
|
|
|
|
#include <pbd/fastlog.h>
|
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "panner_ui.h"
|
|
|
|
#include "panner2d.h"
|
|
|
|
#include "utils.h"
|
2006-12-20 16:03:11 -05:00
|
|
|
#include "panner.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "gui_thread.h"
|
|
|
|
|
|
|
|
#include <ardour/session.h>
|
|
|
|
#include <ardour/panner.h>
|
2006-05-19 13:29:05 -04:00
|
|
|
#include <ardour/route.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace Gtkmm2ext;
|
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
|
|
|
|
2006-12-20 21:52:27 -05:00
|
|
|
const int PannerUI::pan_bar_height = 30;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
PannerUI::PannerUI (boost::shared_ptr<IO> io, Session& s)
|
2005-09-25 14:42:24 -04:00
|
|
|
: _io (io),
|
|
|
|
_session (s),
|
2005-11-12 17:07:07 -05:00
|
|
|
hAdjustment(0.0, 0.0, 0.0),
|
|
|
|
vAdjustment(0.0, 0.0, 0.0),
|
|
|
|
panning_viewport(hAdjustment, vAdjustment),
|
2005-10-29 14:58:47 -04:00
|
|
|
panning_up_arrow (Gtk::ARROW_UP, Gtk::SHADOW_OUT),
|
|
|
|
panning_down_arrow (Gtk::ARROW_DOWN, Gtk::SHADOW_OUT),
|
2006-05-19 13:29:05 -04:00
|
|
|
panning_link_button (_("link")),
|
|
|
|
pan_automation_style_button (""),
|
|
|
|
pan_automation_state_button ("")
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ignore_toggle = false;
|
|
|
|
pan_menu = 0;
|
|
|
|
in_pan_update = false;
|
|
|
|
|
2006-05-19 13:29:05 -04:00
|
|
|
pan_automation_style_button.set_name ("MixerAutomationModeButton");
|
|
|
|
pan_automation_state_button.set_name ("MixerAutomationPlaybackButton");
|
|
|
|
|
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("Pan automation mode"));
|
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("Pan automation type"));
|
|
|
|
|
2006-06-02 08:48:35 -04:00
|
|
|
//set_size_request_to_display_given_text (pan_automation_state_button, X_("O"), 2, 2);
|
|
|
|
//set_size_request_to_display_given_text (pan_automation_style_button, X_("0"), 2, 2);
|
2006-05-21 06:11:59 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
pan_bar_packer.set_size_request (-1, 61);
|
2006-12-30 01:37:00 -05:00
|
|
|
panning_viewport.set_size_request (64, 61);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
panning_viewport.set_name (X_("BaseFrame"));
|
|
|
|
|
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip (panning_link_button,
|
|
|
|
_("panning link control"));
|
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip (panning_link_direction_button,
|
|
|
|
_("panning link direction"));
|
|
|
|
|
2006-05-19 13:29:05 -04:00
|
|
|
pan_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
|
|
|
|
pan_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
|
|
|
|
|
|
|
|
using namespace Menu_Helpers;
|
2006-05-22 07:12:26 -04:00
|
|
|
pan_astate_menu.items().push_back (MenuElem (_("Off"),
|
2006-07-27 12:52:14 -04:00
|
|
|
bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Off)));
|
2006-05-19 13:29:05 -04:00
|
|
|
pan_astate_menu.items().push_back (MenuElem (_("Play"),
|
2006-07-27 12:52:14 -04:00
|
|
|
bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Play)));
|
2006-05-19 13:29:05 -04:00
|
|
|
pan_astate_menu.items().push_back (MenuElem (_("Write"),
|
2006-07-27 12:52:14 -04:00
|
|
|
bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Write)));
|
2006-05-19 13:29:05 -04:00
|
|
|
pan_astate_menu.items().push_back (MenuElem (_("Touch"),
|
2006-07-27 12:52:14 -04:00
|
|
|
bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Touch)));
|
2006-05-19 13:29:05 -04:00
|
|
|
|
|
|
|
pan_astyle_menu.items().push_back (MenuElem (_("Trim")));
|
|
|
|
pan_astyle_menu.items().push_back (MenuElem (_("Abs")));
|
|
|
|
|
|
|
|
pan_astate_menu.set_name ("ArdourContextMenu");
|
|
|
|
pan_astyle_menu.set_name ("ArdourContextMenu");
|
|
|
|
|
|
|
|
pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &PannerUI::pan_automation_style_button_event), false);
|
|
|
|
pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &PannerUI::pan_automation_state_button_event), false);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
panning_link_button.set_name (X_("PanningLinkButton"));
|
|
|
|
panning_link_direction_button.set_name (X_("PanningLinkDirectionButton"));
|
|
|
|
|
2006-05-21 09:21:25 -04:00
|
|
|
panning_link_box.pack_start (panning_link_button, true, true);
|
|
|
|
panning_link_box.pack_start (panning_link_direction_button, true, true);
|
2006-06-02 08:48:35 -04:00
|
|
|
panning_link_box.pack_start (pan_automation_state_button, true, true);
|
2006-05-21 09:21:25 -04:00
|
|
|
|
2006-06-02 08:48:35 -04:00
|
|
|
/* the pixmap will be reset at some point, but the key thing is that
|
|
|
|
we need a pixmap in the button just to get started.
|
|
|
|
*/
|
2006-03-12 10:46:29 -05:00
|
|
|
panning_link_direction_button.add (*(manage (new Image (get_xpm("forwardblarrow.xpm")))));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
panning_link_direction_button.signal_clicked().connect
|
2005-09-25 17:19:23 -04:00
|
|
|
(mem_fun(*this, &PannerUI::panning_link_direction_clicked));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-26 14:24:59 -04:00
|
|
|
panning_link_button.signal_button_press_event().connect
|
2006-05-23 15:54:52 -04:00
|
|
|
(mem_fun(*this, &PannerUI::panning_link_button_press), false);
|
2005-09-26 14:24:59 -04:00
|
|
|
panning_link_button.signal_button_release_event().connect
|
2006-05-23 15:54:52 -04:00
|
|
|
(mem_fun(*this, &PannerUI::panning_link_button_release), false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
panning_up.set_border_width (3);
|
|
|
|
panning_down.set_border_width (3);
|
|
|
|
panning_up.add (panning_up_arrow);
|
|
|
|
panning_down.add (panning_down_arrow);
|
|
|
|
panning_up.set_name (X_("PanScrollerBase"));
|
|
|
|
panning_down.set_name (X_("PanScrollerBase"));
|
|
|
|
panning_up_arrow.set_name (X_("PanScrollerArrow"));
|
|
|
|
panning_down_arrow.set_name (X_("PanScrollerArrow"));
|
|
|
|
|
2006-12-30 01:37:00 -05:00
|
|
|
pan_vbox.set_spacing (2);
|
2005-12-18 08:19:02 -05:00
|
|
|
pan_vbox.pack_start (panning_viewport, Gtk::PACK_SHRINK);
|
2006-06-02 08:48:35 -04:00
|
|
|
pan_vbox.pack_start (panning_link_box, Gtk::PACK_SHRINK);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
pack_start (pan_vbox, true, false);
|
|
|
|
|
|
|
|
panner = 0;
|
|
|
|
|
2006-05-24 18:43:15 -04:00
|
|
|
set_width(Narrow);
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner().Changed.connect (mem_fun(*this, &PannerUI::panner_changed));
|
|
|
|
_io->panner().LinkStateChanged.connect (mem_fun(*this, &PannerUI::update_pan_linkage));
|
|
|
|
_io->panner().StateChanged.connect (mem_fun(*this, &PannerUI::update_pan_state));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
pan_changed (0);
|
|
|
|
update_pan_sensitive ();
|
|
|
|
update_pan_linkage ();
|
2006-05-19 13:29:05 -04:00
|
|
|
pan_automation_state_changed ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-05-23 15:54:52 -04:00
|
|
|
bool
|
2005-09-25 14:42:24 -04:00
|
|
|
PannerUI::panning_link_button_press (GdkEventButton* ev)
|
|
|
|
{
|
2006-05-23 15:54:52 -04:00
|
|
|
cerr << "link press\n";
|
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-05-23 15:54:52 -04:00
|
|
|
bool
|
2005-09-25 14:42:24 -04:00
|
|
|
PannerUI::panning_link_button_release (GdkEventButton* ev)
|
|
|
|
{
|
2006-05-23 15:54:52 -04:00
|
|
|
cerr << "link release\n";
|
2005-09-25 14:42:24 -04:00
|
|
|
if (!ignore_toggle) {
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner().set_linked (!_io->panner().linked());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-05-23 15:54:52 -04:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::panning_link_direction_clicked()
|
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
switch (_io->panner().link_direction()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case Panner::SameDirection:
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner().set_link_direction (Panner::OppositeDirection);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner().set_link_direction (Panner::SameDirection);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::update_pan_linkage ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::update_pan_linkage));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
bool x = _io->panner().linked();
|
2005-09-25 14:42:24 -04:00
|
|
|
bool bx = panning_link_button.get_active();
|
|
|
|
|
|
|
|
if (x != bx) {
|
|
|
|
|
|
|
|
ignore_toggle = true;
|
|
|
|
panning_link_button.set_active (x);
|
|
|
|
ignore_toggle = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
panning_link_direction_button.set_sensitive (x);
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
switch (_io->panner().link_direction()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case Panner::SameDirection:
|
2006-03-12 10:46:29 -05:00
|
|
|
panning_link_direction_button.set_image (*(manage (new Image (get_xpm ("forwardblarrow.xpm")))));
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
2006-03-12 10:46:29 -05:00
|
|
|
panning_link_direction_button.set_image (*(manage (new Image (get_xpm("revdblarrow.xpm")))));
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::set_width (Width w)
|
|
|
|
{
|
|
|
|
switch (w) {
|
|
|
|
case Wide:
|
2006-12-30 01:37:00 -05:00
|
|
|
panning_viewport.set_size_request (64, 61);
|
2005-09-25 14:42:24 -04:00
|
|
|
if (panner) {
|
2006-12-30 01:37:00 -05:00
|
|
|
panner->set_size_request (63, 61);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-12-20 16:03:11 -05:00
|
|
|
for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
|
2006-12-30 01:37:00 -05:00
|
|
|
(*i)->set_size_request (63, pan_bar_height);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-04-22 12:49:51 -04:00
|
|
|
panning_link_button.set_label (_("link"));
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case Narrow:
|
2006-12-30 01:37:00 -05:00
|
|
|
panning_viewport.set_size_request (34, 61);
|
2005-09-25 14:42:24 -04:00
|
|
|
if (panner) {
|
2006-12-30 01:37:00 -05:00
|
|
|
panner->set_size_request (33, 61);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-12-20 16:03:11 -05:00
|
|
|
for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
|
2006-12-30 01:37:00 -05:00
|
|
|
(*i)->set_size_request (33, pan_bar_height);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-04-22 12:49:51 -04:00
|
|
|
panning_link_button.set_label (_("L"));
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
_width = w;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PannerUI::~PannerUI ()
|
|
|
|
{
|
|
|
|
for (vector<Adjustment*>::iterator i = pan_adjustments.begin(); i != pan_adjustments.end(); ++i) {
|
|
|
|
delete (*i);
|
|
|
|
}
|
|
|
|
|
2006-12-20 16:03:11 -05:00
|
|
|
for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
delete (*i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (panner) {
|
|
|
|
delete panner;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pan_menu) {
|
|
|
|
delete pan_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::panner_changed ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD (mem_fun(*this, &PannerUI::panner_changed));
|
2005-09-25 14:42:24 -04:00
|
|
|
setup_pan ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::update_pan_state ()
|
|
|
|
{
|
|
|
|
/* currently nothing to do */
|
2005-09-25 17:19:23 -04:00
|
|
|
// ENSURE_GUI_THREAD (mem_fun(*this, &PannerUI::update_panner_state));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::setup_pan ()
|
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
uint32_t nouts = _io->n_outputs ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (nouts == 0 || nouts == 1) {
|
|
|
|
|
|
|
|
while (!pan_adjustments.empty()) {
|
|
|
|
delete pan_bars.back();
|
|
|
|
pan_bars.pop_back ();
|
|
|
|
delete pan_adjustments.back();
|
|
|
|
pan_adjustments.pop_back ();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (nouts == 2) {
|
|
|
|
|
|
|
|
vector<Adjustment*>::size_type asz;
|
2006-07-27 12:52:14 -04:00
|
|
|
uint32_t npans = _io->panner().size();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
while (!pan_adjustments.empty()) {
|
|
|
|
delete pan_bars.back();
|
|
|
|
pan_bars.pop_back ();
|
|
|
|
delete pan_adjustments.back();
|
|
|
|
pan_adjustments.pop_back ();
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((asz = pan_adjustments.size()) < npans) {
|
|
|
|
|
2006-12-30 01:37:00 -05:00
|
|
|
float x, rx;
|
2006-12-20 16:03:11 -05:00
|
|
|
PannerBar* bc;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-12-30 01:37:00 -05:00
|
|
|
/* initialize adjustment with 0.0 (L) or 1.0 (R) for the first and second panners,
|
|
|
|
which serves as a default, otherwise use current value */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-12-30 01:37:00 -05:00
|
|
|
_io->panner()[asz]->get_position (rx);
|
|
|
|
|
|
|
|
if (npans == 1) {
|
|
|
|
x = 0.5;
|
|
|
|
} else if (asz == 0) {
|
|
|
|
x = 0.0;
|
|
|
|
} else if (asz == 1) {
|
|
|
|
x = 1.0;
|
|
|
|
} else {
|
|
|
|
x = rx;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
pan_adjustments.push_back (new Adjustment (x, 0, 1.0, 0.05, 0.1));
|
2006-12-30 01:37:00 -05:00
|
|
|
bc = new PannerBar (*pan_adjustments[asz], _io->panner()[asz]->control());
|
|
|
|
|
|
|
|
/* now set adjustment with current value of panner, then connect the signals */
|
|
|
|
pan_adjustments.back()->set_value(rx);
|
2005-10-09 01:03:29 -04:00
|
|
|
pan_adjustments.back()->signal_value_changed().connect (bind (mem_fun(*this, &PannerUI::pan_adjustment_changed), (uint32_t) asz));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner()[asz]->Changed.connect (bind (mem_fun(*this, &PannerUI::pan_value_changed), (uint32_t) asz));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
bc->set_name ("PanSlider");
|
2005-10-09 01:03:29 -04:00
|
|
|
bc->set_shadow_type (Gtk::SHADOW_NONE);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
bc->StartGesture.connect (bind (mem_fun (*_io, &IO::start_pan_touch), (uint32_t) asz));
|
|
|
|
bc->StopGesture.connect (bind (mem_fun (*_io, &IO::end_pan_touch), (uint32_t) asz));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
char buf[64];
|
2006-08-01 15:17:49 -04:00
|
|
|
snprintf (buf, sizeof (buf), _("panner for channel %zu"), asz + 1);
|
2005-09-25 14:42:24 -04:00
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip (bc->event_widget(), buf);
|
|
|
|
|
2005-09-26 14:24:59 -04:00
|
|
|
bc->event_widget().signal_button_release_event().connect
|
2005-09-25 17:19:23 -04:00
|
|
|
(bind (mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) asz));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
pan_bars.push_back (bc);
|
|
|
|
switch (_width) {
|
|
|
|
case Wide:
|
2006-12-30 01:37:00 -05:00
|
|
|
bc->set_size_request (63, pan_bar_height);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case Narrow:
|
2006-12-30 01:37:00 -05:00
|
|
|
bc->set_size_request (33, pan_bar_height);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-12-20 21:52:27 -05:00
|
|
|
pan_bar_packer.pack_start (*bc, false, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now that we actually have the pan bars,
|
|
|
|
set their sensitivity based on current
|
|
|
|
automation state.
|
|
|
|
*/
|
|
|
|
|
|
|
|
update_pan_sensitive ();
|
|
|
|
|
|
|
|
panning_viewport.remove ();
|
|
|
|
panning_viewport.add (pan_bar_packer);
|
|
|
|
panning_viewport.show_all ();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
int w = 0;
|
|
|
|
|
|
|
|
switch (_width) {
|
|
|
|
case Wide:
|
2006-12-30 01:37:00 -05:00
|
|
|
w = 63;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
case Narrow:
|
2006-12-30 01:37:00 -05:00
|
|
|
w = 33;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (panner == 0) {
|
2006-07-27 12:52:14 -04:00
|
|
|
panner = new Panner2d (_io->panner(), w, 61);
|
2005-09-25 14:42:24 -04:00
|
|
|
panner->set_name ("MixerPanZone");
|
|
|
|
panner->show ();
|
|
|
|
}
|
|
|
|
|
|
|
|
update_pan_sensitive ();
|
2006-07-27 12:52:14 -04:00
|
|
|
panner->reset (_io->n_inputs());
|
2005-09-25 16:33:00 -04:00
|
|
|
panner->set_size_request (w, 61);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* and finally, add it to the panner frame */
|
|
|
|
|
|
|
|
panning_viewport.remove ();
|
|
|
|
panning_viewport.add (*panner);
|
|
|
|
panning_viewport.show_all ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 15:54:52 -04:00
|
|
|
bool
|
2005-09-25 14:42:24 -04:00
|
|
|
PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which)
|
|
|
|
{
|
|
|
|
switch (ev->button) {
|
|
|
|
case 3:
|
|
|
|
if (pan_menu == 0) {
|
|
|
|
pan_menu = manage (new Menu);
|
|
|
|
pan_menu->set_name ("ArdourContextMenu");
|
|
|
|
}
|
|
|
|
build_pan_menu (which);
|
|
|
|
pan_menu->popup (1, ev->time);
|
2006-05-23 15:54:52 -04:00
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
2006-05-23 15:54:52 -04:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-05-23 15:54:52 -04:00
|
|
|
return false; // what's wrong with gcc?
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::build_pan_menu (uint32_t which)
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
MenuList& items (pan_menu->items());
|
|
|
|
|
|
|
|
items.clear ();
|
|
|
|
|
|
|
|
items.push_back (CheckMenuElem (_("Mute")));
|
|
|
|
|
|
|
|
/* set state first, connect second */
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
(dynamic_cast<CheckMenuItem*> (&items.back()))->set_active (_io->panner()[which]->muted());
|
2005-10-09 01:03:29 -04:00
|
|
|
(dynamic_cast<CheckMenuItem*> (&items.back()))->signal_toggled().connect
|
2005-09-25 17:19:23 -04:00
|
|
|
(bind (mem_fun(*this, &PannerUI::pan_mute), which));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
items.push_back (CheckMenuElem (_("Bypass"), mem_fun(*this, &PannerUI::pan_bypass_toggle)));
|
2005-10-09 01:03:29 -04:00
|
|
|
bypass_menu_item = static_cast<CheckMenuItem*> (&items.back());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* set state first, connect second */
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
bypass_menu_item->set_active (_io->panner().bypassed());
|
2005-10-09 01:03:29 -04:00
|
|
|
bypass_menu_item->signal_toggled().connect (mem_fun(*this, &PannerUI::pan_bypass_toggle));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
items.push_back (MenuElem (_("Reset"), mem_fun(*this, &PannerUI::pan_reset)));
|
2005-09-25 14:42:24 -04:00
|
|
|
items.push_back (SeparatorElem());
|
|
|
|
items.push_back (MenuElem (_("Reset all")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_mute (uint32_t which)
|
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
StreamPanner* sp = _io->panner()[which];
|
2005-09-25 14:42:24 -04:00
|
|
|
sp->set_muted (!sp->muted());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_bypass_toggle ()
|
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
if (bypass_menu_item && (_io->panner().bypassed() != bypass_menu_item->get_active())) {
|
|
|
|
_io->panner().set_bypassed (!_io->panner().bypassed());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_reset ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::effective_pan_display ()
|
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
if (_io->panner().empty()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
switch (_io->n_outputs()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
/* relax */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
update_pan_bars (true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
//panner->move_puck (pan_value (v, right), 0.5);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_changed (void *src)
|
|
|
|
{
|
|
|
|
if (src == this) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
switch (_io->panner().size()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case 0:
|
2006-06-02 08:48:35 -04:00
|
|
|
panning_link_direction_button.set_sensitive (false);
|
|
|
|
panning_link_button.set_sensitive (false);
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
case 1:
|
2006-06-02 08:48:35 -04:00
|
|
|
panning_link_direction_button.set_sensitive (false);
|
|
|
|
panning_link_button.set_sensitive (false);
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
default:
|
2006-06-02 08:48:35 -04:00
|
|
|
panning_link_direction_button.set_sensitive (true);
|
|
|
|
panning_link_button.set_sensitive (true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
uint32_t nouts = _io->n_outputs();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (nouts) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
/* relax */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
update_pan_bars (false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// panner->move_puck (pan_value (pans[0], pans[1]), 0.5);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_adjustment_changed (uint32_t which)
|
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
if (!in_pan_update && which < _io->panner().size()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
float xpos;
|
|
|
|
float val = pan_adjustments[which]->get_value ();
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner()[which]->get_position (xpos);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* add a kinda-sorta detent for the middle */
|
|
|
|
|
|
|
|
if (val != 0.5 && Panner::equivalent (val, 0.5)) {
|
|
|
|
/* this is going to be reentrant, so just
|
|
|
|
return after it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
in_pan_update = true;
|
|
|
|
pan_adjustments[which]->set_value (0.5);
|
|
|
|
in_pan_update = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Panner::equivalent (val, xpos)) {
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner()[which]->set_position (val);
|
2005-09-25 14:42:24 -04:00
|
|
|
/* XXX
|
|
|
|
the panner objects have no access to the session,
|
|
|
|
so do this here. ick.
|
|
|
|
*/
|
|
|
|
_session.set_dirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_value_changed (uint32_t which)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD (bind (mem_fun(*this, &PannerUI::pan_value_changed), which));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
if (_io->n_outputs() > 1 && which < _io->panner().size()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
float xpos;
|
|
|
|
float val = pan_adjustments[which]->get_value ();
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner()[which]->get_position (xpos);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!Panner::equivalent (val, xpos)) {
|
|
|
|
in_pan_update = true;
|
|
|
|
pan_adjustments[which]->set_value (xpos);
|
|
|
|
in_pan_update = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::update_pan_bars (bool only_if_aplay)
|
|
|
|
{
|
|
|
|
uint32_t n;
|
|
|
|
vector<Adjustment*>::iterator i;
|
|
|
|
|
|
|
|
in_pan_update = true;
|
|
|
|
|
|
|
|
/* this runs during automation playback, and moves the bar controllers
|
|
|
|
and/or pucks around.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i = pan_adjustments.begin(), n = 0; i != pan_adjustments.end(); ++i, ++n) {
|
|
|
|
float xpos, val;
|
|
|
|
|
|
|
|
if (only_if_aplay) {
|
2006-07-27 12:52:14 -04:00
|
|
|
AutomationList& alist (_io->panner()[n]->automation());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (!alist.automation_playback()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
_io->panner()[n]->get_effective_position (xpos);
|
2005-09-25 14:42:24 -04:00
|
|
|
val = (*i)->get_value ();
|
|
|
|
|
|
|
|
if (!Panner::equivalent (val, xpos)) {
|
|
|
|
(*i)->set_value (xpos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
in_pan_update = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_printer (char *buf, uint32_t len, Adjustment* adj)
|
|
|
|
{
|
|
|
|
float val = adj->get_value();
|
|
|
|
|
|
|
|
if (val == 0.0f) {
|
|
|
|
snprintf (buf, len, X_("L"));
|
|
|
|
} else if (val == 1.0f) {
|
|
|
|
snprintf (buf, len, X_("R"));
|
|
|
|
} else if (Panner::equivalent (val, 0.5f)) {
|
|
|
|
snprintf (buf, len, X_("C"));
|
|
|
|
} else {
|
|
|
|
/* don't print anything */
|
|
|
|
buf[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::update_pan_sensitive ()
|
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
bool sensitive = !(_io->panner().automation_state() & Play);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
switch (_io->n_outputs()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
case 2:
|
2006-12-20 16:03:11 -05:00
|
|
|
for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
(*i)->set_sensitive (sensitive);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (panner) {
|
|
|
|
panner->set_sensitive (sensitive);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-19 13:29:05 -04:00
|
|
|
gint
|
|
|
|
PannerUI::pan_automation_state_button_event (GdkEventButton *ev)
|
|
|
|
{
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
|
|
|
if (ev->type == GDK_BUTTON_RELEASE) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ev->button) {
|
|
|
|
case 1:
|
|
|
|
pan_astate_menu.popup (1, ev->time);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
PannerUI::pan_automation_style_button_event (GdkEventButton *ev)
|
|
|
|
{
|
|
|
|
if (ev->type == GDK_BUTTON_RELEASE) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ev->button) {
|
|
|
|
case 1:
|
|
|
|
pan_astyle_menu.popup (1, ev->time);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_automation_style_changed ()
|
|
|
|
{
|
|
|
|
ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::pan_automation_style_changed));
|
|
|
|
|
|
|
|
switch (_width) {
|
|
|
|
case Wide:
|
2006-07-27 12:52:14 -04:00
|
|
|
pan_automation_style_button.set_label (astyle_string(_io->panner().automation_style()));
|
2006-05-19 13:29:05 -04:00
|
|
|
break;
|
|
|
|
case Narrow:
|
2006-07-27 12:52:14 -04:00
|
|
|
pan_automation_style_button.set_label (short_astyle_string(_io->panner().automation_style()));
|
2006-05-19 13:29:05 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PannerUI::pan_automation_state_changed ()
|
|
|
|
{
|
|
|
|
ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::pan_automation_state_changed));
|
|
|
|
|
|
|
|
bool x;
|
|
|
|
|
|
|
|
switch (_width) {
|
|
|
|
case Wide:
|
2006-07-27 12:52:14 -04:00
|
|
|
pan_automation_state_button.set_label (astate_string(_io->panner().automation_state()));
|
2006-05-19 13:29:05 -04:00
|
|
|
break;
|
|
|
|
case Narrow:
|
2006-07-27 12:52:14 -04:00
|
|
|
pan_automation_state_button.set_label (short_astate_string(_io->panner().automation_state()));
|
2006-05-19 13:29:05 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* when creating a new session, we get to create busses (and
|
|
|
|
sometimes tracks) with no outputs by the time they get
|
|
|
|
here.
|
|
|
|
*/
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
if (_io->panner().empty()) {
|
2006-05-19 13:29:05 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
x = (_io->panner().front()->automation().automation_state() != Off);
|
2006-05-19 13:29:05 -04:00
|
|
|
|
|
|
|
if (pan_automation_state_button.get_active() != x) {
|
|
|
|
ignore_toggle = true;
|
|
|
|
pan_automation_state_button.set_active (x);
|
|
|
|
ignore_toggle = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
update_pan_sensitive ();
|
|
|
|
|
|
|
|
/* start watching automation so that things move */
|
|
|
|
|
|
|
|
pan_watching.disconnect();
|
|
|
|
|
|
|
|
if (x) {
|
|
|
|
pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (*this, &PannerUI::effective_pan_display));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
PannerUI::astate_string (AutoState state)
|
|
|
|
{
|
|
|
|
return _astate_string (state, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
PannerUI::short_astate_string (AutoState state)
|
|
|
|
{
|
|
|
|
return _astate_string (state, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
PannerUI::_astate_string (AutoState state, bool shrt)
|
|
|
|
{
|
|
|
|
string sstr;
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case Off:
|
2006-05-22 07:12:26 -04:00
|
|
|
sstr = (shrt ? "O" : _("O"));
|
2006-05-19 13:29:05 -04:00
|
|
|
break;
|
|
|
|
case Play:
|
|
|
|
sstr = (shrt ? "P" : _("P"));
|
|
|
|
break;
|
|
|
|
case Touch:
|
|
|
|
sstr = (shrt ? "T" : _("T"));
|
|
|
|
break;
|
|
|
|
case Write:
|
|
|
|
sstr = (shrt ? "W" : _("W"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
PannerUI::astyle_string (AutoStyle style)
|
|
|
|
{
|
|
|
|
return _astyle_string (style, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
PannerUI::short_astyle_string (AutoStyle style)
|
|
|
|
{
|
|
|
|
return _astyle_string (style, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
PannerUI::_astyle_string (AutoStyle style, bool shrt)
|
|
|
|
{
|
|
|
|
if (style & Trim) {
|
|
|
|
return _("Trim");
|
|
|
|
} else {
|
|
|
|
/* XXX it might different in different languages */
|
|
|
|
|
|
|
|
return (shrt ? _("Abs") : _("Abs"));
|
|
|
|
}
|
|
|
|
}
|