projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rename join regions op as combine regions; save and restore nested playlists, sources...
[ardour.git]
/
gtk2_ardour
/
midi_channel_selector.cc
diff --git
a/gtk2_ardour/midi_channel_selector.cc
b/gtk2_ardour/midi_channel_selector.cc
index 4415a65f6539ee6fabbf29940d67295cc7c0bf68..cdaf42e51f7c327125a787c6b51fee4eeedb7eeb 100644
(file)
--- a/
gtk2_ardour/midi_channel_selector.cc
+++ b/
gtk2_ardour/midi_channel_selector.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2008 Paul Davis
+ Copyright (C) 2008 Paul Davis
Author: Hans Baier
This program is free software; you can redistribute it and/or modify
Author: Hans Baier
This program is free software; you can redistribute it and/or modify
@@
-25,20
+25,20
@@
using namespace std;
using namespace Gtk;
using namespace std;
using namespace Gtk;
-using namespace sigc;
using namespace ARDOUR;
using namespace ARDOUR;
-MidiChannelSelector::MidiChannelSelector(int no_rows, int no_columns, int start_row, int start_column) : Table(no_rows, no_columns, true)
- , _recursion_counter(0)
-{
- assert(no_rows >= 4);
- assert(no_rows >= start_row + 4);
- assert(no_columns >=4);
- assert(no_columns >= start_column + 4);
-
+MidiChannelSelector::MidiChannelSelector(int n_rows, int n_columns, int start_row, int start_column)
+ : Table(n_rows, n_columns, true)
+ , _recursion_counter(0)
+{
+ assert(n_rows >= 4);
+ assert(n_rows >= start_row + 4);
+ assert(n_columns >=4);
+ assert(n_columns >= start_column + 4);
+
property_column_spacing() = 0;
property_row_spacing() = 0;
property_column_spacing() = 0;
property_row_spacing() = 0;
-
+
uint8_t channel_nr = 0;
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
uint8_t channel_nr = 0;
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
@@
-48,10
+48,14
@@
MidiChannelSelector::MidiChannelSelector(int no_rows, int no_columns, int start_
_button_labels[row][column].set_justify(JUSTIFY_RIGHT);
_buttons[row][column].add(_button_labels[row][column]);
_buttons[row][column].signal_toggled().connect(
_button_labels[row][column].set_justify(JUSTIFY_RIGHT);
_buttons[row][column].add(_button_labels[row][column]);
_buttons[row][column].signal_toggled().connect(
- bind(
- mem_fun(this, &MidiChannelSelector::button_toggled),
+
sigc::
bind(
+
sigc::
mem_fun(this, &MidiChannelSelector::button_toggled),
&_buttons[row][column],
channel_nr - 1));
&_buttons[row][column],
channel_nr - 1));
+ _buttons[row][column].set_widget_name (X_("MidiChannelSelectorButton"));
+
+ _buttons[row][column].signal_button_release_event().connect(
+ sigc::mem_fun(this, &MidiChannelSelector::was_clicked), false);
int table_row = start_row + row;
int table_column = start_column + column;
int table_row = start_row + row;
int table_column = start_column + column;
@@
-64,6
+68,13
@@
MidiChannelSelector::~MidiChannelSelector()
{
}
{
}
+bool
+MidiChannelSelector::was_clicked (GdkEventButton*)
+{
+ clicked ();
+ return false;
+}
+
void
MidiChannelSelector::set_channel_colors(const uint32_t new_channel_colors[16])
{
void
MidiChannelSelector::set_channel_colors(const uint32_t new_channel_colors[16])
{
@@
-84,8
+95,10
@@
MidiChannelSelector::set_default_channel_color()
{
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
{
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
- _buttons[row][column].unset_bg(STATE_NORMAL);
- _buttons[row][column].unset_bg(STATE_ACTIVE);
+ _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);
}
}
}
}
}
}
@@
-102,10
+115,10
@@
SingleMidiChannelSelector::SingleMidiChannelSelector(uint8_t active_channel)
void
SingleMidiChannelSelector::button_toggled(ToggleButton* button, uint8_t channel)
void
SingleMidiChannelSelector::button_toggled(ToggleButton* button, uint8_t channel)
-{
+{
++_recursion_counter;
if (_recursion_counter == 1) {
++_recursion_counter;
if (_recursion_counter == 1) {
- // if the current button is active it must
+ // if the current button is active it must
// be different from the first one
if (button->get_active()) {
if (_last_active_button) {
// be different from the first one
if (button->get_active()) {
if (_last_active_button) {
@@
-129,19
+142,19
@@
MidiMultipleChannelSelector::MidiMultipleChannelSelector(ChannelMode mode, uint1
{
_select_all.add(*manage(new Label(_("All"))));
_select_all.signal_clicked().connect(
{
_select_all.add(*manage(new Label(_("All"))));
_select_all.signal_clicked().connect(
-
bind(
mem_fun(this, &MidiMultipleChannelSelector::select_all), true));
-
+
sigc::bind(sigc::
mem_fun(this, &MidiMultipleChannelSelector::select_all), true));
+
_select_none.add(*manage(new Label(_("None"))));
_select_none.signal_clicked().connect(
_select_none.add(*manage(new Label(_("None"))));
_select_none.signal_clicked().connect(
-
bind(
mem_fun(this, &MidiMultipleChannelSelector::select_all), false));
-
+
sigc::bind(sigc::
mem_fun(this, &MidiMultipleChannelSelector::select_all), false));
+
_invert_selection.add(*manage(new Label(_("Invert"))));
_invert_selection.signal_clicked().connect(
_invert_selection.add(*manage(new Label(_("Invert"))));
_invert_selection.signal_clicked().connect(
- mem_fun(this, &MidiMultipleChannelSelector::invert_selection));
-
+
sigc::
mem_fun(this, &MidiMultipleChannelSelector::invert_selection));
+
_force_channel.add(*manage(new Label(_("Force"))));
_force_channel.signal_toggled().connect(
_force_channel.add(*manage(new Label(_("Force"))));
_force_channel.signal_toggled().connect(
- mem_fun(this, &MidiMultipleChannelSelector::force_channels_button_toggled));
+
sigc::
mem_fun(this, &MidiMultipleChannelSelector::force_channels_button_toggled));
set_homogeneous(false);
attach(*manage(new VSeparator()), 4, 5, 0, 4, SHRINK, FILL, 0, 0);
set_homogeneous(false);
attach(*manage(new VSeparator()), 4, 5, 0, 4, SHRINK, FILL, 0, 0);
@@
-150,7
+163,7
@@
MidiMultipleChannelSelector::MidiMultipleChannelSelector(ChannelMode mode, uint1
attach(_select_none, 5, 6, 1, 2);
attach(_invert_selection, 5, 6, 2, 3);
attach(_force_channel, 5, 6, 3, 4);
attach(_select_none, 5, 6, 1, 2);
attach(_invert_selection, 5, 6, 2, 3);
attach(_force_channel, 5, 6, 3, 4);
-
+
set_selected_channels(mask);
}
set_selected_channels(mask);
}
@@
-160,7
+173,7
@@
MidiMultipleChannelSelector::~MidiMultipleChannelSelector()
}
void
}
void
-MidiMultipleChannelSelector::set_channel_mode(ChannelMode mode, uint
8
_t mask)
+MidiMultipleChannelSelector::set_channel_mode(ChannelMode mode, uint
16
_t mask)
{
switch (mode) {
case AllChannels:
{
switch (mode) {
case AllChannels:
@@
-180,21
+193,21
@@
MidiMultipleChannelSelector::set_channel_mode(ChannelMode mode, uint8_t mask)
}
}
}
}
-const uint16_t
-MidiMultipleChannelSelector::get_selected_channels() const
-{
+uint16_t
+MidiMultipleChannelSelector::get_selected_channels() const
+{
uint16_t selected_channels = 0;
for (uint16_t i = 0; i < 16; i++) {
const ToggleButton* button = &_buttons[i / 4][i % 4];
if (button->get_active()) {
selected_channels |= (1L << i);
uint16_t selected_channels = 0;
for (uint16_t i = 0; i < 16; i++) {
const ToggleButton* button = &_buttons[i / 4][i % 4];
if (button->get_active()) {
selected_channels |= (1L << i);
- }
+ }
}
}
-
- return selected_channels;
+
+ return selected_channels;
}
}
-void
+void
MidiMultipleChannelSelector::set_selected_channels(uint16_t selected_channels)
{
for (uint16_t i = 0; i < 16; i++) {
MidiMultipleChannelSelector::set_selected_channels(uint16_t selected_channels)
{
for (uint16_t i = 0; i < 16; i++) {
@@
-208,7
+221,7
@@
MidiMultipleChannelSelector::set_selected_channels(uint16_t selected_channels)
}
void
}
void
-MidiMultipleChannelSelector::button_toggled(ToggleButton *
button
, uint8_t channel)
+MidiMultipleChannelSelector::button_toggled(ToggleButton *
/*button*/
, uint8_t channel)
{
++_recursion_counter;
if (_recursion_counter == 1) {
{
++_recursion_counter;
if (_recursion_counter == 1) {
@@
-222,7
+235,7
@@
MidiMultipleChannelSelector::button_toggled(ToggleButton *button, uint8_t channe
--_recursion_counter;
}
--_recursion_counter;
}
-void
+void
MidiMultipleChannelSelector::force_channels_button_toggled()
{
if (_force_channel.get_active()) {
MidiMultipleChannelSelector::force_channels_button_toggled()
{
if (_force_channel.get_active()) {
@@
-241,13
+254,13
@@
MidiMultipleChannelSelector::force_channels_button_toggled()
found_first_active = true;
active_channel = i;
}
found_first_active = true;
active_channel = i;
}
- }
+ }
}
}
-
+
if (!found_first_active) {
_buttons[0][0].set_active(true);
}
if (!found_first_active) {
_buttons[0][0].set_active(true);
}
-
+
_select_all.set_sensitive(false);
_select_none.set_sensitive(false);
_invert_selection.set_sensitive(false);
_select_all.set_sensitive(false);
_select_none.set_sensitive(false);
_invert_selection.set_sensitive(false);
@@
-261,7
+274,7
@@
MidiMultipleChannelSelector::force_channels_button_toggled()
}
}
}
}
-void
+void
MidiMultipleChannelSelector::select_all(bool on)
{
if (_channel_mode == ForceChannel)
MidiMultipleChannelSelector::select_all(bool on)
{
if (_channel_mode == ForceChannel)
@@
-276,7
+289,7
@@
MidiMultipleChannelSelector::select_all(bool on)
mode_changed.emit(_channel_mode, get_selected_channels());
}
mode_changed.emit(_channel_mode, get_selected_channels());
}
-void
+void
MidiMultipleChannelSelector::invert_selection(void)
{
if (_channel_mode == ForceChannel)
MidiMultipleChannelSelector::invert_selection(void)
{
if (_channel_mode == ForceChannel)