summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_matrix_component.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-11-18 13:35:31 +0000
committerCarl Hetherington <carl@carlh.net>2009-11-18 13:35:31 +0000
commit73a0cd56f8bab790e0bbcf09b4f51e20175f4dc8 (patch)
tree4589913ad551505381b0a7ac0a0c5277ce67148e /gtk2_ardour/port_matrix_component.cc
parentef92349187b61349d2d5182f49f700183901f59e (diff)
Rework port matrix to use Gtk notebook tabs to select visible groups.
git-svn-id: svn://localhost/ardour2/branches/3.0@6117 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_matrix_component.cc')
-rw-r--r--gtk2_ardour/port_matrix_component.cc128
1 files changed, 45 insertions, 83 deletions
diff --git a/gtk2_ardour/port_matrix_component.cc b/gtk2_ardour/port_matrix_component.cc
index c617070907..8feb7a5309 100644
--- a/gtk2_ardour/port_matrix_component.cc
+++ b/gtk2_ardour/port_matrix_component.cc
@@ -126,17 +126,13 @@ PortMatrixComponent::group_size (boost::shared_ptr<const PortGroup> 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 +140,35 @@ PortMatrixComponent::group_size (boost::shared_ptr<const PortGroup> 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<const PortGroup> 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,57 +176,34 @@ PortMatrixComponent::channel_to_position (ARDOUR::BundleChannel bc, PortGroupLis
}
-pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel>
-PortMatrixComponent::position_to_group_and_channel (double p, double, PortGroupList const * groups) const
+ARDOUR::BundleChannel
+PortMatrixComponent::position_to_channel (double p, double, boost::shared_ptr<const PortGroup> group) const
{
p /= grid_spacing ();
- 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<ARDOUR::Bundle> (), 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;
- }
-
- }
+ 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 == 0) {
+ return ARDOUR::BundleChannel (j->bundle, 0);
+ } 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<PortGroup> (), ARDOUR::BundleChannel (boost::shared_ptr<ARDOUR::Bundle> (), 0));
+
+ return ARDOUR::BundleChannel (boost::shared_ptr<ARDOUR::Bundle> (), 0);
}