Fly my pretties!
[ardour.git] / gtk2_ardour / region_selection.h
1 #ifndef __ardour_gtk_region_selection_h__
2 #define __ardour_gtk_region_selection_h__
3
4 #include <set>
5 #include <list>
6 #include <sigc++/signal.h>
7 #include <ardour/types.h>
8
9 using std::list;
10 using std::set;
11
12 class AudioRegionView;
13
14 struct AudioRegionComparator {
15     bool operator() (const AudioRegionView* a, const AudioRegionView* b) const;
16 };
17
18 class AudioRegionSelection : public set<AudioRegionView*, AudioRegionComparator>, public sigc::trackable
19 {
20   public:
21         AudioRegionSelection();
22         AudioRegionSelection (const AudioRegionSelection&);
23
24         AudioRegionSelection& operator= (const AudioRegionSelection&);
25
26         void add (AudioRegionView*, bool dosort = true);
27         bool remove (AudioRegionView*);
28         bool contains (AudioRegionView*);
29
30         void clear_all();
31         
32         jack_nframes_t start () const {
33                 return _current_start;
34         }
35
36         /* collides with list<>::end */
37
38         jack_nframes_t end_frame () const { 
39                 return _current_end;
40         }
41
42         const list<AudioRegionView *> & by_layer() const { return _bylayer; }
43         void  by_position (list<AudioRegionView*>&) const;
44         
45   private:
46         void remove_it (AudioRegionView*);
47
48         void add_to_layer (AudioRegionView *);
49         
50         jack_nframes_t _current_start;
51         jack_nframes_t _current_end;
52
53         list<AudioRegionView *> _bylayer;
54 };
55
56 #endif /* __ardour_gtk_region_selection_h__ */