2 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
4 * Copyright (C) 2011-2016 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "gtkmm2ext/utils.h"
24 #include "ardour/route_group.h"
26 #include "gtkmm2ext/colors.h"
29 #include "editor_group_tabs.h"
30 #include "editor_route_groups.h"
31 #include "editor_routes.h"
32 #include "rgb_macros.h"
33 #include "route_time_axis.h"
34 #include "ui_config.h"
40 using namespace ARDOUR;
41 using namespace ARDOUR_UI_UTILS;
43 EditorGroupTabs::EditorGroupTabs (Editor* e)
50 EditorGroupTabs::compute_tabs () const
59 for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
61 if ((*i)->marked_for_display() == false) {
65 RouteGroup* g = (*i)->route_group ();
76 tab.color = group_color (g);
80 y += (*i)->effective_height ();
92 EditorGroupTabs::draw_tab (cairo_t* cr, Tab const & tab)
94 double const arc_radius = get_width();
97 if (tab.group && tab.group->is_active()) {
98 Gtkmm2ext::color_to_rgba (tab.color, r, g, b, a);
100 Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("inactive group tab"), r, g, b, a);
105 cairo_set_source_rgba (cr, r, g, b, a);
106 cairo_move_to (cr, 0, tab.from + arc_radius);
107 cairo_arc (cr, get_width(), tab.from + arc_radius, arc_radius, M_PI, 3 * M_PI / 2);
108 cairo_line_to (cr, get_width(), tab.to);
109 cairo_arc (cr, get_width(), tab.to - arc_radius, arc_radius, M_PI / 2, M_PI);
110 cairo_line_to (cr, 0, tab.from + arc_radius);
113 if (tab.group && (tab.to - tab.from) > arc_radius) {
114 int text_width, text_height;
116 Glib::RefPtr<Pango::Layout> layout;
117 layout = Pango::Layout::create (get_pango_context ());
118 layout->set_ellipsize (Pango::ELLIPSIZE_MIDDLE);
120 layout->set_text (tab.group->name ());
121 layout->set_width ((tab.to - tab.from - arc_radius) * PANGO_SCALE);
122 layout->get_pixel_size (text_width, text_height);
124 cairo_move_to (cr, (get_width() - text_height) * .5, (text_width + tab.to + tab.from) * .5);
126 Gtkmm2ext::Color c = Gtkmm2ext::contrasting_text_color (Gtkmm2ext::rgba_to_color (r, g, b, a));
127 Gtkmm2ext::color_to_rgba (c, r, g, b, a);
128 cairo_set_source_rgb (cr, r, g, b);
131 cairo_rotate (cr, M_PI * -.5);
132 pango_cairo_show_layout (cr, layout->gobj ());
138 EditorGroupTabs::primary_coordinate (double, double y) const
144 EditorGroupTabs::routes_for_tab (Tab const * t) const
149 for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
151 if ((*i)->marked_for_display() == false) {
155 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
159 /* tab finishes before this track starts */
163 double const h = y + (*i)->effective_height() / 2;
165 if (t->from < h && t->to > h) {
166 routes.push_back (rtv->route ());
170 y += (*i)->effective_height ();
178 EditorGroupTabs::add_menu_items (Gtk::Menu* m, RouteGroup* g)
180 using namespace Gtk::Menu_Helpers;
183 MenuList& items = m->items ();
184 items.push_back (MenuElem (_("Fit to Window"), sigc::bind (sigc::mem_fun (*_editor, &Editor::fit_route_group), g)));
189 EditorGroupTabs::selected_routes () const
193 for (TrackSelection::iterator i = _editor->get_selection().tracks.begin(); i != _editor->get_selection().tracks.end(); ++i) {
194 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
196 rl.push_back (rtv->route());