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
This commit is contained in:
Carl Hetherington 2009-07-19 19:07:31 +00:00
parent af5b9f92a5
commit 6da5dd6d41
11 changed files with 107 additions and 75 deletions

View file

@ -25,6 +25,7 @@
#include <gtkmm/entry.h> #include <gtkmm/entry.h>
#include "ardour_dialog.h" #include "ardour_dialog.h"
#include "port_matrix.h" #include "port_matrix.h"
#include "i18n.h"
namespace ARDOUR { namespace ARDOUR {
class Session; class Session;
@ -50,6 +51,10 @@ class BundleEditorMatrix : public PortMatrix
void setup_ports (int); void setup_ports (int);
bool list_is_global (int) const; bool list_is_global (int) const;
std::string disassociation_verb () const {
return _("Disassociate");
}
private: private:
enum { enum {
OTHER = 0, OTHER = 0,

View file

@ -24,6 +24,7 @@
#include "port_matrix.h" #include "port_matrix.h"
#include "port_group.h" #include "port_group.h"
#include "ardour_dialog.h" #include "ardour_dialog.h"
#include "i18n.h"
class GlobalPortMatrix : public PortMatrix class GlobalPortMatrix : public PortMatrix
{ {
@ -44,6 +45,10 @@ public:
return false; return false;
} }
std::string disassociation_verb () const {
return _("Disconnect");
}
bool list_is_global (int) const { bool list_is_global (int) const {
return true; return true;
} }

View file

@ -22,6 +22,7 @@
#include "ardour_dialog.h" #include "ardour_dialog.h"
#include "port_matrix.h" #include "port_matrix.h"
#include "i18n.h"
namespace ARDOUR { namespace ARDOUR {
class PortInsert; class PortInsert;
@ -44,6 +45,10 @@ class IOSelector : public PortMatrix
return false; return false;
} }
std::string disassociation_verb () const {
return _("Disconnect");
}
uint32_t n_io_ports () const; uint32_t n_io_ports () const;
boost::shared_ptr<ARDOUR::IO> const io () { return _io; } boost::shared_ptr<ARDOUR::IO> const io () { return _io; }
void setup_ports (int); void setup_ports (int);
@ -61,7 +66,6 @@ class IOSelector : public PortMatrix
return _other; return _other;
} }
private: private:
int _other; int _other;

View file

@ -30,6 +30,7 @@
#include "ardour/route.h" #include "ardour/route.h"
#include "port_matrix.h" #include "port_matrix.h"
#include "port_matrix_body.h" #include "port_matrix_body.h"
#include "port_matrix_component.h"
#include "i18n.h" #include "i18n.h"
using namespace std; using namespace std;
@ -319,11 +320,13 @@ PortMatrix::popup_menu (
boost::weak_ptr<ARDOUR::Bundle> w (bc[dim].bundle); boost::weak_ptr<ARDOUR::Bundle> w (bc[dim].bundle);
if (_show_only_bundles) { 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 { } else {
snprintf ( snprintf (
buf, sizeof (buf), _("Disassociate all from '%s/%s'"), buf, sizeof (buf), _("%s all from '%s/%s'"),
bc[dim].bundle->name().c_str(), bc[dim].bundle->channel_name (bc[dim].channel).c_str() 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 (); 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;
}

View file

@ -129,6 +129,7 @@ public:
virtual void remove_channel (ARDOUR::BundleChannel) = 0; virtual void remove_channel (ARDOUR::BundleChannel) = 0;
virtual bool can_rename_channels (int) const = 0; virtual bool can_rename_channels (int) const = 0;
virtual void rename_channel (ARDOUR::BundleChannel) {} virtual void rename_channel (ARDOUR::BundleChannel) {}
virtual std::string disassociation_verb () const = 0;
enum Result { enum Result {
Cancelled, Cancelled,
@ -162,6 +163,7 @@ private:
void hide_group (boost::weak_ptr<PortGroup>); void hide_group (boost::weak_ptr<PortGroup>);
void show_group (boost::weak_ptr<PortGroup>); void show_group (boost::weak_ptr<PortGroup>);
void toggle_show_only_bundles (); void toggle_show_only_bundles ();
bool on_scroll_event (GdkEventScroll *);
/// port type that we are working with /// port type that we are working with
ARDOUR::DataType _type; ARDOUR::DataType _type;

View file

@ -49,26 +49,30 @@ PortMatrixColumnLabels::compute_dimensions ()
_highest_text = 0; _highest_text = 0;
/* width of the whole thing */ /* width of the whole thing */
_width = 0; _width = 0;
_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(); PortGroup::BundleList const c = _matrix->columns()->bundles();
for (PortGroup::BundleList::const_iterator i = c.begin (); i != c.end(); ++i) { for (PortGroup::BundleList::const_iterator j = c.begin (); j != c.end(); ++j) {
cairo_text_extents_t ext; cairo_text_extents_t ext;
cairo_text_extents (cr, i->bundle->name().c_str(), &ext); cairo_text_extents (cr, j->bundle->name().c_str(), &ext);
if (ext.width > _longest_bundle_name) { if (ext.width > _longest_bundle_name) {
_longest_bundle_name = ext.width; _longest_bundle_name = ext.width;
} }
if (ext.height > _highest_text) { if (ext.height > _highest_text) {
_highest_text = ext.height; _highest_text = ext.height;
} }
for (uint32_t j = 0; j < i->bundle->nchannels (); ++j) { for (uint32_t k = 0; k < j->bundle->nchannels (); ++k) {
cairo_text_extents ( cairo_text_extents (
cr, cr,
i->bundle->channel_name (j).c_str(), j->bundle->channel_name (k).c_str(),
&ext &ext
); );
}
if (ext.width > _longest_channel_name) { if (ext.width > _longest_channel_name) {
_longest_channel_name = ext.width; _longest_channel_name = ext.width;
@ -78,24 +82,13 @@ PortMatrixColumnLabels::compute_dimensions ()
} }
} }
if (_matrix->show_only_bundles()) { _width += group_size (*i) * grid_spacing ();
_width += grid_spacing();
} else {
_width += i->bundle->nchannels() * 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_t ext;
cairo_text_extents (cr, (*i)->name.c_str(), &ext); cairo_text_extents (cr, (*i)->name.c_str(), &ext);
if (ext.height > _highest_group_name) { if (ext.height > _highest_group_name) {
_highest_group_name = ext.height; _highest_group_name = ext.height;
} }
} else {
_width += grid_spacing ();
}
} }
cairo_destroy (cr); cairo_destroy (cr);

View file

@ -39,6 +39,7 @@ void
PortMatrixGrid::compute_dimensions () PortMatrixGrid::compute_dimensions ()
{ {
_width = 0; _width = 0;
for (PortGroupList::List::const_iterator i = _matrix->columns()->begin(); i != _matrix->columns()->end(); ++i) { for (PortGroupList::List::const_iterator i = _matrix->columns()->begin(); i != _matrix->columns()->end(); ++i) {
_width += group_size (*i) * grid_spacing (); _width += group_size (*i) * grid_spacing ();
} }

View file

@ -45,42 +45,35 @@ PortMatrixRowLabels::compute_dimensions ()
_longest_port_name = 0; _longest_port_name = 0;
_longest_bundle_name = 0; _longest_bundle_name = 0;
_height = 0; _height = 0;
_highest_group_name = 0;
PortGroup::BundleList const r = _matrix->rows()->bundles(); for (PortGroupList::List::const_iterator i = _matrix->rows()->begin(); i != _matrix->rows()->end(); ++i) {
for (PortGroup::BundleList::const_iterator i = r.begin(); i != r.end(); ++i) {
for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) { 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_t ext;
cairo_text_extents (cr, i->bundle->channel_name(j).c_str(), &ext); cairo_text_extents (cr, j->bundle->channel_name(k).c_str(), &ext);
if (ext.width > _longest_port_name) { if (ext.width > _longest_port_name) {
_longest_port_name = ext.width; _longest_port_name = ext.width;
} }
} }
cairo_text_extents_t ext; cairo_text_extents_t ext;
cairo_text_extents (cr, i->bundle->name().c_str(), &ext); cairo_text_extents (cr, j->bundle->name().c_str(), &ext);
if (ext.width > _longest_bundle_name) { if (ext.width > _longest_bundle_name) {
_longest_bundle_name = ext.width; _longest_bundle_name = ext.width;
} }
if (_matrix->show_only_bundles()) {
_height += grid_spacing ();
} else {
_height += i->bundle->nchannels() * grid_spacing();
}
} }
_highest_group_name = 0; _height += group_size (*i) * grid_spacing ();
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_t ext;
cairo_text_extents (cr, (*i)->name.c_str(), &ext); cairo_text_extents (cr, (*i)->name.c_str(), &ext);
if (ext.height > _highest_group_name) { if (ext.height > _highest_group_name) {
_highest_group_name = ext.height; _highest_group_name = ext.height;
} }
} else {
/* add another grid_spacing for a tab for this hidden group */
_height += grid_spacing ();
}
} }
cairo_destroy (cr); cairo_destroy (cr);

View file

@ -511,8 +511,6 @@ RouteParams_UI::show_track_menu()
void void
RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Processor> insert) RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Processor> insert)
{ {
Placement place = PreFader;
boost::shared_ptr<Send> send; boost::shared_ptr<Send> send;
boost::shared_ptr<Return> retrn; boost::shared_ptr<Return> retrn;
boost::shared_ptr<PluginInsert> plugin_insert; boost::shared_ptr<PluginInsert> plugin_insert;

View file

@ -102,6 +102,10 @@ public:
return false; return false;
} }
std::string disassociation_verb () const {
return _("Disassociate");
}
private: private:
/* see PortMatrix: signal flow from 0 to 1 (out to in) */ /* see PortMatrix: signal flow from 0 to 1 (out to in) */
enum { enum {