0c72ed14f976a9d9dced6e0dd099a63c6a81b419
[ardour.git] / gtk2_ardour / automation_time_axis.h
1 #ifndef __ardour_gtk_automation_time_axis_h__
2 #define __ardour_gtk_automation_time_axis_h__
3
4 #include <vector>
5 #include <list>
6 #include <string>
7
8 #include <boost/shared_ptr.hpp>
9
10 #include <ardour/types.h>
11
12 #include "canvas.h"
13 #include "time_axis_view.h"
14 #include "simplerect.h"
15
16 using std::vector;
17 using std::list;
18 using std::string;
19
20 namespace ARDOUR {
21         class Session;
22         class Route;
23 }
24
25 class PublicEditor;
26 class TimeSelection;
27 class AudioRegionSelection;
28 class PointSelection;
29 class AutomationLine;
30 class GhostRegion;
31 class Selection;
32 class Selectable;
33
34 class AutomationTimeAxisView : public TimeAxisView {
35   public:
36         AutomationTimeAxisView (ARDOUR::Session&,
37                                 boost::shared_ptr<ARDOUR::Route>,
38                                 PublicEditor&,
39                                 TimeAxisView& parent,
40                                 ArdourCanvas::Canvas& canvas,
41                                 const string & name, /* translatable */
42                                 const string & state_name, /* not translatable */
43                                 const string & plug_name = "");
44
45         ~AutomationTimeAxisView();
46         
47         virtual void set_height (TimeAxisView::TrackHeight);
48         void set_samples_per_unit (double);
49         std::string name() const { return _name; }
50
51         virtual void add_automation_event (ArdourCanvas::Item *item, GdkEvent *event, jack_nframes_t, double) = 0;
52
53         virtual void clear_lines ();
54         virtual void add_line (AutomationLine&);
55
56         vector<AutomationLine*> lines;
57
58         void set_selected_points (PointSelection&);
59         void get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list<Selectable *>&);
60         void get_inverted_selectables (Selection&, list<Selectable*>& results);
61
62         void show_timestretch (jack_nframes_t start, jack_nframes_t end) {}
63         void hide_timestretch () {}
64
65         /* editing operations */
66         
67         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
68         bool cut_copy_clear_objects (PointSelection&, Editing::CutCopyOp);
69         bool paste (jack_nframes_t, float times, Selection&, size_t nth);
70         void reset_objects (PointSelection&);
71
72         void add_ghost (GhostRegion*);
73         void remove_ghost (GhostRegion*);
74
75         void show_all_control_points ();
76         void hide_all_but_selected_control_points ();
77         void set_state (const XMLNode&);
78         XMLNode* get_state_node ();
79
80   protected:
81         boost::shared_ptr<ARDOUR::Route> route;
82         ArdourCanvas::SimpleRect* base_rect;
83         string _name;
84         string _state_name;
85         bool    in_destructor;
86
87         Gtk::Button        hide_button;
88         Gtk::Button        height_button;
89         Gtk::Button        clear_button;
90         Gtk::Button        auto_button; 
91         Gtk::Menu*         automation_menu;
92         Gtk::Label*        plugname;
93         bool               plugname_packed;
94
95         Gtk::CheckMenuItem*     auto_off_item;
96         Gtk::CheckMenuItem*     auto_play_item;
97         Gtk::CheckMenuItem*     auto_touch_item;
98         Gtk::CheckMenuItem*     auto_write_item;
99
100         void clear_clicked ();
101         void height_clicked ();
102         void hide_clicked ();
103         void auto_clicked ();
104
105         virtual void build_display_menu ();
106
107         list<GhostRegion*> ghosts;
108
109         bool cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
110         bool cut_copy_clear_objects_one (AutomationLine&, PointSelection&, Editing::CutCopyOp);
111         bool paste_one (AutomationLine&, jack_nframes_t, float times, Selection&, size_t nth);
112         void reset_objects_one (AutomationLine&, PointSelection&);
113
114         virtual void set_automation_state (ARDOUR::AutoState) = 0;
115         bool ignore_state_request;
116
117         void automation_state_changed ();
118         sigc::connection automation_connection;
119
120         void entered ();
121         void exited ();
122 };
123
124 #endif /* __ardour_gtk_automation_time_axis_h__ */