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 <boost/foreach.hpp>
22 #include "gtkmm2ext/utils.h"
24 #include "ardour/route_group.h"
26 #include "canvas/colors.h"
28 #include "mixer_group_tabs.h"
29 #include "mixer_strip.h"
31 #include "rgb_macros.h"
32 #include "route_group_dialog.h"
33 #include "ui_config.h"
40 using namespace ARDOUR;
41 using namespace ARDOUR_UI_UTILS;
44 MixerGroupTabs::MixerGroupTabs (Mixer_UI* m)
52 MixerGroupTabs::compute_tabs () const
61 TreeModel::Children rows = _mixer->track_model->children ();
62 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
64 MixerStrip* s = (*i)[_mixer->track_columns.strip];
66 if (s->route()->is_master() || s->route()->is_monitor() || !s->marked_for_display()) {
70 RouteGroup* g = s->route_group ();
82 tab.color = group_color (g);
87 s->get_size_request (ww, wh); // widget may not be realized, get_width() is invalid.
100 MixerGroupTabs::draw_tab (cairo_t* cr, Tab const & tab) const
102 double const arc_radius = get_height();
105 if (tab.group && tab.group->is_active()) {
106 ArdourCanvas::color_to_rgba (tab.color, r, g, b, a);
108 ArdourCanvas::color_to_rgba (UIConfiguration::instance().color ("inactive group tab"), r, g, b, a);
113 cairo_set_source_rgba (cr, r, g, b, a);
114 cairo_arc (cr, tab.from + arc_radius, get_height(), arc_radius, M_PI, 3 * M_PI / 2);
115 cairo_line_to (cr, tab.to - arc_radius, 0);
116 cairo_arc (cr, tab.to - arc_radius, get_height(), arc_radius, 3 * M_PI / 2, 2 * M_PI);
117 cairo_line_to (cr, tab.from, get_height());
121 pair<string, double> const f = Gtkmm2ext::fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
123 cairo_text_extents_t ext;
124 cairo_text_extents (cr, tab.group->name().c_str(), &ext);
126 ArdourCanvas::Color c = ArdourCanvas::contrasting_text_color (ArdourCanvas::rgba_to_color (r, g, b, a));
127 ArdourCanvas::color_to_rgba (c, r, g, b, a);
129 cairo_set_source_rgb (cr, r, g, b);
130 cairo_move_to (cr, tab.from + (tab.to - tab.from - f.second) / 2, get_height() - ext.height / 2);
132 cairo_show_text (cr, f.first.c_str());
138 MixerGroupTabs::primary_coordinate (double x, double) const
144 MixerGroupTabs::routes_for_tab (Tab const * t) const
149 TreeModel::Children rows = _mixer->track_model->children ();
150 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
152 MixerStrip* s = (*i)[_mixer->track_columns.strip];
154 if (s->route()->is_master() || s->route()->is_monitor() || !s->marked_for_display()) {
159 /* tab finishes before this track starts */
163 double const h = x + s->get_width() / 2;
165 if (t->from < h && t->to > h) {
166 routes.push_back (s->route ());
169 x += s->get_width ();
176 MixerGroupTabs::selected_routes () const
179 BOOST_FOREACH (RouteUI* r, _mixer->selection().routes) {
180 boost::shared_ptr<Route> rp = r->route();
189 MixerGroupTabs::sync_order_keys ()
191 _mixer->sync_order_keys_from_treeview ();