Include gtkmm2ext/gtk_ui.h
[ardour.git] / gtk2_ardour / mixer_strip.cc
index f37076aaa3a442c677a1f964c094714d712f1fc1..346f9ec2dd180271d8251ff3d7ef3f2599eb26f9 100644 (file)
@@ -144,6 +144,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
        ignore_toggle = false;
        ignore_speed_adjustment = false;
        comment_window = 0;
+       comment_area = 0;
 
        width_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(lr_xpm)))));
        hide_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(small_x_xpm)))));
@@ -258,13 +259,10 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
 
                ARDOUR_UI::instance()->tooltips().set_tip (speed_spinner, _("varispeed"));
 
-               speed_spinner.show ();
-               speed_frame.show  ();
-
                button_table.attach (speed_frame, 0, 2, 6, 7);
                button_table.attach (*rec_enable_button, 0, 2, 7, 8);
        }
-       
+
        name_button.add (name_label);
        name_button.set_name ("MixerNameButton");
        Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
@@ -298,14 +296,14 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
 
        whvbox->pack_start (width_hide_box, true, true);
 
-       global_vpacker.pack_start (*whvbox, false, false);
-       global_vpacker.pack_start (button_table, false, false);
+       global_vpacker.pack_start (*whvbox, Gtk::PACK_SHRINK);
+       global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
        global_vpacker.pack_start (pre_redirect_box, true, true);
-       global_vpacker.pack_start (gpm, false, false);
+       global_vpacker.pack_start (gpm, Gtk::PACK_SHRINK);
        global_vpacker.pack_start (post_redirect_box, true, true);
-       global_vpacker.pack_start (panners, false, false);
-       global_vpacker.pack_start (output_button, false, false);
-       global_vpacker.pack_start (comment_button, false, false);
+       global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
+       global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
+       global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
 
        global_frame.add (global_vpacker);
        global_frame.set_shadow_type (Gtk::SHADOW_IN);
@@ -318,30 +316,6 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
        _selected = true;
        set_selected (false);
 
-       whvbox->show_all ();
-       name_label.show ();
-       group_label.show();
-       input_label.show ();
-       output_label.show ();
-       pre_redirect_box.show_all ();
-       post_redirect_box.show_all ();
-       button_table.show ();
-       comment_button.show ();
-       name_button.show ();
-       input_button.show ();
-       group_button.show ();
-       output_button.show ();
-       rec_enable_button->show ();
-       solo_button->show ();
-       mute_button->show ();
-       gain_automation_style_button.show ();
-       gain_automation_state_button.show ();
-       pan_automation_style_button.show ();
-       pan_automation_state_button.show ();
-       polarity_button.show ();
-       global_vpacker.show ();
-       global_frame.show ();
-
        _packed = false;
        _embedded = false;
 
@@ -364,8 +338,8 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
        _route.comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed));
        _route.gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed));
 
-       input_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::input_press));
-       output_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::output_press));
+       input_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
+       output_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
 
        rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press));
        solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press));
@@ -373,21 +347,21 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
        mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press));
        mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release));
 
-       gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event));
-       gain_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event));
-       pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event));
-       pan_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event));
+       gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
+       gain_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
+       pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
+       pan_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
 
-       gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event));
-       gain_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event));
-       pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event));
-       pan_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event));
+       gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
+       gain_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
+       pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
+       pan_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
 
        polarity_button.signal_toggled().connect (mem_fun(*this, &MixerStrip::polarity_toggled));
 
-       name_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::name_button_button_release));
+       name_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::name_button_button_release), false);
 
-       group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_mix_group));
+       group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_mix_group), false);
 
        _width = (Width) -1;
        set_stuff_from_route ();
@@ -627,7 +601,6 @@ MixerStrip::input_press (GdkEventButton *ev)
        citems.push_back (SeparatorElem());
 
        _session.foreach_connection (this, &MixerStrip::add_connection_to_input_menu);
-
        input_menu.popup (1, ev->time);
 
        return TRUE;
@@ -1113,31 +1086,48 @@ MixerStrip::comment_button_clicked ()
 
        if (comment_window->is_visible()) {
                comment_window->hide ();
-       } else {
-               comment_window->set_position (Gtk::WIN_POS_MOUSE);
-               comment_window->show_all ();
+               return;
+       } 
+
+       comment_window->set_position (Gtk::WIN_POS_MOUSE);
+       comment_window->show_all ();
+       comment_window->present();
+       
+       ResponseType response = (ResponseType) comment_window->run();
+       comment_window->hide ();
+
+       switch (response) {
+       case RESPONSE_ACCEPT:
+               break;
+       default:
+               return;
        }
