+ int dh = std::max (4.f, rintf(4.f * UIConfiguration::instance().get_ui_scale()));
+ double ht = _terminal ? height - dh : height;
+
+ // draw outputs of this
+ const uint32_t pc_out = _sources.n_total();
+ const uint32_t pc_out_midi = _sources.n_midi();
+ const uint32_t n_out = _out.n_total();
+ const uint32_t n_out_midi = _out.n_midi();
+
+ for (uint32_t i = 0; i < pc_out; ++i) {
+ const bool is_midi = i < pc_out_midi;
+ bool valid_out;
+ uint32_t pn = is_midi ? i : i - pc_out_midi;
+ DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
+ uint32_t idx = _out_map.get (dt, pn, &valid_out);
+ if (!valid_out) {
+ continue;
+ }
+ // skip connections that are not used in the next's input
+ if (_feeding) {
+ bool valid_thru, valid_sink;
+ _i_in_map.get_src (dt, idx, &valid_sink);
+ _i_thru_map.get_src (dt, idx, &valid_thru);
+ if (!valid_thru && !valid_sink) {
+ if (!is_midi || i != 0) { // special case midi-bypass
+ continue;
+ }
+ }
+ }
+ double c_x0 = pin_x_pos (i, width, pc_out, 0, false);
+ double c_x1 = pin_x_pos (idx, width, n_out, n_out_midi, is_midi);
+ draw_connection (cr, c_x0, c_x1, 0, ht, is_midi);
+ }
+
+ for (uint32_t i = 0; i < n_out; ++i) {
+ const bool is_midi = i < n_out_midi;
+ uint32_t pn = is_midi ? i : i - n_out_midi;
+ DataType dt = is_midi ? DataType::MIDI : DataType::AUDIO;
+ double x = pin_x_pos (i, width, n_out, 0, is_midi);
+
+ if (!_terminal) {
+ bool valid_thru_f = false;
+ // skip connections that are not used in the next's input
+ if (_feeding) {
+ bool valid_sink;
+ _i_in_map.get_src (dt, pn, &valid_sink);
+ _i_thru_map.get_src (dt, pn, &valid_thru_f);
+ if (!valid_thru_f && !valid_sink) {
+ if (!is_midi || i != 0) { // special case midi-bypass
+ continue;
+ }
+ }
+ }
+
+ bool valid_src;
+ _out_map.get_src (dt, pn, &valid_src);
+ if (!valid_src) {
+ bool valid_thru;
+ uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
+ if (valid_thru) {
+ if (idx >= _in.get (dt)) {
+ draw_sidechain (cr, x, 0, height, is_midi);
+ } else {
+ draw_thru_src (cr, x, 0, height, is_midi);
+ }
+ } else if (valid_thru_f){
+ // gnd is part of input, unless it's a thru input
+ // (also only true if !coalesced into one small display)
+ draw_gnd (cr, x, 0, height, is_midi);
+ }
+ }
+ } else {
+ // terminal node, add arrows
+ bool valid_src;
+ _out_map.get_src (dt, pn, &valid_src);
+ if (!valid_src) {
+ bool valid_thru;
+ uint32_t idx = _thru_map.get (dt, pn, &valid_thru);
+ if (valid_thru) {
+ if (idx >= _in.get (dt)) {
+ draw_sidechain (cr, x, 0, height - dh, is_midi);
+ } else {
+ draw_thru_src (cr, x, 0, height - dh, is_midi);
+ }
+ } else {
+ draw_gnd (cr, x, 0, height - dh, is_midi);
+ }
+ }
+
+ set_routing_color (cr, is_midi);
+ cairo_set_line_width (cr, 1.0);
+ cairo_move_to (cr, x, height - dh);
+ cairo_line_to (cr, x, height - 2);
+ cairo_stroke (cr);
+
+ const double ar = dh - 1;
+ cairo_move_to (cr, x - ar, height - ar);
+ cairo_line_to (cr, x , height - .5);
+ cairo_line_to (cr, x + ar, height - ar);
+ cairo_line_to (cr, x , height - ar * .5);
+ cairo_close_path (cr);
+ cairo_fill_preserve (cr);
+ cairo_stroke (cr);
+ }
+ }