Fix thinkos in cubasish theme
[ardour.git] / gtk2_ardour / ghostregion.h
1 /*
2  * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
4  * Copyright (C) 2006-2015 Tim Mayberry <mojofunk@gmail.com>
5  * Copyright (C) 2008-2014 David Robillard <d@drobilla.net>
6  * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
7  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
8  * Copyright (C) 2016-2017 Nick Mainsbridge <mainsbridge@gmail.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __ardour_gtk_ghost_region_h__
26 #define __ardour_gtk_ghost_region_h__
27
28 #include <vector>
29 #include <boost/unordered_map.hpp>
30 #include "pbd/signals.h"
31
32 namespace ArdourWaveView {
33         class WaveView;
34 }
35
36 class NoteBase;
37 class Note;
38 class Hit;
39 class MidiStreamView;
40 class TimeAxisView;
41 class RegionView;
42 class MidiRegionView;
43
44 class GhostRegion : public sigc::trackable
45 {
46 public:
47         GhostRegion(RegionView& rv,
48                     ArdourCanvas::Container* parent,
49                     TimeAxisView& tv,
50                     TimeAxisView& source_tv,
51                     double initial_unit_pos);
52
53         virtual ~GhostRegion();
54
55         virtual void set_samples_per_pixel (double) = 0;
56         virtual void set_height();
57         virtual void set_colors();
58
59         void set_duration(double units);
60
61         guint source_track_color(unsigned char alpha = 0xff);
62         bool is_automation_ghost();
63
64         RegionView& parent_rv;
65         /** TimeAxisView that is the AutomationTimeAxisView that we are on */
66         TimeAxisView& trackview;
67         /** TimeAxisView that we are a ghost for */
68         TimeAxisView& source_trackview;
69         ArdourCanvas::Container* group;
70         ArdourCanvas::Rectangle* base_rect;
71 };
72
73 class AudioGhostRegion : public GhostRegion {
74 public:
75         AudioGhostRegion(RegionView& rv,
76                          TimeAxisView& tv,
77                          TimeAxisView& source_tv,
78                          double initial_unit_pos);
79
80         void set_samples_per_pixel (double);
81         void set_height();
82         void set_colors();
83
84         std::vector<ArdourWaveView::WaveView*> waves;
85 };
86
87 class MidiGhostRegion : public GhostRegion {
88 public:
89         class GhostEvent : public sigc::trackable
90         {
91         public:
92                 GhostEvent(::NoteBase *, ArdourCanvas::Container *);
93                 virtual ~GhostEvent ();
94
95                 NoteBase* event;
96                 ArdourCanvas::Item* item;
97                 bool is_hit;
98         };
99
100         MidiGhostRegion(MidiRegionView& rv,
101                         TimeAxisView& tv,
102                         TimeAxisView& source_tv,
103                         double initial_unit_pos);
104
105         MidiGhostRegion(MidiRegionView& rv,
106                         MidiStreamView& msv,
107                         TimeAxisView& source_tv,
108                         double initial_unit_pos);
109
110         ~MidiGhostRegion();
111
112         MidiStreamView* midi_view();
113
114         void set_height();
115         void set_samples_per_pixel (double spu);
116         void set_colors();
117
118         void update_contents_height();
119
120         void add_note(NoteBase*);
121         void update_note (GhostEvent* note);
122         void update_hit (GhostEvent* hit);
123         void remove_note (NoteBase*);
124
125         void redisplay_model();
126         void clear_events();
127
128 private:
129         ArdourCanvas::Container* _note_group;
130         Gtkmm2ext::Color _outline;
131         ArdourCanvas::Rectangle* _tmp_rect;
132         ArdourCanvas::Polygon* _tmp_poly;
133
134         MidiRegionView& parent_mrv;
135         typedef Evoral::Note<Temporal::Beats> NoteType;
136         MidiGhostRegion::GhostEvent* find_event (boost::shared_ptr<NoteType>);
137
138         typedef boost::unordered_map<boost::shared_ptr<NoteType>, MidiGhostRegion::GhostEvent* > EventList;
139         EventList events;
140         EventList::iterator _optimization_iterator;
141 };
142
143 #endif /* __ardour_gtk_ghost_region_h__ */