summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-11-15 00:26:28 +0000
committerCarl Hetherington <carl@carlh.net>2009-11-15 00:26:28 +0000
commit2e02e157c30464ccc1cd9d8dc7564d2fabc95e5e (patch)
treed1cbf7ee53f73314a5481747b976a5a70cbfac28 /gtk2_ardour
parentccf58b8de23619db9983a45f696fd97e13a15cce (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')
-rw-r--r--gtk2_ardour/port_group.cc11
-rw-r--r--gtk2_ardour/port_group.h6
-rw-r--r--gtk2_ardour/port_matrix_body.cc32
3 files changed, 47 insertions, 2 deletions
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<ARDOUR::Bundle> b) const
return boost::shared_ptr<IO> ();
}
+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<Bundle> 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<void> Changed;
sigc::signal<void, ARDOUR::Bundle::Change> 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<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 */