Provide a visual cue to indicate that MIDI and audio ports cannot be connected to...
authorCarl Hetherington <carl@carlh.net>
Wed, 21 Jul 2010 23:20:56 +0000 (23:20 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 21 Jul 2010 23:20:56 +0000 (23:20 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7463 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/port_matrix_component.h
gtk2_ardour/port_matrix_grid.cc
gtk2_ardour/port_matrix_grid.h

index 196a24b0c01333987d88a7e156a906a1e42bf3b7..3fdd26394a94fbf11657cdd7c33ba35b2cea5f0e 100644 (file)
@@ -137,7 +137,7 @@ protected:
        }
 
        /** @return colour to paint grid squares when they can't be associated */
-       static Gdk::Color unknown_colour () {
+       static Gdk::Color non_connectable_colour () {
                return Gdk::Color ("#cccccc");
        }
 
index f4ca28fcd2da1b55c975ad884b1a91a212993ce3..8a12df236e2450ee549803067a3afcefd4b4b51b 100644 (file)
@@ -127,7 +127,11 @@ PortMatrixGrid::render (cairo_t* cr)
                ++N;
        }
 
-       /* ASSOCIATION INDICATORS */
+       /* ASSOCIATION INDICATORS and NON-CONNECTABLE INDICATORS */
+
+       /* we draw a grey square in a matrix box if the two ports that intersect at that box
+          cannot be connected because they are of different types (MIDI vs. audio)
+       */
 
        uint32_t bx = 0;
        uint32_t by = 0;
@@ -182,18 +186,24 @@ PortMatrixGrid::render (cairo_t* cr)
                                                c[_matrix->column_index()] = ARDOUR::BundleChannel ((*i)->bundle, k);
                                                c[_matrix->row_index()] = ARDOUR::BundleChannel ((*j)->bundle, l);
 
-                                               PortMatrixNode::State const s = _matrix->get_state (c);
-
-                                               switch (s) {
-                                               case PortMatrixNode::ASSOCIATED:
-                                                       draw_association_indicator (cr, x, y);
-                                                       break;
-
-                                               case PortMatrixNode::NOT_ASSOCIATED:
-                                                       break;
-
-                                               default:
-                                                       break;
+                                               if (c[0].bundle->channel_type (c[0].channel) != c[1].bundle->channel_type (c[1].channel)) {
+                                                       /* these two channels are of different types */
+                                                       draw_non_connectable_indicator (cr, x, y);
+                                               } else {
+                                                       /* these two channels might be associated */
+                                                       PortMatrixNode::State const s = _matrix->get_state (c);
+                                                       
+                                                       switch (s) {
+                                                       case PortMatrixNode::ASSOCIATED:
+                                                               draw_association_indicator (cr, x, y);
+                                                               break;
+                                                               
+                                                       case PortMatrixNode::NOT_ASSOCIATED:
+                                                               break;
+                                                               
+                                                       default:
+                                                               break;
+                                                       }
                                                }
 
                                                y += grid_spacing();
@@ -241,6 +251,23 @@ PortMatrixGrid::draw_empty_square (cairo_t* cr, uint32_t x, uint32_t y)
        cairo_fill (cr);
 }
 
+/** Draw a square to indicate that two channels in a matrix cannot be associated
+ *  with each other.
+ */
+void
+PortMatrixGrid::draw_non_connectable_indicator (cairo_t* cr, uint32_t x, uint32_t y)
+{
+       set_source_rgb (cr, non_connectable_colour ());
+       cairo_rectangle (
+               cr,
+               x + thick_grid_line_width(),
+               y + thick_grid_line_width(),
+               grid_spacing() - 2 * thick_grid_line_width(),
+               grid_spacing() - 2 * thick_grid_line_width()
+               );
+       cairo_fill (cr);
+}
+
 PortMatrixNode
 PortMatrixGrid::position_to_node (double x, double y) const
 {
index f90626334dabd80b38d937ecd24937309746db62..cb3a415ed15d7eb0fa530beddf0eacee696abf20 100644 (file)
@@ -62,6 +62,7 @@ private:
        void queue_draw_for (std::list<PortMatrixNode> const &);
        void draw_association_indicator (cairo_t *, uint32_t, uint32_t, double p = 1);
        void draw_empty_square (cairo_t *, uint32_t, uint32_t);
+       void draw_non_connectable_indicator (cairo_t *, uint32_t, uint32_t);
        std::list<PortMatrixNode> nodes_on_line (int, int, int, int) const;
        PortMatrixNode::State get_association (PortMatrixNode) const;
        void set_association (PortMatrixNode, bool);