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