add new action and loop marker menu item for setting up loop record
[ardour.git] / gtk2_ardour / editor_ops.cc
index 3cdeff7c6de13641b197d1e149322f8cfdb5d3e5..c7a46d0ad3d9493d207822fea8f31af80501719f 100644 (file)
@@ -61,7 +61,6 @@
 #include "canvas/canvas.h"
 
 #include "actions.h"
-#include "ardour_ui.h"
 #include "audio_region_view.h"
 #include "audio_streamview.h"
 #include "audio_time_axis.h"
@@ -98,6 +97,7 @@
 #include "time_axis_view.h"
 #include "transpose_dialog.h"
 #include "transform_dialog.h"
+#include "ui_config.h"
 
 #include "i18n.h"
 
@@ -2045,7 +2045,7 @@ Editor::temporal_zoom_to_frame (bool coarser, framepos_t frame)
 bool
 Editor::choose_new_marker_name(string &name) {
 
-       if (!ARDOUR_UI::config()->get_name_new_markers()) {
+       if (!UIConfiguration::instance().get_name_new_markers()) {
                /* don't prompt user for a new name */
                return true;
        }
@@ -2537,7 +2537,7 @@ Editor::get_preroll ()
 void
 Editor::maybe_locate_with_edit_preroll ( framepos_t location )
 {
-       if ( _session->transport_rolling() || !ARDOUR_UI::config()->get_follow_edits() || _ignore_follow_edits )
+       if ( _session->transport_rolling() || !UIConfiguration::instance().get_follow_edits() || _ignore_follow_edits )
                return;
 
        location -= get_preroll();
@@ -4792,6 +4792,7 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
 
        framepos_t const start_frame = regions.start ();
        framepos_t const end_frame = regions.end_frame ();
+       framecnt_t const gap = end_frame - start_frame;
 
        begin_reversible_command (Operations::duplicate_region);
 
@@ -4806,9 +4807,10 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
                latest_regionviews.clear ();
                sigc::connection c = rtv->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view));
 
+               framepos_t const position = end_frame + (r->first_frame() - start_frame);
                playlist = (*i)->region()->playlist();
                playlist->clear_changes ();
-               playlist->duplicate (r, end_frame + (r->first_frame() - start_frame), times);
+               playlist->duplicate (r, position, gap, times);
                _session->add_command(new StatefulDiffCommand (playlist));
 
                c.disconnect ();
@@ -5177,6 +5179,8 @@ Editor::strip_region_silence ()
                }
        }
 
+       assert (!audio_only.empty());
+
        StripSilenceDialog d (_session, audio_only);
        int const r = d.run ();
 
@@ -5469,9 +5473,6 @@ Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress
                                _session->add_commands (cmds);
                                
                                _session->add_command(new StatefulDiffCommand (playlist));
-
-                       } else {
-                               continue;
                        }
 
                        if (progress) {
@@ -6115,7 +6116,7 @@ Editor::set_playhead_cursor ()
                }
        }
 
-       if (ARDOUR_UI::config()->get_follow_edits()) {
+       if (UIConfiguration::instance().get_follow_edits()) {
                cancel_time_selection();
        }
 }
@@ -6264,6 +6265,60 @@ Editor::set_punch_from_selection ()
        set_punch_range (start, end,  _("set punch range from selection"));
 }
 
+void
+Editor::set_punch_from_loop ()
+{
+       if (_session == 0) {
+               return;
+       }
+
+       Location* tll;
+
+       if ((tll = transport_loop_location()) == 0) {
+               return;
+       }
+
+       set_punch_range (tll->start(), tll->end(),  _("set punch range from loop"));
+}
+
+void
+Editor::setup_loop_record ()
+{
+       if (_session == 0) {
+               return;
+       }
+
+       Location * looploc = _session->locations()->auto_loop_location();
+
+       if (!looploc) {
+               return;
+       }
+
+       set_punch_range (looploc->start(), looploc->end(), _("setup loop recording"));
+
+       Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
+
+       if (action) {
+
+               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
+
+               if (!tact) {
+                       return;
+               }
+
+               /* drive the other two actions from this one */
+
+               Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
+               Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
+
+               if (in_action && out_action) {
+                       Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
+                       Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
+                       tiact->set_active (true);
+                       toact->set_active (true);
+               }
+       }
+}
 void
 Editor::set_session_extents_from_selection ()
 {
@@ -7889,7 +7944,7 @@ Editor::unlock ()
        
        delete _main_menu_disabler;
 
-       if (ARDOUR_UI::config()->get_lock_gui_after_seconds()) {
+       if (UIConfiguration::instance().get_lock_gui_after_seconds()) {
                start_lock_event_timing ();
        }
 }