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