Ardour  8.12
ghostregion.h
Go to the documentation of this file.
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 
31 #include "evoral/Note.h"
32 #include "pbd/signals.h"
33 
34 #include "gtkmm2ext/colors.h"
35 
36 namespace ArdourWaveView {
37  class WaveView;
38 }
39 
40 namespace ArdourCanvas {
41  class Container;
42  class Rectangle;
43  class Item;
44  class Polygon;
45 }
46 
47 class NoteBase;
48 class Note;
49 class Hit;
50 class MidiStreamView;
51 class TimeAxisView;
52 class RegionView;
53 class MidiRegionView;
54 
55 class GhostRegion : virtual public sigc::trackable
56 {
57 public:
60  TimeAxisView& tv,
61  TimeAxisView& source_tv,
62  double initial_unit_pos);
63 
64  virtual ~GhostRegion();
65 
66  virtual void set_samples_per_pixel (double) = 0;
67  virtual void set_height();
68  virtual void set_colors();
69 
70  void set_duration(double units);
71 
72  virtual void set_selected (bool) {}
73 
74  guint source_track_color(unsigned char alpha = 0xff);
76 
84 };
85 
86 class AudioGhostRegion : public GhostRegion {
87 public:
89  TimeAxisView& tv,
90  TimeAxisView& source_tv,
91  double initial_unit_pos);
92 
93  void set_samples_per_pixel (double);
94  void set_height();
95  void set_colors();
96 
97  std::vector<ArdourWaveView::WaveView*> waves;
98 };
99 
100 class MidiGhostRegion : public GhostRegion {
101 public:
102  class GhostEvent : public sigc::trackable
103  {
104  public:
107  virtual ~GhostEvent ();
108 
111  bool is_hit;
113  };
114 
116  TimeAxisView& tv,
117  TimeAxisView& source_tv,
118  double initial_unit_pos);
119 
122 
123  void set_height();
124  void set_samples_per_pixel (double spu);
125  void set_colors();
126 
127  virtual void update_contents_height();
128 
129  virtual void add_note(NoteBase*);
130  virtual void update_note (GhostEvent* note);
131  virtual void update_hit (GhostEvent* hit);
132  virtual void remove_note (NoteBase*);
133  virtual void note_selected (NoteBase*) {}
134 
136  void view_changed();
137  void clear_events();
138 
139  protected:
144 
146  /* must match typedef in NoteBase */
148  MidiGhostRegion::GhostEvent* find_event (std::shared_ptr<NoteType>);
149 
150  typedef boost::unordered_map<std::shared_ptr<NoteType>, MidiGhostRegion::GhostEvent* > EventList;
152  EventList::iterator _optimization_iterator;
153 };
154 
155 #endif /* __ardour_gtk_ghost_region_h__ */
std::vector< ArdourWaveView::WaveView * > waves
Definition: ghostregion.h:97
AudioGhostRegion(RegionView &rv, TimeAxisView &tv, TimeAxisView &source_tv, double initial_unit_pos)
void set_samples_per_pixel(double)
TimeAxisView & source_trackview
Definition: ghostregion.h:81
guint source_track_color(unsigned char alpha=0xff)
virtual void set_height()
void set_duration(double units)
virtual void set_selected(bool)
Definition: ghostregion.h:72
GhostRegion(RegionView &rv, ArdourCanvas::Container *parent, TimeAxisView &tv, TimeAxisView &source_tv, double initial_unit_pos)
ArdourCanvas::Container * group
Definition: ghostregion.h:82
virtual ~GhostRegion()
ArdourCanvas::Rectangle * base_rect
Definition: ghostregion.h:83
virtual void set_samples_per_pixel(double)=0
virtual void set_colors()
bool is_automation_ghost()
TimeAxisView & trackview
Definition: ghostregion.h:79
RegionView & parent_rv
Definition: ghostregion.h:77
Definition: hit.h:31
GhostEvent(::NoteBase *, ArdourCanvas::Container *)
GhostEvent(::NoteBase *, ArdourCanvas::Container *, ArdourCanvas::Item *i)
ArdourCanvas::Item * item
Definition: ghostregion.h:110
ArdourCanvas::Rectangle * _tmp_rect
Definition: ghostregion.h:142
Evoral::Note< Temporal::Beats > NoteType
Definition: ghostregion.h:147
virtual void update_hit(GhostEvent *hit)
MidiGhostRegion::GhostEvent * find_event(std::shared_ptr< NoteType >)
virtual void note_selected(NoteBase *)
Definition: ghostregion.h:133
virtual void update_contents_height()
ArdourCanvas::Polygon * _tmp_poly
Definition: ghostregion.h:143
ArdourCanvas::Container * _note_group
Definition: ghostregion.h:140
virtual void update_note(GhostEvent *note)
Gtkmm2ext::Color _outline
Definition: ghostregion.h:141
EventList::iterator _optimization_iterator
Definition: ghostregion.h:152
virtual void add_note(NoteBase *)
EventList events
Definition: ghostregion.h:151
boost::unordered_map< std::shared_ptr< NoteType >, MidiGhostRegion::GhostEvent * > EventList
Definition: ghostregion.h:150
MidiGhostRegion(MidiRegionView &rv, TimeAxisView &tv, TimeAxisView &source_tv, double initial_unit_pos)
MidiRegionView & parent_mrv
Definition: ghostregion.h:145
void set_samples_per_pixel(double spu)
MidiStreamView * midi_view()
virtual void remove_note(NoteBase *)
void model_changed()
uint32_t Color
Definition: colors.h:33
DebugBits WaveView