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"
27 #include "route_group_dialog.h"
31 using namespace ARDOUR;
33 MixerGroupTabs::MixerGroupTabs (Mixer_UI* m)
43 MixerGroupTabs::compute_tabs () const
52 TreeModel::Children rows = _mixer->track_model->children ();
53 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
55 MixerStrip* s = (*i)[_mixer->track_columns.strip];
57 if (s->route()->is_master() || s->route()->is_control() || !s->marked_for_display()) {
61 RouteGroup* g = s->route_group ();
71 tab.colour = s->color ();
86 MixerGroupTabs::draw_tab (cairo_t* cr, Tab const & tab) const
88 double const arc_radius = _height;
90 if (tab.group && tab.group->is_active()) {
91 cairo_set_source_rgba (cr, tab.colour.get_red_p (), tab.colour.get_green_p (), tab.colour.get_blue_p (), 1);
93 cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
96 cairo_arc (cr, tab.from + arc_radius, _height, arc_radius, M_PI, 3 * M_PI / 2);
97 cairo_line_to (cr, tab.to - arc_radius, 0);
98 cairo_arc (cr, tab.to - arc_radius, _height, arc_radius, 3 * M_PI / 2, 2 * M_PI);
99 cairo_line_to (cr, tab.from, _height);
103 pair<string, double> const f = fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
105 cairo_text_extents_t ext;
106 cairo_text_extents (cr, tab.group->name().c_str(), &ext);
108 cairo_set_source_rgb (cr, 1, 1, 1);
109 cairo_move_to (cr, tab.from + (tab.to - tab.from - f.second) / 2, _height - ext.height / 2);
111 cairo_show_text (cr, f.first.c_str());
117 MixerGroupTabs::primary_coordinate (double x, double) const
123 MixerGroupTabs::routes_for_tab (Tab const * t) const
128 TreeModel::Children rows = _mixer->track_model->children ();
129 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
131 MixerStrip* s = (*i)[_mixer->track_columns.strip];
133 if (s->route()->is_master() || s->route()->is_control() || !s->marked_for_display()) {
138 /* tab finishes before this track starts */
142 double const h = x + s->get_width() / 2;
144 if (t->from < h && t->to > h) {
145 routes.push_back (s->route ());
148 x += s->get_width ();
155 MixerGroupTabs::get_menu (RouteGroup* g)
161 using namespace Menu_Helpers;
166 MenuList& items = _menu->items ();
167 items.push_back (MenuElem (_("Edit..."), bind (mem_fun (*this, &MixerGroupTabs::edit_group), g)));
168 items.push_back (MenuElem (_("Subgroup"), bind (mem_fun (*this, &MixerGroupTabs::make_subgroup), g)));
169 items.push_back (SeparatorElem());
170 items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &MixerGroupTabs::remove_group), g)));
176 MixerGroupTabs::edit_group (RouteGroup* g)
178 RouteGroupDialog d (g, Gtk::Stock::APPLY);
183 MixerGroupTabs::remove_group (RouteGroup *g)
185 _session->remove_route_group (*g);
189 MixerGroupTabs::make_subgroup (RouteGroup* g)
195 MixerGroupTabs::destroy_subgroup (RouteGroup* g)
197 g->destroy_subgroup ();
201 MixerGroupTabs::new_route_group () const
203 RouteGroup* g = new RouteGroup (
207 (RouteGroup::Property) (RouteGroup::Gain | RouteGroup::Mute | RouteGroup::Solo | RouteGroup::RecEnable)
210 RouteGroupDialog d (g, Gtk::Stock::NEW);
211 int const r = d.do_run ();
213 if (r != Gtk::RESPONSE_OK) {
218 _session->add_route_group (g);