*** NEW CODING POLICY ***
[ardour.git] / gtk2_ardour / ghostregion.h
1 /*
2     Copyright (C) 2004 Paul Davis 
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_gtk_ghost_region_h__
21 #define __ardour_gtk_ghost_region_h__
22
23 #include <vector>
24 #include <sigc++/signal.h>
25 #include <libgnomecanvasmm.h>
26 #include "ardour/configuration.h"
27 #include "canvas.h"
28
29 namespace Gnome {
30         namespace Canvas {
31                 class CanvasNoteEvent;
32                 class CanvasNote;
33                 class CanvasHit;
34                 class Diamond;
35         }
36 }
37
38 class MidiStreamView;
39 class TimeAxisView;
40
41 class GhostRegion : public sigc::trackable 
42 {
43 public:
44         GhostRegion(ArdourCanvas::Group* parent, TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
45         virtual ~GhostRegion();
46
47         virtual void set_samples_per_unit(double spu) = 0;
48         virtual void set_height();
49         virtual void set_colors();
50
51         void set_duration(double units);
52
53         guint source_track_color(unsigned char alpha = 0xff);
54         bool is_automation_ghost();
55
56         sigc::signal<void,GhostRegion*> GoingAway;
57
58         TimeAxisView& trackview;
59         TimeAxisView& source_trackview;
60         ArdourCanvas::Group* group;
61         ArdourCanvas::SimpleRect* base_rect;
62 };
63
64 class AudioGhostRegion : public GhostRegion {
65 public:
66         AudioGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
67
68         void set_samples_per_unit(double spu);
69         void set_height();
70         void set_colors();
71
72         std::vector<ArdourCanvas::WaveView*> waves;
73 };
74
75 class MidiGhostRegion : public GhostRegion {
76 public:
77         class Event : public sigc::trackable {
78         public:
79                 Event(ArdourCanvas::CanvasNoteEvent*);
80                 virtual ~Event() {}
81
82                 virtual void x_changed() = 0;
83                 ArdourCanvas::CanvasNoteEvent* event;
84         };
85
86         class Note : public Event {
87         public:
88                 Note(ArdourCanvas::CanvasNote*, ArdourCanvas::Group*);
89                 ~Note();
90
91                 void x_changed();
92                 ArdourCanvas::SimpleRect* rect;
93         };
94
95         class Hit : public Event {
96         public:
97                 Hit(ArdourCanvas::CanvasHit*, ArdourCanvas::Group*);
98                 ~Hit();
99
100                 void x_changed();
101                 ArdourCanvas::Diamond* diamond;
102         };
103         
104         MidiGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
105         MidiGhostRegion(MidiStreamView& msv, TimeAxisView& source_tv, double initial_unit_pos);
106         ~MidiGhostRegion();
107
108         MidiStreamView* midi_view();
109
110         void set_height();
111         void set_samples_per_unit(double spu);
112         void set_colors();
113
114         void update_range();
115
116         void add_note(ArdourCanvas::CanvasNote*);
117         void add_hit(ArdourCanvas::CanvasHit*);
118
119         void clear_events();
120
121         typedef std::list<MidiGhostRegion::Event*> EventList;
122         EventList events;
123 };
124
125 #endif /* __ardour_gtk_ghost_region_h__ */