diff options
author | Carl Hetherington <carl@carlh.net> | 2009-11-15 00:26:28 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2009-11-15 00:26:28 +0000 |
commit | 2e02e157c30464ccc1cd9d8dc7564d2fabc95e5e (patch) | |
tree | d1cbf7ee53f73314a5481747b976a5a70cbfac28 /gtk2_ardour/port_matrix_body.cc | |
parent | ccf58b8de23619db9983a45f696fd97e13a15cce (diff) |
Tidy up a bit in the case where the port matrix has nothing to display.
git-svn-id: svn://localhost/ardour2/branches/3.0@6089 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_matrix_body.cc')
-rw-r--r-- | gtk2_ardour/port_matrix_body.cc | 32 |
1 files changed, 32 insertions, 0 deletions
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<int, int> const row = _row_labels->dimensions (); pair<int, int> 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 */ |