diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 8d10be23c8..938e82af0b 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -565,6 +565,17 @@ PortGroupList::io_from_bundle (boost::shared_ptr b) const return boost::shared_ptr (); } +bool +PortGroupList::empty () const +{ + List::const_iterator i = _groups.begin (); + while (i != _groups.end() && (*i)->total_channels() == 0) { + ++i; + } + + return (i == _groups.end()); +} + RouteBundle::RouteBundle (boost::shared_ptr r) : _route (r) diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h index 27698ddbb0..e367adec9b 100644 --- a/gtk2_ardour/port_group.h +++ b/gtk2_ardour/port_group.h @@ -122,13 +122,15 @@ class PortGroupList : public sigc::trackable void resume_signals (); List::const_iterator begin () const { - return _groups.begin(); + return _groups.begin (); } List::const_iterator end () const { - return _groups.end(); + return _groups.end (); } + bool empty () const; + sigc::signal Changed; sigc::signal BundleChanged; diff --git a/gtk2_ardour/port_matrix_body.cc b/gtk2_ardour/port_matrix_body.cc index 6fcc773253..6696a67204 100644 --- a/gtk2_ardour/port_matrix_body.cc +++ b/gtk2_ardour/port_matrix_body.cc @@ -55,6 +55,31 @@ PortMatrixBody::~PortMatrixBody () bool PortMatrixBody::on_expose_event (GdkEventExpose* event) { + if (_matrix->columns()->empty() || _matrix->rows()->empty()) { + + /* nothing to connect */ + + cairo_t* cr = gdk_cairo_create (get_window()->gobj()); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_rectangle (cr, 0, 0, _alloc_width, _alloc_height); + cairo_fill (cr); + + stringstream t; + t << _("There are no ") << (_matrix->type() == ARDOUR::DataType::AUDIO ? _("audio") : _("MIDI")) << _(" ports to connect."); + + cairo_text_extents_t ext; + cairo_text_extents (cr, t.str().c_str(), &ext); + + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_move_to (cr, (_alloc_width - ext.width) / 2, (_alloc_height + ext.height) / 2); + cairo_show_text (cr, t.str().c_str ()); + + cairo_destroy (cr); + + return true; + } + Gdk::Rectangle const exposure ( event->area.x, event->area.y, event->area.width, event->area.height ); @@ -147,6 +172,13 @@ PortMatrixBody::on_size_request (Gtk::Requisition *req) pair const row = _row_labels->dimensions (); pair const grid = _grid->dimensions (); + if (grid.first == 0 && grid.second == 0) { + /* nothing to display */ + req->width = 256; + req->height = 64; + return; + } + /* don't ask for the maximum size of our contents, otherwise GTK won't let the containing window shrink below this size */