X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_ops.cc;h=b70d0f06647ec4088b86be5c501061515b7091ad;hb=6e661e734b5910f80895acdda50443f837a7cab2;hp=1dbad3ac2e34c73a2363cf7bbf57a88dea5ef6ae;hpb=64425f77e71833d913a5834ed13354b4199c40d2;p=ardour.git diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 1dbad3ac2e..b70d0f0664 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -44,17 +44,16 @@ #include "ardour/dB.h" #include "ardour/location.h" #include "ardour/midi_region.h" +#include "ardour/midi_track.h" #include "ardour/operations.h" #include "ardour/playlist_factory.h" #include "ardour/quantize.h" #include "ardour/region_factory.h" #include "ardour/reverse.h" -#include "ardour/route_group.h" #include "ardour/session.h" #include "ardour/session_playlists.h" #include "ardour/strip_silence.h" #include "ardour/transient_detector.h" -#include "ardour/utils.h" #include "ardour_ui.h" #include "debug.h" @@ -63,6 +62,7 @@ #include "route_time_axis.h" #include "audio_time_axis.h" #include "automation_time_axis.h" +#include "control_point.h" #include "streamview.h" #include "audio_streamview.h" #include "audio_region_view.h" @@ -1278,11 +1278,17 @@ Editor::scroll_tracks_up_line () void Editor::tav_zoom_step (bool coarser) { - ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser) - _routes->suspend_redisplay (); - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + TrackViewList* ts; + + if (selection->tracks.empty()) { + ts = &track_views; + } else { + ts = &selection->tracks; + } + + for (TrackViewList::iterator i = ts->begin(); i != ts->end(); ++i) { TimeAxisView *tv = (static_cast(*i)); tv->step_height (coarser); } @@ -1290,28 +1296,78 @@ Editor::tav_zoom_step (bool coarser) _routes->resume_redisplay (); } +void +Editor::tav_zoom_smooth (bool coarser, bool force_all) +{ + _routes->suspend_redisplay (); + + TrackViewList* ts; + + if (selection->tracks.empty() || force_all) { + ts = &track_views; + } else { + ts = &selection->tracks; + } + + for (TrackViewList::iterator i = ts->begin(); i != ts->end(); ++i) { + TimeAxisView *tv = (static_cast(*i)); + uint32_t h = tv->current_height (); + + if (coarser) { + if (h > 5) { + h -= 5; // pixels + if (h >= TimeAxisView::preset_height (HeightSmall)) { + tv->set_height (h); + } + } + } else { + tv->set_height (h + 5); + } + } + + _routes->resume_redisplay (); +} + +bool +Editor::clamp_frames_per_unit (double& fpu) const +{ + bool clamped = false; + + if (fpu < 2.0) { + fpu = 2.0; + clamped = true; + } + + if (max_framepos / fpu < 800) { + fpu = max_framepos / 800.0; + clamped = true; + } + + return clamped; +} + void Editor::temporal_zoom_step (bool coarser) { ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser) - double nfpu; - - nfpu = frames_per_unit; + double nfpu = frames_per_unit; if (coarser) { - nfpu *= 1.61803399; + nfpu = min (9e6, nfpu * 1.61803399); } else { - nfpu = max(1.0,(nfpu/1.61803399)); + nfpu = max (1.0, nfpu / 1.61803399); } temporal_zoom (nfpu); } void -Editor::temporal_zoom (gdouble fpu) +Editor::temporal_zoom (double fpu) { - if (!_session) return; + if (!_session) { + return; + } framepos_t current_page = current_page_frames(); framepos_t current_leftmost = leftmost_frame; @@ -1325,13 +1381,19 @@ Editor::temporal_zoom (gdouble fpu) double nfpu; double l; - /* XXX this limit is also in ::set_frames_per_unit() */ - - if (frames_per_unit <= 1.0 && fpu <= frames_per_unit) { + clamp_frames_per_unit (fpu); + if (fpu == frames_per_unit) { return; } nfpu = fpu; + + // Imposing an arbitrary limit to zoom out as too much zoom out produces + // segfaults for lack of memory. If somebody decides this is not high enough I + // believe it can be raisen to higher values but some limit must be in place. + if (nfpu > 8e+08) { + nfpu = 8e+08; + } new_page_size = (framepos_t) floor (_canvas_width * nfpu); half_page_size = new_page_size / 2; @@ -1785,13 +1847,13 @@ Editor::jump_forward_to_mark () return; } - Location *location = _session->locations()->first_location_after (playhead_cursor->current_frame); + framepos_t pos = _session->locations()->first_mark_after (playhead_cursor->current_frame); - if (location) { - _session->request_locate (location->start(), _session->transport_rolling()); - } else { - _session->request_locate (_session->current_end_frame()); + if (pos < 0) { + return; } + + _session->request_locate (pos, _session->transport_rolling()); } void @@ -1801,13 +1863,13 @@ Editor::jump_backward_to_mark () return; } - Location *location = _session->locations()->first_location_before (playhead_cursor->current_frame); + framepos_t pos = _session->locations()->first_mark_before (playhead_cursor->current_frame); - if (location) { - _session->request_locate (location->start(), _session->transport_rolling()); - } else { - _session->goto_start (); + if (pos < 0) { + return; } + + _session->request_locate (pos, _session->transport_rolling()); } void @@ -2045,7 +2107,7 @@ Editor::transition_to_rolling (bool fwd) } if (_session->config.get_external_sync()) { - switch (_session->config.get_sync_source()) { + switch (Config->get_sync_source()) { case JACK: break; default: @@ -2108,6 +2170,55 @@ Editor::play_selection () _session->request_play_range (&selection->time, true); } +framepos_t +Editor::get_preroll () +{ + return 1.0 /*Config->get_edit_preroll_seconds()*/ * _session->frame_rate(); +} + + +void +Editor::maybe_locate_with_edit_preroll ( framepos_t location ) +{ + if ( _session->transport_rolling() || !Config->get_always_play_range() ) + return; + + location -= get_preroll(); + + //don't try to locate before the beginning of time + if ( location < 0 ) + location = 0; + + //if follow_playhead is on, keep the playhead on the screen + if ( _follow_playhead ) + if ( location < leftmost_frame ) + location = leftmost_frame; + + _session->request_locate( location ); +} + +void +Editor::play_with_preroll () +{ + if (selection->time.empty()) { + return; + } else { + framepos_t preroll = get_preroll(); + + framepos_t start = 0; + if (selection->time[clicked_selection].start > preroll) + start = selection->time[clicked_selection].start - preroll; + + framepos_t end = selection->time[clicked_selection].end + preroll; + + AudioRange ar (start, end, 0); + list lar; + lar.push_back (ar); + + _session->request_play_range (&lar, true); + } +} + void Editor::play_location (Location& location) { @@ -2272,7 +2383,6 @@ Editor::rename_region () d.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); d.set_size_request (300, -1); - d.set_position (Gtk::WIN_POS_MOUSE); entry.set_text (rs.front()->region()->name()); entry.select_region (0, -1); @@ -2472,7 +2582,7 @@ static void add_if_covered (RegionView* rv, const AudioRange* ar, RegionSelection* rs) { switch (rv->region()->coverage (ar->start, ar->end - 1)) { - case OverlapNone: + case Evoral::OverlapNone: break; default: rs->push_back (rv); @@ -2615,7 +2725,7 @@ Editor::separate_region_from_selection () returns a single range. */ - if (mouse_mode == MouseRange && !selection->time.empty()) { + if (!selection->time.empty()) { separate_regions_between (selection->time); @@ -3163,15 +3273,10 @@ Editor::trim_region (bool front) framepos_t where = get_preferred_edit_position(); RegionSelection rs = get_regions_from_selection_and_edit_point (); - cerr << "trim regions\n"; - if (rs.empty()) { - cerr << " no regions\n"; return; } - cerr << "where = " << where << endl; - begin_reversible_command (front ? _("trim front") : _("trim back")); for (list::const_iterator i = rs.by_layer().begin(); i != rs.by_layer().end(); ++i) { @@ -3181,8 +3286,10 @@ Editor::trim_region (bool front) if (front) { (*i)->region()->trim_front (where); + maybe_locate_with_edit_preroll ( where ); } else { (*i)->region()->trim_end (where); + maybe_locate_with_edit_preroll ( where ); } _session->add_command (new StatefulDiffCommand ((*i)->region())); @@ -3225,7 +3332,7 @@ Editor::trim_region_to_location (const Location& loc, const char* str) /* require region to span proposed trim */ switch (rv->region()->coverage (loc.start(), loc.end())) { - case OverlapInternal: + case Evoral::OverlapInternal: break; default: continue; @@ -3354,10 +3461,10 @@ Editor::freeze_thread () /* create event pool because we may need to talk to the session */ SessionEvent::create_per_thread_pool ("freeze events", 64); /* create per-thread buffers for process() tree to use */ - current_interthread_info->process_thread.init (); - + current_interthread_info->process_thread.get_buffers (); clicked_routeview->audio_track()->freeze_me (*current_interthread_info); current_interthread_info->done = true; + current_interthread_info->process_thread.drop_buffers(); return 0; } @@ -3444,7 +3551,7 @@ Editor::bounce_range_selection (bool replace, bool enable_processing) if (rtv && rtv->track() && replace && enable_processing && !rtv->track()->bounceable (rtv->track()->main_outs(), false)) { MessageDialog d ( _("You can't perform this operation because the processing of the signal " - "will cause one or more of the tracks will end up with a region with more channels than this track has inputs.\n\n" + "will cause one or more of the tracks to end up with a region with more channels than this track has inputs.\n\n" "You can do this without processing, which is a different operation.") ); d.set_title (_("Cannot bounce")); @@ -3534,7 +3641,7 @@ Editor::copy () bool Editor::can_cut_copy () const { - switch (current_mouse_mode()) { + switch (effective_mouse_mode()) { case MouseObject: if (!selection->regions.empty() || !selection->points.empty()) { @@ -3593,7 +3700,8 @@ Editor::cut_copy (CutCopyOp op) } } - cut_buffer->clear (); + if ( op != Clear ) //"Delete" doesn't change copy/paste buf + cut_buffer->clear (); if (entered_marker) { @@ -3612,7 +3720,7 @@ Editor::cut_copy (CutCopyOp op) if (internal_editing()) { - switch (current_mouse_mode()) { + switch (effective_mouse_mode()) { case MouseObject: case MouseRange: cut_copy_midi (op); @@ -3623,19 +3731,62 @@ Editor::cut_copy (CutCopyOp op) } else { - RegionSelection rs; + RegionSelection rs; - /* we only want to cut regions if some are selected */ + /* we only want to cut regions if some are selected */ - if (doing_object_stuff()) { - rs = get_regions_from_selection (); - if (!rs.empty() || !selection->points.empty()) { + if (!selection->regions.empty()) { + rs = selection->regions; + } + switch (effective_mouse_mode()) { +/* + * case MouseGain: { + //find regions's gain line + AudioRegionView *rview = dynamic_cast(clicked_regionview); + AutomationTimeAxisView *tview = dynamic_cast(clicked_trackview); + if (rview) { + AudioRegionGainLine *line = rview->get_gain_line(); + if (!line) break; + + //cut region gain points in the selection + AutomationList& alist (line->the_list()); + XMLNode &before = alist.get_state(); + AutomationList* what_we_got = 0; + if ((what_we_got = alist.cut (selection->time.front().start - rview->audio_region()->position(), selection->time.front().end - rview->audio_region()->position())) != 0) { + session->add_command(new MementoCommand(alist, &before, &alist.get_state())); + delete what_we_got; + what_we_got = 0; + } + + rview->set_envelope_visible(true); + rview->audio_region()->set_envelope_active(true); + + } else if (tview) { + AutomationLine *line = *(tview->lines.begin()); + if (!line) break; + + //cut auto points in the selection + AutomationList& alist (line->the_list()); + XMLNode &before = alist.get_state(); + AutomationList* what_we_got = 0; + if ((what_we_got = alist.cut (selection->time.front().start, selection->time.front().end)) != 0) { + session->add_command(new MementoCommand(alist, &before, &alist.get_state())); + delete what_we_got; + what_we_got = 0; + } + } else + break; + } break; +*/ + case MouseObject: + case MouseRange: + if (!rs.empty() || !selection->points.empty()) { begin_reversible_command (opname + _(" objects")); if (!rs.empty()) { cut_copy_regions (op, rs); - + if (op == Cut || op == Delete) { selection->clear_regions (); } @@ -3648,16 +3799,11 @@ Editor::cut_copy (CutCopyOp op) selection->clear_points (); } } - commit_reversible_command (); - goto out; - } - if (!selection->time.empty() && (_join_object_range_state == JOIN_OBJECT_RANGE_NONE)) { - /* don't cause suprises */ - goto out; - } - } - if (doing_range_stuff()) { + commit_reversible_command (); + break; + } + if (selection->time.empty()) { framepos_t start, end; if (!get_edit_op_range (start, end)) { @@ -3665,36 +3811,108 @@ Editor::cut_copy (CutCopyOp op) } selection->set (start, end); } - + begin_reversible_command (opname + _(" range")); cut_copy_ranges (op); commit_reversible_command (); - + if (op == Cut || op == Delete) { selection->clear_time (); } + + break; + + default: + break; } } - out: if (op == Delete || op == Cut || op == Clear) { _drags->abort (); } } +struct AutomationRecord { + AutomationRecord () : state (0) {} + AutomationRecord (XMLNode* s) : state (s) {} + + XMLNode* state; ///< state before any operation + boost::shared_ptr copy; ///< copied events for the cut buffer +}; + /** Cut, copy or clear selected automation points. - * @param op Operation (Cut, Copy or Clear) + * @param op Operation (Cut, Copy or Clear) */ void Editor::cut_copy_points (CutCopyOp op) { + if (selection->points.empty ()) { + return; + } + + /* XXX: not ideal, as there may be more than one track involved in the point selection */ + _last_cut_copy_source_track = &selection->points.front()->line().trackview; + + /* Keep a record of the AutomationLists that we end up using in this operation */ + typedef std::map, AutomationRecord> Lists; + Lists lists; + + /* Go through all selected points, making an AutomationRecord for each distinct AutomationList */ for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) { + boost::shared_ptr al = (*i)->line().the_list(); + if (lists.find (al) == lists.end ()) { + /* We haven't seen this list yet, so make a record for it. This includes + taking a copy of its current state, in case this is needed for undo later. + */ + lists[al] = AutomationRecord (&al->get_state ()); + } + } - AutomationTimeAxisView* atv = dynamic_cast((*i).track); - _last_cut_copy_source_track = atv; + if (op == Cut || op == Copy) { + /* This operation will involve putting things in the cut buffer, so create an empty + ControlList for each of our source lists to put the cut buffer data in. + */ + for (Lists::iterator i = lists.begin(); i != lists.end(); ++i) { + i->second.copy = i->first->create (i->first->parameter ()); + } - if (atv) { - atv->cut_copy_clear_objects (selection->points, op); + /* Add all selected points to the relevant copy ControlLists */ + for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) { + boost::shared_ptr al = (*i)->line().the_list(); + AutomationList::const_iterator j = (*i)->model (); + lists[al].copy->add ((*j)->when, (*j)->value); + } + + for (Lists::iterator i = lists.begin(); i != lists.end(); ++i) { + /* Correct this copy list so that it starts at time 0 */ + double const start = i->second.copy->front()->when; + for (AutomationList::iterator j = i->second.copy->begin(); j != i->second.copy->end(); ++j) { + (*j)->when -= start; + } + + /* And add it to the cut buffer */ + cut_buffer->add (i->second.copy); + } + } + + if (op == Delete || op == Cut) { + /* This operation needs to remove things from the main AutomationList, so do that now */ + + for (Lists::iterator i = lists.begin(); i != lists.end(); ++i) { + i->first->freeze (); + } + + /* Remove each selected point from its AutomationList */ + for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) { + boost::shared_ptr al = (*i)->line().the_list(); + al->erase ((*i)->model ()); + } + + /* Thaw the lists and add undo records for them */ + for (Lists::iterator i = lists.begin(); i != lists.end(); ++i) { + boost::shared_ptr al = i->first; + al->thaw (); + _session->add_command (new MementoCommand (*al.get(), i->second.state, &(al->get_state ()))); } } } @@ -4063,12 +4281,15 @@ Editor::paste_internal (framepos_t position, float times) /* get everything in the correct order */ - if (!selection->tracks.empty()) { - /* there are some selected tracks, so paste to them */ + if (_edit_point == Editing::EditAtMouse && entered_track) { + /* With the mouse edit point, paste onto the track under the mouse */ + ts.push_back (entered_track); + } else if (!selection->tracks.empty()) { + /* Otherwise, if there are some selected tracks, paste to them */ ts = selection->tracks.filter_to_unique_playlists (); sort_track_selection (ts); } else if (_last_cut_copy_source_track) { - /* otherwise paste to the track that the cut/copy came from; + /* Otherwise paste to the track that the cut/copy came from; see discussion in mantis #3333. */ ts.push_back (_last_cut_copy_source_track); @@ -4190,18 +4411,13 @@ Editor::duplicate_selection (float times) commit_reversible_command (); } +/** Reset all selected points to the relevant default value */ void Editor::reset_point_selection () { - /* reset all selected points to the relevant default value */ - for (PointSelection::iterator i = selection->points.begin(); i != selection->points.end(); ++i) { - - AutomationTimeAxisView* atv = dynamic_cast((*i).track); - - if (atv) { - atv->reset_objects (selection->points); - } + ARDOUR::AutomationList::iterator j = (*i)->model (); + (*j)->value = (*i)->line().the_list()->default_value (); } } @@ -4605,8 +4821,7 @@ Editor::quantize_region () qd->hide (); if (r == Gtk::RESPONSE_OK) { - Quantize quant (*_session, Plain, - qd->snap_start(), qd->snap_end(), + Quantize quant (*_session, qd->snap_start(), qd->snap_end(), qd->start_grid_size(), qd->end_grid_size(), qd->strength(), qd->swing(), qd->threshold()); @@ -4625,8 +4840,14 @@ Editor::insert_patch_change (bool from_context) const framepos_t p = get_preferred_edit_position (false, from_context); + /* XXX: bit of a hack; use the MIDNAM from the first selected region; + there may be more than one, but the PatchChangeDialog can only offer + one set of patch menus. + */ + MidiRegionView* first = dynamic_cast (rs.front ()); + Evoral::PatchChange empty (0, 0, 0, 0); - PatchChangeDialog d (0, _session, empty, Gtk::Stock::ADD); + PatchChangeDialog d (0, _session, empty, first->instrument_info(), Gtk::Stock::ADD); if (d.run() == RESPONSE_CANCEL) { return; @@ -4756,16 +4977,16 @@ Editor::reset_region_gain_envelopes () } void -Editor::set_region_gain_visibility (RegionView* rv, bool yn) +Editor::set_region_gain_visibility (RegionView* rv) { AudioRegionView* arv = dynamic_cast (rv); if (arv) { - arv->set_envelope_visible (yn); + arv->update_envelope_visibility(); } } void -Editor::set_gain_envelope_visibility (bool yn) +Editor::set_gain_envelope_visibility () { if (!_session) { return; @@ -4774,7 +4995,7 @@ Editor::set_gain_envelope_visibility (bool yn) for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { AudioTimeAxisView* v = dynamic_cast(*i); if (v) { - v->audio_view()->foreach_regionview (sigc::bind (sigc::mem_fun (this, &Editor::set_region_gain_visibility), yn)); + v->audio_view()->foreach_regionview (sigc::mem_fun (this, &Editor::set_region_gain_visibility)); } } } @@ -4830,6 +5051,30 @@ Editor::toggle_region_lock () _session->commit_reversible_command (); } +void +Editor::toggle_region_video_lock () +{ + if (_ignore_region_action) { + return; + } + + RegionSelection rs = get_regions_from_selection_and_entered (); + + if (!_session || rs.empty()) { + return; + } + + _session->begin_reversible_command (_("Toggle Video Lock")); + + for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { + (*i)->region()->clear_changes (); + (*i)->region()->set_video_locked (!(*i)->region()->video_locked()); + _session->add_command (new StatefulDiffCommand ((*i)->region())); + } + + _session->commit_reversible_command (); +} + void Editor::toggle_region_lock_style () { @@ -5147,6 +5392,10 @@ Editor::set_fade_out_active (bool yn) void Editor::toggle_region_fades (int dir) { + if (_ignore_region_action) { + return; + } + boost::shared_ptr ar; bool yn = false; @@ -5207,24 +5456,6 @@ Editor::update_region_fade_visibility () } } -/** Update crossfade visibility after its configuration has been changed */ -void -Editor::update_xfade_visibility () -{ - _xfade_visibility = _session->config.get_xfades_visible (); - - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - AudioTimeAxisView* v = dynamic_cast(*i); - if (v) { - if (_xfade_visibility) { - v->show_all_xfades (); - } else { - v->hide_all_xfades (); - } - } - } -} - void Editor::set_edit_point () { @@ -5271,14 +5502,15 @@ Editor::set_playhead_cursor () _session->request_locate (where, _session->transport_rolling()); } } + + if ( Config->get_always_play_range() ) + cancel_time_selection(); } void Editor::split_region () { - if (((mouse_mode == MouseRange) || - (mouse_mode != MouseObject && _join_object_range_state == JOIN_OBJECT_RANGE_RANGE)) && - !selection->time.empty()) { + if ( !selection->time.empty()) { separate_regions_between (selection->time); return; } @@ -5294,28 +5526,9 @@ Editor::split_region () split_regions_at (where, rs); } -void -Editor::ensure_entered_track_selected (bool op_really_wants_one_track_if_none_are_selected) -{ - if (entered_track && mouse_mode == MouseObject) { - if (!selection->tracks.empty()) { - if (!selection->selected (entered_track)) { - selection->add (entered_track); - } - } else { - /* there is no selection, but this operation requires/prefers selected objects */ - - if (op_really_wants_one_track_if_none_are_selected) { - selection->set (entered_track); - } - } - } -} - struct EditorOrderRouteSorter { bool operator() (boost::shared_ptr a, boost::shared_ptr b) { - /* use of ">" forces the correct sort order */ - return a->order_key ("editor") < b->order_key ("editor"); + return a->order_key (EditorSort) < b->order_key (EditorSort); } }; @@ -5680,7 +5893,9 @@ Editor::define_one_bar (framepos_t start, framepos_t end) } else if (t.frame() == start) { _session->tempo_map().change_existing_tempo_at (start, beats_per_minute, t.note_type()); } else { - _session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), start); + Timecode::BBT_Time bbt; + _session->tempo_map().bbt_time (start, bbt); + _session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), bbt); } XMLNode& after (_session->tempo_map().get_state()); @@ -5835,6 +6050,10 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList plist.add (ARDOUR::Properties::layer, 0); boost::shared_ptr nr = RegionFactory::create (r->sources(), plist, false); + /* because we set annouce to false, manually add the new region to the + RegionFactory map + */ + RegionFactory::map_add (nr); pl->add_region (nr, r->position() + pos); @@ -5859,6 +6078,10 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList plist.add (ARDOUR::Properties::layer, 0); boost::shared_ptr nr = RegionFactory::create (r->sources(), plist, false); + /* because we set annouce to false, manually add the new region to the + RegionFactory map + */ + RegionFactory::map_add (nr); pl->add_region (nr, r->position() + pos); if (select_new) { @@ -5978,8 +6201,7 @@ Editor::close_region_gaps () Table table (2, 3); table.set_spacings (12); table.set_border_width (12); - Label* l = manage (new Label (_("Crossfade length"))); - l->set_alignment (0, 0.5); + Label* l = manage (left_aligned_label (_("Crossfade length"))); table.attach (*l, 0, 1, 0, 1); SpinButton spin_crossfade (1, 0); @@ -5990,8 +6212,7 @@ Editor::close_region_gaps () table.attach (*manage (new Label (_("ms"))), 2, 3, 0, 1); - l = manage (new Label (_("Pull-back length"))); - l->set_alignment (0, 0.5); + l = manage (left_aligned_label (_("Pull-back length"))); table.attach (*l, 0, 1, 1, 2); SpinButton spin_pullback (1, 0); @@ -6726,3 +6947,26 @@ Editor::uncombine_regions () commit_reversible_command (); } +void +Editor::toggle_midi_input_active (bool flip_others) +{ + bool onoff; + boost::shared_ptr rl (new RouteList); + + for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + RouteTimeAxisView *rtav = dynamic_cast(*i); + + if (!rtav) { + continue; + } + + boost::shared_ptr mt = rtav->midi_track(); + + if (mt) { + rl->push_back (rtav->route()); + onoff = !mt->input_active(); + } + } + + _session->set_exclusive_input_active (rl, onoff, flip_others); +}