First go at saving window visibility and position state across saves.
[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 <list>
24 #include <string>
25 #include <utility>
26
27 #include <boost/shared_ptr.hpp>
28
29 #include "ardour/types.h"
30 #include "ardour/automatable.h"
31 #include "ardour/automation_list.h"
32
33 #include "canvas.h"
34 #include "time_axis_view.h"
35 #include "simplerect.h"
36 #include "automation_controller.h"
37
38 namespace ARDOUR {
39         class Session;
40         class Route;
41         class AutomationControl;
42 }
43
44 class PublicEditor;
45 class TimeSelection;
46 class RegionSelection;
47 class PointSelection;
48 class AutomationLine;
49 class Selection;
50 class Selectable;
51 class AutomationStreamView;
52 class AutomationController;
53
54
55 class AutomationTimeAxisView : public TimeAxisView {
56   public:
57         AutomationTimeAxisView (ARDOUR::Session*,
58                                 boost::shared_ptr<ARDOUR::Route>,
59                                 boost::shared_ptr<ARDOUR::Automatable>,
60                                 boost::shared_ptr<ARDOUR::AutomationControl>,
61                                 PublicEditor&,
62                                 TimeAxisView& parent,
63                                 bool show_regions,
64                                 ArdourCanvas::Canvas& canvas,
65                                 const std::string & name, /* translatable */
66                                 const std::string & plug_name = "");
67
68         ~AutomationTimeAxisView();
69
70         virtual void set_height (uint32_t);
71         void set_samples_per_unit (double);
72         bool set_visibility (bool yn);
73         std::string name() const { return _name; }
74
75         void add_automation_event (ArdourCanvas::Item *item, GdkEvent *event, nframes_t, double);
76
77         void clear_lines ();
78         boost::shared_ptr<AutomationLine> line() { return _line; }
79
80         void set_selected_points (PointSelection&);
81         void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, double top, double bot, std::list<Selectable *>&);
82         void get_inverted_selectables (Selection&, std::list<Selectable*>& results);
83
84         void show_timestretch (nframes_t /*start*/, nframes_t /*end*/) {}
85         void hide_timestretch () {}
86
87         /* editing operations */
88
89         void cut_copy_clear (Selection&, Editing::CutCopyOp);
90         void cut_copy_clear_objects (PointSelection&, Editing::CutCopyOp);
91         bool paste (ARDOUR::framepos_t, float times, Selection&, size_t nth);
92         void reset_objects (PointSelection&);
93
94         int  set_state (const XMLNode&, int version);
95         guint32 show_at (double y, int& nth, Gtk::VBox *parent);
96         void hide ();
97
98         static const std::string state_node_name;
99         XMLNode* get_state_node();
100
101         boost::shared_ptr<ARDOUR::AutomationControl> control()    { return _control; }
102         boost::shared_ptr<AutomationController>      controller() { return _controller; }
103
104         ArdourCanvas::Item* base_item () const {
105                 return _base_rect;
106         }
107
108         bool has_automation () const;
109
110         boost::shared_ptr<ARDOUR::Route> parent_route () {
111                 return _route;
112         }
113
114   protected:
115         boost::shared_ptr<ARDOUR::Route> _route; ///< Parent route
116         boost::shared_ptr<ARDOUR::AutomationControl> _control; ///< Control
117         boost::shared_ptr<ARDOUR::Automatable> _automatable; ///< Control owner, maybe = _route
118
119         boost::shared_ptr<AutomationController> _controller;
120
121         ArdourCanvas::SimpleRect* _base_rect;
122         boost::shared_ptr<AutomationLine> _line;
123         /** AutomationStreamView if we are editing region-based automation (for MIDI), otherwise 0 */
124         AutomationStreamView* _view;
125
126         std::string _name;
127         bool    ignore_toggle;
128
129         bool    first_call_to_set_height;
130
131         Gtk::Button        hide_button;
132         Gtk::Button        auto_button;
133         Gtk::Menu*         automation_menu;
134         Gtk::Label*        plugname;
135         bool               plugname_packed;
136
137         Gtk::CheckMenuItem*     auto_off_item;
138         Gtk::CheckMenuItem*     auto_play_item;
139         Gtk::CheckMenuItem*     auto_touch_item;
140         Gtk::CheckMenuItem*     auto_write_item;
141
142         Gtk::CheckMenuItem* mode_discrete_item;
143         Gtk::CheckMenuItem* mode_line_item;
144
145         void add_line (boost::shared_ptr<AutomationLine>);
146
147         void clear_clicked ();
148         void hide_clicked ();
149         void auto_clicked ();
150
151         void build_display_menu ();
152
153         void cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
154         void cut_copy_clear_objects_one (AutomationLine&, PointSelection&, Editing::CutCopyOp);
155         bool paste_one (AutomationLine&, ARDOUR::framepos_t, float times, Selection&, size_t nth);
156         void reset_objects_one (AutomationLine&, PointSelection&);
157
158         void set_automation_state (ARDOUR::AutoState);
159         bool ignore_state_request;
160
161         void automation_state_changed ();
162
163         void set_interpolation (ARDOUR::AutomationList::InterpolationStyle);
164         void interpolation_changed (ARDOUR::AutomationList::InterpolationStyle);
165
166         PBD::ScopedConnectionList _list_connections;
167
168         void update_extra_xml_shown (bool editor_shown);
169
170         void entered ();
171         void exited ();
172
173         //void set_colors ();
174         void color_handler ();
175
176         static Pango::FontDescription* name_font;
177         static bool have_name_font;
178 };
179
180 #endif /* __ardour_gtk_automation_time_axis_h__ */