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 "ardour/route_group.h"
21 #include "ardour/session.h"
22 #include "mixer_group_tabs.h"
23 #include "mixer_strip.h"
28 using namespace ARDOUR;
30 MixerGroupTabs::MixerGroupTabs (Mixer_UI* m)
38 MixerGroupTabs::compute_tabs () const
47 for (list<MixerStrip*>::iterator i = _mixer->strips.begin(); i != _mixer->strips.end(); ++i) {
49 if ((*i)->route()->is_master() || (*i)->route()->is_control() || !(*i)->marked_for_display()) {
53 RouteGroup* g = (*i)->route_group ();
58 tab.last_ui_size = (*i)->get_width ();
64 tab.colour = (*i)->color ();
65 tab.first_ui_size = (*i)->get_width ();
68 x += (*i)->get_width ();
80 MixerGroupTabs::draw_tab (cairo_t* cr, Tab const & tab) const
82 double const arc_radius = _height;
84 if (tab.group->is_active()) {
85 cairo_set_source_rgba (cr, tab.colour.get_red_p (), tab.colour.get_green_p (), tab.colour.get_blue_p (), 1);
87 cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
90 cairo_arc (cr, tab.from + arc_radius, _height, arc_radius, M_PI, 3 * M_PI / 2);
91 cairo_line_to (cr, tab.to - arc_radius, 0);
92 cairo_arc (cr, tab.to - arc_radius, _height, arc_radius, 3 * M_PI / 2, 2 * M_PI);
93 cairo_line_to (cr, tab.from, _height);
96 pair<string, double> const f = fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
98 cairo_text_extents_t ext;
99 cairo_text_extents (cr, tab.group->name().c_str(), &ext);
101 cairo_set_source_rgb (cr, 1, 1, 1);
102 cairo_move_to (cr, tab.from + (tab.to - tab.from - f.second) / 2, _height - ext.height / 2);
104 cairo_show_text (cr, f.first.c_str());
109 MixerGroupTabs::primary_coordinate (double x, double) const
115 MixerGroupTabs::reflect_tabs (list<Tab> const & tabs)
117 list<Tab>::const_iterator j = tabs.begin ();
120 for (list<MixerStrip*>::iterator i = _mixer->strips.begin(); i != _mixer->strips.end(); ++i) {
122 if ((*i)->route()->is_master() || (*i)->route()->is_control() || !(*i)->marked_for_display()) {
126 if (j == tabs.end()) {
128 /* already run out of tabs, so no edit group */
129 (*i)->route()->set_route_group (0, this);
134 /* this tab finishes before this track starts, so onto the next tab */
138 double const h = x + (*i)->get_width() / 2;
140 if (j->from < h && j->to > h) {
141 (*i)->route()->set_route_group (j->group, this);
143 (*i)->route()->set_route_group (0, this);
148 x += (*i)->get_width ();