Small optimisation. Fix mouseover highlighting in the port matrix.
authorCarl Hetherington <carl@carlh.net>
Fri, 17 Jul 2009 14:21:54 +0000 (14:21 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 17 Jul 2009 14:21:54 +0000 (14:21 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5369 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/port_group.cc
gtk2_ardour/port_group.h
gtk2_ardour/port_matrix_column_labels.cc
gtk2_ardour/port_matrix_labels.cc
gtk2_ardour/port_matrix_row_labels.cc

index f64b1031efa4a49eace6838a4f446e49b5569525..149baf30467ce83a7b6f9c0ddeecbdcaf4f8aea1 100644 (file)
@@ -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<Bundle>
@@ -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<PortGroup> g)
                );
 
        emit_changed ();
+       _bundles_dirty = true;
 }
 
 void
@@ -456,6 +463,7 @@ PortGroupList::remove_bundle (boost::shared_ptr<Bundle> b)
        }
 
        emit_changed ();
+       _bundles_dirty = true;
 }
 
 void
index f3f84a23ad19d40f66557f25cd32ff7ae126cca4..21dc9445cc29cf10130e15aead56f63635891893 100644 (file)
@@ -134,6 +134,7 @@ class PortGroupList : public sigc::trackable
 
        ARDOUR::DataType _type;
        mutable PortGroup::BundleList _bundles;
+       mutable bool _bundles_dirty;
        List _groups;
        std::vector<sigc::connection> _bundle_changed_connections;
        bool _signals_suspended;
index e630dec4c08a15d475d4fd3ee8269d78017f521d..92affb1f31ea07f967b0c2438ab280558113ecb4 100644 (file)
@@ -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();
 }
 
index 8b34b71ffbc3e886a648c66982a76c4861f833c0..d29a9244dfba575cc37734519112e0c119d5da0e 100644 (file)
@@ -25,7 +25,6 @@ void
 PortMatrixLabels::draw_extra (cairo_t* cr)
 {
        for (std::vector<ARDOUR::BundleChannel>::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<ARDOUR::BundleChannel>::const_iterator i = _channel_highlights.begin(); i != _channel_highlights.end(); ++i) {
-
                queue_draw_for (*i);
        }
 
index ded591278ec2b3f472d62a9cae7cb2d3f0422d2f..4802d4ca3350f80005c74e362c3d68648c84e8d9 100644 (file)
@@ -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 {