set a theme color for VCA axes in the editor
[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 "pbd/signals.h"
25
26 namespace ArdourCanvas {
27         class WaveView;
28 }
29
30 class NoteBase;
31 class Note;
32 class Hit;
33 class MidiStreamView;
34 class TimeAxisView;
35 class RegionView;
36
37 class GhostRegion : public sigc::trackable
38 {
39 public:
40         GhostRegion(RegionView& rv,
41                     ArdourCanvas::Container* parent,
42                     TimeAxisView& tv,
43                     TimeAxisView& source_tv,
44                     double initial_unit_pos);
45
46         virtual ~GhostRegion();
47
48         virtual void set_samples_per_pixel (double) = 0;
49         virtual void set_height();
50         virtual void set_colors();
51
52         void set_duration(double units);
53
54         guint source_track_color(unsigned char alpha = 0xff);
55         bool is_automation_ghost();
56
57         RegionView& parent_rv;
58         /** TimeAxisView that is the AutomationTimeAxisView that we are on */
59         TimeAxisView& trackview;
60         /** TimeAxisView that we are a ghost for */
61         TimeAxisView& source_trackview;
62         ArdourCanvas::Container* group;
63         ArdourCanvas::Rectangle* base_rect;
64 };
65
66 class AudioGhostRegion : public GhostRegion {
67 public:
68         AudioGhostRegion(RegionView& rv,
69                          TimeAxisView& tv,
70                          TimeAxisView& source_tv,
71                          double initial_unit_pos);
72
73         void set_samples_per_pixel (double);
74         void set_height();
75         void set_colors();
76
77         std::vector<ArdourCanvas::WaveView*> waves;
78 };
79
80 class MidiGhostRegion : public GhostRegion {
81 public:
82         class GhostEvent : public sigc::trackable {
83           public:
84             GhostEvent(::NoteBase *, ArdourCanvas::Container *);
85             virtual ~GhostEvent ();
86
87             NoteBase* event;
88             ArdourCanvas::Item* item;
89         };
90
91         MidiGhostRegion(RegionView& rv,
92                         TimeAxisView& tv,
93                         TimeAxisView& source_tv,
94                         double initial_unit_pos);
95
96         MidiGhostRegion(RegionView& rv,
97                         MidiStreamView& msv,
98                         TimeAxisView& source_tv,
99                         double initial_unit_pos);
100
101         ~MidiGhostRegion();
102
103         MidiStreamView* midi_view();
104
105         void set_height();
106         void set_samples_per_pixel (double spu);
107         void set_colors();
108
109         void update_range();
110
111         void add_note(NoteBase*);
112         void update_note (NoteBase*);
113         void remove_note (NoteBase*);
114
115         void clear_events();
116
117 private:
118         ArdourCanvas::Color _fill;
119         ArdourCanvas::Color _outline;
120
121         MidiGhostRegion::GhostEvent* find_event (NoteBase*);
122
123         typedef std::list<MidiGhostRegion::GhostEvent*> EventList;
124         EventList events;
125         EventList::iterator _optimization_iterator;
126 };
127
128 #endif /* __ardour_gtk_ghost_region_h__ */