2009-06-20 13:15:33 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009 Paul Davis
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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-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-06-20 13:15:33 -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];
|
|
|
|
|
|
|
|
if (s->route()->is_master() || s->route()->is_control() || !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;
|
2009-06-22 18:17:48 -04:00
|
|
|
tab.last_ui_size = s->get_width ();
|
2009-06-21 18:17:17 -04:00
|
|
|
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 ();
|
|
|
|
tab.first_ui_size = s->get_width ();
|
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-06-21 18:17:17 -04:00
|
|
|
if (tab.group->is_active()) {
|
|
|
|
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-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-06-21 18:17:17 -04:00
|
|
|
pair<string, double> const f = fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
|
2009-06-20 13:15:33 -04:00
|
|
|
|
|
|
|
cairo_text_extents_t ext;
|
2009-06-21 18:17:17 -04:00
|
|
|
cairo_text_extents (cr, tab.group->name().c_str(), &ext);
|
2009-06-20 13:15:33 -04:00
|
|
|
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
2009-06-21 18:17:17 -04:00
|
|
|
cairo_move_to (cr, tab.from + (tab.to - tab.from - f.second) / 2, _height - ext.height / 2);
|
2009-06-20 13:15:33 -04:00
|
|
|
cairo_save (cr);
|
|
|
|
cairo_show_text (cr, f.first.c_str());
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MixerGroupTabs::reflect_tabs (list<Tab> const & tabs)
|
|
|
|
{
|
|
|
|
list<Tab>::const_iterator j = tabs.begin ();
|
|
|
|
|
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 14:39:23 -04:00
|
|
|
|
2009-06-22 18:17:48 -04:00
|
|
|
MixerStrip* s = (*i)[_mixer->track_columns.strip];
|
|
|
|
|
|
|
|
if (s->route()->is_master() || s->route()->is_control() || !s->marked_for_display()) {
|
2009-06-21 18:17:17 -04:00
|
|
|
continue;
|
2009-06-20 14:39:23 -04:00
|
|
|
}
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
if (j == tabs.end()) {
|
|
|
|
|
|
|
|
/* already run out of tabs, so no edit group */
|
2009-06-22 18:17:48 -04:00
|
|
|
s->route()->set_route_group (0, this);
|
2009-06-21 18:17:17 -04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (x >= j->to) {
|
|
|
|
/* this tab finishes before this track starts, so onto the next tab */
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
|
2009-06-22 18:17:48 -04:00
|
|
|
double const h = x + s->get_width() / 2;
|
2009-06-21 18:17:17 -04:00
|
|
|
|
|
|
|
if (j->from < h && j->to > h) {
|
2009-06-22 18:17:48 -04:00
|
|
|
s->route()->set_route_group (j->group, this);
|
2009-06-21 18:17:17 -04:00
|
|
|
} else {
|
2009-06-22 18:17:48 -04:00
|
|
|
s->route()->set_route_group (0, this);
|
2009-06-21 18:17:17 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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-06-21 21:25:21 -04:00
|
|
|
using namespace Menu_Helpers;
|
|
|
|
|
|
|
|
delete _menu;
|
|
|
|
_menu = new Menu;
|
|
|
|
|
|
|
|
MenuList& items = _menu->items ();
|
|
|
|
items.push_back (MenuElem (_("Edit..."), bind (mem_fun (*this, &MixerGroupTabs::edit_group), g)));
|
2009-06-25 16:46:39 -04:00
|
|
|
items.push_back (MenuElem (_("Subgroup"), bind (mem_fun (*this, &MixerGroupTabs::make_subgroup), g)));
|
|
|
|
items.push_back (SeparatorElem());
|
2009-06-21 21:25:21 -04:00
|
|
|
items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &MixerGroupTabs::remove_group), g)));
|
|
|
|
|
|
|
|
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 ();
|
|
|
|
}
|