Remove CannotRecordNoInput signal (allowing recording without input connections)...
[ardour.git] / gtk2_ardour / plugin_ui.cc
index 958654dab5de976a218f7eb7cedf4812a3e93633..5815221d66f0c87fd54ad4ac2890b9b489ffac20 100644 (file)
@@ -100,7 +100,7 @@ PluginUIWindow::PluginUIWindow (AudioEngine &engine, PluginInsert& insert, bool
 
        set_position (Gtk::WIN_POS_MOUSE);
        set_name ("PluginEditor");
-       add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
+       add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
 
        signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window*> (this)));
        insert.GoingAway.connect (mem_fun(*this, &PluginUIWindow::plugin_going_away));
@@ -135,20 +135,17 @@ PluginUI::PluginUI (AudioEngine &engine, PluginInsert& pi, bool scrollable)
 
        HBox* constraint_hbox = manage (new HBox);
        HBox* smaller_hbox = manage (new HBox);
+       Label* combo_label = manage (new Label (_("<span size=\"large\">Presets</span>")));
+       combo_label->set_use_markup (true);
 
+       smaller_hbox->pack_start (*combo_label, false, false, 10);
        smaller_hbox->pack_start (combo, false, false);
        smaller_hbox->pack_start (save_button, false, false);
 
-       constraint_hbox->set_spacing (10);
+       constraint_hbox->set_spacing (5);
        constraint_hbox->pack_start (*smaller_hbox, true, false);
        constraint_hbox->pack_end (bypass_button, false, false);
 
-//     name_ebox.add (*text_hbox);
-//     info_vbox.pack_start (name_ebox, false, false);
-//     info_vbox.pack_start (makerinfo_label, false, false);
-//     info_vbox.pack_start (paraminfo_label, false, false, 5);
-
-//     settings_box.pack_start (info_vbox, false, false, 10);
        settings_box.pack_end (*constraint_hbox, false, false);
 
        pack_start (settings_box, false, false);
@@ -165,9 +162,6 @@ PluginUI::PluginUI (AudioEngine &engine, PluginInsert& pi, bool scrollable)
        }
        else {
                pack_start (hpacker, false, false);
-
-               // this is a hack to get the theme right
-               name_ebox.set_name ("PluginNameBox");
        }
 
        insert.active_changed.connect (mem_fun(*this, &PluginUI::redirect_active_changed));
@@ -192,7 +186,6 @@ PluginUI::build (AudioEngine &engine)
        Frame* frame;
        Frame* bt_frame;
        VBox* box;
-       char info[32];
        int output_row, output_col;
        int button_row, button_col;
        int output_rows, output_cols;
@@ -228,8 +221,12 @@ PluginUI::build (AudioEngine &engine)
        hpacker.pack_start(*bt_frame, true, true);
 
        box = manage (new VBox);
+       box->set_border_width (5);
+       box->set_spacing (1);
+
        frame = manage (new Frame);
        frame->set_name ("BaseFrame");
+       frame->set_label (_("Controls"));
        frame->add (*box);
        hpacker.pack_start(*frame, true, true);
 
