summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_matrix_component.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-07-17 22:54:45 +0000
committerCarl Hetherington <carl@carlh.net>2009-07-17 22:54:45 +0000
commit50437bff22279473cd364d007d5e474af2a542bc (patch)
tree4ebe55e6ac2ae8ded3dfd12a2f1b6e866a9dd6c4 /gtk2_ardour/port_matrix_component.cc
parentb89a786b3e300ce3eb28c4e6791e8e141afb19f9 (diff)
Various tweaks to the port matrix: open to full size; remove buttons and move their functionality into a context menu;
set maximum size hint to stop port matrix windows being resized beyond their useful size; remove visibility checkbuttons - visibility now controlled through menu or by clicking on group names; port groups fold down to a small tab when hidden; don't swap the orientation of the matrix once it has been opened. git-svn-id: svn://localhost/ardour2/branches/3.0@5373 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_matrix_component.cc')
-rw-r--r--gtk2_ardour/port_matrix_component.cc98
1 files changed, 96 insertions, 2 deletions
diff --git a/gtk2_ardour/port_matrix_component.cc b/gtk2_ardour/port_matrix_component.cc
index c6a26d41de..6a60110f3e 100644
--- a/gtk2_ardour/port_matrix_component.cc
+++ b/gtk2_ardour/port_matrix_component.cc
@@ -21,6 +21,8 @@
#include "port_matrix.h"
#include "port_matrix_body.h"
+using namespace std;
+
/** Constructor.
* @param p Port matrix that we're in.
*/
@@ -98,7 +100,7 @@ PortMatrixComponent::set_source_rgba (cairo_t *cr, Gdk::Color const & c, double
cairo_set_source_rgba (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p(), a);
}
-std::pair<uint32_t, uint32_t>
+pair<uint32_t, uint32_t>
PortMatrixComponent::dimensions ()
{
if (_dimension_computation_required) {
@@ -107,7 +109,7 @@ PortMatrixComponent::dimensions ()
_body->component_size_changed ();
}
- return std::make_pair (_width, _height);
+ return make_pair (_width, _height);
}
Gdk::Color
@@ -115,3 +117,95 @@ PortMatrixComponent::background_colour ()
{
return _matrix->get_style()->get_bg (Gtk::STATE_NORMAL);
}
+
+uint32_t
+PortMatrixComponent::group_width (boost::shared_ptr<const PortGroup> g) const
+{
+ uint32_t width = 0;
+
+ if (g->visible()) {
+ PortGroup::BundleList const & bundles = g->bundles ();
+ if (_matrix->show_only_bundles()) {
+ width = bundles.size() * column_width ();
+ } else {
+ for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
+ width += i->bundle->nchannels() * column_width ();
+ }
+ }
+ } else {
+ width = column_width ();
+ }
+
+ return width;
+}
+
+uint32_t
+PortMatrixComponent::group_height (boost::shared_ptr<const PortGroup> g) const
+{
+ uint32_t height = 0;
+
+ if (g->visible ()) {
+ PortGroup::BundleList const & bundles = g->bundles ();
+ if (_matrix->show_only_bundles()) {
+ height = bundles.size() * row_height ();
+ } else {
+ for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
+ height += i->bundle->nchannels() * row_height ();
+ }
+ }
+ } else {
+ height = row_height ();
+ }
+
+ return height;
+}
+
+
+pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel>
+PortMatrixComponent::y_position_to_group_and_channel (double y) const
+{
+ PortGroupList::List::const_iterator i = _matrix->rows()->begin();
+
+ while (i != _matrix->rows()->end()) {
+
+ uint32_t const gh = group_height (*i);
+
+ if (y < gh) {
+
+ /* it's in this group */
+
+ PortGroup::BundleList const & bundles = (*i)->bundles ();
+ for (PortGroup::BundleList::const_iterator j = bundles.begin(); j != bundles.end(); ++j) {
+
+ if (_matrix->show_only_bundles()) {
+
+ if (y < row_height()) {
+ return make_pair (*i, ARDOUR::BundleChannel (j->bundle, 0));
+ } else {
+ y -= row_height ();
+ }
+
+ } else {
+
+ uint32_t const h = j->bundle->nchannels () * row_height ();
+ if (y < h) {
+ return make_pair (*i, ARDOUR::BundleChannel (j->bundle, y / row_height()));
+ } else {
+ y -= h;
+ }
+
+ }
+
+ }
+
+ } else {
+
+ y -= gh;
+
+ }
+
+ ++i;
+ }
+
+ return make_pair (boost::shared_ptr<PortGroup> (), ARDOUR::BundleChannel (boost::shared_ptr<ARDOUR::Bundle> (), 0));
+}