2012-06-06 07:47:09 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-06-06 07:47:09 -04:00
|
|
|
|
2017-07-16 21:48:18 -04:00
|
|
|
#include <gtkmm/table.h>
|
|
|
|
|
2012-06-06 07:47:09 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
#include "gtkmm2ext/gtk_ui.h"
|
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
|
|
|
#include "pbd/controllable.h"
|
|
|
|
#include "mono_panner_editor.h"
|
|
|
|
#include "mono_panner.h"
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2012-06-06 07:47:09 -04:00
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
|
2016-01-02 04:58:23 -05:00
|
|
|
using PBD::Controllable;
|
|
|
|
|
2012-06-06 07:47:09 -04:00
|
|
|
MonoPannerEditor::MonoPannerEditor (MonoPanner* p)
|
|
|
|
: PannerEditor (_("Mono Panner"))
|
|
|
|
, _panner (p)
|
|
|
|
, _ignore_changes (false)
|
|
|
|
{
|
|
|
|
Table* t = manage (new Table (2, 3));
|
|
|
|
t->set_spacings (6);
|
|
|
|
|
|
|
|
int n = 0;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-06 07:47:09 -04:00
|
|
|
t->attach (*manage (left_aligned_label (_("Left"))), 0, 1, n, n + 1);
|
|
|
|
t->attach (_left, 1, 2, n, n + 1);
|
|
|
|
t->attach (*manage (left_aligned_label (_("%"))), 2, 3, n, n + 1);
|
|
|
|
++n;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-06 07:47:09 -04:00
|
|
|
t->attach (*manage (left_aligned_label (_("Right"))), 0, 1, n, n + 1);
|
|
|
|
t->attach (_right, 1, 2, n, n + 1);
|
|
|
|
t->attach (*manage (left_aligned_label (_("%"))), 2, 3, n, n + 1);
|
|
|
|
++n;
|
|
|
|
|
|
|
|
get_vbox()->pack_start (*manage (t));
|
|
|
|
get_vbox()->set_spacing (6);
|
|
|
|
|
|
|
|
_left.set_increments (1, 10);
|
|
|
|
_left.set_range (0, 100);
|
|
|
|
_right.set_increments (1, 10);
|
|
|
|
_right.set_range (0, 100);
|
|
|
|
|
2024-10-18 19:51:44 -04:00
|
|
|
_panner->get_controllable()->Changed.connect (_connections, invalidator (*this), std::bind (&MonoPannerEditor::update_editor, this), gui_context ());
|
|
|
|
_panner->DropReferences.connect (_connections, invalidator (*this), std::bind (&MonoPannerEditor::panner_going_away, this), gui_context ());
|
2012-06-06 07:47:09 -04:00
|
|
|
_left.signal_value_changed().connect (sigc::mem_fun (*this, &MonoPannerEditor::left_changed));
|
|
|
|
_right.signal_value_changed().connect (sigc::mem_fun (*this, &MonoPannerEditor::right_changed));
|
|
|
|
|
|
|
|
show_all ();
|
|
|
|
update_editor ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MonoPannerEditor::panner_going_away ()
|
|
|
|
{
|
|
|
|
_panner = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MonoPannerEditor::update_editor ()
|
|
|
|
{
|
|
|
|
if (!_panner) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-06 07:47:09 -04:00
|
|
|
float const v = _panner->get_controllable()->get_value();
|
|
|
|
|
|
|
|
_ignore_changes = true;
|
|
|
|
_left.set_value (100 * (1 - v));
|
|
|
|
_right.set_value (100 * v);
|
|
|
|
_ignore_changes = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MonoPannerEditor::left_changed ()
|
|
|
|
{
|
|
|
|
if (_ignore_changes || !_panner) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float const v = 1 - _left.get_value () / 100;
|
|
|
|
|
|
|
|
_ignore_changes = true;
|
|
|
|
_right.set_value (100 * v);
|
2016-01-02 04:58:23 -05:00
|
|
|
_panner->get_controllable()->set_value (v, Controllable::NoGroup);
|
2012-06-06 07:47:09 -04:00
|
|
|
_ignore_changes = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MonoPannerEditor::right_changed ()
|
|
|
|
{
|
|
|
|
if (_ignore_changes || !_panner) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float const v = _right.get_value () / 100;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-06 07:47:09 -04:00
|
|
|
_ignore_changes = true;
|
|
|
|
_left.set_value (100 * (1 - v));
|
2016-01-02 04:58:23 -05:00
|
|
|
_panner->get_controllable()->set_value (v, Controllable::NoGroup);
|
2012-06-06 07:47:09 -04:00
|
|
|
_ignore_changes = false;
|
|
|
|
}
|
|
|
|
|