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 "canvas/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) const
92 double const arc_radius = get_width();
95 if (tab.group && tab.group->is_active()) {
96 ArdourCanvas::color_to_rgba (tab.color, r, g, b, a);
98 ArdourCanvas::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);
112 pair<string, double> const f = Gtkmm2ext::fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
114 cairo_text_extents_t ext;
115 cairo_text_extents (cr, tab.group->name().c_str(), &ext);
117 ArdourCanvas::Color c = ArdourCanvas::contrasting_text_color (ArdourCanvas::rgba_to_color (r, g, b, a));
118 ArdourCanvas::color_to_rgba (c, r, g, b, a);
120 cairo_set_source_rgb (cr, r, g, b);
121 cairo_move_to (cr, get_width() - ext.height / 2, tab.from + (f.second + tab.to - tab.from) / 2);
123 cairo_rotate (cr, - M_PI / 2);
124 cairo_show_text (cr, f.first.c_str());
130 EditorGroupTabs::primary_coordinate (double, double y) const
136 EditorGroupTabs::routes_for_tab (Tab const * t) const
141 for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
143 if ((*i)->marked_for_display() == false) {
147 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
151 /* tab finishes before this track starts */
155 double const h = y + (*i)->effective_height() / 2;
157 if (t->from < h && t->to > h) {
158 routes.push_back (rtv->route ());
162 y += (*i)->effective_height ();
170 EditorGroupTabs::add_menu_items (Gtk::Menu* m, RouteGroup* g)
172 using namespace Gtk::Menu_Helpers;
175 MenuList& items = m->items ();
176 items.push_back (MenuElem (_("Fit to Window"), sigc::bind (sigc::mem_fun (*_editor, &Editor::fit_route_group), g)));
181 EditorGroupTabs::selected_routes () const
185 for (TrackSelection::iterator i = _editor->get_selection().tracks.begin(); i != _editor->get_selection().tracks.end(); ++i) {
186 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
188 rl.push_back (rtv->route());
196 EditorGroupTabs::sync_order_keys ()
198 _editor->_routes->sync_order_keys_from_treeview ();