fix some thinkos with audio/midi port counting.
authorRobin Gareus <robin@gareus.org>
Sat, 2 Apr 2016 01:20:43 +0000 (03:20 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 2 Apr 2016 01:20:43 +0000 (03:20 +0200)
(there's more to come w/multiple midi ports grouped left)

gtk2_ardour/plugin_pin_dialog.cc
gtk2_ardour/processor_box.cc

index 48f09f12ff7d0b787ee6f9871fc4caf061913005..b7f9d7f8102b2ffb1ef22cf2b370f416d5741950 100644 (file)
@@ -179,11 +179,13 @@ PluginPinDialog::update_elements ()
        _selection.reset();
 
        for (uint32_t i = 0; i < _in.n_total (); ++i) {
-               _elements.push_back (CtrlWidget (Input, (i < _in.n_midi () ? DataType::MIDI : DataType::AUDIO), i));
+               int id = (i < _in.n_midi ()) ? i : i - _in.n_midi ();
+               _elements.push_back (CtrlWidget (Input, (i < _in.n_midi () ? DataType::MIDI : DataType::AUDIO), id));
        }
 
        for (uint32_t i = 0; i < _out.n_total (); ++i) {
-               _elements.push_back (CtrlWidget (Output, (i < _out.n_midi () ? DataType::MIDI : DataType::AUDIO), i));
+               int id = (i < _out.n_midi ()) ? i : i - _out.n_midi ();
+               _elements.push_back (CtrlWidget (Output, (i < _out.n_midi () ? DataType::MIDI : DataType::AUDIO), id));
        }
 
        for (uint32_t n = 0; n < _n_plugins; ++n) {
@@ -214,16 +216,24 @@ PluginPinDialog::update_element_pos ()
        for (CtrlElemList::iterator i = _elements.begin(); i != _elements.end(); ++i) {
                switch (i->e->ct) {
                        case Input:
-                               i->x = rint ((i->e->id + 1) * _width / (1. + _in.n_total ())) - 5.5;
-                               i->y = y_in - 25;
-                               i->w = 10;
-                               i->h = 25;
+                               {
+                                       uint32_t idx = i->e->id;
+                                       if (i->e->dt == DataType::AUDIO) { idx += _in.n_midi (); }
+                                       i->x = rint ((idx + 1) * _width / (1. + _in.n_total ())) - 5.5;
+                                       i->y = y_in - 25;
+                                       i->w = 10;
+                                       i->h = 25;
+                               }
                                break;
                        case Output:
-                               i->x = rint ((i->e->id + 1) * _width / (1. + _out.n_total ())) - 5.5;
-                               i->y = y_out;
-                               i->w = 10;
-                               i->h = 25;
+                               {
+                                       uint32_t idx = i->e->id;
+                                       if (i->e->dt == DataType::AUDIO) { idx += _out.n_midi (); }
+                                       i->x = rint ((idx + 1) * _width / (1. + _out.n_total ())) - 5.5;
+                                       i->y = y_out;
+                                       i->w = 10;
+                                       i->h = 25;
+                               }
                                break;
                        case Sink:
                                {
index 9d5fbaf8d378e84bccb824de6648699ceddeefdb..f8d72590c78ff3a26bb85a93fc7430a8c3c98a16 100644 (file)
@@ -1157,7 +1157,7 @@ ProcessorEntry::RoutingIcon::expose_map (cairo_t* cr, const double width, const
                        bool valid_src;
                        uint32_t src = _f_out_map.get_src (is_midi ? DataType::MIDI : DataType::AUDIO, idx, &valid_src);
                        if (!valid_src) {
-                               double x = pin_x_pos (i, width, pc_in, pc_in_midi, is_midi);
+                               double x = pin_x_pos (i, width, pc_in, 0, false);
                                draw_gnd (cr, x, height, is_midi);
                                continue;
                        }