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 "editor_group_tabs.h"
23 #include "route_time_axis.h"
25 #include "editor_route_groups.h"
26 #include "editor_routes.h"
30 using namespace ARDOUR
;
32 EditorGroupTabs::EditorGroupTabs (Editor
* e
)
39 EditorGroupTabs::compute_tabs () const
48 for (TrackViewList::iterator i
= _editor
->track_views
.begin(); i
!= _editor
->track_views
.end(); ++i
) {
50 if ((*i
)->marked_for_display() == false) {
54 RouteGroup
* g
= (*i
)->route_group ();
64 tab
.colour
= (*i
)->color ();
67 y
+= (*i
)->effective_height ();
79 EditorGroupTabs::draw_tab (cairo_t
* cr
, Tab
const & tab
) const
81 double const arc_radius
= _width
;
83 if (tab
.group
&& tab
.group
->is_active()) {
84 cairo_set_source_rgba (cr
, tab
.colour
.get_red_p (), tab
.colour
.get_green_p (), tab
.colour
.get_blue_p (), 1);
86 cairo_set_source_rgba (cr
, 1, 1, 1, 0.2);
89 cairo_move_to (cr
, 0, tab
.from
+ arc_radius
);
90 cairo_arc (cr
, _width
, tab
.from
+ arc_radius
, arc_radius
, M_PI
, 3 * M_PI
/ 2);
91 cairo_line_to (cr
, _width
, tab
.to
);
92 cairo_arc (cr
, _width
, tab
.to
- arc_radius
, arc_radius
, M_PI
/ 2, M_PI
);
93 cairo_line_to (cr
, 0, tab
.from
+ arc_radius
);
97 pair
<string
, double> const f
= fit_to_pixels (cr
, tab
.group
->name(), tab
.to
- tab
.from
- arc_radius
* 2);
99 cairo_text_extents_t ext
;
100 cairo_text_extents (cr
, tab
.group
->name().c_str(), &ext
);
102 cairo_set_source_rgb (cr
, 1, 1, 1);
103 cairo_move_to (cr
, _width
- ext
.height
/ 2, tab
.from
+ (f
.second
+ tab
.to
- tab
.from
) / 2);
105 cairo_rotate (cr
, - M_PI
/ 2);
106 cairo_show_text (cr
, f
.first
.c_str());
112 EditorGroupTabs::primary_coordinate (double, double y
) const
118 EditorGroupTabs::routes_for_tab (Tab
const * t
) const
123 for (TrackViewList::iterator i
= _editor
->track_views
.begin(); i
!= _editor
->track_views
.end(); ++i
) {
125 if ((*i
)->marked_for_display() == false) {
129 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*> (*i
);
133 /* tab finishes before this track starts */
137 double const h
= y
+ (*i
)->effective_height() / 2;
139 if (t
->from
< h
&& t
->to
> h
) {
140 routes
.push_back (rtv
->route ());
144 y
+= (*i
)->effective_height ();
152 EditorGroupTabs::add_menu_items (Gtk::Menu
* m
, RouteGroup
* g
)
154 using namespace Gtk::Menu_Helpers
;
157 MenuList
& items
= m
->items ();
158 items
.push_back (MenuElem (_("Fit to Window"), sigc::bind (sigc::mem_fun (*_editor
, &Editor::fit_route_group
), g
)));
163 EditorGroupTabs::default_properties () const
165 PBD::PropertyList plist
;
167 plist
.add (Properties::active
, true);
168 plist
.add (Properties::mute
, true);
169 plist
.add (Properties::solo
, true);
170 plist
.add (Properties::recenable
, true);
171 plist
.add (Properties::edit
, true);
177 EditorGroupTabs::order_key () const
183 EditorGroupTabs::selected_routes () const
187 for (TrackSelection::iterator i
= _editor
->get_selection().tracks
.begin(); i
!= _editor
->get_selection().tracks
.end(); ++i
) {
188 RouteTimeAxisView
* rtv
= dynamic_cast<RouteTimeAxisView
*> (*i
);
190 rl
.push_back (rtv
->route());
198 EditorGroupTabs::sync_order_keys ()
200 _editor
->_routes
->sync_order_keys ("");