Use small Astate buttons for plugins with many controls
[ardour.git] / gtk2_ardour / generic_pluginui.cc
index 8530486c836d7b0c0aca75a71730e12bd1b5566f..b1d3b8c49d105d57f4dffef1870dcf3e13894643 100644 (file)
@@ -220,6 +220,7 @@ std::size_t s1pos, s2pos, n = 0;
 
 static const guint32 min_controls_per_column = 17, max_controls_per_column = 24;
 static const float default_similarity_threshold = 0.3;
+static const guint32 max_columns_for_big_autostate = 2;
 
 void
 GenericPluginUI::build ()
@@ -474,6 +475,7 @@ GenericPluginUI::automatic_layout (const std::vector<ControlUI*>& control_uis)
        // starting a new column when necessary.
 
        i = 0;
+       size_t columns = 1;
        for (vector<ControlUI*>::iterator cuip = cui_controls_list.begin(); cuip != cui_controls_list.end(); ++cuip, ++i) {
 
                ControlUI* cui = *cuip;
@@ -493,6 +495,7 @@ GenericPluginUI::automatic_layout (const std::vector<ControlUI*>& control_uis)
                                frame->add (*box);
                                hpacker.pack_start(*frame, true, true);
                                x = 0;
+                               ++columns;
                        } else {
                                HSeparator *split = new HSeparator();
                                split->set_size_request(-1, 5);
@@ -503,6 +506,14 @@ GenericPluginUI::automatic_layout (const std::vector<ControlUI*>& control_uis)
                box->pack_start (*cui, false, false);
        }
 
+       if (columns > max_columns_for_big_autostate) {
+               for (vector<ControlUI*>::iterator cuip = cui_controls_list.begin();
+                                                 cuip != cui_controls_list.end();
+                                                 ++cuip) {
+                       set_short_autostate(*cuip, true);
+               }
+       }
+
        if (is_scrollable) {
                prefheight = 30 * i;
        }
@@ -529,9 +540,8 @@ GenericPluginUI::automatic_layout (const std::vector<ControlUI*>& control_uis)
                delete output_table;
        }
 
-       if (plugin->has_inline_display ()) {
+       if (plugin->has_inline_display () && plugin->inline_display_in_gui ()) {
                PluginDisplay* pd = manage (new PluginDisplay (plugin, 300));
-               pd->set_name("inside gui");
                hpacker.pack_end (*pd, true, true);
        }
        show_all();
@@ -551,6 +561,11 @@ GenericPluginUI::custom_layout (const std::vector<ControlUI*>& control_uis)
                layout->attach (*cui, cui->x0, cui->x1, cui->y0, cui->y1, FILL, SHRINK, 2, 2);
        }
        hpacker.pack_start (*layout, true, true);
+
+       if (plugin->has_inline_display () && plugin->inline_display_in_gui ()) {
+               PluginDisplay* pd = manage (new PluginDisplay (plugin, 300));
+               hpacker.pack_end (*pd, true, true);
+       }
 }
 
 GenericPluginUI::ControlUI::ControlUI (const Evoral::Parameter& p)
@@ -569,13 +584,6 @@ GenericPluginUI::ControlUI::ControlUI (const Evoral::Parameter& p)
        automate_button.set_name ("plugin automation state button");
        set_tooltip (automate_button, _("Automation control"));
 
-       /* XXX translators: use a string here that will be at least as long
-          as the longest automation label (see ::automation_state_changed()
-          below). be sure to include a descender.
-       */
-
-       automate_button.set_sizing_text(_("Mgnual"));
-
        ignore_change = false;
        update_pending = false;
        button = false;
@@ -591,6 +599,21 @@ GenericPluginUI::ControlUI::~ControlUI()
        }
 }
 
+void
+GenericPluginUI::set_short_autostate (ControlUI* cui, bool value)
+{
+       cui->short_autostate = value;
+       if (value) {
+               cui->automate_button.set_sizing_text("M");
+       } else {
+               /* XXX translators: use a string here that will be at least as long
+                  as the longest automation label (see ::automation_state_changed()
+                  below). be sure to include a descender. */
+               cui->automate_button.set_sizing_text(_("Mgnual"));
+       }
+       automation_state_changed(cui);
+}
+
 void
 GenericPluginUI::automation_state_changed (ControlUI* cui)
 {
@@ -603,7 +626,7 @@ GenericPluginUI::automation_state_changed (ControlUI* cui)
 
        cui->automate_button.set_active((state != ARDOUR::Off));
 
-       if (cui->knobtable) {
+       if (cui->short_autostate) {
                cui->automate_button.set_text (
                                GainMeterBase::astate_string (state));
                return;
@@ -674,6 +697,7 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter&             param,
        control_ui->label.set_alignment (0.0, 0.5);
        control_ui->label.set_name ("PluginParameterLabel");
        control_ui->set_spacing (5);
+       set_short_autostate(control_ui, false);
 
        if (is_input) {
 
@@ -793,7 +817,7 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter&             param,
                }
 
                if (use_knob) {
-                       control_ui->automate_button.set_sizing_text("M");
+                       set_short_autostate(control_ui, true);
 
                        control_ui->label.set_alignment (0.5, 0.5);
                        control_ui->knobtable = manage (new Table());