2009-06-20 09:47:10 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2009 Paul Davis
|
2009-06-20 09:47:10 -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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-06-20 09:44:47 -04:00
|
|
|
#include "ardour/route_group.h"
|
|
|
|
#include "editor_group_tabs.h"
|
|
|
|
#include "editor.h"
|
2009-06-21 18:17:17 -04:00
|
|
|
#include "route_time_axis.h"
|
2009-06-20 09:44:47 -04:00
|
|
|
#include "utils.h"
|
2009-07-03 14:37:15 -04:00
|
|
|
#include "editor_route_groups.h"
|
2010-07-19 17:47:07 -04:00
|
|
|
#include "editor_routes.h"
|
2011-04-22 23:34:42 -04:00
|
|
|
#include "i18n.h"
|
2009-06-20 09:44:47 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
|
|
|
EditorGroupTabs::EditorGroupTabs (Editor* e)
|
2010-07-19 17:47:07 -04:00
|
|
|
: EditorComponent (e)
|
2009-06-20 09:44:47 -04:00
|
|
|
{
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
list<GroupTabs::Tab>
|
|
|
|
EditorGroupTabs::compute_tabs () const
|
2009-06-20 09:44:47 -04:00
|
|
|
{
|
2009-06-21 18:17:17 -04:00
|
|
|
list<Tab> tabs;
|
2009-06-20 09:44:47 -04:00
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
Tab tab;
|
|
|
|
tab.from = 0;
|
|
|
|
tab.group = 0;
|
2009-06-20 09:44:47 -04:00
|
|
|
|
|
|
|
int32_t y = 0;
|
2009-12-13 14:09:52 -05:00
|
|
|
for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
|
2009-06-20 13:55:14 -04:00
|
|
|
|
|
|
|
if ((*i)->marked_for_display() == false) {
|
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-21 15:59:56 -04:00
|
|
|
RouteGroup* g = (*i)->route_group ();
|
2009-06-20 09:44:47 -04:00
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
if (g != tab.group) {
|
|
|
|
if (tab.group) {
|
|
|
|
tab.to = y;
|
|
|
|
tabs.push_back (tab);
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
tab.from = y;
|
|
|
|
tab.group = g;
|
|
|
|
tab.colour = (*i)->color ();
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
y += (*i)->effective_height ();
|
|
|
|
}
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
if (tab.group) {
|
|
|
|
tab.to = y;
|
|
|
|
tabs.push_back (tab);
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
2009-06-21 18:17:17 -04:00
|
|
|
|
|
|
|
return tabs;
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-06-21 18:17:17 -04:00
|
|
|
EditorGroupTabs::draw_tab (cairo_t* cr, Tab const & tab) const
|
2009-06-20 09:44:47 -04:00
|
|
|
{
|
|
|
|
double const arc_radius = _width;
|
|
|
|
|
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 09:44:47 -04:00
|
|
|
} else {
|
|
|
|
cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
cairo_move_to (cr, 0, tab.from + arc_radius);
|
|
|
|
cairo_arc (cr, _width, tab.from + arc_radius, arc_radius, M_PI, 3 * M_PI / 2);
|
|
|
|
cairo_line_to (cr, _width, tab.to);
|
|
|
|
cairo_arc (cr, _width, tab.to - arc_radius, arc_radius, M_PI / 2, M_PI);
|
|
|
|
cairo_line_to (cr, 0, tab.from + arc_radius);
|
2009-06-20 09:44:47 -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);
|
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);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_move_to (cr, _width - ext.height / 2, tab.from + (f.second + tab.to - tab.from) / 2);
|
|
|
|
cairo_save (cr);
|
|
|
|
cairo_rotate (cr, - M_PI / 2);
|
|
|
|
cairo_show_text (cr, f.first.c_str());
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
double
|
|
|
|
EditorGroupTabs::primary_coordinate (double, double y) const
|
|
|
|
{
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
RouteList
|
|
|
|
EditorGroupTabs::routes_for_tab (Tab const * t) const
|
2009-06-20 09:44:47 -04:00
|
|
|
{
|
2009-12-01 10:32:42 -05:00
|
|
|
RouteList routes;
|
2009-06-20 09:44:47 -04:00
|
|
|
int32_t y = 0;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-13 14:09:52 -05:00
|
|
|
for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
|
2009-06-20 14:39:23 -04:00
|
|
|
|
2009-06-21 18:17:17 -04:00
|
|
|
if ((*i)->marked_for_display() == false) {
|
|
|
|
continue;
|
2009-06-20 14:39:23 -04:00
|
|
|
}
|
2009-06-21 18:17:17 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
|
2009-06-21 18:17:17 -04:00
|
|
|
if (rtv) {
|
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
if (y >= t->to) {
|
|
|
|
/* tab finishes before this track starts */
|
|
|
|
break;
|
|
|
|
}
|
2009-06-21 18:17:17 -04:00
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
double const h = y + (*i)->effective_height() / 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 (rtv->route ());
|
2009-06-21 18:17:17 -04:00
|
|
|
}
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
2009-06-21 18:17:17 -04:00
|
|
|
|
|
|
|
y += (*i)->effective_height ();
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
2009-12-01 10:32:42 -05:00
|
|
|
|
|
|
|
return routes;
|
2009-06-20 09:44:47 -04:00
|
|
|
}
|
2009-06-21 21:25:21 -04:00
|
|
|
|
|
|
|
|
2010-07-19 17:47:07 -04:00
|
|
|
void
|
|
|
|
EditorGroupTabs::add_menu_items (Gtk::Menu* m, RouteGroup* g)
|
|
|
|
{
|
|
|
|
using namespace Gtk::Menu_Helpers;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-19 17:47:07 -04:00
|
|
|
if (g) {
|
|
|
|
MenuList& items = m->items ();
|
|
|
|
items.push_back (MenuElem (_("Fit to Window"), sigc::bind (sigc::mem_fun (*_editor, &Editor::fit_route_group), g)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PBD::PropertyList
|
|
|
|
EditorGroupTabs::default_properties () const
|
|
|
|
{
|
|
|
|
PBD::PropertyList plist;
|
2011-06-01 13:00:29 -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::recenable, true);
|
|
|
|
plist.add (Properties::edit, true);
|
|
|
|
|
|
|
|
return plist;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-07-19 17:47:07 -04:00
|
|
|
string
|
|
|
|
EditorGroupTabs::order_key () const
|
2009-06-21 21:25:21 -04:00
|
|
|
{
|
2010-07-19 17:47:07 -04:00
|
|
|
return X_("editor");
|
2009-06-21 21:25:21 -04:00
|
|
|
}
|
2009-12-01 10:32:42 -05:00
|
|
|
|
2010-07-19 17:47:07 -04:00
|
|
|
RouteList
|
|
|
|
EditorGroupTabs::selected_routes () const
|
|
|
|
{
|
|
|
|
RouteList rl;
|
|
|
|
|
|
|
|
for (TrackSelection::iterator i = _editor->get_selection().tracks.begin(); i != _editor->get_selection().tracks.end(); ++i) {
|
|
|
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
|
|
|
|
if (rtv) {
|
|
|
|
rl.push_back (rtv->route());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorGroupTabs::sync_order_keys ()
|
2009-12-01 10:32:42 -05:00
|
|
|
{
|
2010-07-19 17:47:07 -04:00
|
|
|
_editor->_routes->sync_order_keys ("");
|
2009-12-01 10:32:42 -05:00
|
|
|
}
|