2 Copyright (C) 2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "gtkmm2ext/utils.h"
22 #include "ardour/route_group.h"
24 #include "gtkmm2ext/colors.h"
27 #include "editor_group_tabs.h"
28 #include "editor_route_groups.h"
29 #include "editor_routes.h"
30 #include "rgb_macros.h"
31 #include "route_time_axis.h"
32 #include "ui_config.h"
38 using namespace ARDOUR;
39 using namespace ARDOUR_UI_UTILS;
41 EditorGroupTabs::EditorGroupTabs (Editor* e)
48 EditorGroupTabs::compute_tabs () const
57 for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
59 if ((*i)->marked_for_display() == false) {
63 RouteGroup* g = (*i)->route_group ();
74 tab.color = group_color (g);
78 y += (*i)->effective_height ();
90 EditorGroupTabs::draw_tab (cairo_t* cr, Tab const & tab)
92 double const arc_radius = get_width();
95 if (tab.group && tab.group->is_active()) {
96 Gtkmm2ext::color_to_rgba (tab.color, r, g, b, a);
98 Gtkmm2ext::color_to_rgba (UIConfiguration::instance().color ("inactive group tab"), r, g, b, a);
103 cairo_set_source_rgba (cr, r, g, b, a);
104 cairo_move_to (cr, 0, tab.from + arc_radius);
105 cairo_arc (cr, get_width(), tab.from + arc_radius, arc_radius, M_PI, 3 * M_PI / 2);
106 cairo_line_to (cr, get_width(), tab.to);
107 cairo_arc (cr, get_width(), tab.to - arc_radius, arc_radius, M_PI / 2, M_PI);
108 cairo_line_to (cr, 0, tab.from + arc_radius);
111 if (tab.group && (tab.to - tab.from) > arc_radius) {
112 int text_width, text_height;
114 Glib::RefPtr<Pango::Layout> layout;
115 layout = Pango::Layout::create (get_pango_context ());
116 layout->set_ellipsize (Pango::ELLIPSIZE_MIDDLE);
118 layout->set_text (tab.group->name ());
119 layout->set_width ((tab.to - tab.from - arc_radius) * PANGO_SCALE);
120 layout->get_pixel_size (text_width, text_height);
122 cairo_move_to (cr, (get_width() - text_height) * .5, (text_width + tab.to + tab.from) * .5);
124 Gtkmm2ext::Color c = Gtkmm2ext::contrasting_text_color (Gtkmm2ext::rgba_to_color (r, g, b, a));
125 Gtkmm2ext::color_to_rgba (c, r, g, b, a);
126 cairo_set_source_rgb (cr, r, g, b);
129 cairo_rotate (cr, M_PI * -.5);
130 pango_cairo_show_layout (cr, layout->gobj ());
136 EditorGroupTabs::primary_coordinate (double, double y) const
142 EditorGroupTabs::routes_for_tab (Tab const * t) const
147 for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
149 if ((*i)->marked_for_display() == false) {
153 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
157 /* tab finishes before this track starts */
161 double const h = y + (*i)->effective_height() / 2;
163 if (t->from < h && t->to > h) {
164 routes.push_back (rtv->route ());
168 y += (*i)->effective_height ();
176 EditorGroupTabs::add_menu_items (Gtk::Menu* m, RouteGroup* g)
178 using namespace Gtk::Menu_Helpers;
181 MenuList& items = m->items ();
182 items.push_back (MenuElem (_("Fit to Window"), sigc::bind (sigc::mem_fun (*_editor, &Editor::fit_route_group), g)));
187 EditorGroupTabs::selected_routes () const
191 for (TrackSelection::iterator i = _editor->get_selection().tracks.begin(); i != _editor->get_selection().tracks.end(); ++i) {
192 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
194 rl.push_back (rtv->route());