2009-06-20 13:15:33 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2009-06-20 13:15:33 -04:00
|
|
|
|
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
|
|
|
|
2017-07-17 12:34:35 -04:00
|
|
|
#include "gtkmm2ext/colors.h"
|
2014-06-09 23:28:32 -04:00
|
|
|
|
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"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2009-06-20 13:15:33 -04:00
|
|
|
#include "utils.h"
|
2014-06-09 23:28:32 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/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
|
|
|
|
2016-06-05 16:29:22 -04:00
|
|
|
AxisView* av = (*i)[_mixer->stripable_columns.strip];
|
|
|
|
MixerStrip* s = dynamic_cast<MixerStrip*> (av);
|
2009-06-22 18:17:48 -04:00
|
|
|
|
2016-02-27 22:16:37 -05:00
|
|
|
if (!s) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2016-12-21 06:14:44 -05:00
|
|
|
#ifdef MIXBUS
|
|
|
|
if (s->route()->mixbus()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif
|
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
|
|
|
}
|
|
|
|
|
2015-09-26 19:33:02 -04:00
|
|
|
int ww = 0, wh = 0;
|
|
|
|
s->get_size_request (ww, wh); // widget may not be realized, get_width() is invalid.
|
|
|
|
x += ww;
|
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
|
2017-05-04 13:15:18 -04:00
|
|
|
MixerGroupTabs::draw_tab (cairo_t* cr, Tab const & tab)
|
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;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
if (tab.group && tab.group->is_active()) {
|
2017-07-17 12:34:35 -04:00
|
|
|
Gtkmm2ext::color_to_rgba (tab.color, r, g, b, a);
|
2009-06-20 13:15:33 -04:00
|
|
|
} else {
|
2017-07-17 12:34:35 -04:00
|
|
|
Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("inactive group tab"), r, g, b, a);
|
2009-06-20 13:15:33 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -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);
|
|
|
|
|
2017-05-04 13:15:18 -04:00
|
|
|
if (tab.group && (tab.to - tab.from) > arc_radius) {
|
|
|
|
int text_width, text_height;
|
|
|
|
|
|
|
|
Glib::RefPtr<Pango::Layout> layout;
|
|
|
|
layout = Pango::Layout::create (get_pango_context ());
|
|
|
|
layout->set_ellipsize (Pango::ELLIPSIZE_MIDDLE);
|
|
|
|
|
|
|
|
layout->set_text (tab.group->name ());
|
|
|
|
layout->set_width ((tab.to - tab.from - arc_radius) * PANGO_SCALE);
|
|
|
|
layout->get_pixel_size (text_width, text_height);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2017-05-04 13:15:18 -04:00
|
|
|
cairo_move_to (cr, tab.from + (tab.to - tab.from - text_width) * .5, (get_height () - text_height) * .5);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2017-07-17 12:34:35 -04:00
|
|
|
Gtkmm2ext::Color c = Gtkmm2ext::contrasting_text_color (Gtkmm2ext::rgba_to_color (r, g, b, a));
|
|
|
|
Gtkmm2ext::color_to_rgba (c, r, g, b, a);
|
2014-06-09 23:28:32 -04:00
|
|
|
cairo_set_source_rgb (cr, r, g, b);
|
2017-05-04 13:15:18 -04:00
|
|
|
|
|
|
|
pango_cairo_show_layout (cr, layout->gobj ());
|
2009-12-01 10:32:42 -05:00
|
|
|
}
|
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
|
|
|
|
2016-06-05 16:29:22 -04:00
|
|
|
AxisView* av = (*i)[_mixer->stripable_columns.strip];
|
|
|
|
MixerStrip* s = dynamic_cast<MixerStrip*> (av);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-02-27 22:16:37 -05:00
|
|
|
if (!s) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->route()->is_master() || s->route()->is_monitor() || !s->marked_for_display()) {
|
|
|
|
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
|
|
|
RouteList
|
|
|
|
MixerGroupTabs::selected_routes () const
|
2009-06-25 16:46:39 -04:00
|
|
|
{
|
2011-11-04 13:53:21 -04:00
|
|
|
RouteList rl;
|
2016-07-06 13:37:30 -04:00
|
|
|
BOOST_FOREACH (AxisView* r, _mixer->selection().axes) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Route> rp = std::dynamic_pointer_cast<Route> (r->stripable());
|
2011-11-04 14:11:34 -04:00
|
|
|
if (rp) {
|
|
|
|
rl.push_back (rp);
|
|
|
|
}
|
|
|
|
}
|
2011-11-04 13:53:21 -04:00
|
|
|
return rl;
|
2009-06-25 16:46:39 -04:00
|
|
|
}
|
|
|
|
|