1 #include "midi_channel_selector.h"
6 MidiChannelSelector::MidiChannelSelector() :
9 property_column_spacing() = 0;
10 property_row_spacing() = 0;
12 uint8_t channel_nr = 0;
13 for(int row = 0; row < 4; ++row) {
14 for(int column = 0; column < 4; ++column) {
15 ostringstream channel;
16 channel << int(++channel_nr);
17 _button_labels[row][column].set_text(channel.str());
18 _button_labels[row][column].set_justify(Gtk::JUSTIFY_RIGHT);
19 _buttons[row][column].add(_button_labels[row][column]);
20 _buttons[row][column].signal_toggled().connect(
22 sigc::mem_fun(this, &MidiChannelSelector::button_toggled),
23 &_buttons[row][column],
25 attach(_buttons[row][column], column, column + 1, row, row + 1);
30 MidiChannelSelector::~MidiChannelSelector()
34 SingleMidiChannelSelector::SingleMidiChannelSelector(uint8_t active_channel)
35 : MidiChannelSelector()
38 Gtk::ToggleButton *button = &_buttons[active_channel / 4][active_channel % 4];
39 button->set_active(true);
40 _active_button = button;
41 _active_channel = active_channel;
45 SingleMidiChannelSelector::button_toggled(Gtk::ToggleButton *button, uint8_t channel)
47 if(button->get_active()) {
49 _active_button->set_active(false);
51 _active_button = button;
52 _active_channel = channel;
53 channel_selected.emit(channel);
58 MidiMultipleChannelSelector::button_toggled(Gtk::ToggleButton *button, uint8_t channel)
60 if(button->get_active()) {
61 _selected_channels.insert(channel);
63 _selected_channels.erase(channel);