various fixes to MidiRegionView selection handling, key handling, drawing of ghost...
[ardour2.git] / gtk2_ardour / ghostregion.h
blob103d7ecf97bacb26aba2e87327f609344385746d
1 /*
2 Copyright (C) 2004 Paul Davis
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.
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.
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.
20 #ifndef __ardour_gtk_ghost_region_h__
21 #define __ardour_gtk_ghost_region_h__
23 #include <vector>
24 #include <libgnomecanvasmm.h>
25 #include "pbd/signals.h"
26 #include "canvas.h"
28 namespace Gnome {
29 namespace Canvas {
30 class CanvasNoteEvent;
31 class CanvasNote;
32 class CanvasHit;
33 class Diamond;
37 class MidiStreamView;
38 class TimeAxisView;
40 class GhostRegion : public sigc::trackable
42 public:
43 GhostRegion(ArdourCanvas::Group* parent, TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
44 virtual ~GhostRegion();
46 virtual void set_samples_per_unit(double spu) = 0;
47 virtual void set_height();
48 virtual void set_colors();
50 void set_duration(double units);
52 guint source_track_color(unsigned char alpha = 0xff);
53 bool is_automation_ghost();
55 /** TimeAxisView that is the AutomationTimeAxisView that we are on */
56 TimeAxisView& trackview;
57 /** TimeAxisView that we are a ghost for */
58 TimeAxisView& source_trackview;
59 ArdourCanvas::Group* group;
60 ArdourCanvas::SimpleRect* base_rect;
62 static PBD::Signal1<void,GhostRegion*> CatchDeletion;
65 class AudioGhostRegion : public GhostRegion {
66 public:
67 AudioGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
69 void set_samples_per_unit(double spu);
70 void set_height();
71 void set_colors();
73 std::vector<ArdourCanvas::WaveView*> waves;
76 class MidiGhostRegion : public GhostRegion {
77 public:
78 class Event : public sigc::trackable {
79 public:
80 Event(ArdourCanvas::CanvasNoteEvent*);
81 virtual ~Event() {}
83 ArdourCanvas::CanvasNoteEvent* event;
86 class Note : public Event {
87 public:
88 Note(ArdourCanvas::CanvasNote*, ArdourCanvas::Group*);
89 ~Note();
91 ArdourCanvas::SimpleRect* rect;
94 MidiGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
95 MidiGhostRegion(MidiStreamView& msv, TimeAxisView& source_tv, double initial_unit_pos);
96 ~MidiGhostRegion();
98 MidiStreamView* midi_view();
100 void set_height();
101 void set_samples_per_unit(double spu);
102 void set_colors();
104 void update_range();
106 void add_note(ArdourCanvas::CanvasNote*);
107 void update_note (ArdourCanvas::CanvasNote *);
109 void clear_events();
111 private:
113 MidiGhostRegion::Event* find_event (ArdourCanvas::CanvasNote *);
115 typedef std::list<MidiGhostRegion::Event*> EventList;
116 EventList events;
117 EventList::iterator _optimization_iterator;
120 #endif /* __ardour_gtk_ghost_region_h__ */