- switch( type ) {
- case Tracks::MUTE: { // negative logic for normally off
- int total_selected = mwindow->edl->tracks->total() -
- mwindow->edl->tracks->total_of(type);
- int current_output = *output;
- int selected = !total_selected || (total_selected == 1 &&
- !current_output ) ? 0 : 1;
- mwindow->edl->tracks->select_all(type, selected);
- if( selected ) *output = 0;
- break; }
- default: {
- int total_selected = mwindow->edl->tracks->total_of(type);
- int current_output = *output;
- int selected = !total_selected || (total_selected == 1 &&
- current_output ) ? 1 : 0;
- mwindow->edl->tracks->select_all(type, selected);
- if( !selected ) *output = 1;
- break; }
- }
+ int total_type = mwindow->edl->tracks->total_of(type);
+ int total_selected = sense ? total_type :
+ mwindow->edl->tracks->total() - total_type;
+ int selected = !total_selected || (total_selected == 1 &&
+ *output == sense ) ? sense : 1-sense;
+ mwindow->edl->tracks->select_all(type, selected);
+ if( selected != sense ) *output = sense;