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