X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fport_matrix_component.cc;h=440376d1fa0fdcb003b4d004def9bc89c07944a7;hb=fcbb78b010a53686d1c350864d731a73bd204956;hp=2f5a498d416d5fadd6a0a0e945c608429414af6f;hpb=91dae1fb0329b49deb74f2972418c71b0373114c;p=ardour.git diff --git a/gtk2_ardour/port_matrix_component.cc b/gtk2_ardour/port_matrix_component.cc index 2f5a498d41..440376d1fa 100644 --- a/gtk2_ardour/port_matrix_component.cc +++ b/gtk2_ardour/port_matrix_component.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2009 Paul Davis + Copyright (C) 2002-2009 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,8 @@ using namespace std; /** Constructor. - * @param p Port matrix that we're in. + * @param m Port matrix that we're in. + * @param b Port matrix body that we're in. */ PortMatrixComponent::PortMatrixComponent (PortMatrix* m, PortMatrixBody* b) : _matrix (m), @@ -33,14 +34,14 @@ PortMatrixComponent::PortMatrixComponent (PortMatrix* m, PortMatrixBody* b) _render_required (true), _dimension_computation_required (true) { - + } /** Destructor */ PortMatrixComponent::~PortMatrixComponent () { if (_pixmap) { - gdk_pixmap_unref (_pixmap); + g_object_unref (_pixmap); } } @@ -73,7 +74,7 @@ PortMatrixComponent::get_pixmap (GdkDrawable *drawable) /* make a pixmap of the right size */ if (_pixmap) { - gdk_pixmap_unref (_pixmap); + g_object_unref (_pixmap); } _pixmap = gdk_pixmap_new (drawable, _width, _height, -1); @@ -125,18 +126,14 @@ uint32_t PortMatrixComponent::group_size (boost::shared_ptr g) const { uint32_t s = 0; - - if (g->visible()) { - PortGroup::BundleList const & bundles = g->bundles (); - if (_matrix->show_only_bundles()) { - s = bundles.size(); - } else { - for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) { - s += i->bundle->nchannels(); - } - } + + PortGroup::BundleList const & bundles = g->bundles (); + if (_matrix->show_only_bundles()) { + s = bundles.size(); } else { - s = 1; + for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) { + s += (*i)->bundle->nchannels(); + } } return s; @@ -144,46 +141,35 @@ PortMatrixComponent::group_size (boost::shared_ptr g) const /** @param bc Channel. * @param groups List of groups. - * @return Position of bc in groups in grid units, taking visibility and show_only_bundles into account. + * @return Position of bc in groups in grid units, taking show_only_bundles into account. */ uint32_t -PortMatrixComponent::channel_to_position (ARDOUR::BundleChannel bc, PortGroupList const * groups) const +PortMatrixComponent::channel_to_position (ARDOUR::BundleChannel bc, boost::shared_ptr group) const { uint32_t p = 0; - for (PortGroupList::List::const_iterator i = groups->begin(); i != groups->end(); ++i) { + PortGroup::BundleList const & bundles = group->bundles (); - PortGroup::BundleList const & bundles = (*i)->bundles (); + for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) { - for (PortGroup::BundleList::const_iterator j = bundles.begin(); j != bundles.end(); ++j) { - - if (j->bundle == bc.bundle) { - - /* found the bundle */ - - if (_matrix->show_only_bundles() || !(*i)->visible()) { - return p; - } else { - return p + bc.channel; - } + if ((*i)->bundle == bc.bundle) { + /* found the bundle */ + + if (_matrix->show_only_bundles()) { + return p; + } else { + return p + bc.channel; } - - if ((*i)->visible()) { - - /* move past this bundle */ - - if (_matrix->show_only_bundles()) { - p += 1; - } else { - p += j->bundle->nchannels (); - } - } + } - if (!(*i)->visible()) { - /* if this group isn't visible we won't have updated p, so do it now */ + /* move past this bundle */ + + if (_matrix->show_only_bundles()) { p += 1; + } else { + p += (*i)->bundle->nchannels (); } } @@ -191,55 +177,34 @@ PortMatrixComponent::channel_to_position (ARDOUR::BundleChannel bc, PortGroupLis } -pair, ARDOUR::BundleChannel> -PortMatrixComponent::position_to_group_and_channel (uint32_t p, PortGroupList const * groups) const +ARDOUR::BundleChannel +PortMatrixComponent::position_to_channel (double p, double, boost::shared_ptr group) const { - PortGroupList::List::const_iterator i = groups->begin (); - - while (i != groups->end()) { - - uint32_t const gs = group_size (*i); - - if (p < gs) { - - /* it's in this group */ - - if (!(*i)->visible()) { - return make_pair (*i, ARDOUR::BundleChannel (boost::shared_ptr (), 0)); - } - - PortGroup::BundleList const & bundles = (*i)->bundles (); - for (PortGroup::BundleList::const_iterator j = bundles.begin(); j != bundles.end(); ++j) { - - if (_matrix->show_only_bundles()) { - - if (p == 0) { - return make_pair (*i, ARDOUR::BundleChannel (j->bundle, 0)); - } else { - p -= 1; - } - - } else { - - uint32_t const s = j->bundle->nchannels (); - if (p < s) { - return make_pair (*i, ARDOUR::BundleChannel (j->bundle, p)); - } else { - p -= s; - } - - } + p /= grid_spacing (); + + PortGroup::BundleList const & bundles = group->bundles (); + for (PortGroup::BundleList::const_iterator j = bundles.begin(); j != bundles.end(); ++j) { + if (_matrix->show_only_bundles()) { + + if (p < 1) { + return ARDOUR::BundleChannel ((*j)->bundle, -1); + } else { + p -= 1; } - + } else { - - p -= gs; - + + uint32_t const s = (*j)->bundle->nchannels (); + if (p < s) { + return ARDOUR::BundleChannel ((*j)->bundle, p); + } else { + p -= s; + } + } - - ++i; + } - - return make_pair (boost::shared_ptr (), ARDOUR::BundleChannel (boost::shared_ptr (), 0)); + + return ARDOUR::BundleChannel (boost::shared_ptr (), -1); }