* made channel selector look quite nice, see http://www.flickr.com/photos/24012642@N02/2425203856/ (still needs some work...)

git-svn-id: svn://localhost/ardour2/branches/3.0@3268 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-04-19 10:30:38 +00:00
parent 85c223da0d
commit d8adfa49a6
4 changed files with 63 additions and 36 deletions

View File

@ -4,9 +4,11 @@
#include <sstream>
using namespace std;
using namespace Gtk;
using namespace sigc;
MidiChannelSelector::MidiChannelSelector(int no_rows, int no_columns, int start_row, int start_column) :
Gtk::Table(no_rows, no_columns, true)
Table(no_rows, no_columns, true)
{
assert(no_rows >= 4);
assert(no_rows >= start_row + 4);
@ -22,11 +24,11 @@ MidiChannelSelector::MidiChannelSelector(int no_rows, int no_columns, int start_
ostringstream channel;
channel << int(++channel_nr);
_button_labels[row][column].set_text(channel.str());
_button_labels[row][column].set_justify(Gtk::JUSTIFY_RIGHT);
_button_labels[row][column].set_justify(JUSTIFY_RIGHT);
_buttons[row][column].add(_button_labels[row][column]);
_buttons[row][column].signal_toggled().connect(
sigc::bind(
sigc::mem_fun(this, &MidiChannelSelector::button_toggled),
bind(
mem_fun(this, &MidiChannelSelector::button_toggled),
&_buttons[row][column],
channel_nr - 1));
@ -45,14 +47,14 @@ SingleMidiChannelSelector::SingleMidiChannelSelector(uint8_t active_channel)
: MidiChannelSelector()
{
_active_button = 0;
Gtk::ToggleButton *button = &_buttons[active_channel / 4][active_channel % 4];
ToggleButton *button = &_buttons[active_channel / 4][active_channel % 4];
button->set_active(true);
_active_button = button;
_active_channel = active_channel;
}
void
SingleMidiChannelSelector::button_toggled(Gtk::ToggleButton *button, uint8_t channel)
SingleMidiChannelSelector::button_toggled(ToggleButton *button, uint8_t channel)
{
if(button->get_active()) {
if(_active_button) {
@ -65,30 +67,33 @@ SingleMidiChannelSelector::button_toggled(Gtk::ToggleButton *button, uint8_t cha
}
MidiMultipleChannelSelector::MidiMultipleChannelSelector(uint16_t initial_selection)
: MidiChannelSelector(6, 4, 0, 0)
: MidiChannelSelector(4, 6, 0, 0)
{
_select_all.add(*Gtk::manage(new Gtk::Label(_("All"))));
_select_all.add(*manage(new Label(_("All"))));
_select_all.signal_clicked().connect(
sigc::bind(sigc::mem_fun(this, &MidiMultipleChannelSelector::select_all), true));
bind(mem_fun(this, &MidiMultipleChannelSelector::select_all), true));
_select_none.add(*Gtk::manage(new Gtk::Label(_("None"))));
_select_none.add(*manage(new Label(_("None"))));
_select_none.signal_clicked().connect(
sigc::bind(sigc::mem_fun(this, &MidiMultipleChannelSelector::select_all), false));
bind(mem_fun(this, &MidiMultipleChannelSelector::select_all), false));
_invert_selection.add(*Gtk::manage(new Gtk::Label(_("Invert"))));
_invert_selection.add(*manage(new Label(_("Invert"))));
_invert_selection.signal_clicked().connect(
sigc::mem_fun(this, &MidiMultipleChannelSelector::invert_selection));
mem_fun(this, &MidiMultipleChannelSelector::invert_selection));
_force_channel.add(*manage(new Label(_("Force"))));
set_homogeneous(false);
attach(*Gtk::manage(new Gtk::HSeparator()), 0, 4, 4, 5, Gtk::FILL, Gtk::SHRINK, 0, 0);
set_col_spacing(4, -5);
attach(_select_all, 0, 2, 5, 6);
attach(_select_none, 2, 4, 5, 6);
attach(_invert_selection, 0, 4, 6, 7);
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);
_selected_channels = 0;
for(uint16_t i = 0; i < 16; i++) {
Gtk::ToggleButton *button = &_buttons[i / 4][i % 4];
ToggleButton *button = &_buttons[i / 4][i % 4];
if(initial_selection & (1L << i)) {
button->set_active(true);
} else {
@ -98,7 +103,7 @@ MidiMultipleChannelSelector::MidiMultipleChannelSelector(uint16_t initial_select
}
void
MidiMultipleChannelSelector::button_toggled(Gtk::ToggleButton *button, uint8_t channel)
MidiMultipleChannelSelector::button_toggled(ToggleButton *button, uint8_t channel)
{
_selected_channels = _selected_channels ^ (1L << channel);
selection_changed.emit(_selected_channels);
@ -108,7 +113,7 @@ void
MidiMultipleChannelSelector::select_all(bool on)
{
for(uint16_t i = 0; i < 16; i++) {
Gtk::ToggleButton *button = &_buttons[i / 4][i % 4];
ToggleButton *button = &_buttons[i / 4][i % 4];
button->set_active(on);
}
selection_changed.emit(_selected_channels);
@ -118,7 +123,7 @@ void
MidiMultipleChannelSelector::invert_selection(void)
{
for(uint16_t i = 0; i < 16; i++) {
Gtk::ToggleButton *button = &_buttons[i / 4][i % 4];
ToggleButton *button = &_buttons[i / 4][i % 4];
if(button->get_active()) {
button->set_active(false);
} else {

View File

@ -55,6 +55,7 @@ protected:
Gtk::Button _select_all;
Gtk::Button _select_none;
Gtk::Button _invert_selection;
Gtk::ToggleButton _force_channel;
uint16_t _selected_channels;
};

View File

@ -90,6 +90,8 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
, _note_mode(Sustained)
, _note_mode_item(NULL)
, _percussion_mode_item(NULL)
, _channel_selector(0)
, _midi_expander("MIDI")
{
subplugin_menu.set_name ("ArdourContextMenu");
@ -100,18 +102,6 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
mute_button->set_active (false);
solo_button->set_active (false);
// add channel selection button
_channel_selection_button.add(*manage(new Label("c")));
controls_table.property_n_rows() = 3;
controls_table.attach(_channel_selection_button, 1, 2, 2, 3);
_channel_selection_button.show_all();
// add channel selector
controls_vbox.pack_end(_channel_selector);
_channel_selector.selection_changed.connect(
mem_fun(*midi_track()->midi_diskstream(), &MidiDiskstream::set_channel_mask));
_channel_selector.show_all();
if (is_midi_track()) {
controls_ebox.set_name ("MidiTimeAxisViewControlsBaseUnselected");
_note_mode = midi_track()->note_mode();
@ -146,6 +136,18 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
_view->RegionViewAdded.connect (mem_fun(*this, &MidiTimeAxisView::region_view_added));
_view->attach ();
}
// add channel selector
_channel_selector = manage(new MidiMultipleChannelSelector(0xFFFF));
HBox *channel_selector_box = manage(new HBox());
channel_selector_box->pack_start(*_channel_selector, SHRINK, 0);
_midi_expander.add(*channel_selector_box);
_midi_expander.property_expanded().signal_changed().connect(
mem_fun(this, &MidiTimeAxisView::channel_selector_toggled));
controls_vbox.pack_end(_midi_expander, SHRINK, 0);
_channel_selector->selection_changed.connect(
mem_fun(*midi_track()->midi_diskstream(), &MidiDiskstream::set_channel_mask));
}
MidiTimeAxisView::~MidiTimeAxisView ()
@ -382,3 +384,20 @@ MidiTimeAxisView::route_active_changed ()
}
}
}
void
MidiTimeAxisView::channel_selector_toggled()
{
static TimeAxisView::TrackHeight previous_height;
assert(_channel_selector);
if(_midi_expander.property_expanded()) {
previous_height = height_style;
if(previous_height != TimeAxisView::Largest) {
TimeAxisView::set_height(TimeAxisView::Large);
}
} else {
TimeAxisView::set_height(previous_height);
}
}

View File

@ -87,6 +87,8 @@ class MidiTimeAxisView : public RouteTimeAxisView
void add_insert_to_subplugin_menu (ARDOUR::Processor *);
void channel_selector_toggled();
Gtk::Menu _subplugin_menu;
MidiScroomer* _range_scroomer;
@ -94,8 +96,8 @@ class MidiTimeAxisView : public RouteTimeAxisView
ARDOUR::NoteMode _note_mode;
Gtk::RadioMenuItem* _note_mode_item;
Gtk::RadioMenuItem* _percussion_mode_item;
Gtk::ToggleButton _channel_selection_button;
MidiMultipleChannelSelector _channel_selector;
Gtk::Expander _midi_expander;
MidiMultipleChannelSelector* _channel_selector;
};
#endif /* __ardour_midi_time_axis_h__ */