Set route remote control IDs from a dialog rather than a menu. I think this is
authorCarl Hetherington <carl@carlh.net>
Sat, 29 Aug 2009 23:31:59 +0000 (23:31 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 29 Aug 2009 23:31:59 +0000 (23:31 +0000)
more practical (especially with large track counts), and also prevents a N-entry
menu being built for each of N tracks every time the mixer strip order is changed,
which speeds some operations up.

git-svn-id: svn://localhost/ardour2/branches/3.0@5605 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/mixer_strip.cc
gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_ui.cc
gtk2_ardour/route_ui.h

index 8ab7454ab8846e519714b2095955d14864bae692..53411c1336f060bf543a3358badfad39ec4dedc1 100644 (file)
@@ -1165,9 +1165,8 @@ MixerStrip::build_route_ops_menu ()
        denormal_menu_item->set_active (_route->denormal_protection());
 
        if (!Profile->get_sae()) {
-               build_remote_control_menu ();
                items.push_back (SeparatorElem());
-               items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
+               items.push_back (MenuElem (_("Remote Control ID..."), mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
         }
 
        items.push_back (SeparatorElem());
@@ -1193,8 +1192,6 @@ MixerStrip::list_route_operations ()
        if (route_ops_menu == 0) {
                build_route_ops_menu ();
        }
-       
-       refresh_remote_control_menu();
 }
 
 void
index b929385f530800f54ca0f4a19fb8afc0198d0ff2..be114e6be05b5de80d8dd0653bde7d311457657c 100644 (file)
@@ -475,8 +475,7 @@ RouteTimeAxisView::build_display_menu ()
        items.push_back (SeparatorElem());
 
        if (!Profile->get_sae()) {
-               build_remote_control_menu ();
-               items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
+               items.push_back (MenuElem (_("Remote Control ID..."), mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
                /* rebuild this every time */
                build_automation_action_menu ();
                items.push_back (MenuElem (_("Automation"), *automation_action_menu));
@@ -2400,4 +2399,3 @@ RouteTimeAxisView::set_button_names ()
 
        mute_button_label.set_text (_("m"));
 }
-
index ad63daad5d7df4fa4cef72fd0774268e237ce038..6d21de844ebbb4e0a73d189a539f4b55900d5231 100644 (file)
@@ -84,7 +84,6 @@ RouteUI::~RouteUI()
        
        delete solo_menu;
        delete mute_menu;
-       delete remote_control_menu;
        delete sends_menu;
 }
 
@@ -95,7 +94,6 @@ RouteUI::init ()
        xml_node = 0;
        mute_menu = 0;
        solo_menu = 0;
-       remote_control_menu = 0;
        sends_menu = 0;
        ignore_toggle = false;
        wait_for_release = false;
@@ -215,8 +213,6 @@ RouteUI::set_route (boost::shared_ptr<Route> rp)
                solo_button->show();
        }
 
-       connections.push_back (_route->RemoteControlIDChanged.connect (mem_fun(*this, &RouteUI::refresh_remote_control_menu)));
-
        /* map the current state */
 
        mute_changed (0);
@@ -775,72 +771,6 @@ RouteUI::update_rec_display ()
        }
 }
 
