2009-06-20 13:15:33 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2009 Paul Davis
|
2009-06-20 13:15:33 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ardour/route_group.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "mixer_group_tabs.h"
|
|
|
|
#include "mixer_strip.h"
|
|
|
|
#include "mixer_ui.h"
|
|
|
|
#include "utils.h"
|
2009-06-21 21:25:21 -04:00
|
|
|
#include "i18n.h"
|
|
|
|
#include "route_group_dialog.h"
|
2009-06-20 13:15:33 -04:00
|
|
|
|
|
|
|
using namespace std;
|
2009-06-21 21:25:21 -04:00
|
|
|
using namespace Gtk;
|
2009-06-20 13:15:33 -04:00
|
|
|
using namespace ARDOUR;
|
2010-02-18 08:59:49 -05:00
|
|
|
using namespace PBD;
|
2009-06-20 13:15:33 -04:00
|
|
|
|
|
|
|
MixerGroupTabs::MixerGroupTabs (Mixer_UI* m)
|
2009-07-03 14:37:15 -04:00
|
|
|
: GroupTabs (0),
|
|
|
|
_mixer (m),
|
2009-06-21 21:25:21 -04:00
|
|
|
_menu (0)
|
2009-06-20 13:15:33 -04:00
|
|
|
{
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
list<GroupTabs::Tab>
|
|
|
|
MixerGroupTabs::compute_tabs () const
|
2009-06-20 13:15:33 -04:00
|
|
|
{
|
2009-06-21 18:17:17 -04:00
|
|
|
list<Tab> tabs;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
Tab tab;
|
|
|
|
tab.from = 0;
|
|
|
|
tab.group = 0;
|
2009-06-20 13:15:33 -04:00
|
|
|
|
|
|
|
int32_t x = 0;
|
2009-06-22 18:17:48 -04:00
|
|
|
TreeModel::Children rows = _mixer->track_model->children ();
|
|
|
|
for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
|
2009-06-20 13:15:33 -04:00
|
|
|
|
2009-06-22 18:17:48 -04:00
|
|
|
MixerStrip* s = (*i)[_mixer->track_columns.strip];
|
|
|
|
|
2010-03-23 08:19:21 -04:00
|
|
|
if (s->route()->is_master() || s->route()->is_monitor() || !s->marked_for_display()) {
|
2009-06-20 13:15:33 -04:00
|
|
|
continue;
|
|
|
|
}
|
2009-06-21 12:58:57 -04:00
|
|
|
|
2009-06-22 18:17:48 -04:00
|
|
|
RouteGroup* g = s->route_group ();
|
2009-06-20 13:15:33 -04:00
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
if (g != tab.group) {
|
|
|
|
if (tab.group) {
|
|
|
|
tab.to = x;
|
|
|
|
tabs.push_back (tab);
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
tab.from = x;
|
|
|
|
tab.group = g;
|
2009-06-22 18:17:48 -04:00
|
|
|
tab.colour = s->color ();
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
|
|
|
|
2009-06-22 18:17:48 -04:00
|
|
|
x += s->get_width ();
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
if (tab.group) {
|
|
|
|
tab.to = x;
|
|
|
|
tabs.push_back (tab);
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
2009-06-21 18:17:17 -04:00
|
|
|
|
|
|
|
return tabs;
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-21 18:17:17 -04:00
|
|
|
MixerGroupTabs::draw_tab (cairo_t* cr, Tab const & tab) const
|
2009-06-20 13:15:33 -04:00
|
|
|
{
|
|
|
|
double const arc_radius = _height;
|
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
if (tab.group && tab.group->is_active()) {
|
2009-06-21 18:17:17 -04:00
|
|
|
cairo_set_source_rgba (cr, tab.colour.get_red_p (), tab.colour.get_green_p (), tab.colour.get_blue_p (), 1);
|
2009-06-20 13:15:33 -04:00
|
|
|
} else {
|
|
|
|
cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
cairo_arc (cr, tab.from + arc_radius, _height, arc_radius, M_PI, 3 * M_PI / 2);
|
|
|
|
cairo_line_to (cr, tab.to - arc_radius, 0);
|
|
|
|
cairo_arc (cr, tab.to - arc_radius, _height, arc_radius, 3 * M_PI / 2, 2 * M_PI);
|
|
|
|
cairo_line_to (cr, tab.from, _height);
|
2009-06-20 13:15:33 -04:00
|
|
|
cairo_fill (cr);
|
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
if (tab.group) {
|
|
|
|
pair<string, double> const f = fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
|
|
|
|
|
|
|
|
cairo_text_extents_t ext;
|
|
|
|
cairo_text_extents (cr, tab.group->name().c_str(), &ext);
|
|
|
|
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_move_to (cr, tab.from + (tab.to - tab.from - f.second) / 2, _height - ext.height / 2);
|
|
|
|
cairo_save (cr);
|
|
|
|
cairo_show_text (cr, f.first.c_str());
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
double
|
|
|
|
MixerGroupTabs::primary_coordinate (double x, double) const
|
2009-06-20 13:15:33 -04:00
|
|
|
{
|
2009-06-21 18:17:17 -04:00
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
RouteList
|
|
|
|
MixerGroupTabs::routes_for_tab (Tab const * t) const
|
2009-06-21 18:17:17 -04:00
|
|
|
{
|
2009-12-01 10:32:42 -05:00
|
|
|
RouteList routes;
|
2009-06-20 13:15:33 -04:00
|
|
|
int32_t x = 0;
|
2009-12-01 10:32:42 -05:00
|
|
|
|
2009-06-22 18:17:48 -04:00
|
|
|
TreeModel::Children rows = _mixer->track_model->children ();
|
|
|
|
for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
|
2009-06-20 14:39:23 -04:00
|
|
|
|
2009-06-22 18:17:48 -04:00
|
|
|
MixerStrip* s = (*i)[_mixer->track_columns.strip];
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-03-23 08:19:21 -04:00
|
|
|
if (s->route()->is_master() || s->route()->is_monitor() || !s->marked_for_display()) {
|
2009-12-01 10:32:42 -05:00
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
if (x >= t->to) {
|
|
|
|
/* tab finishes before this track starts */
|
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
double const h = x + s->get_width() / 2;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
if (t->from < h && t->to > h) {
|
|
|
|
routes.push_back (s->route ());
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
|
|
|
|
2009-06-22 18:17:48 -04:00
|
|
|
x += s->get_width ();
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
2009-12-01 10:32:42 -05:00
|
|
|
|
|
|
|
return routes;
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
2009-06-21 18:17:17 -04:00
|
|
|
|
2009-06-21 21:25:21 -04:00
|
|
|
Gtk::Menu*
|
|
|
|
MixerGroupTabs::get_menu (RouteGroup* g)
|
|
|
|
{
|
2009-06-23 19:05:14 -04:00
|
|
|
if (g == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-21 21:25:21 -04:00
|
|
|
using namespace Menu_Helpers;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-21 21:25:21 -04:00
|
|
|
delete _menu;
|
|
|
|
_menu = new Menu;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-21 21:25:21 -04:00
|
|
|
MenuList& items = _menu->items ();
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Edit..."), sigc::bind (sigc::mem_fun (*this, &MixerGroupTabs::edit_group), g)));
|
|
|
|
items.push_back (MenuElem (_("Subgroup"), sigc::bind (sigc::mem_fun (*this, &MixerGroupTabs::make_subgroup), g)));
|
2009-06-25 16:46:39 -04:00
|
|
|
items.push_back (SeparatorElem());
|
2009-12-11 18:29:48 -05:00
|
|
|
items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun (*this, &MixerGroupTabs::remove_group), g)));
|
2009-06-21 21:25:21 -04:00
|
|
|
|
|
|
|
return _menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MixerGroupTabs::edit_group (RouteGroup* g)
|
|
|
|
{
|
|
|
|
RouteGroupDialog d (g, Gtk::Stock::APPLY);
|
|
|
|
d.do_run ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MixerGroupTabs::remove_group (RouteGroup *g)
|
|
|
|
{
|
|
|
|
_session->remove_route_group (*g);
|
|
|
|
}
|
2009-06-25 16:46:39 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
MixerGroupTabs::make_subgroup (RouteGroup* g)
|
|
|
|
{
|
|
|
|
g->make_subgroup ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MixerGroupTabs::destroy_subgroup (RouteGroup* g)
|
|
|
|
{
|
|
|
|
g->destroy_subgroup ();
|
|
|
|
}
|
2009-12-01 10:32:42 -05:00
|
|
|
|
|
|
|
ARDOUR::RouteGroup *
|
|
|
|
MixerGroupTabs::new_route_group () const
|
|
|
|
{
|
2010-02-18 08:59:49 -05:00
|
|
|
PropertyList plist;
|
|
|
|
|
|
|
|
plist.add (Properties::active, true);
|
|
|
|
plist.add (Properties::mute, true);
|
|
|
|
plist.add (Properties::solo, true);
|
|
|
|
plist.add (Properties::gain, true);
|
|
|
|
plist.add (Properties::recenable, true);
|
|
|
|
|
|
|
|
RouteGroup* g = new RouteGroup (*_session, "");
|
|
|
|
g->set_properties (plist);
|
2009-12-01 10:32:42 -05:00
|
|
|
|
|
|
|
RouteGroupDialog d (g, Gtk::Stock::NEW);
|
|
|
|
int const r = d.do_run ();
|
|
|
|
|
|
|
|
if (r != Gtk::RESPONSE_OK) {
|
|
|
|
delete g;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_session->add_route_group (g);
|
|
|
|
return g;
|
|
|
|
}
|