changes to waveform clipping display
[ardour.git] / gtk2_ardour / generic_pluginui.cc
index bc5403099e62d514bf462797ec06a2a93c332152..52bb468a676a59054af654a1a03489113d25debe 100644 (file)
@@ -101,6 +101,9 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrol
        VBox* v1_box = manage (new VBox);
        VBox* v2_box = manage (new VBox);
        pack_end (plugin_analysis_expander, false, false);
+       if (!plugin->get_docs().empty()) {
+               pack_end (description_expander, false, false);
+       }
 
        v1_box->pack_start (*smaller_hbox, false, true);
        v2_box->pack_start (focus_button, false, true);
@@ -253,6 +256,10 @@ GenericPluginUI::build ()
                                continue;
                        }
 
+                       if (plugin->describe_parameter (Evoral::Parameter(PluginAutomation, 0, i)) == X_("hidden")) {
+                               continue;
+                       }
+
                        ControlUI* cui;
 
                        boost::shared_ptr<ARDOUR::AutomationControl> c
@@ -264,6 +271,11 @@ GenericPluginUI::build ()
                                continue;
                        }
 
+                       const std::string param_docs = plugin->get_parameter_docs(i);
+                       if (!param_docs.empty()) {
+                               ARDOUR_UI::instance()->set_tip(cui, param_docs.c_str());
+                       }
+
                        if (cui->controller || cui->clickbox || cui->combo) {
                                // Get all of the controls into a list, so that
                                // we can lay them out a bit more nicely later.
@@ -459,9 +471,25 @@ GenericPluginUI::automation_state_changed (ControlUI* cui)
 }
 
 
-static void integer_printer (char buf[32], Adjustment &adj, void */*arg*/)
+bool
+GenericPluginUI::integer_printer (char buf[32], Adjustment &adj, ControlUI* cui)
 {
-       snprintf (buf, 32, "%.0f", adj.get_value());
+       float const v = adj.get_value ();
+       
+       if (cui->scale_points) {
+               Plugin::ScalePoints::const_iterator i = cui->scale_points->begin ();
+               while (i != cui->scale_points->end() && i->second != v) {
+                       ++i;
+               }
+
+               if (i != cui->scale_points->end ()) {
+                       snprintf (buf, 32, "%s", i->first.c_str());
+                       return true;
+               }
+       }
+               
+       snprintf (buf, 32, "%.0f", v);
+       return true;
 }
 
 void
@@ -494,11 +522,21 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
 
        if (plugin->parameter_is_input(port_index)) {
 
-               /* Build a combo box */
-
+               /* See if there any named values for our input value */
                control_ui->scale_points = plugin->get_scale_points (port_index);
 
-               if (control_ui->scale_points) {
+               /* If this parameter is an integer, work out the number of distinct values
+                  it can take on (assuming that lower and upper values are allowed).
+               */
+               int const steps = desc.integer_step ? (desc.upper - desc.lower + 1) / desc.step : 0;
+
+               if (control_ui->scale_points && ((steps && int (control_ui->scale_points->size()) == steps) || desc.enumeration)) {
+                       
+                       /* Either:
+                        *   a) There is a label for each possible value of this input, or
+                        *   b) This port is marked as being an enumeration.
+                        */
+
                        std::vector<std::string> labels;
                        for (
                                ARDOUR::Plugin::ScalePoints::const_iterator i = control_ui->scale_points->begin();
@@ -574,7 +612,7 @@ GenericPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automat
                if (desc.integer_step) {
                        control_ui->clickbox = new ClickBox (adj, "PluginUIClickBox");
                        Gtkmm2ext::set_size_request_to_display_given_text (*control_ui->clickbox, "g9999999", 2, 2);
-                       control_ui->clickbox->set_print_func (integer_printer, 0);
+                       control_ui->clickbox->set_printer (sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::integer_printer), control_ui));
                } else {
                        //sigc::slot<void,char*,uint32_t> pslot = sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::print_parameter), (uint32_t) port_index);