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 "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,

View File

@ -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;
}

View File

@ -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<ARDOUR::IO> const io () { return _io; }
@ -61,7 +66,6 @@ class IOSelector : public PortMatrix
return _other;
}
private:
int _other;

View File

@ -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<ARDOUR::Bundle> 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;
}

View File

@ -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<PortGroup>);
void show_group (boost::weak_ptr<PortGroup>);
void toggle_show_only_bundles ();
bool on_scroll_event (GdkEventScroll *);
/// port type that we are working with
ARDOUR::DataType _type;

View File

@ -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));

View File

@ -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;
}
}

View File

@ -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 ();
}

View File

@ -45,44 +45,37 @@ PortMatrixRowLabels::compute_dimensions ()
_longest_port_name = 0;
_longest_bundle_name = 0;
_height = 0;
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_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();
}
}
_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;
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;
}
}
} else {
/* add another grid_spacing for a tab for this hidden group */
_height += grid_spacing ();
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;
}
}
_height += group_size (*i) * 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;
}
}
cairo_destroy (cr);
gdk_pixmap_unref (pm);

View File

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

View File

@ -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) */