Allow strips to add or remove personal sends
[ardour.git] / gtk2_ardour / route_ui.cc
index f059a0adf03f13b46020699b85c6adf55a93e2d8..b9ece1ed075340a57381854de54e4976696dfa5e 100644 (file)
@@ -66,6 +66,7 @@
 #include "keyboard.h"
 #include "latency_gui.h"
 #include "mixer_strip.h"
+#include "patch_change_widget.h"
 #include "plugin_pin_dialog.h"
 #include "rgb_macros.h"
 #include "route_time_axis.h"
@@ -121,6 +122,8 @@ RouteUI::~RouteUI()
                ARDOUR_UI::instance()->gui_object_state->remove_node (route_state_id());
        }
 
+       delete_patch_change_dialog ();
+
        _route.reset (); /* drop reference to route, so that it can be cleaned up */
        route_connections.drop_connections ();
 
@@ -246,6 +249,7 @@ RouteUI::reset ()
        delete mute_menu;
        mute_menu = 0;
 
+       delete_patch_change_dialog ();
        _color_picker.reset ();
 
        denormal_menu_item = 0;
@@ -495,7 +499,7 @@ RouteUI::mute_press (GdkEventButton* ev)
                                        }
 
                                        boost::shared_ptr<MuteControl> mc = _route->mute_control();
-                                       mc->start_touch (_session->audible_frame ());
+                                       mc->start_touch (_session->audible_sample ());
                                        _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), _route->muted_by_self() ? 0.0 : 1.0, Controllable::InverseGroup);
                                }
 
@@ -511,7 +515,7 @@ RouteUI::mute_press (GdkEventButton* ev)
                                }
 
                                boost::shared_ptr<MuteControl> mc = _route->mute_control();
-                               mc->start_touch (_session->audible_frame ());
+                               mc->start_touch (_session->audible_sample ());
                                mc->set_value (!_route->muted_by_self(), Controllable::UseGroup);
                        }
                }
@@ -529,7 +533,7 @@ RouteUI::mute_release (GdkEventButton* /*ev*/)
                _mute_release = 0;
        }
 
-       _route->mute_control()->stop_touch (_session->audible_frame ());
+       _route->mute_control()->stop_touch (_session->audible_sample ());
 
        return false;
 }
@@ -902,17 +906,10 @@ RouteUI::monitor_release (GdkEventButton* ev, MonitorChoice monitor_choice)
        MonitorChoice mc;
        boost::shared_ptr<RouteList> rl;
 
-       /* XXX for now, monitoring choices are orthogonal. cue monitoring
-          will follow in 3.X but requires mixing the input and playback (disk)
-          signal together, which requires yet more buffers.
-       */
-
        if (t->monitoring_control()->monitoring_choice() & monitor_choice) {
                mc = MonitorChoice (t->monitoring_control()->monitoring_choice() & ~monitor_choice);
        } else {
-               /* this line will change when the options are non-orthogonal */
-               // mc = MonitorChoice (t->monitoring_choice() | monitor_choice);
-               mc = monitor_choice;
+               mc = MonitorChoice (t->monitoring_control()->monitoring_choice() | monitor_choice);
        }
 
        if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
@@ -1613,6 +1610,39 @@ RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check)
        _route->solo_safe_control()->set_value (check->get_active() ? 1.0 : 0.0, Controllable::UseGroup);
 }
 
+void
+RouteUI::delete_patch_change_dialog ()
+{
+       if (!_route) {
+               return;
+       }
+       delete _route->patch_selector_dialog ();
+       _route->set_patch_selector_dialog (0);
+}
+
+PatchChangeGridDialog*
+RouteUI::patch_change_dialog () const
+{
+       return _route->patch_selector_dialog ();
+}
+
+void
+RouteUI::select_midi_patch ()
+{
+       if (patch_change_dialog ()) {
+               patch_change_dialog()->present ();
+               return;
+       }
+
+       /* note: RouteTimeAxisView is resoponsible to updating
+        * the Dialog (PatchChangeGridDialog::refresh())
+        * when the midnam model changes.
+        */
+       PatchChangeGridDialog* d = new PatchChangeGridDialog (_route);
+       _route->set_patch_selector_dialog (d);
+       d->present ();
+}
+
 /** Ask the user to choose a colour, and then apply that color to my route */
 void
 RouteUI::choose_color ()
@@ -1890,7 +1920,7 @@ RouteUI::map_frozen ()
 void
 RouteUI::adjust_latency ()
 {
-       LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->frame_rate(), AudioEngine::instance()->samples_per_cycle());
+       LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->sample_rate(), AudioEngine::instance()->samples_per_cycle());
 }
 
 
@@ -1900,7 +1930,7 @@ RouteUI::save_as_template_dialog_response (int response, SaveTemplateDialog* d)
        if (response == RESPONSE_ACCEPT) {
                const string name = d->get_template_name ();
                const string desc = d->get_description ();
-               const string path = Glib::build_filename(ARDOUR::user_route_template_directory (), name);
+               const string path = Glib::build_filename(ARDOUR::user_route_template_directory (), name + ARDOUR::template_suffix);
 
                if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { /* file already exists. */
                        bool overwrite = overwrite_file_dialog (*d,
@@ -1921,17 +1951,14 @@ RouteUI::save_as_template_dialog_response (int response, SaveTemplateDialog* d)
 void
 RouteUI::save_as_template ()
 {
-       std::string dir;
-
-       dir = ARDOUR::user_route_template_directory ();
+       const std::string dir = ARDOUR::user_route_template_directory ();
 
        if (g_mkdir_with_parents (dir.c_str(), 0755)) {
                error << string_compose (_("Cannot create route template directory %1"), dir) << endmsg;
                return;
        }
 
-       SaveTemplateDialog* d = new SaveTemplateDialog (_route->name());
-
+       SaveTemplateDialog* d = new SaveTemplateDialog (_route->name(), _route->comment());
        d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::save_as_template_dialog_response), d));
        d->show ();
 }
@@ -2399,3 +2426,11 @@ RouteUI::stripable () const
 {
        return _route;
 }
+
+void
+RouteUI::set_disk_io_point (DiskIOPoint diop)
+{
+       if (_route && is_track()) {
+               track()->set_disk_io_point (diop);
+       }
+}