2009-06-20 09:47:10 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2011-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 09:47:10 -04:00
|
|
|
|
2009-06-20 09:44:47 -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 09:44:47 -04:00
|
|
|
#include "editor.h"
|
2014-06-09 23:28:32 -04:00
|
|
|
#include "editor_group_tabs.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"
|
2014-06-09 23:28:32 -04:00
|
|
|
#include "route_time_axis.h"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2014-06-09 23:28:32 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2009-06-20 09:44:47 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2009-06-20 09:44:47 -04:00
|
|
|
|
|
|
|
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;
|
2011-08-30 05:48:53 -04:00
|
|
|
if (g) {
|
|
|
|
tab.color = group_color (g);
|
|
|
|
}
|
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
|
2017-05-04 13:15:18 -04:00
|
|
|
EditorGroupTabs::draw_tab (cairo_t* cr, Tab const & tab)
|
2009-06-20 09:44:47 -04:00
|
|
|
{
|
2011-11-18 10:35:58 -05:00
|
|
|
double const arc_radius = get_width();
|
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 09:44:47 -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 09:44:47 -04:00
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2014-06-09 23:28:32 -04:00
|
|
|
a = 1.0;
|
|
|
|
|
|
|
|
cairo_set_source_rgba (cr, r, g, b, a);
|
2009-06-21 18:17:17 -04:00
|
|
|
cairo_move_to (cr, 0, tab.from + arc_radius);
|
2011-11-18 10:35:58 -05:00
|
|
|
cairo_arc (cr, get_width(), tab.from + arc_radius, arc_radius, M_PI, 3 * M_PI / 2);
|
|
|
|
cairo_line_to (cr, get_width(), tab.to);
|
|
|
|
cairo_arc (cr, get_width(), tab.to - arc_radius, arc_radius, M_PI / 2, M_PI);
|
2009-06-21 18:17:17 -04:00
|
|
|
cairo_line_to (cr, 0, tab.from + arc_radius);
|
2009-06-20 09:44:47 -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, (get_width() - text_height) * .5, (text_width + tab.to + tab.from) * .5);
|
2011-06-01 13:00:29 -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
|
|
|
|
2009-12-01 10:32:42 -05:00
|
|
|
cairo_save (cr);
|
2017-05-04 13:15:18 -04:00
|
|
|
cairo_rotate (cr, M_PI * -.5);
|
|
|
|
pango_cairo_show_layout (cr, layout->gobj ());
|
2009-12-01 10:32:42 -05:00
|
|
|
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)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|