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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-11-04 14:11:34 -04:00
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
|
2011-12-07 08:08:00 -05:00
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
2009-06-20 13:15:33 -04:00
|
|
|
#include "ardour/route_group.h"
|
2014-06-09 23:28:32 -04:00
|
|
|
|
2014-11-07 14:24:27 -05:00
|
|
|
#include "canvas/colors.h"
|
2014-06-09 23:28:32 -04:00
|
|
|
|
2014-06-30 10:14:06 -04:00
|
|
|
#include "ardour_ui.h"
|
2009-06-20 13:15:33 -04:00
|
|
|
#include "mixer_group_tabs.h"
|
|
|
|
#include "mixer_strip.h"
|
|
|
|
#include "mixer_ui.h"
|
2014-06-09 23:28:32 -04:00
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "route_group_dialog.h"
|
2009-06-20 13:15:33 -04:00
|
|
|
#include "utils.h"
|
2014-06-09 23:28:32 -04:00
|
|
|
|
2009-06-21 21:25:21 -04:00
|
|
|
#include "i18n.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;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2010-02-18 08:59:49 -05:00
|
|
|
using namespace PBD;
|
2009-06-20 13:15:33 -04:00
|
|
|
|
|
|
|
MixerGroupTabs::MixerGroupTabs (Mixer_UI* m)
|
2010-07-19 17:47:07 -04:00
|
|
|
: _mixer (m)
|
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;
|
2011-08-30 05:48:53 -04:00
|
|
|
|
|
|
|
if (g) {
|
|
|
|
tab.color = group_color (g);
|
|
|
|
}
|
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
|
|
|
{
|
2011-11-18 10:35:58 -05:00
|
|
|
double const arc_radius = get_height();
|
2014-06-09 23:28:32 -04:00
|
|
|
double r, g, b, a;
|
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
if (tab.group && tab.group->is_active()) {
|
2014-06-09 23:28:32 -04:00
|
|
|
ArdourCanvas::color_to_rgba (tab.color, r, g, b, a);
|
2009-06-20 13:15:33 -04:00
|
|
|
} else {
|
2014-12-14 16:15:38 -05:00
|
|
|
ArdourCanvas::color_to_rgba (ARDOUR_UI::config()->color ("inactive group tab"), r, g, b, a);
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
2014-06-09 23:28:32 -04:00
|
|
|
|
|
|
|
a = 1.0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2014-06-09 23:28:32 -04:00
|
|
|
cairo_set_source_rgba (cr, r, g, b, a);
|
2011-11-18 10:35:58 -05:00
|
|
|
cairo_arc (cr, tab.from + arc_radius, get_height(), arc_radius, M_PI, 3 * M_PI / 2);
|
2009-06-21 18:17:17 -04:00
|
|
|
cairo_line_to (cr, tab.to - arc_radius, 0);
|
2011-11-18 10:35:58 -05:00
|
|
|
cairo_arc (cr, tab.to - arc_radius, get_height(), arc_radius, 3 * M_PI / 2, 2 * M_PI);
|
|
|
|
cairo_line_to (cr, tab.from, get_height());
|
2009-06-20 13:15:33 -04:00
|
|
|
cairo_fill (cr);
|
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
if (tab.group) {
|
2011-12-07 08:08:00 -05:00
|
|
|
pair<string, double> const f = Gtkmm2ext::fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
cairo_text_extents_t ext;
|
|
|
|
cairo_text_extents (cr, tab.group->name().c_str(), &ext);
|
2014-06-09 23:28:32 -04:00
|
|
|
|
2014-06-30 10:38:45 -04:00
|
|
|
ArdourCanvas::Color c = ArdourCanvas::contrasting_text_color (ArdourCanvas::rgba_to_color (r, g, b, a));
|
2014-06-09 23:28:32 -04:00
|
|
|
ArdourCanvas::color_to_rgba (c, r, g, b, a);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-06-09 23:28:32 -04:00
|
|
|
cairo_set_source_rgb (cr, r, g, b);
|
2011-11-18 10:35:58 -05:00
|
|
|
cairo_move_to (cr, tab.from + (tab.to - tab.from - f.second) / 2, get_height() - ext.height / 2);
|
2009-12-01 10:32:42 -05:00
|
|
|
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
|
|
|
|
2010-07-19 17:47:07 -04:00
|
|
|
PropertyList
|
|
|
|
MixerGroupTabs::default_properties () const
|
2009-06-21 21:25:21 -04:00
|
|
|
{
|
2010-07-19 17:47:07 -04:00
|
|
|
PropertyList plist;
|
2009-06-21 21:25:21 -04:00
|
|
|
|
2010-07-19 17:47:07 -04:00
|
|
|
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);
|
2009-06-21 21:25:21 -04:00
|
|
|
|
2010-07-19 17:47:07 -04:00
|
|
|
return plist;
|
2009-06-21 21:25:21 -04:00
|
|
|
}
|
|
|
|
|
2010-07-19 17:47:07 -04:00
|
|
|
RouteList
|
|
|
|
MixerGroupTabs::selected_routes () const
|
2009-06-25 16:46:39 -04:00
|
|
|
{
|
2011-11-04 13:53:21 -04:00
|
|
|
RouteList rl;
|
2011-11-04 14:11:34 -04:00
|
|
|
BOOST_FOREACH (RouteUI* r, _mixer->selection().routes) {
|
|
|
|
boost::shared_ptr<Route> rp = r->route();
|
|
|
|
if (rp) {
|
|
|
|
rl.push_back (rp);
|
|
|
|
}
|
|
|
|
}
|
2011-11-04 13:53:21 -04:00
|
|
|
return rl;
|
2009-06-25 16:46:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-07-19 17:47:07 -04:00
|
|
|
MixerGroupTabs::sync_order_keys ()
|
2009-12-01 10:32:42 -05:00
|
|
|
{
|
2012-07-19 18:35:43 -04:00
|
|
|
_mixer->sync_order_keys_from_treeview ();
|
2009-12-01 10:32:42 -05:00
|
|
|
}
|