2008-05-11 22:40:48 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2008-2015 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2008 Hans Baier <hansfbaier@googlemail.com>
|
|
|
|
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2015 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-05-11 22:40:48 -04:00
|
|
|
|
2013-01-19 02:00:43 -05:00
|
|
|
#include <algorithm>
|
2008-05-11 22:40:48 -04:00
|
|
|
#include <sstream>
|
2013-03-27 21:50:18 -04:00
|
|
|
#include <gtkmm/separator.h>
|
|
|
|
#include <gtkmm/box.h>
|
|
|
|
#include <gtkmm/label.h>
|
|
|
|
#include <gtkmm/togglebutton.h>
|
|
|
|
#include <gtkmm/radiobutton.h>
|
|
|
|
#include <gtkmm/table.h>
|
|
|
|
|
|
|
|
#include "pbd/compose.h"
|
2015-03-28 23:24:41 -04:00
|
|
|
#include "pbd/ffs.h"
|
2013-03-27 21:50:18 -04:00
|
|
|
|
|
|
|
#include "gtkmm2ext/gtk_ui.h"
|
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
2013-03-28 17:10:57 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
2013-03-27 21:50:18 -04:00
|
|
|
|
|
|
|
#include "ardour/midi_track.h"
|
2013-01-19 02:00:43 -05:00
|
|
|
|
2008-04-14 02:23:11 -04:00
|
|
|
#include "midi_channel_selector.h"
|
2008-12-25 04:28:57 -05:00
|
|
|
#include "rgb_macros.h"
|
2008-04-14 02:23:11 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2008-04-14 02:23:11 -04:00
|
|
|
using namespace std;
|
2008-04-19 06:30:38 -04:00
|
|
|
using namespace Gtk;
|
2008-05-11 22:40:48 -04:00
|
|
|
using namespace ARDOUR;
|
2008-04-14 02:23:11 -04:00
|
|
|
|
2009-02-16 00:13:05 -05:00
|
|
|
MidiChannelSelector::MidiChannelSelector(int n_rows, int n_columns, int start_row, int start_column)
|
2014-11-18 02:52:56 -05:00
|
|
|
: Table(std::max(4, std::max(n_rows, start_row + 4)),
|
|
|
|
std::max(4, std::max(n_columns, start_column + 4)),
|
|
|
|
true)
|
2009-02-16 00:13:05 -05:00
|
|
|
, _recursion_counter(0)
|
2009-10-14 12:10:01 -04:00
|
|
|
{
|
2008-04-14 02:23:11 -04:00
|
|
|
property_column_spacing() = 0;
|
|
|
|
property_row_spacing() = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-14 02:23:11 -04:00
|
|
|
uint8_t channel_nr = 0;
|
2008-05-11 22:40:48 -04:00
|
|
|
for (int row = 0; row < 4; ++row) {
|
|
|
|
for (int column = 0; column < 4; ++column) {
|
2008-04-14 02:23:11 -04:00
|
|
|
ostringstream channel;
|
|
|
|
channel << int(++channel_nr);
|
|
|
|
_button_labels[row][column].set_text(channel.str());
|
2008-04-19 06:30:38 -04:00
|
|
|
_button_labels[row][column].set_justify(JUSTIFY_RIGHT);
|
2008-04-14 02:23:11 -04:00
|
|
|
_buttons[row][column].add(_button_labels[row][column]);
|
|
|
|
_buttons[row][column].signal_toggled().connect(
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::bind(
|
|
|
|
sigc::mem_fun(this, &MidiChannelSelector::button_toggled),
|
2008-04-14 02:23:11 -04:00
|
|
|
&_buttons[row][column],
|
|
|
|
channel_nr - 1));
|
2011-05-16 14:18:13 -04:00
|
|
|
_buttons[row][column].set_widget_name (X_("MidiChannelSelectorButton"));
|
2008-04-17 06:27:03 -04:00
|
|
|
|
2010-07-25 17:19:55 -04:00
|
|
|
_buttons[row][column].signal_button_release_event().connect(
|
|
|
|
sigc::mem_fun(this, &MidiChannelSelector::was_clicked), false);
|
|
|
|
|
2008-04-17 06:27:03 -04:00
|
|
|
int table_row = start_row + row;
|
|
|
|
int table_column = start_column + column;
|
|
|
|
attach(_buttons[row][column], table_column, table_column + 1, table_row, table_row + 1);
|
2008-04-14 02:23:11 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MidiChannelSelector::~MidiChannelSelector()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-07-25 17:19:55 -04:00
|
|
|
bool
|
|
|
|
MidiChannelSelector::was_clicked (GdkEventButton*)
|
|
|
|
{
|
2017-07-01 12:42:24 -04:00
|
|
|
clicked ();
|
|
|
|
return false;
|
2010-07-25 17:19:55 -04:00
|
|
|
}
|
|
|
|
|
2008-12-25 04:28:57 -05:00
|
|
|
void
|
|
|
|
MidiChannelSelector::set_channel_colors(const uint32_t new_channel_colors[16])
|
|
|
|
{
|
|
|
|
for (int row = 0; row < 4; ++row) {
|
|
|
|
for (int column = 0; column < 4; ++column) {
|
|
|
|
char color_normal[8];
|
|
|
|
char color_active[8];
|
|
|
|
snprintf(color_normal, 8, "#%x", UINT_INTERPOLATE(new_channel_colors[row * 4 + column], 0x000000ff, 0.6));
|
|
|
|
snprintf(color_active, 8, "#%x", new_channel_colors[row * 4 + column]);
|
|
|
|
_buttons[row][column].modify_bg(STATE_NORMAL, Gdk::Color(color_normal));
|
|
|
|
_buttons[row][column].modify_bg(STATE_ACTIVE, Gdk::Color(color_active));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelector::set_default_channel_color()
|
|
|
|
{
|
|
|
|
for (int row = 0; row < 4; ++row) {
|
|
|
|
for (int column = 0; column < 4; ++column) {
|
2011-05-16 14:18:13 -04:00
|
|
|
_buttons[row][column].unset_fg (STATE_NORMAL);
|
|
|
|
_buttons[row][column].unset_fg (STATE_ACTIVE);
|
|
|
|
_buttons[row][column].unset_bg (STATE_NORMAL);
|
|
|
|
_buttons[row][column].unset_bg (STATE_ACTIVE);
|
2008-12-25 04:28:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-14 02:23:11 -04:00
|
|
|
SingleMidiChannelSelector::SingleMidiChannelSelector(uint8_t active_channel)
|
|
|
|
: MidiChannelSelector()
|
|
|
|
{
|
2008-04-21 05:39:05 -04:00
|
|
|
_last_active_button = 0;
|
2008-05-11 22:40:48 -04:00
|
|
|
ToggleButton* button = &_buttons[active_channel / 4][active_channel % 4];
|
2008-04-14 02:23:11 -04:00
|
|
|
_active_channel = active_channel;
|
2008-04-21 05:39:05 -04:00
|
|
|
button->set_active(true);
|
|
|
|
_last_active_button = button;
|
2008-04-14 02:23:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-05-11 22:40:48 -04:00
|
|
|
SingleMidiChannelSelector::button_toggled(ToggleButton* button, uint8_t channel)
|
2009-10-14 12:10:01 -04:00
|
|
|
{
|
2008-04-21 05:39:05 -04:00
|
|
|
++_recursion_counter;
|
2008-05-11 22:40:48 -04:00
|
|
|
if (_recursion_counter == 1) {
|
2009-10-14 12:10:01 -04:00
|
|
|
// if the current button is active it must
|
2008-04-21 05:39:05 -04:00
|
|
|
// be different from the first one
|
2008-05-11 22:40:48 -04:00
|
|
|
if (button->get_active()) {
|
|
|
|
if (_last_active_button) {
|
2008-04-21 05:39:05 -04:00
|
|
|
_last_active_button->set_active(false);
|
|
|
|
_active_channel = channel;
|
|
|
|
_last_active_button = button;
|
2008-05-09 07:28:14 -04:00
|
|
|
channel_selected.emit(channel);
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// if not, the user pressed the already active button
|
|
|
|
button->set_active(true);
|
|
|
|
_active_channel = channel;
|
2008-04-14 02:23:11 -04:00
|
|
|
}
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
|
|
|
--_recursion_counter;
|
2008-04-14 02:23:11 -04:00
|
|
|
}
|
|
|
|
|
2008-05-11 22:40:48 -04:00
|
|
|
MidiMultipleChannelSelector::MidiMultipleChannelSelector(ChannelMode mode, uint16_t mask)
|
|
|
|
: MidiChannelSelector(4, 6, 0, 0)
|
|
|
|
, _channel_mode(mode)
|
2008-04-17 06:27:03 -04:00
|
|
|
{
|
2008-04-19 06:30:38 -04:00
|
|
|
_select_all.add(*manage(new Label(_("All"))));
|
2008-04-17 06:27:03 -04:00
|
|
|
_select_all.signal_clicked().connect(
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::bind(sigc::mem_fun(this, &MidiMultipleChannelSelector::select_all), true));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-19 06:30:38 -04:00
|
|
|
_select_none.add(*manage(new Label(_("None"))));
|
2008-04-17 06:27:03 -04:00
|
|
|
_select_none.signal_clicked().connect(
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::bind(sigc::mem_fun(this, &MidiMultipleChannelSelector::select_all), false));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-19 06:30:38 -04:00
|
|
|
_invert_selection.add(*manage(new Label(_("Invert"))));
|
2008-04-17 06:27:03 -04:00
|
|
|
_invert_selection.signal_clicked().connect(
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::mem_fun(this, &MidiMultipleChannelSelector::invert_selection));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-19 06:30:38 -04:00
|
|
|
_force_channel.add(*manage(new Label(_("Force"))));
|
2008-04-21 05:39:05 -04:00
|
|
|
_force_channel.signal_toggled().connect(
|
2009-12-11 18:29:48 -05:00
|
|
|
sigc::mem_fun(this, &MidiMultipleChannelSelector::force_channels_button_toggled));
|
2008-04-17 06:27:03 -04:00
|
|
|
|
|
|
|
set_homogeneous(false);
|
2008-04-19 06:30:38 -04:00
|
|
|
attach(*manage(new VSeparator()), 4, 5, 0, 4, SHRINK, FILL, 0, 0);
|
|
|
|
//set_row_spacing(4, -5);
|
|
|
|
attach(_select_all, 5, 6, 0, 1);
|
|
|
|
attach(_select_none, 5, 6, 1, 2);
|
|
|
|
attach(_invert_selection, 5, 6, 2, 3);
|
|
|
|
attach(_force_channel, 5, 6, 3, 4);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-05-11 22:40:48 -04:00
|
|
|
set_selected_channels(mask);
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MidiMultipleChannelSelector::~MidiMultipleChannelSelector()
|
|
|
|
{
|
2008-05-11 22:40:48 -04:00
|
|
|
mode_changed.clear();
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
|
|
|
|
2008-05-11 22:40:48 -04:00
|
|
|
void
|
2008-12-28 19:19:18 -05:00
|
|
|
MidiMultipleChannelSelector::set_channel_mode(ChannelMode mode, uint16_t mask)
|
2008-04-21 05:39:05 -04:00
|
|
|
{
|
2008-05-11 22:40:48 -04:00
|
|
|
switch (mode) {
|
|
|
|
case AllChannels:
|
|
|
|
_force_channel.set_active(false);
|
|
|
|
set_selected_channels(0xFFFF);
|
|
|
|
break;
|
|
|
|
case FilterChannels:
|
|
|
|
_force_channel.set_active(false);
|
|
|
|
set_selected_channels(mask);
|
|
|
|
break;
|
|
|
|
case ForceChannel:
|
|
|
|
_force_channel.set_active(true);
|
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
|
|
|
ToggleButton* button = &_buttons[i / 4][i % 4];
|
|
|
|
button->set_active(i == mask);
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
2008-04-21 11:10:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
uint16_t
|
|
|
|
MidiMultipleChannelSelector::get_selected_channels() const
|
|
|
|
{
|
2008-04-21 05:39:05 -04:00
|
|
|
uint16_t selected_channels = 0;
|
2008-05-11 22:40:48 -04:00
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
|
|
|
const ToggleButton* button = &_buttons[i / 4][i % 4];
|
|
|
|
if (button->get_active()) {
|
2008-04-21 05:39:05 -04:00
|
|
|
selected_channels |= (1L << i);
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
return selected_channels;
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2008-04-21 05:39:05 -04:00
|
|
|
MidiMultipleChannelSelector::set_selected_channels(uint16_t selected_channels)
|
|
|
|
{
|
2008-05-11 22:40:48 -04:00
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
|
|
|
ToggleButton* button = &_buttons[i / 4][i % 4];
|
|
|
|
if (selected_channels & (1L << i)) {
|
2008-04-17 06:27:03 -04:00
|
|
|
button->set_active(true);
|
|
|
|
} else {
|
|
|
|
button->set_active(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-14 02:23:11 -04:00
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
MidiMultipleChannelSelector::button_toggled(ToggleButton */*button*/, uint8_t channel)
|
2008-04-14 02:23:11 -04:00
|
|
|
{
|
2008-04-21 05:39:05 -04:00
|
|
|
++_recursion_counter;
|
2008-05-11 22:40:48 -04:00
|
|
|
if (_recursion_counter == 1) {
|
|
|
|
if (_channel_mode == ForceChannel) {
|
|
|
|
mode_changed.emit(_channel_mode, channel);
|
2008-04-21 05:39:05 -04:00
|
|
|
set_selected_channels(1 << channel);
|
2008-05-11 22:40:48 -04:00
|
|
|
} else {
|
|
|
|
mode_changed.emit(_channel_mode, get_selected_channels());
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
--_recursion_counter;
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2008-04-21 05:39:05 -04:00
|
|
|
MidiMultipleChannelSelector::force_channels_button_toggled()
|
|
|
|
{
|
2008-05-11 22:40:48 -04:00
|
|
|
if (_force_channel.get_active()) {
|
|
|
|
_channel_mode = ForceChannel;
|
2008-04-21 05:39:05 -04:00
|
|
|
bool found_first_active = false;
|
|
|
|
// leave only the first button enabled
|
2008-05-11 22:40:48 -04:00
|
|
|
uint16_t active_channel = 0;
|
|
|
|
for (int i = 0; i <= 15; i++) {
|
|
|
|
ToggleButton* button = &_buttons[i / 4][i % 4];
|
|
|
|
if (button->get_active()) {
|
|
|
|
if (found_first_active) {
|
2008-04-21 05:39:05 -04:00
|
|
|
++_recursion_counter;
|
|
|
|
button->set_active(false);
|
|
|
|
--_recursion_counter;
|
|
|
|
} else {
|
|
|
|
found_first_active = true;
|
2008-05-11 22:40:48 -04:00
|
|
|
active_channel = i;
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-05-11 22:40:48 -04:00
|
|
|
if (!found_first_active) {
|
2008-04-21 05:39:05 -04:00
|
|
|
_buttons[0][0].set_active(true);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-21 05:39:05 -04:00
|
|
|
_select_all.set_sensitive(false);
|
|
|
|
_select_none.set_sensitive(false);
|
|
|
|
_invert_selection.set_sensitive(false);
|
2008-05-11 22:40:48 -04:00
|
|
|
mode_changed.emit(_channel_mode, active_channel);
|
2008-04-21 05:39:05 -04:00
|
|
|
} else {
|
2008-05-11 22:40:48 -04:00
|
|
|
_channel_mode = FilterChannels;
|
2008-04-21 05:39:05 -04:00
|
|
|
_select_all.set_sensitive(true);
|
|
|
|
_select_none.set_sensitive(true);
|
|
|
|
_invert_selection.set_sensitive(true);
|
2008-05-11 22:40:48 -04:00
|
|
|
mode_changed.emit(FilterChannels, get_selected_channels());
|
2008-04-21 05:39:05 -04:00
|
|
|
}
|
2008-04-17 06:27:03 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2008-04-17 06:27:03 -04:00
|
|
|
MidiMultipleChannelSelector::select_all(bool on)
|
|
|
|
{
|
2008-05-11 22:40:48 -04:00
|
|
|
if (_channel_mode == ForceChannel)
|
|
|
|
return;
|
|
|
|
|
2008-04-21 05:39:05 -04:00
|
|
|
++_recursion_counter;
|
2008-05-11 22:40:48 -04:00
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
|
|
|
ToggleButton* button = &_buttons[i / 4][i % 4];
|
2008-04-17 06:27:03 -04:00
|
|
|
button->set_active(on);
|
2008-04-14 02:23:11 -04:00
|
|
|
}
|
2008-04-21 05:39:05 -04:00
|
|
|
--_recursion_counter;
|
2008-05-11 22:40:48 -04:00
|
|
|
mode_changed.emit(_channel_mode, get_selected_channels());
|
2008-04-14 02:23:11 -04:00
|
|
|
}
|
2008-04-17 06:27:03 -04:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2008-04-17 06:27:03 -04:00
|
|
|
MidiMultipleChannelSelector::invert_selection(void)
|
|
|
|
{
|
2008-05-11 22:40:48 -04:00
|
|
|
if (_channel_mode == ForceChannel)
|
|
|
|
return;
|
|
|
|
|
2008-04-21 05:39:05 -04:00
|
|
|
++_recursion_counter;
|
2008-05-11 22:40:48 -04:00
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
|
|
|
ToggleButton* button = &_buttons[i / 4][i % 4];
|
|
|
|
if (button->get_active()) {
|
2008-04-17 06:27:03 -04:00
|
|
|
button->set_active(false);
|
|
|
|
} else {
|
|
|
|
button->set_active(true);
|
|
|
|
}
|
|
|
|
}
|
2008-04-21 05:39:05 -04:00
|
|
|
--_recursion_counter;
|
2008-05-11 22:40:48 -04:00
|
|
|
mode_changed.emit(_channel_mode, get_selected_channels());
|
2008-04-17 06:27:03 -04:00
|
|
|
}
|
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
/*-----------------------------------------*/
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
MidiChannelSelectorWindow::MidiChannelSelectorWindow (std::shared_ptr<MidiTrack> mt)
|
2013-03-28 17:10:57 -04:00
|
|
|
: ArdourWindow (_("MIDI Channel Control"))
|
2013-03-27 21:50:18 -04:00
|
|
|
, track (mt)
|
2013-03-28 17:10:57 -04:00
|
|
|
, playback_all_button (playback_button_group, _("Playback all channels"))
|
|
|
|
, playback_filter_button (playback_button_group, _("Play only selected channels"))
|
|
|
|
, playback_force_button (playback_button_group, _("Use a single fixed channel for all playback"))
|
|
|
|
, capture_all_button (capture_button_group, _("Record all channels"))
|
|
|
|
, capture_filter_button (capture_button_group, _("Record only selected channels"))
|
|
|
|
, capture_force_button (capture_button_group, _("Force all channels to 1 channel"))
|
|
|
|
, last_drawn_capture_mode (AllChannels)
|
|
|
|
, last_drawn_playback_mode (AllChannels)
|
2013-03-27 21:50:18 -04:00
|
|
|
{
|
|
|
|
build ();
|
|
|
|
|
|
|
|
playback_mode_changed ();
|
|
|
|
capture_mode_changed ();
|
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
playback_mask_changed ();
|
|
|
|
capture_mask_changed ();
|
|
|
|
|
2015-03-28 23:24:41 -04:00
|
|
|
track->playback_filter().ChannelMaskChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&MidiChannelSelectorWindow::playback_mask_changed, this), gui_context());
|
|
|
|
track->playback_filter().ChannelModeChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&MidiChannelSelectorWindow::playback_mode_changed, this), gui_context());
|
|
|
|
track->capture_filter().ChannelMaskChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&MidiChannelSelectorWindow::capture_mask_changed, this), gui_context());
|
|
|
|
track->capture_filter().ChannelModeChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&MidiChannelSelectorWindow::capture_mode_changed, this), gui_context());
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MidiChannelSelectorWindow::~MidiChannelSelectorWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::build ()
|
|
|
|
{
|
|
|
|
VBox* vpacker;
|
2013-03-28 17:10:57 -04:00
|
|
|
HBox* capture_controls;
|
|
|
|
HBox* playback_controls;
|
2017-07-01 12:42:24 -04:00
|
|
|
Button* b;
|
|
|
|
Label* l;
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
vpacker = manage (new VBox);
|
|
|
|
vpacker->set_spacing (6);
|
|
|
|
vpacker->set_border_width (12);
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
l = manage (new Label (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("Inbound"))));
|
2013-03-27 21:50:18 -04:00
|
|
|
l->set_use_markup (true);
|
2017-07-01 12:42:24 -04:00
|
|
|
vpacker->pack_start (*l, true, true);
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
vpacker->pack_start (capture_all_button);
|
|
|
|
capture_all_button.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &MidiChannelSelectorWindow::capture_mode_toggled), AllChannels));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
vpacker->pack_start (capture_filter_button);
|
|
|
|
capture_filter_button.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &MidiChannelSelectorWindow::capture_mode_toggled), FilterChannels));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
vpacker->pack_start (capture_force_button);
|
|
|
|
capture_force_button.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &MidiChannelSelectorWindow::capture_mode_toggled), ForceChannel));
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
vpacker->pack_start (capture_mask_box);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
capture_controls = manage (new HBox);
|
|
|
|
capture_controls->set_spacing (6);
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
b = manage (new Button (_("All")));
|
2013-03-27 21:50:18 -04:00
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*b, _("Click to enable recording all channels"));
|
2013-03-28 17:10:57 -04:00
|
|
|
capture_controls->pack_start (*b);
|
|
|
|
capture_mask_controls.push_back (b);
|
2015-10-04 14:51:05 -04:00
|
|
|
b->signal_clicked().connect (sigc::mem_fun (*this, &MidiChannelSelectorWindow::fill_capture_mask));
|
2017-07-01 12:42:24 -04:00
|
|
|
b = manage (new Button (_("None")));
|
2013-03-27 21:50:18 -04:00
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*b, _("Click to disable recording all channels"));
|
2013-03-28 17:10:57 -04:00
|
|
|
capture_controls->pack_start (*b);
|
|
|
|
capture_mask_controls.push_back (b);
|
2015-10-04 14:51:05 -04:00
|
|
|
b->signal_clicked().connect (sigc::mem_fun (*this, &MidiChannelSelectorWindow::zero_capture_mask));
|
2017-07-01 12:42:24 -04:00
|
|
|
b = manage (new Button (_("Invert")));
|
2013-03-27 21:50:18 -04:00
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*b, _("Click to invert currently selected recording channels"));
|
2013-03-28 17:10:57 -04:00
|
|
|
capture_controls->pack_start (*b);
|
|
|
|
capture_mask_controls.push_back (b);
|
2015-10-04 14:51:05 -04:00
|
|
|
b->signal_clicked().connect (sigc::mem_fun (*this, &MidiChannelSelectorWindow::invert_capture_mask));
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
vpacker->pack_start (*capture_controls);
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2017-02-02 22:44:31 -05:00
|
|
|
Gtk::HSeparator *hseparator2 = manage(new Gtk::HSeparator);
|
|
|
|
vpacker->pack_start (*hseparator2, false, false, 6);
|
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
l = manage (new Label (string_compose ("<span size=\"large\" weight=\"bold\">%1</span>", _("Playback"))));
|
2013-03-27 21:50:18 -04:00
|
|
|
l->set_use_markup (true);
|
2017-07-01 12:42:24 -04:00
|
|
|
vpacker->pack_start (*l);
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
vpacker->pack_start (playback_all_button);
|
|
|
|
playback_all_button.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &MidiChannelSelectorWindow::playback_mode_toggled), AllChannels));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
vpacker->pack_start (playback_filter_button);
|
|
|
|
playback_filter_button.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &MidiChannelSelectorWindow::playback_mode_toggled), FilterChannels));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
vpacker->pack_start (playback_force_button);
|
|
|
|
playback_force_button.signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &MidiChannelSelectorWindow::playback_mode_toggled), ForceChannel));
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
vpacker->pack_start (playback_mask_box);
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
playback_controls = manage (new HBox);
|
|
|
|
playback_controls->set_spacing (6);
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
b = manage (new Button (_("All")));
|
2013-03-27 21:50:18 -04:00
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*b, _("Click to enable playback of all channels"));
|
2013-03-28 17:10:57 -04:00
|
|
|
playback_controls->pack_start (*b);
|
|
|
|
playback_mask_controls.push_back (b);
|
2015-10-04 14:51:05 -04:00
|
|
|
b->signal_clicked().connect (sigc::mem_fun (*this, &MidiChannelSelectorWindow::fill_playback_mask));
|
2017-07-01 12:42:24 -04:00
|
|
|
b = manage (new Button (_("None")));
|
2013-03-27 21:50:18 -04:00
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*b, _("Click to disable playback of all channels"));
|
2013-03-28 17:10:57 -04:00
|
|
|
playback_controls->pack_start (*b);
|
|
|
|
playback_mask_controls.push_back (b);
|
2015-10-04 14:51:05 -04:00
|
|
|
b->signal_clicked().connect (sigc::mem_fun (*this, &MidiChannelSelectorWindow::zero_playback_mask));
|
2013-03-27 21:50:18 -04:00
|
|
|
b = manage (new Button (_("Invert")));
|
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*b, _("Click to invert current selected playback channels"));
|
2013-03-28 17:10:57 -04:00
|
|
|
playback_controls->pack_start (*b);
|
|
|
|
playback_mask_controls.push_back (b);
|
2013-03-27 21:50:18 -04:00
|
|
|
b->signal_clicked().connect (sigc::mem_fun (*this, &MidiChannelSelectorWindow::invert_playback_mask));
|
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
vpacker->pack_start (*playback_controls);
|
2013-03-27 21:50:18 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
add (*vpacker);
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::fill_playback_mask ()
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
if (track->get_playback_channel_mode() == FilterChannels) {
|
|
|
|
track->set_playback_channel_mask (0xffff);
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::zero_playback_mask ()
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
if (track->get_playback_channel_mode() == FilterChannels) {
|
|
|
|
track->set_playback_channel_mask (0);
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::invert_playback_mask ()
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
if (track->get_playback_channel_mode() == FilterChannels) {
|
|
|
|
track->set_playback_channel_mask (~track->get_playback_channel_mask());
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::fill_capture_mask ()
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
if (track->get_capture_channel_mode() == FilterChannels) {
|
|
|
|
track->set_capture_channel_mask (0xffff);
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::zero_capture_mask ()
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
if (track->get_capture_channel_mode() == FilterChannels) {
|
|
|
|
track->set_capture_channel_mask (0);
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::invert_capture_mask ()
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
if (track->get_capture_channel_mode() == FilterChannels) {
|
|
|
|
track->set_capture_channel_mask (~track->get_capture_channel_mask());
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::set_playback_selected_channels (uint16_t mask)
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
switch (track->get_playback_channel_mode()) {
|
|
|
|
case AllChannels:
|
|
|
|
/* they are insensitive, so we don't care */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FilterChannels:
|
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
|
|
|
playback_buttons[i]->set_active ((1<<i) & mask);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
case ForceChannel:
|
|
|
|
/* only set the lowest set channel in the mask as active */
|
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
2013-07-19 04:40:50 -04:00
|
|
|
playback_buttons[i]->set_active (i == (PBD::ffs (mask) - 1));
|
2013-03-28 17:10:57 -04:00
|
|
|
}
|
|
|
|
break;
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::set_capture_selected_channels (uint16_t mask)
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
switch (track->get_capture_channel_mode()) {
|
|
|
|
case AllChannels:
|
|
|
|
/* they are insensitive, so we don't care */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FilterChannels:
|
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
|
|
|
capture_buttons[i]->set_active ((1<<i) & mask);
|
|
|
|
}
|
|
|
|
break;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
case ForceChannel:
|
|
|
|
/* only set the lowest set channel in the mask as active */
|
|
|
|
for (uint16_t i = 0; i < 16; i++) {
|
2013-07-19 04:40:50 -04:00
|
|
|
capture_buttons[i]->set_active (i == (PBD::ffs (mask) - 1));
|
2013-03-28 17:10:57 -04:00
|
|
|
}
|
|
|
|
break;
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::playback_mask_changed ()
|
|
|
|
{
|
|
|
|
set_playback_selected_channels (track->get_playback_channel_mask());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::capture_mask_changed ()
|
|
|
|
{
|
|
|
|
set_capture_selected_channels (track->get_capture_channel_mask());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::playback_mode_changed ()
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
uint32_t first_channel = 0;
|
|
|
|
ChannelMode mode = track->get_playback_channel_mode();
|
|
|
|
|
|
|
|
switch (mode) {
|
2013-03-27 21:50:18 -04:00
|
|
|
case AllChannels:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (last_drawn_playback_mode == ForceChannel) {
|
|
|
|
/* force mode used radio buttons. not what we want,
|
|
|
|
* though one could argue that we want no buttons
|
|
|
|
* at since they are insensitive
|
|
|
|
*/
|
|
|
|
playback_buttons.clear ();
|
|
|
|
}
|
|
|
|
for (vector<Widget*>::iterator i = playback_mask_controls.begin(); i != playback_mask_controls.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (false);
|
|
|
|
}
|
|
|
|
playback_all_button.set_active ();
|
2013-03-27 21:50:18 -04:00
|
|
|
break;
|
2013-03-28 17:10:57 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
case FilterChannels:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (last_drawn_playback_mode == ForceChannel) {
|
|
|
|
playback_buttons.clear ();
|
|
|
|
} else if (last_drawn_playback_mode == AllChannels) {
|
|
|
|
for (vector<ToggleButton*>::iterator i = playback_buttons.begin(); i != playback_buttons.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (vector<Widget*>::iterator i = playback_mask_controls.begin(); i != playback_mask_controls.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (true);
|
|
|
|
}
|
|
|
|
playback_filter_button.set_active ();
|
2013-03-27 21:50:18 -04:00
|
|
|
break;
|
2013-03-28 17:10:57 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
case ForceChannel:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (last_drawn_playback_mode == AllChannels || last_drawn_playback_mode == FilterChannels) {
|
|
|
|
playback_buttons.clear ();
|
2013-07-19 04:40:50 -04:00
|
|
|
first_channel = PBD::ffs (track->get_playback_channel_mask()) - 1;
|
2013-03-28 17:10:57 -04:00
|
|
|
}
|
|
|
|
for (vector<Widget*>::iterator i = playback_mask_controls.begin(); i != playback_mask_controls.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (false);
|
|
|
|
}
|
|
|
|
playback_force_button.set_active ();
|
2013-03-27 21:50:18 -04:00
|
|
|
break;
|
|
|
|
}
|
2013-03-28 17:10:57 -04:00
|
|
|
|
|
|
|
if (playback_buttons.empty()) {
|
|
|
|
|
|
|
|
Gtkmm2ext::container_clear (playback_mask_box);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
ToggleButton* tb;
|
|
|
|
RadioButtonGroup group;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
for (uint32_t n = 0; n < 16; ++n) {
|
|
|
|
char buf[3];
|
|
|
|
snprintf (buf, sizeof (buf), "%d", n+1);
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case AllChannels:
|
|
|
|
case FilterChannels:
|
|
|
|
tb = manage (new ToggleButton (buf));
|
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*tb, string_compose (_("Click to toggle playback of channel %1"), n+1));
|
|
|
|
break;
|
|
|
|
case ForceChannel:
|
|
|
|
tb = manage (new RadioButton (group, buf));
|
|
|
|
tb->property_draw_indicator() = false;
|
|
|
|
if (n == first_channel) {
|
|
|
|
tb->set_active (true);
|
|
|
|
}
|
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*tb, string_compose (_("Click to force all MIDI channel messages to channel %1"), n+1));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
playback_buttons.push_back (tb);
|
|
|
|
tb->set_name (X_("MidiChannelSelectorButton"));
|
|
|
|
playback_mask_box.pack_start (*tb);
|
|
|
|
tb->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &MidiChannelSelectorWindow::playback_channel_clicked), n));
|
|
|
|
tb->show ();
|
|
|
|
|
|
|
|
if (mode == AllChannels) {
|
|
|
|
tb->set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
if (mode != ForceChannel) {
|
|
|
|
set_playback_selected_channels (track->get_playback_channel_mask());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == AllChannels) {
|
|
|
|
for (vector<ToggleButton*>::iterator i = playback_buttons.begin(); i != playback_buttons.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-03 13:16:06 -05:00
|
|
|
playback_mask_changed(); // update buttons
|
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
last_drawn_playback_mode = mode;
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::capture_mode_changed ()
|
|
|
|
{
|
2013-03-28 17:10:57 -04:00
|
|
|
uint32_t first_channel = 0;
|
|
|
|
ChannelMode mode = track->get_capture_channel_mode();
|
|
|
|
|
|
|
|
switch (mode) {
|
2013-03-27 21:50:18 -04:00
|
|
|
case AllChannels:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (last_drawn_capture_mode == ForceChannel) {
|
|
|
|
/* force mode used radio buttons. not what we want,
|
|
|
|
* though one could argue that we want no buttons
|
|
|
|
* at since they are insensitive
|
|
|
|
*/
|
|
|
|
capture_buttons.clear ();
|
|
|
|
}
|
|
|
|
for (vector<Widget*>::iterator i = capture_mask_controls.begin(); i != capture_mask_controls.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (false);
|
|
|
|
}
|
|
|
|
capture_all_button.set_active ();
|
2013-03-27 21:50:18 -04:00
|
|
|
break;
|
2013-03-28 17:10:57 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
case FilterChannels:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (last_drawn_capture_mode == ForceChannel) {
|
|
|
|
capture_buttons.clear ();
|
|
|
|
} else if (last_drawn_capture_mode == AllChannels) {
|
|
|
|
for (vector<ToggleButton*>::iterator i = capture_buttons.begin(); i != capture_buttons.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (vector<Widget*>::iterator i = capture_mask_controls.begin(); i != capture_mask_controls.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (true);
|
|
|
|
}
|
|
|
|
capture_filter_button.set_active ();
|
2013-03-27 21:50:18 -04:00
|
|
|
break;
|
2013-03-28 17:10:57 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
case ForceChannel:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (last_drawn_capture_mode == AllChannels || last_drawn_capture_mode == FilterChannels) {
|
|
|
|
capture_buttons.clear ();
|
2013-07-19 04:40:50 -04:00
|
|
|
first_channel = PBD::ffs (track->get_capture_channel_mask()) - 1;
|
2013-03-28 17:10:57 -04:00
|
|
|
}
|
|
|
|
for (vector<Widget*>::iterator i = capture_mask_controls.begin(); i != capture_mask_controls.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (false);
|
|
|
|
}
|
|
|
|
capture_force_button.set_active ();
|
2013-03-27 21:50:18 -04:00
|
|
|
break;
|
|
|
|
}
|
2013-03-28 17:10:57 -04:00
|
|
|
|
|
|
|
if (capture_buttons.empty()) {
|
|
|
|
|
|
|
|
Gtkmm2ext::container_clear (capture_mask_box);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
ToggleButton* tb;
|
|
|
|
RadioButtonGroup group;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
for (uint32_t n = 0; n < 16; ++n) {
|
|
|
|
char buf[3];
|
|
|
|
snprintf (buf, sizeof (buf), "%d", n+1);
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case AllChannels:
|
|
|
|
case FilterChannels:
|
|
|
|
tb = manage (new ToggleButton (buf));
|
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*tb, string_compose (_("Click to toggle recording of channel %1"), n+1));
|
|
|
|
break;
|
|
|
|
case ForceChannel:
|
|
|
|
tb = manage (new RadioButton (group, buf));
|
|
|
|
tb->property_draw_indicator() = false;
|
|
|
|
if (n == first_channel) {
|
|
|
|
tb->set_active (true);
|
|
|
|
}
|
|
|
|
Gtkmm2ext::UI::instance()->set_tip (*tb, string_compose (_("Click to force all recorded channels to %1"), n+1));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
capture_buttons.push_back (tb);
|
|
|
|
tb->set_name (X_("MidiChannelSelectorButton"));
|
|
|
|
capture_mask_box.pack_start (*tb);
|
|
|
|
tb->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &MidiChannelSelectorWindow::capture_channel_clicked), n));
|
|
|
|
tb->show ();
|
|
|
|
|
|
|
|
if (mode == AllChannels) {
|
|
|
|
tb->set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
if (mode != ForceChannel) {
|
|
|
|
set_capture_selected_channels (track->get_capture_channel_mask());
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2013-03-28 17:10:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == AllChannels) {
|
|
|
|
for (vector<ToggleButton*>::iterator i = capture_buttons.begin(); i != capture_buttons.end(); ++i) {
|
|
|
|
(*i)->set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
capture_mask_changed (); // update buttons
|
2015-11-03 13:16:06 -05:00
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
last_drawn_capture_mode = mode;
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::playback_channel_clicked (uint16_t n)
|
|
|
|
{
|
|
|
|
if (playback_buttons[n]->get_active()) {
|
2013-03-28 17:10:57 -04:00
|
|
|
switch (track->get_playback_channel_mode()) {
|
|
|
|
case AllChannels:
|
|
|
|
break;
|
|
|
|
case FilterChannels:
|
|
|
|
track->set_playback_channel_mask (track->get_playback_channel_mask() | (1<<n));
|
|
|
|
break;
|
|
|
|
case ForceChannel:
|
|
|
|
track->set_playback_channel_mask (1<<n);
|
|
|
|
break;
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
} else {
|
2013-03-28 17:10:57 -04:00
|
|
|
if (track->get_playback_channel_mode() == FilterChannels) {
|
|
|
|
track->set_playback_channel_mask (track->get_playback_channel_mask() & ~(1<<n));
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::capture_channel_clicked (uint16_t n)
|
|
|
|
{
|
|
|
|
if (capture_buttons[n]->get_active()) {
|
2013-03-28 17:10:57 -04:00
|
|
|
switch (track->get_capture_channel_mode()) {
|
|
|
|
case AllChannels:
|
|
|
|
break;
|
|
|
|
case FilterChannels:
|
|
|
|
track->set_capture_channel_mask (track->get_capture_channel_mask() | (1<<n));
|
|
|
|
break;
|
|
|
|
case ForceChannel:
|
|
|
|
track->set_capture_channel_mask (1<<n);
|
|
|
|
break;
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
} else {
|
2013-03-28 17:10:57 -04:00
|
|
|
if (track->get_capture_channel_mode() == FilterChannels) {
|
|
|
|
track->set_capture_channel_mask (track->get_capture_channel_mask() & ~(1<<n));
|
|
|
|
}
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::capture_mode_toggled (ChannelMode mode)
|
|
|
|
{
|
|
|
|
/* this is called twice for every radio button change. the first time
|
|
|
|
is for the button/mode that has been turned off, and the second is for the
|
|
|
|
button/mode that has been turned on.
|
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
so we take action only if the button is active (i.e it is the one
|
|
|
|
just clicked on)
|
2013-03-27 21:50:18 -04:00
|
|
|
*/
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
switch (mode) {
|
|
|
|
case AllChannels:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (capture_all_button.get_active()) {
|
|
|
|
track->set_capture_channel_mode (AllChannels, track->get_capture_channel_mask());
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FilterChannels:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (capture_filter_button.get_active()) {
|
|
|
|
track->set_capture_channel_mode (FilterChannels, track->get_capture_channel_mask());
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ForceChannel:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (capture_force_button.get_active()) {
|
|
|
|
track->set_capture_channel_mode (ForceChannel, track->get_capture_channel_mask());
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::playback_mode_toggled (ChannelMode mode)
|
|
|
|
{
|
|
|
|
/* this is called twice for every radio button change. the first time
|
|
|
|
is for the button/mode that has been turned off, and the second is for the
|
|
|
|
button/mode that has been turned on.
|
|
|
|
|
2013-03-28 17:10:57 -04:00
|
|
|
so we take action only if the button is active (i.e it is the one
|
|
|
|
just clicked on)
|
2013-03-27 21:50:18 -04:00
|
|
|
*/
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
switch (mode) {
|
|
|
|
case AllChannels:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (playback_all_button.get_active()) {
|
|
|
|
track->set_playback_channel_mode (AllChannels, track->get_playback_channel_mask());
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FilterChannels:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (playback_filter_button.get_active()) {
|
|
|
|
track->set_playback_channel_mode (FilterChannels, track->get_playback_channel_mask());
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ForceChannel:
|
2013-03-28 17:10:57 -04:00
|
|
|
if (playback_force_button.get_active()) {
|
|
|
|
track->set_playback_channel_mode (ForceChannel, track->get_playback_channel_mask());
|
2013-03-27 21:50:18 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::set_channel_colors (const uint32_t new_channel_colors[16])
|
|
|
|
{
|
|
|
|
for (uint32_t n = 0; n < 16; ++n) {
|
|
|
|
|
|
|
|
char color_normal[8];
|
|
|
|
char color_active[8];
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-03-27 21:50:18 -04:00
|
|
|
snprintf(color_normal, 8, "#%x", UINT_INTERPOLATE(new_channel_colors[n], 0x000000ff, 0.6));
|
|
|
|
snprintf(color_active, 8, "#%x", new_channel_colors[n]);
|
|
|
|
|
|
|
|
playback_buttons[n]->modify_bg(STATE_NORMAL, Gdk::Color(color_normal));
|
|
|
|
playback_buttons[n]->modify_bg(STATE_ACTIVE, Gdk::Color(color_active));
|
|
|
|
|
|
|
|
capture_buttons[n]->modify_bg(STATE_NORMAL, Gdk::Color(color_normal));
|
|
|
|
capture_buttons[n]->modify_bg(STATE_ACTIVE, Gdk::Color(color_active));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MidiChannelSelectorWindow::set_default_channel_color()
|
|
|
|
{
|
|
|
|
for (uint32_t n = 0; n < 16; ++n) {
|
|
|
|
playback_buttons[n]->unset_fg (STATE_NORMAL);
|
|
|
|
playback_buttons[n]->unset_bg (STATE_NORMAL);
|
|
|
|
playback_buttons[n]->unset_fg (STATE_ACTIVE);
|
|
|
|
playback_buttons[n]->unset_bg (STATE_ACTIVE);
|
|
|
|
|
|
|
|
capture_buttons[n]->unset_fg (STATE_NORMAL);
|
|
|
|
capture_buttons[n]->unset_bg (STATE_NORMAL);
|
|
|
|
capture_buttons[n]->unset_fg (STATE_ACTIVE);
|
|
|
|
capture_buttons[n]->unset_bg (STATE_ACTIVE);
|
|
|
|
}
|
|
|
|
}
|