fix drawing of zero-length notes
[ardour.git] / gtk2_ardour / track_selection.h
1 /*
2  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #ifndef __ardour_gtk_track_selection_h__
22 #define __ardour_gtk_track_selection_h__
23
24 #include "track_view_list.h"
25 #include "route_ui.h"
26 #include "audio_time_axis.h"
27 #include "midi_time_axis.h"
28
29 class PublicEditor;
30
31 class TrackSelection : public TrackViewList
32 {
33 public:
34         TrackSelection (PublicEditor const * e) : _editor (e) {}
35         TrackSelection (PublicEditor const *, TrackViewList const &);
36
37         virtual ~TrackSelection ();
38
39         template <typename Function>
40         void foreach_time_axis (Function f) {
41                 for (iterator i = begin(); i != end(); ++i) {
42                         f (*i);
43                 }
44         }
45
46         template <typename Function>
47         void foreach_route_ui (Function f) {
48                 for (iterator i = begin(); i != end(); ) {
49                         iterator tmp = i;
50                         ++tmp;
51
52                         RouteUI* t = dynamic_cast<RouteUI*> (*i);
53                         if (t) {
54                                 f (t);
55                         }
56                         i = tmp;
57                 }
58         }
59
60         template <typename Function>
61         void foreach_route_time_axis (Function f) {
62                 for (iterator i = begin(); i != end(); ) {
63                         iterator tmp = i;
64                         ++tmp;
65                         RouteTimeAxisView* t = dynamic_cast<RouteTimeAxisView*> (*i);
66                         if (t) {
67                                 f (t);
68                         }
69                         i = tmp;
70                 }
71         }
72
73         template <typename Function>
74         void foreach_audio_time_axis (Function f) {
75                 for (iterator i = begin(); i != end(); ) {
76                         iterator tmp = i;
77                         ++tmp;
78                         AudioTimeAxisView* t = dynamic_cast<AudioTimeAxisView*> (*i);
79                         if (t) {
80                                 f (t);
81                         }
82                         i = tmp;
83                 }
84         }
85
86         template <typename Function>
87         void foreach_midi_time_axis (Function f) {
88                 for (iterator i = begin(); i != end(); ) {
89                         iterator tmp = i;
90                         ++tmp;
91                         MidiTimeAxisView* t = dynamic_cast<MidiTimeAxisView*> (*i);
92                         if (t) {
93                                 f (t);
94                         }
95                         i = tmp;
96                 }
97         }
98
99 private:
100         PublicEditor const * _editor;
101 };
102
103 #endif /* __ardour_gtk_track_selection_h__ */