30fa71bea973608bff90dfc4f10b2c29508ce0f5
[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 RegionSelection;
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, 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 (nframes_t start, nframes_t end, double top, double bot, list<Selectable *>&);
60         void get_inverted_selectables (Selection&, list<Selectable*>& results);
61
62         void show_timestretch (nframes_t start, 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 (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         bool    first_call_to_set_height;
88
89         Gtk::Button        hide_button;
90         Gtk::Button        height_button;
91         Gtk::Button        clear_button;
92         Gtk::Button        auto_button; 
93         Gtk::Menu*         automation_menu;
94         Gtk::Label*        plugname;
95         bool               plugname_packed;
96
97         Gtk::CheckMenuItem*     auto_off_item;
98         Gtk::CheckMenuItem*     auto_play_item;
99         Gtk::CheckMenuItem*     auto_touch_item;
100         Gtk::CheckMenuItem*     auto_write_item;
101
102         void clear_clicked ();
103         void height_clicked ();
104         void hide_clicked ();
105         void auto_clicked ();
106
107         virtual void build_display_menu ();
108
109         list<GhostRegion*> ghosts;
110
111         bool cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
112         bool cut_copy_clear_objects_one (AutomationLine&, PointSelection&, Editing::CutCopyOp);
113         bool paste_one (AutomationLine&, nframes_t, float times, Selection&, size_t nth);
114         void reset_objects_one (AutomationLine&, PointSelection&);
115
116         virtual void set_automation_state (ARDOUR::AutoState) = 0;
117         bool ignore_state_request;
118
119         void automation_state_changed ();
120         sigc::connection automation_connection;
121
122         void entered ();
123         void exited ();
124 };
125
126 #endif /* __ardour_gtk_automation_time_axis_h__ */