- cairo_move_to (cr, width * 0.3, height);
- cairo_line_to (cr, width * 0.3, height * 0.5);
- cairo_line_to (cr, width * 0.7, height * 0.5);
- cairo_line_to (cr, width * 0.7, height);
- cairo_move_to (cr, width * 0.5, height * 0.5);
- cairo_line_to (cr, width * 0.5, 0);
- cairo_stroke (cr);
-
+ const uint32_t sources = _sources.n_total();
+ const uint32_t sinks = _sinks.n_total();
+
+ /* MIDI */
+ const uint32_t midi_sources = _sources.n_midi();
+ const uint32_t midi_sinks = _sinks.n_midi();
+
+ cairo_set_source_rgb (cr,
+ UINT_RGBA_R_FLT(midi_port_color),
+ UINT_RGBA_G_FLT(midi_port_color),
+ UINT_RGBA_B_FLT(midi_port_color));
+ if (midi_sources > 0 && midi_sinks > 0 && sinks > 1 && sources > 1) {
+ for (uint32_t i = 0 ; i < midi_sources; ++i) {
+ const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
+ const float si_x0 = rintf(width * (.2f + .6f * i / (sources - 1.f))) + .5f;
+ cairo_move_to (cr, si_x, height);
+ cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
+ cairo_stroke (cr);
+ }
+ } else if (midi_sources == 1 && midi_sinks == 1 && sinks == 1 && sources == 1) {
+ const float si_x = rintf(width * .5f) + .5f;
+ cairo_move_to (cr, si_x, height);
+ cairo_line_to (cr, si_x, 0);
+ cairo_stroke (cr);
+ }
+
+ /* AUDIO */
+ const uint32_t audio_sources = _sources.n_audio();
+ const uint32_t audio_sinks = _sinks.n_audio();
+ cairo_set_source_rgb (cr,
+ UINT_RGBA_R_FLT(audio_port_color),
+ UINT_RGBA_G_FLT(audio_port_color),
+ UINT_RGBA_B_FLT(audio_port_color));
+
+ if (_splitting) {
+ assert(audio_sinks > 1);
+ const float si_x0 = rintf(width * .5f) + .5f;
+ for (uint32_t i = midi_sinks; i < sinks; ++i) {
+ const float si_x = rintf(width * (.2f + .6f * i / (sinks - 1.f))) + .5f;
+ cairo_move_to (cr, si_x, height);
+ cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
+ cairo_stroke (cr);
+ }
+ } else if (audio_sources > 1) {
+ for (uint32_t i = 0 ; i < audio_sources; ++i) {
+ const float si_x = rintf(width * (.2f + .6f * (i + midi_sinks) / (sinks - 1.f))) + .5f;
+ const float si_x0 = rintf(width * (.2f + .6f * (i + midi_sources) / (sources - 1.f))) + .5f;
+ cairo_move_to (cr, si_x, height);
+ cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
+ cairo_stroke (cr);
+ }
+ } else if (audio_sources == 1 && audio_sinks == 1) {
+ const float si_x = rintf(width * .5f) + .5f;
+ cairo_move_to (cr, si_x, height);
+ cairo_line_to (cr, si_x, 0);
+ cairo_stroke (cr);
+ }
+ cairo_destroy(cr);