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