From 6da5dd6d41df9e3d05b9b8cceaf1b671b4e21141 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 19 Jul 2009 19:07:31 +0000 Subject: Port matrix tweaks: scroll wheel support; use the correct verb for disassociation in the menu; fixes for gaps appearing when groups are hidden. git-svn-id: svn://localhost/ardour2/branches/3.0@5382 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/bundle_manager.h | 5 +++ gtk2_ardour/global_port_matrix.h | 5 +++ gtk2_ardour/io_selector.h | 6 ++- gtk2_ardour/port_matrix.cc | 33 +++++++++++++++-- gtk2_ardour/port_matrix.h | 2 + gtk2_ardour/port_matrix_body.cc | 2 +- gtk2_ardour/port_matrix_column_labels.cc | 63 ++++++++++++++------------------ gtk2_ardour/port_matrix_grid.cc | 1 + gtk2_ardour/port_matrix_row_labels.cc | 51 +++++++++++--------------- gtk2_ardour/route_params_ui.cc | 2 - gtk2_ardour/session_option_editor.cc | 4 ++ 11 files changed, 103 insertions(+), 71 deletions(-) diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h index 2d0f41e10e..035bc6ffac 100644 --- a/gtk2_ardour/bundle_manager.h +++ b/gtk2_ardour/bundle_manager.h @@ -25,6 +25,7 @@ #include #include "ardour_dialog.h" #include "port_matrix.h" +#include "i18n.h" namespace ARDOUR { class Session; @@ -50,6 +51,10 @@ class BundleEditorMatrix : public PortMatrix void setup_ports (int); bool list_is_global (int) const; + std::string disassociation_verb () const { + return _("Disassociate"); + } + private: enum { OTHER = 0, diff --git a/gtk2_ardour/global_port_matrix.h b/gtk2_ardour/global_port_matrix.h index 0e5fb02dc5..1372c651f1 100644 --- a/gtk2_ardour/global_port_matrix.h +++ b/gtk2_ardour/global_port_matrix.h @@ -24,6 +24,7 @@ #include "port_matrix.h" #include "port_group.h" #include "ardour_dialog.h" +#include "i18n.h" class GlobalPortMatrix : public PortMatrix { @@ -44,6 +45,10 @@ public: return false; } + std::string disassociation_verb () const { + return _("Disconnect"); + } + bool list_is_global (int) const { return true; } diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h index 24e99e27ec..eccdd91a26 100644 --- a/gtk2_ardour/io_selector.h +++ b/gtk2_ardour/io_selector.h @@ -22,6 +22,7 @@ #include "ardour_dialog.h" #include "port_matrix.h" +#include "i18n.h" namespace ARDOUR { class PortInsert; @@ -43,6 +44,10 @@ class IOSelector : public PortMatrix bool can_rename_channels (int d) const { return false; } + + std::string disassociation_verb () const { + return _("Disconnect"); + } uint32_t n_io_ports () const; boost::shared_ptr const io () { return _io; } @@ -61,7 +66,6 @@ class IOSelector : public PortMatrix return _other; } - private: int _other; diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 8727c1f677..001d06081f 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -30,6 +30,7 @@ #include "ardour/route.h" #include "port_matrix.h" #include "port_matrix_body.h" +#include "port_matrix_component.h" #include "i18n.h" using namespace std; @@ -319,11 +320,13 @@ PortMatrix::popup_menu ( boost::weak_ptr w (bc[dim].bundle); if (_show_only_bundles) { - snprintf (buf, sizeof (buf), _("Disassociate all from '%s'"), bc[dim].bundle->name().c_str()); + snprintf (buf, sizeof (buf), _("%s all from '%s'"), disassociation_verb().c_str(), bc[dim].bundle->name().c_str()); } else { snprintf ( - buf, sizeof (buf), _("Disassociate all from '%s/%s'"), - bc[dim].bundle->name().c_str(), bc[dim].bundle->channel_name (bc[dim].channel).c_str() + buf, sizeof (buf), _("%s all from '%s/%s'"), + disassociation_verb().c_str(), + bc[dim].bundle->name().c_str(), + bc[dim].bundle->channel_name (bc[dim].channel).c_str() ); } @@ -464,3 +467,27 @@ PortMatrix::setup_max_size () { MaxSizeChanged (); } + +bool +PortMatrix::on_scroll_event (GdkEventScroll* ev) +{ + double const h = _hscroll.get_value (); + double const v = _vscroll.get_value (); + + switch (ev->direction) { + case GDK_SCROLL_UP: + _vscroll.set_value (v - PortMatrixComponent::grid_spacing ()); + break; + case GDK_SCROLL_DOWN: + _vscroll.set_value (v + PortMatrixComponent::grid_spacing ()); + break; + case GDK_SCROLL_LEFT: + _hscroll.set_value (h - PortMatrixComponent::grid_spacing ()); + break; + case GDK_SCROLL_RIGHT: + _hscroll.set_value (h + PortMatrixComponent::grid_spacing ()); + break; + } + + return true; +} diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h index 4d103bf369..885745aa6a 100644 --- a/gtk2_ardour/port_matrix.h +++ b/gtk2_ardour/port_matrix.h @@ -129,6 +129,7 @@ public: virtual void remove_channel (ARDOUR::BundleChannel) = 0; virtual bool can_rename_channels (int) const = 0; virtual void rename_channel (ARDOUR::BundleChannel) {} + virtual std::string disassociation_verb () const = 0; enum Result { Cancelled, @@ -162,6 +163,7 @@ private: void hide_group (boost::weak_ptr); void show_group (boost::weak_ptr); void toggle_show_only_bundles (); + bool on_scroll_event (GdkEventScroll *); /// port type that we are working with ARDOUR::DataType _type; diff --git a/gtk2_ardour/port_matrix_body.cc b/gtk2_ardour/port_matrix_body.cc index 93345e893e..f61593d540 100644 --- a/gtk2_ardour/port_matrix_body.cc +++ b/gtk2_ardour/port_matrix_body.cc @@ -210,7 +210,7 @@ PortMatrixBody::compute_rectangles () } else if (_matrix->arrangement() == PortMatrix::LEFT_TO_BOTTOM) { col_rect.set_height (min (_alloc_height, col.second)); - + row_rect.set_x (0); row_rect.set_y (0); row_rect.set_width (min (_alloc_width, row.first)); diff --git a/gtk2_ardour/port_matrix_column_labels.cc b/gtk2_ardour/port_matrix_column_labels.cc index 3183d96a9d..1679b321df 100644 --- a/gtk2_ardour/port_matrix_column_labels.cc +++ b/gtk2_ardour/port_matrix_column_labels.cc @@ -49,26 +49,30 @@ PortMatrixColumnLabels::compute_dimensions () _highest_text = 0; /* width of the whole thing */ _width = 0; - - PortGroup::BundleList const c = _matrix->columns()->bundles(); - for (PortGroup::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) { - - cairo_text_extents_t ext; - cairo_text_extents (cr, i->bundle->name().c_str(), &ext); - if (ext.width > _longest_bundle_name) { - _longest_bundle_name = ext.width; - } - if (ext.height > _highest_text) { - _highest_text = ext.height; - } - - for (uint32_t j = 0; j < i->bundle->nchannels (); ++j) { + _highest_group_name = 0; + + for (PortGroupList::List::const_iterator i = _matrix->columns()->begin(); i != _matrix->columns()->end(); ++i) { + PortGroup::BundleList const c = _matrix->columns()->bundles(); + for (PortGroup::BundleList::const_iterator j = c.begin (); j != c.end(); ++j) { - cairo_text_extents ( - cr, - i->bundle->channel_name (j).c_str(), - &ext - ); + cairo_text_extents_t ext; + cairo_text_extents (cr, j->bundle->name().c_str(), &ext); + if (ext.width > _longest_bundle_name) { + _longest_bundle_name = ext.width; + } + + if (ext.height > _highest_text) { + _highest_text = ext.height; + } + + for (uint32_t k = 0; k < j->bundle->nchannels (); ++k) { + + cairo_text_extents ( + cr, + j->bundle->channel_name (k).c_str(), + &ext + ); + } if (ext.width > _longest_channel_name) { _longest_channel_name = ext.width; @@ -78,23 +82,12 @@ PortMatrixColumnLabels::compute_dimensions () } } - if (_matrix->show_only_bundles()) { - _width += grid_spacing(); - } else { - _width += i->bundle->nchannels() * grid_spacing(); - } - } + _width += group_size (*i) * grid_spacing (); - _highest_group_name = 0; - for (PortGroupList::List::const_iterator i = _matrix->columns()->begin(); i != _matrix->columns()->end(); ++i) { - if ((*i)->visible()) { - cairo_text_extents_t ext; - cairo_text_extents (cr, (*i)->name.c_str(), &ext); - if (ext.height > _highest_group_name) { - _highest_group_name = ext.height; - } - } else { - _width += grid_spacing (); + cairo_text_extents_t ext; + cairo_text_extents (cr, (*i)->name.c_str(), &ext); + if (ext.height > _highest_group_name) { + _highest_group_name = ext.height; } } diff --git a/gtk2_ardour/port_matrix_grid.cc b/gtk2_ardour/port_matrix_grid.cc index 66bf09aaa7..feaf6b1222 100644 --- a/gtk2_ardour/port_matrix_grid.cc +++ b/gtk2_ardour/port_matrix_grid.cc @@ -39,6 +39,7 @@ void PortMatrixGrid::compute_dimensions () { _width = 0; + for (PortGroupList::List::const_iterator i = _matrix->columns()->begin(); i != _matrix->columns()->end(); ++i) { _width += group_size (*i) * grid_spacing (); } diff --git a/gtk2_ardour/port_matrix_row_labels.cc b/gtk2_ardour/port_matrix_row_labels.cc index 00806b36a5..7b4383155d 100644 --- a/gtk2_ardour/port_matrix_row_labels.cc +++ b/gtk2_ardour/port_matrix_row_labels.cc @@ -45,44 +45,37 @@ PortMatrixRowLabels::compute_dimensions () _longest_port_name = 0; _longest_bundle_name = 0; _height = 0; + _highest_group_name = 0; + + for (PortGroupList::List::const_iterator i = _matrix->rows()->begin(); i != _matrix->rows()->end(); ++i) { + + PortGroup::BundleList const r = (*i)->bundles (); + for (PortGroup::BundleList::const_iterator j = r.begin(); j != r.end(); ++j) { + + for (uint32_t k = 0; k < j->bundle->nchannels(); ++k) { + cairo_text_extents_t ext; + cairo_text_extents (cr, j->bundle->channel_name(k).c_str(), &ext); + if (ext.width > _longest_port_name) { + _longest_port_name = ext.width; + } + } - PortGroup::BundleList const r = _matrix->rows()->bundles(); - for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) { - for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) { cairo_text_extents_t ext; - cairo_text_extents (cr, i->bundle->channel_name(j).c_str(), &ext); - if (ext.width > _longest_port_name) { - _longest_port_name = ext.width; + cairo_text_extents (cr, j->bundle->name().c_str(), &ext); + if (ext.width > _longest_bundle_name) { + _longest_bundle_name = ext.width; } } + _height += group_size (*i) * grid_spacing (); + cairo_text_extents_t ext; - cairo_text_extents (cr, i->bundle->name().c_str(), &ext); - if (ext.width > _longest_bundle_name) { - _longest_bundle_name = ext.width; - } - - if (_matrix->show_only_bundles()) { - _height += grid_spacing (); - } else { - _height += i->bundle->nchannels() * grid_spacing(); + cairo_text_extents (cr, (*i)->name.c_str(), &ext); + if (ext.height > _highest_group_name) { + _highest_group_name = ext.height; } } - _highest_group_name = 0; - for (PortGroupList::List::const_iterator i = _matrix->rows()->begin(); i != _matrix->rows()->end(); ++i) { - if ((*i)->visible()) { - cairo_text_extents_t ext; - cairo_text_extents (cr, (*i)->name.c_str(), &ext); - if (ext.height > _highest_group_name) { - _highest_group_name = ext.height; - } - } else { - /* add another grid_spacing for a tab for this hidden group */ - _height += grid_spacing (); - } - } - cairo_destroy (cr); gdk_pixmap_unref (pm); diff --git a/gtk2_ardour/route_params_ui.cc b/gtk2_ardour/route_params_ui.cc index 245b0019dc..aadd7ccdee 100644 --- a/gtk2_ardour/route_params_ui.cc +++ b/gtk2_ardour/route_params_ui.cc @@ -511,8 +511,6 @@ RouteParams_UI::show_track_menu() void RouteParams_UI::redirect_selected (boost::shared_ptr insert) { - Placement place = PreFader; - boost::shared_ptr send; boost::shared_ptr retrn; boost::shared_ptr plugin_insert; diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc index 09138f428e..5defe27e9d 100644 --- a/gtk2_ardour/session_option_editor.cc +++ b/gtk2_ardour/session_option_editor.cc @@ -101,6 +101,10 @@ public: bool can_rename_channels (int) const { return false; } + + std::string disassociation_verb () const { + return _("Disassociate"); + } private: /* see PortMatrix: signal flow from 0 to 1 (out to in) */ -- cgit v1.2.3