-void
-RouteUI::build_remote_control_menu ()
-{
-       remote_control_menu = new Menu;
-       refresh_remote_control_menu ();
-}
-
-void
-RouteUI::refresh_remote_control_menu ()
-{
-       ENSURE_GUI_THREAD (mem_fun (*this, &RouteUI::refresh_remote_control_menu));
-
-       // only refresh the menu if it has been instantiated
-
-       if (remote_control_menu == 0) {
-               return;
-       }
-
-       using namespace Menu_Helpers;
-
-       RadioMenuItem::Group rc_group;
-       CheckMenuItem* rc_active;
-       uint32_t limit = _session.ntracks() + _session.nbusses();
-       char buf[32];
-
-       MenuList& rc_items = remote_control_menu->items();
-       rc_items.clear ();
-
-       /* note that this menu list starts at zero, not 1, because zero
-          is a valid, if useless, ID.
-       */
-
-       limit += 4; /* leave some breathing room */
-       
-       rc_items.push_back (RadioMenuElem (rc_group, _("None")));
-       if (_route->remote_control_id() == 0) {
-               rc_active = dynamic_cast<CheckMenuItem*> (&rc_items.back());
-               rc_active->set_active ();
-       }
-               
-       for (uint32_t i = 1; i < limit; ++i) {
-               snprintf (buf, sizeof (buf), "%u", i);
-               rc_items.push_back (RadioMenuElem (rc_group, buf));
-               rc_active = dynamic_cast<RadioMenuItem*>(&rc_items.back());
-               if (_route->remote_control_id() == i) {
-                       rc_active = dynamic_cast<CheckMenuItem*> (&rc_items.back());
-                       rc_active->set_active ();
-               }
-               rc_active->signal_activate().connect (bind (mem_fun (*this, &RouteUI::set_remote_control_id), i, rc_active));
-       }
-}
-
-void
-RouteUI::set_remote_control_id (uint32_t id, CheckMenuItem* item)
-{
-       /* this is called when the radio menu item is toggled, and so 
-          is actually invoked twice per menu selection. we only
-          care about the invocation for the item that was being
-          marked active.
-       */
-
-       if (item->get_active()) {
-               _route->set_remote_control_id (id);
-       }
-}
-
 void
 RouteUI::build_solo_menu (void)
 {
@@ -1448,3 +1378,32 @@ RouteUI::page_gain_down ()
 {
        _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.5), this);
 }
+
+void
+RouteUI::open_remote_control_id_dialog ()
+{
+       ArdourDialog dialog (_("Remote Control ID"));
+
+       uint32_t const limit = _session.ntracks() + _session.nbusses () + 4;
+
+       HBox* hbox = manage (new HBox);
+       hbox->set_spacing (6);
+       hbox->pack_start (*manage (new Label (_("Remote control ID:"))));
+       SpinButton* spin = manage (new SpinButton);
+       spin->set_digits (0);
+       spin->set_increments (1, 10);
+       spin->set_range (0, limit);
+       spin->set_value (_route->remote_control_id());
+       hbox->pack_start (*spin);
+       dialog.get_vbox()->pack_start (*hbox);
+
+       dialog.add_button (Stock::CANCEL, RESPONSE_CANCEL);
+       dialog.add_button (Stock::APPLY, RESPONSE_ACCEPT);
+
+       dialog.show_all ();
+       int const r = dialog.run ();
+
+       if (r == RESPONSE_ACCEPT) {
+               _route->set_remote_control_id (spin->get_value_as_int ());
+       }
+}
index c2f03eb3947b261cef32efea888235e5f9b7b7c1..1ac87a04045eb16da2ba2632ace9c859607ea439 100644 (file)
@@ -97,7 +97,6 @@ class RouteUI : public virtual AxisView
        
        Gtk::Menu* mute_menu;
        Gtk::Menu* solo_menu;
-       Gtk::Menu* remote_control_menu;
        Gtk::Menu* sends_menu;
 
        XMLNode *xml_node;
@@ -133,9 +132,7 @@ class RouteUI : public virtual AxisView
        void route_rec_enable_changed();
        void session_rec_enable_changed();
 
-       void build_solo_menu (void);
-       void build_remote_control_menu (void);
-       void refresh_remote_control_menu ();
+       void build_solo_menu ();
 
        void solo_isolated_toggle (void*, Gtk::CheckMenuItem*);
        void toggle_solo_isolated (Gtk::CheckMenuItem*);
@@ -185,13 +182,12 @@ class RouteUI : public virtual AxisView
 
        virtual void map_frozen ();
 
-       void set_remote_control_id (uint32_t id, Gtk::CheckMenuItem* item);
-
        void reversibly_apply_route_boolean (std::string name, void (ARDOUR::Route::*func)(bool, void*), bool, void *);
        void reversibly_apply_track_boolean (std::string name, void (ARDOUR::Track::*func)(bool, void*), bool, void *);
 
        void adjust_latency ();
        void save_as_template ();
+       void open_remote_control_id_dialog ();
  
    protected:
        std::vector<sigc::connection> connections;