Consider size of port matrix column labels for size of row labels
authorJohannes Mueller <github@johannes-mueller.org>
Sun, 28 Oct 2018 16:22:32 +0000 (17:22 +0100)
committerJohannes Mueller <github@johannes-mueller.org>
Thu, 1 Nov 2018 17:53:27 +0000 (18:53 +0100)
The column labels are drawn in an angle towards the edge where the row labels
are. Therefore, if the column labels are much longer than the row labels it can
happen that they go beyond the left edge. In that case we have to add an extra
width to the row labels.

gtk2_ardour/port_matrix_body.cc
gtk2_ardour/port_matrix_row_labels.cc
gtk2_ardour/port_matrix_row_labels.h

index c07a6dc529f60a3de162a047ca086bcf251f90a7..66ed3ecc3e2c0cea55212f770ea8a05b45004c6e 100644 (file)
@@ -43,7 +43,7 @@ PortMatrixBody::PortMatrixBody (PortMatrix* p)
          _ignore_component_size_changed (false)
 {
        _column_labels = new PortMatrixColumnLabels (p, this);
-       _row_labels = new PortMatrixRowLabels (p, this);
+       _row_labels = new PortMatrixRowLabels (p, this, *_column_labels);
        _grid = new PortMatrixGrid (p, this);
 
        _components.push_back (_column_labels);
index ff7ac6a48ad29b607a28a816ab6d307836a65939..893313c607012b4c93d295bb125269eba6800c7f 100644 (file)
 #include "gtkmm2ext/colors.h"
 #include "utils.h"
 #include "port_matrix_row_labels.h"
+#include "port_matrix_column_labels.h"
 #include "port_matrix.h"
 #include "port_matrix_body.h"
 #include "pbd/i18n.h"
 
 using namespace std;
 
-PortMatrixRowLabels::PortMatrixRowLabels (PortMatrix* m, PortMatrixBody* b)
+PortMatrixRowLabels::PortMatrixRowLabels (PortMatrix* m, PortMatrixBody* b, PortMatrixColumnLabels& cols)
        : PortMatrixLabels (m, b)
+       , _column_labels (cols)
 {
 
 }
@@ -93,6 +95,13 @@ PortMatrixRowLabels::compute_dimensions ()
                _width += _longest_port_name;
                _width += name_pad() * 2;
        }
+
+       uint32_t needed_by_columns = _column_labels.dimensions().second * tan (angle());
+
+       if (_width < needed_by_columns) {
+               _longest_bundle_name += (needed_by_columns - _width);
+               _width = needed_by_columns;
+       }
 }
 
 
index 21839df41e77914a57dafc704aef44b78977fa59..59a945479a00b066e1f49611d6bcc7fa347658a5 100644 (file)
@@ -27,6 +27,7 @@
 class PortMatrix;
 class PortMatrixBody;
 class PortMatrixNode;
+class PortMatrixColumnLabels;
 
 namespace ARDOUR {
        class Bundle;
@@ -41,7 +42,7 @@ namespace Gtk {
 class PortMatrixRowLabels : public PortMatrixLabels
 {
 public:
-       PortMatrixRowLabels (PortMatrix *, PortMatrixBody *);
+       PortMatrixRowLabels (PortMatrix *, PortMatrixBody *, PortMatrixColumnLabels&);
 
        void button_press (double, double, GdkEventButton *);
 
@@ -68,6 +69,8 @@ private:
 
        double _longest_port_name;
        double _longest_bundle_name;
+
+       PortMatrixColumnLabels& _column_labels;
 };
 
 #endif