From cc83e1a9bfd7339c4ebfcde4a57d511eec51923e Mon Sep 17 00:00:00 2001 From: Johannes Mueller Date: Sun, 28 Oct 2018 17:22:32 +0100 Subject: [PATCH] Consider size of port matrix column labels for size of row labels 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 | 2 +- gtk2_ardour/port_matrix_row_labels.cc | 11 ++++++++++- gtk2_ardour/port_matrix_row_labels.h | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/port_matrix_body.cc b/gtk2_ardour/port_matrix_body.cc index c07a6dc529..66ed3ecc3e 100644 --- a/gtk2_ardour/port_matrix_body.cc +++ b/gtk2_ardour/port_matrix_body.cc @@ -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); diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc index ff7ac6a48a..893313c607 100644 --- a/gtk2_ardour/port_matrix_row_labels.cc +++ b/gtk2_ardour/port_matrix_row_labels.cc @@ -25,14 +25,16 @@ #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; + } } diff --git a/gtk2_ardour/port_matrix_row_labels.h b/gtk2_ardour/port_matrix_row_labels.h index 21839df41e..59a945479a 100644 --- a/gtk2_ardour/port_matrix_row_labels.h +++ b/gtk2_ardour/port_matrix_row_labels.h @@ -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