From dc86434283718b7c4a4ed6af52a950e6cfc5e86f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 7 Dec 2009 18:35:42 +0000 Subject: Redraw the matrix correctly when available ports change in the currently visible tab. git-svn-id: svn://localhost/ardour2/branches/3.0@6322 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/global_port_matrix.cc | 2 +- gtk2_ardour/port_group.cc | 4 +- gtk2_ardour/port_matrix.cc | 106 +++++++++++++++++--------------------- gtk2_ardour/port_matrix.h | 12 ++--- gtk2_ardour/port_matrix_body.cc | 32 +++++++----- 5 files changed, 73 insertions(+), 83 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/global_port_matrix.cc b/gtk2_ardour/global_port_matrix.cc index 327ba41b06..ae51e7fb68 100644 --- a/gtk2_ardour/global_port_matrix.cc +++ b/gtk2_ardour/global_port_matrix.cc @@ -155,7 +155,7 @@ GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session* s, ARDOUR::Data } add (_port_matrix); - show_all (); + _port_matrix.show (); } void diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 6d3f92d267..2589722264 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -245,7 +245,7 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups) if (session == 0) { return; } - + boost::shared_ptr bus (new PortGroup (_("Bus"))); boost::shared_ptr track (new PortGroup (_("Track"))); boost::shared_ptr system (new PortGroup (_("System"))); @@ -351,6 +351,8 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups) std::string const p = ports[n]; + cout << p << "\n"; + if (!system->has_port(p) && !bus->has_port(p) && !track->has_port(p) && diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 58c8a099bd..604fecbe6b 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -69,10 +69,10 @@ PortMatrix::PortMatrix (Window* parent, Session* session, DataType type) _hbox.pack_start (_hnotebook, false, false); _hbox.pack_start (_hlabel, true, true); - _vnotebook.signal_switch_page().connect (mem_fun (*this, &PortMatrix::v_page_selected)); + _vnotebook.signal_switch_page().connect (mem_fun (*this, &PortMatrix::notebook_page_selected)); _vnotebook.property_tab_border() = 4; _vnotebook.set_name (X_("PortMatrixLabel")); - _hnotebook.signal_switch_page().connect (mem_fun (*this, &PortMatrix::h_page_selected)); + _hnotebook.signal_switch_page().connect (mem_fun (*this, &PortMatrix::notebook_page_selected)); _hnotebook.property_tab_border() = 4; _hnotebook.set_name (X_("PortMatrixLabel")); @@ -92,9 +92,12 @@ PortMatrix::PortMatrix (Window* parent, Session* session, DataType type) _body->show (); _vbox.show (); _hbox.show (); + _vscroll.show (); + _hscroll.show (); _vlabel.show (); _hlabel.show (); _hspacer.show (); + _vspacer.show (); } PortMatrix::~PortMatrix () @@ -115,14 +118,6 @@ PortMatrix::init () { select_arrangement (); - if (!_ports[0].empty()) { - _visible_ports[0] = *_ports[0].begin(); - } - - if (!_ports[1].empty()) { - _visible_ports[1] = *_ports[1].begin(); - } - /* Signal handling is kind of split into two parts: * * 1. When _ports[] changes, we call setup(). This essentially sorts out our visual @@ -207,9 +202,13 @@ PortMatrix::routes_changed () void PortMatrix::setup () { + /* this needs to be done first, as the visible_ports() method uses the + notebook state to decide which ports are being shown */ + + setup_notebooks (); + _body->setup (); setup_scrollbars (); - setup_notebooks (); queue_draw (); } @@ -342,10 +341,10 @@ PortMatrix::columns () const return &_ports[_column_index]; } -boost::shared_ptr +boost::shared_ptr PortMatrix::visible_columns () const { - return _visible_ports[_column_index]; + return visible_ports (_column_index); } /* @return rows list */ @@ -355,10 +354,10 @@ PortMatrix::rows () const return &_ports[_row_index]; } -boost::shared_ptr +boost::shared_ptr PortMatrix::visible_rows () const { - return _visible_ports[_row_index]; + return visible_ports (_row_index); } void @@ -510,7 +509,7 @@ void PortMatrix::setup_global_ports () { ENSURE_GUI_THREAD (mem_fun (*this, &PortMatrix::setup_global_ports)); - + for (int i = 0; i < 2; ++i) { if (list_is_global (i)) { setup_ports (i); @@ -683,7 +682,7 @@ PortMatrix::setup_notebooks () if (_hnotebook.get_n_pages() <= 1) { _hbox.hide (); } else { - _vbox.show (); + _hbox.show (); } if (_vnotebook.get_n_pages() <= 1) { @@ -704,53 +703,15 @@ PortMatrix::remove_notebook_pages (Notebook& n) } void -PortMatrix::v_page_selected (GtkNotebookPage *, guint n) -{ - if (_ignore_notebook_page_selected) { - return; - } - - PortGroupList& p = _ports[_row_index]; - - n = p.size() - n - 1; - - int i = 0; - PortGroupList::List::const_iterator j = p.begin(); - while (i != int (n) && j != p.end()) { - ++i; - ++j; - } - - if (j != p.end()) { - _visible_ports[_row_index] = *j; - _body->setup (); - setup_scrollbars (); - queue_draw (); - } -} - -void -PortMatrix::h_page_selected (GtkNotebookPage *, guint n) +PortMatrix::notebook_page_selected (GtkNotebookPage *, guint) { if (_ignore_notebook_page_selected) { return; } - PortGroupList& p = _ports[_column_index]; - - int i = 0; - PortGroupList::List::const_iterator j = p.begin(); - while (i != int (n) && j != p.end()) { - ++i; - ++j; - } - - if (j != p.end()) { - _visible_ports[_column_index] = *j; - _body->setup (); - setup_scrollbars (); - queue_draw (); - } + _body->setup (); + setup_scrollbars (); + queue_draw (); } void @@ -771,3 +732,30 @@ PortMatrix::body_dimensions_changed () } } + + +boost::shared_ptr +PortMatrix::visible_ports (int d) const +{ + PortGroupList const & p = _ports[d]; + PortGroupList::List::const_iterator j = p.begin (); + + int n = 0; + if (d == _row_index) { + n = p.size() - _vnotebook.get_current_page () - 1; + } else { + n = _hnotebook.get_current_page (); + } + + int i = 0; + while (i != int (n) && j != p.end ()) { + ++i; + ++j; + } + + if (j == p.end()) { + return boost::shared_ptr (); + } + + return *j; +} diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h index f228a4101f..477b0947dc 100644 --- a/gtk2_ardour/port_matrix.h +++ b/gtk2_ardour/port_matrix.h @@ -88,7 +88,7 @@ public: } PortGroupList const * columns () const; - boost::shared_ptr visible_columns () const; + boost::shared_ptr visible_columns () const; /** @return index into the _ports array for the list which is displayed as columns */ int column_index () const { @@ -96,7 +96,7 @@ public: } PortGroupList const * rows () const; - boost::shared_ptr visible_rows () const; + boost::shared_ptr visible_rows () const; /** @return index into the _ports array for the list which is displayed as rows */ int row_index () const { @@ -107,9 +107,7 @@ public: return &_ports[d]; } - boost::shared_ptr visible_ports (int d) const { - return _visible_ports[d]; - } + boost::shared_ptr visible_ports (int d) const; void init (); void setup (); @@ -156,7 +154,6 @@ protected: from left to right as you go from list 0 to list 1. Hence subclasses which deal with inputs and outputs should put outputs in list 0 and inputs in list 1. */ PortGroupList _ports[2]; - boost::shared_ptr _visible_ports[2]; ARDOUR::Session* _session; private: @@ -176,8 +173,7 @@ private: boost::shared_ptr io_from_bundle (boost::shared_ptr) const; void setup_notebooks (); void remove_notebook_pages (Gtk::Notebook &); - void v_page_selected (GtkNotebookPage *, guint); - void h_page_selected (GtkNotebookPage *, guint); + void notebook_page_selected (GtkNotebookPage *, guint); void route_processors_changed (ARDOUR::RouteProcessorChange); void body_dimensions_changed (); void session_going_away (); diff --git a/gtk2_ardour/port_matrix_body.cc b/gtk2_ardour/port_matrix_body.cc index 72da040ed7..847ee2f2ca 100644 --- a/gtk2_ardour/port_matrix_body.cc +++ b/gtk2_ardour/port_matrix_body.cc @@ -253,22 +253,26 @@ PortMatrixBody::setup () /* Connect to bundles so that we find out when their names change */ - PortGroup::BundleList r = _matrix->visible_rows()->bundles (); - for (PortGroup::BundleList::iterator i = r.begin(); i != r.end(); ++i) { - - _bundle_connections.push_back ( - i->bundle->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_row_labels))) - ); - + if (_matrix->visible_rows()) { + PortGroup::BundleList r = _matrix->visible_rows()->bundles (); + for (PortGroup::BundleList::iterator i = r.begin(); i != r.end(); ++i) { + + _bundle_connections.push_back ( + i->bundle->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_row_labels))) + ); + + } } - - PortGroup::BundleList c = _matrix->visible_columns()->bundles (); - for (PortGroup::BundleList::iterator i = c.begin(); i != c.end(); ++i) { - _bundle_connections.push_back ( - i->bundle->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_column_labels))) - ); + + if (_matrix->visible_columns()) { + PortGroup::BundleList c = _matrix->visible_columns()->bundles (); + for (PortGroup::BundleList::iterator i = c.begin(); i != c.end(); ++i) { + _bundle_connections.push_back ( + i->bundle->Changed.connect (sigc::hide (sigc::mem_fun (*this, &PortMatrixBody::rebuild_and_draw_column_labels))) + ); + } } - + for (list::iterator i = _components.begin(); i != _components.end(); ++i) { (*i)->setup (); } -- cgit v1.2.3