From 748ad24ace7a37059b6812a1f9f0145d4725ba66 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 17 Jul 2009 14:21:54 +0000 Subject: [PATCH] Small optimisation. Fix mouseover highlighting in the port matrix. git-svn-id: svn://localhost/ardour2/branches/3.0@5369 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/port_group.cc | 20 ++++++++++++++------ gtk2_ardour/port_group.h | 1 + gtk2_ardour/port_matrix_column_labels.cc | 7 ++++--- gtk2_ardour/port_matrix_labels.cc | 2 -- gtk2_ardour/port_matrix_row_labels.cc | 5 +++-- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index f64b1031ef..149baf3046 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -159,7 +159,7 @@ PortGroup::total_channels () const /** PortGroupList constructor. */ PortGroupList::PortGroupList () - : _type (DataType::AUDIO), _signals_suspended (false), _pending_change (false) + : _type (DataType::AUDIO), _signals_suspended (false), _pending_change (false), _bundles_dirty (true) { } @@ -319,6 +319,7 @@ PortGroupList::gather (ARDOUR::Session& session, bool inputs) add_group (other); emit_changed (); + _bundles_dirty = true; } boost::shared_ptr @@ -402,18 +403,23 @@ PortGroupList::clear () _bundle_changed_connections.clear (); emit_changed (); + _bundles_dirty = true; } PortGroup::BundleList const & PortGroupList::bundles () const { - _bundles.clear (); - - for (PortGroupList::List::const_iterator i = begin (); i != end (); ++i) { - if ((*i)->visible()) { - std::copy ((*i)->bundles().begin(), (*i)->bundles().end(), std::back_inserter (_bundles)); + if (_bundles_dirty) { + _bundles.clear (); + + for (PortGroupList::List::const_iterator i = begin (); i != end (); ++i) { + if ((*i)->visible()) { + std::copy ((*i)->bundles().begin(), (*i)->bundles().end(), std::back_inserter (_bundles)); + } } + + _bundles_dirty = false; } return _bundles; @@ -446,6 +452,7 @@ PortGroupList::add_group (boost::shared_ptr g) ); emit_changed (); + _bundles_dirty = true; } void @@ -456,6 +463,7 @@ PortGroupList::remove_bundle (boost::shared_ptr b) } emit_changed (); + _bundles_dirty = true; } void diff --git a/gtk2_ardour/port_group.h b/gtk2_ardour/port_group.h index f3f84a23ad..21dc9445cc 100644 --- a/gtk2_ardour/port_group.h +++ b/gtk2_ardour/port_group.h @@ -134,6 +134,7 @@ class PortGroupList : public sigc::trackable ARDOUR::DataType _type; mutable PortGroup::BundleList _bundles; + mutable bool _bundles_dirty; List _groups; std::vector _bundle_changed_connections; bool _signals_suspended; diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc index e630dec4c0..92affb1f31 100644 --- a/gtk2_ardour/port_matrix_column_labels.cc +++ b/gtk2_ardour/port_matrix_column_labels.cc @@ -413,8 +413,9 @@ PortMatrixColumnLabels::channel_x (ARDOUR::BundleChannel const &bc) const { uint32_t n = 0; - PortGroup::BundleList::const_iterator i = _matrix->columns()->bundles().begin(); - while (i != _matrix->columns()->bundles().end() && i->bundle != bc.bundle) { + PortGroup::BundleList const & b = _matrix->columns()->bundles (); + PortGroup::BundleList::const_iterator i = b.begin(); + while (i != b.end() && i->bundle != bc.bundle) { if (_matrix->show_only_bundles()) { n += 1; } else { @@ -426,7 +427,7 @@ PortMatrixColumnLabels::channel_x (ARDOUR::BundleChannel const &bc) const if (!_matrix->show_only_bundles()) { n += bc.channel; } - + return n * column_width(); } diff --git a/gtk2_ardour/port_matrix_labels.cc b/gtk2_ardour/port_matrix_labels.cc index 8b34b71ffb..d29a9244df 100644 --- a/gtk2_ardour/port_matrix_labels.cc +++ b/gtk2_ardour/port_matrix_labels.cc @@ -25,7 +25,6 @@ void PortMatrixLabels::draw_extra (cairo_t* cr) { for (std::vector::const_iterator i = _channel_highlights.begin(); i != _channel_highlights.end(); ++i) { - if (_matrix->show_only_bundles()) { render_bundle_name ( cr, @@ -50,7 +49,6 @@ void PortMatrixLabels::clear_channel_highlights () { for (std::vector::const_iterator i = _channel_highlights.begin(); i != _channel_highlights.end(); ++i) { - queue_draw_for (*i); } diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc index ded591278e..4802d4ca33 100644 --- a/gtk2_ardour/port_matrix_row_labels.cc +++ b/gtk2_ardour/port_matrix_row_labels.cc @@ -316,8 +316,9 @@ PortMatrixRowLabels::channel_y (ARDOUR::BundleChannel const& bc) const { uint32_t n = 0; - PortGroup::BundleList::const_iterator i = _matrix->rows()->bundles().begin(); - while (i != _matrix->rows()->bundles().end() && i->bundle != bc.bundle) { + PortGroup::BundleList const & bundles = _matrix->rows()->bundles(); + PortGroup::BundleList::const_iterator i = bundles.begin (); + while (i != bundles.end() && i->bundle != bc.bundle) { if (_matrix->show_only_bundles()) { n += 1; } else { -- 2.30.2