+
+       string str =  comment_area->get_buffer()->get_text();
+       _route.set_comment (str, this);
+       ARDOUR_UI::instance()->tooltips().set_tip (comment_button, 
+                                                  str.empty() ? _("click to add/edit comments") : str);
 }
 
 void
 MixerStrip::setup_comment_editor ()
 {
-       comment_window = new Window (WINDOW_TOPLEVEL);
+       string title;
+       title = _route.name();
+       title += _(": comment editor");
 
-       string str;
-       str = _route.name();
-       str += _(": comment editor");
-       comment_window->set_title (str);
+       comment_window = new ArdourDialog (title, false);
+       comment_area = manage (new TextView());
 
-       comment_area.set_name ("MixerTrackCommentArea");
-       comment_area.set_editable (true);
-         comment_area.changed.connect (mem_fun(*this, &MixerStrip::comment_edited));
-       // GTK2FIX
-       // comment_area.signal_button_release_event().connect_after (ptr_fun (do_not_propagate));
-       comment_area.show ();
+       comment_area->set_name ("MixerTrackCommentArea");
+       comment_area->set_editable (true);
+       comment_area->get_buffer()->set_text (_route.comment());
+       comment_area->set_size_request (200,100);
+       comment_area->show ();
 
-       comment_window->add (comment_area);
-       comment_window->signal_delete_event().connect (bind (ptr_fun (just_hide_it), comment_window));
+       comment_window->get_vbox()->pack_start (*comment_area);
+       comment_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
+       comment_window->add_button (Stock::OK, RESPONSE_ACCEPT);
 }
 
 void
@@ -1147,28 +1137,13 @@ MixerStrip::comment_changed (void *src)
        
        if (src != this) {
                ignore_comment_edit = true;
-               // comment_area.freeze ();
-               //comment_area.get_buffer()->delete_text (0, -1);
-               //comment_area.set_point (0);
-               comment_area.get_buffer()->set_text (_route.comment());
-               // comment_area.thaw ();
+               if (comment_area) {
+                       comment_area->get_buffer()->set_text (_route.comment());
+               }
                ignore_comment_edit = false;
        }
 }
 
-void
-MixerStrip::comment_edited ()
-{
-       ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::comment_edited));
-       
-       if (!ignore_comment_edit) {
-               string str =  comment_area.get_buffer()->get_text();
-               _route.set_comment (str, this);
-               ARDOUR_UI::instance()->tooltips().set_tip (comment_button, 
-                                                          str.empty() ? _("click to add/edit comments") : str);
-       }
-}
-
 void
 MixerStrip::set_mix_group (RouteGroup *rg)
 
@@ -1250,13 +1225,10 @@ MixerStrip::route_gui_changed (string what_changed, void* ignored)
 void
 MixerStrip::show_route_color ()
 {
-       Glib::RefPtr<Gtk::Style> style;
-
        name_button.ensure_style ();
-       style = name_button.get_style()->copy();
+       Glib::RefPtr<Gtk::Style> style = name_button.get_style()->copy();
        style->set_bg (Gtk::STATE_NORMAL, color());
        name_button.set_style (style);
-       style->unreference();
 
        route_active_changed ();
 }
@@ -1272,7 +1244,7 @@ MixerStrip::build_route_ops_menu ()
 {
        using namespace Menu_Helpers;
 
-       route_ops_menu = new Menu;
+       route_ops_menu = manage (new Menu);
        route_ops_menu->set_name ("ArdourContextMenu");
 
        MenuList& items = route_ops_menu->items();
@@ -1283,6 +1255,11 @@ MixerStrip::build_route_ops_menu ()
        route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
        route_active_menu_item->set_active (_route.active());
 
+       build_remote_control_menu ();
+       
+       items.push_back (SeparatorElem());
+       items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
+
        items.push_back (SeparatorElem());
        items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
 }
@@ -1302,6 +1279,8 @@ MixerStrip::list_route_operations ()
        if (route_ops_menu == 0) {
                build_route_ops_menu ();
        }
+       
+       refresh_remote_control_menu();
 
        route_ops_menu->popup (1, 0);
 }