@@ -238,9 +235,15 @@ PluginUI::build (AudioEngine &engine)
        for (i = 0; i < plugin.parameter_count(); ++i) {
 
                if (plugin.parameter_is_control (i)) {
+                       
+                       /* Don't show latency control ports */
+
+                       if (plugin.describe_parameter (i) == X_("latency")) {
+                               continue;
+                       }
 
                        ControlUI* cui;
-                               
+       
                        /* if we are scrollable, just use one long column */
 
                        if (!is_scrollable) {
@@ -259,12 +262,6 @@ PluginUI::build (AudioEngine &engine)
                                }
                        }
 
-                       /* Don't show latency control ports */
-
-                       if (plugin.describe_parameter (i) == X_("latency")) {
-                               continue;
-                       }
-
                        if ((cui = build_control_ui (engine, i, plugin.get_nth_midi_control (i))) == 0) {
                                error << string_compose(_("Plugin Editor: could not build control element for port %1"), i) << endmsg;
                                continue;
@@ -290,6 +287,19 @@ PluginUI::build (AudioEngine &engine)
 
                        } else if (cui->display) {
 
+                               output_table.attach (*cui, output_col, output_col + 1, output_row, output_row+1, 
+                                                    FILL|EXPAND, FILL);
+                               
+                               // TODO: The meters should be divided into multiple rows 
+                               
+                               if (++output_col == output_cols) {
+                                       output_cols ++;
+                                       output_table.resize (output_rows, output_cols);
+                               }
+                               
+                               /* old code, which divides meters into
+                                * columns first, rows later. New code divides into one row
+                                
                                if (output_row == output_rows) {
                                        output_row = 0;
                                        if (++output_col == output_cols) {
@@ -302,6 +312,7 @@ PluginUI::build (AudioEngine &engine)
                                                     FILL|EXPAND, FILL);
  
                                output_row++;
+                               */
                        }
                                
                        /* HACK: ideally the preferred height would be queried from
@@ -334,42 +345,6 @@ PluginUI::build (AudioEngine &engine)
 
        output_update ();
 
-       string pname = plugin.name();
-       
-       if (pname.length() > 24) {
-               pname = pname.substr (0, 24);
-               pname += "...";
-               ARDOUR_UI::instance()->tooltips().set_tip(name_ebox, plugin.name());
-       }
-
-       
-       nameinfo_label.set_text (pname);
-       nameinfo_label.set_name ("PluginNameInfo");
-       nameinfo_label.set_alignment (0.0, 0.0);
-
-       string maker = plugin.maker();
-       string::size_type email_pos;
-
-       if ((email_pos = maker.find_first_of ('<')) != string::npos) {
-               maker = maker.substr (0, email_pos - 1);
-       }
-
-       if (maker.length() > 32) {
-               maker = maker.substr (0, 32);
-               maker += " ...";
-       }
-
-       makerinfo_label.set_text (maker);
-       makerinfo_label.set_name ("PluginMakerInfo");
-       makerinfo_label.set_alignment (0.0, 0.0);
-       
-       snprintf (info, sizeof(info),"[ %u %s | %u %s ]",
-                 n_ins, ngettext(_("in"), _("ins"), n_ins),
-                 n_outs, ngettext(_("out"), _("outs"), n_outs));
-       paraminfo_label.set_text (info);
-       paraminfo_label.set_name ("PluginParameterInfo");
-       paraminfo_label.set_alignment (0.0, 0.0);
-
        output_table.show_all ();
        button_table.show_all ();
 }
@@ -379,11 +354,11 @@ PluginUI::ControlUI::ControlUI ()
 {
        automate_button.set_name ("PluginAutomateButton");
        ARDOUR_UI::instance()->tooltips().set_tip (automate_button,
-                                                  _("automation control"));
+                                                  _("Automation control"));
 
        /* don't fix the height, it messes up the bar controllers */
 
-       set_size_request_to_display_given_text (automate_button, X_("longenuff"), 2, -1);
+       set_size_request_to_display_given_text (automate_button, X_("longenuff"), 2, 2);
 
        ignore_change = 0;
        display = 0;
@@ -413,19 +388,19 @@ PluginUI::automation_state_changed (ControlUI* cui)
 
        switch (insert.get_port_automation_state (cui->port_index) & (Off|Play|Touch|Write)) {
        case Off:
-               static_cast<Gtk::Label*>(cui->automate_button.get_child())->set_text (_("off"));
+               cui->automate_button.set_label (_("Isolate"));
                break;
        case Play:
-               static_cast<Gtk::Label*>(cui->automate_button.get_child())->set_text (_("play"));
+               cui->automate_button.set_label (_("Play"));
                break;
        case Write:
-               static_cast<Gtk::Label*>(cui->automate_button.get_child())->set_text (_("write"));
+               cui->automate_button.set_label (_("Write"));
                break;
        case Touch:
-               static_cast<Gtk::Label*>(cui->automate_button.get_child())->set_text (_("touch"));
+               cui->automate_button.set_label (_("Touch"));
                break;
        default:
-               static_cast<Gtk::Label*>(cui->automate_button.get_child())->set_text (_("???"));
+               cui->automate_button.set_label (_("???"));
                break;
        }
 }
@@ -538,14 +513,11 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, MIDI::Contr
                        Gtkmm2ext::set_size_request_to_display_given_text (*control_ui->clickbox, "g9999999", 2, 2);
                        control_ui->clickbox->set_print_func (integer_printer, 0);
                } else {
-//                     control_ui->control = new HSliderController (ARDOUR_UI::instance()->plugin_ui_slider_pix(),
-//                                                                  control_ui->adjustment,
-//                                                                  mcontrol);
-
                        sigc::slot<void,char*,uint32_t> pslot = sigc::bind (mem_fun(*this, &PluginUI::print_parameter), (uint32_t) port_index);
 
                        control_ui->control = new BarController (*control_ui->adjustment, mcontrol, pslot);
-                       control_ui->control->set_size_request (200, 15);
+                       // should really match the height of the text in the automation button+label
+                       control_ui->control->set_size_request (200, 22);
                        control_ui->control->set_name (X_("PluginSlider"));
                        control_ui->control->set_style (BarController::LeftToRight);
                        control_ui->control->set_use_parent (true);
@@ -574,7 +546,7 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, MIDI::Contr
                }
 
                control_ui->pack_start (control_ui->automate_button, false, false);
-control_ui->adjustment->signal_value_changed().connect (bind (mem_fun(*this, &PluginUI::control_adjustment_changed), control_ui));
+               control_ui->adjustment->signal_value_changed().connect (bind (mem_fun(*this, &PluginUI::control_adjustment_changed), control_ui));
                control_ui->automate_button.signal_clicked().connect (bind (mem_fun(*this, &PluginUI::astate_clicked), control_ui, (uint32_t) port_index));
 
                automation_state_changed (control_ui);
@@ -589,10 +561,11 @@ control_ui->adjustment->signal_value_changed().connect (bind (mem_fun(*this, &Pl
                control_ui->display->set_name ("ParameterValueDisplay");
 
                control_ui->display_label = manage (new Label);
+
                control_ui->display_label->set_name ("ParameterValueDisplay");
 
                control_ui->display->add (*control_ui->display_label);
-               Gtkmm2ext::set_size_request_to_display_given_text (*control_ui->display, "g999999", 2, 2);
+               Gtkmm2ext::set_size_request_to_display_given_text (*control_ui->display, "-99,99", 2, 2);
 
                control_ui->display->show_all ();
 
@@ -602,7 +575,7 @@ control_ui->adjustment->signal_value_changed().connect (bind (mem_fun(*this, &Pl
                MeterInfo * info = new MeterInfo(port_index);
                control_ui->meterinfo = info;
                
-               info->meter = new FastMeter (100, 5, FastMeter::Horizontal);
+               info->meter = new FastMeter (5, 100, FastMeter::Vertical);
 
                info->min_unbound = desc.min_unbound;
                info->max_unbound = desc.max_unbound;
@@ -611,12 +584,17 @@ control_ui->adjustment->signal_value_changed().connect (bind (mem_fun(*this, &Pl
                info->max = desc.upper;
 
                control_ui->vbox = manage (new VBox);
+               control_ui->hbox = manage (new HBox);
+               
+               control_ui->label.set_angle(90);
+               control_ui->hbox->pack_start (control_ui->label, false, false);
+               control_ui->hbox->pack_start (*info->meter, false, false);
 
-               control_ui->vbox->pack_start (control_ui->label, false, false);
-               control_ui->vbox->pack_start (*info->meter, false, false);
+               control_ui->vbox->pack_start (*control_ui->hbox, false, false);
                
-               control_ui->pack_start (*control_ui->vbox, false, false);
-               control_ui->pack_start (*control_ui->display, false, false);
+               control_ui->vbox->pack_start (*control_ui->display, false, false);
+
+               control_ui->pack_start (*control_ui->vbox);
 
                control_ui->meterinfo->meter->show_all();
                control_ui->meterinfo->packed = true;
@@ -653,13 +631,13 @@ PluginUI::astate_clicked (ControlUI* cui, uint32_t port)
        MenuList& items (automation_menu->items());
 
        items.clear ();
-       items.push_back (MenuElem (_("off"), 
+       items.push_back (MenuElem (_("Isolate"), 
                                   bind (mem_fun(*this, &PluginUI::set_automation_state), (AutoState) Off, cui)));
-       items.push_back (MenuElem (_("play"),
+       items.push_back (MenuElem (_("Play"),
                                   bind (mem_fun(*this, &PluginUI::set_automation_state), (AutoState) Play, cui)));
-       items.push_back (MenuElem (_("write"),
+       items.push_back (MenuElem (_("Write"),
                                   bind (mem_fun(*this, &PluginUI::set_automation_state), (AutoState) Write, cui)));
-       items.push_back (MenuElem (_("touch"),
+       items.push_back (MenuElem (_("Touch"),
                                   bind (mem_fun(*this, &PluginUI::set_automation_state), (AutoState) Touch, cui)));
 
        automation_menu->popup (1, 0);
@@ -851,11 +829,12 @@ PluginUI::setup_scale_values(guint32 port_index, ControlUI* cui)
 PlugUIBase::PlugUIBase (PluginInsert& pi)
        : insert (pi),
          plugin (insert.plugin()),
-         save_button(_("save")),
-         bypass_button (_("bypass"))
+         save_button(_("Add")),
+         bypass_button (_("Bypass"))
 {
         //combo.set_use_arrows_always(true);
        set_popdown_strings (combo, plugin.get_presets());
+       combo.set_size_request (100, -1);
        combo.set_active_text ("");
        combo.signal_changed().connect(mem_fun(*this, &PlugUIBase::setting_selected));
 
@@ -881,7 +860,9 @@ void
 PlugUIBase::save_plugin_setting ()
 {
        ArdourPrompter prompter (true);
-       prompter.set_prompt(_("Name for plugin settings:"));
+       prompter.set_prompt(_("Name of New Preset:"));
+       prompter.add_button (Gtk::Stock::ADD, Gtk::RESPONSE_ACCEPT);
+       prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
 
        prompter.show_all();