2 Copyright (C) 2002 Paul Davis
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.
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.
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.
21 #ifndef __ardour_automation_line_h__
22 #define __ardour_automation_line_h__
27 #include <sys/types.h>
30 #include <libgnomecanvasmm/libgnomecanvasmm.h>
31 #include <sigc++/signal.h>
35 #include <ardour/automation_event.h>
45 class AutomationTimeAxisView;
58 ControlPoint (AutomationLine& al);
59 ControlPoint (const ControlPoint&, bool dummy_arg_to_force_special_copy_constructor);
60 virtual ~ControlPoint ();
68 void move_to (double x, double y, ShapeType);
69 void reset (double x, double y, ARDOUR::AutomationList::iterator, uint32_t, ShapeType);
70 double get_x() const { return _x; }
71 double get_y() const { return _y; }
75 void show_color (bool entered, bool hide_too);
77 void set_size (double);
78 void set_visible (bool);
80 Gnome::Canvas::SimpleRect* item;
83 ARDOUR::AutomationList::iterator model;
88 virtual bool event_handler (GdkEvent*);
97 class AutomationLine : public sigc::trackable
100 AutomationLine (string name, TimeAxisView&, Gnome::Canvas::Group&, ARDOUR::AutomationList&);
101 virtual ~AutomationLine ();
107 void set_selected_points (PointSelection&);
108 void get_selectables (jack_nframes_t& start, jack_nframes_t& end,
109 double botfrac, double topfrac,
110 list<Selectable*>& results);
111 void get_inverted_selectables (Selection&, list<Selectable*>& results);
113 virtual void remove_point (ControlPoint&);
114 bool control_points_adjacent (double xval, uint32_t& before, uint32_t& after);
118 virtual void start_drag (ControlPoint*, float fraction);
119 virtual void point_drag(ControlPoint&, jack_nframes_t x, float, bool with_push);
120 virtual void end_drag (ControlPoint*);
121 virtual void line_drag(uint32_t i1, uint32_t i2, float, bool with_push);
123 ControlPoint* nth (uint32_t);
124 uint32_t npoints() const { return control_points.size(); }
126 string name() const { return _name; }
127 bool visible() const { return _visible; }
128 guint32 height() const { return _height; }
130 void set_line_color (uint32_t);
131 uint32_t get_line_color() const { return _line_color; }
135 void set_height (guint32);
136 void set_verbose_cursor_uses_gain_mapping (bool yn);
138 TimeAxisView& trackview;
140 Gnome::Canvas::Group& canvas_group() const { return *group; }
141 Gnome::Canvas::Item& parent_group() const { return _parent_group; }
142 Gnome::Canvas::Item& grab_item() const { return *line; }
144 void show_selection();
145 void hide_selection ();
147 void set_point_size (double size);
149 virtual string get_verbose_cursor_string (float);
150 virtual void view_to_model_y (double&) = 0;
151 virtual void model_to_view_y (double&) = 0;
153 ARDOUR::AutomationList& the_list() const { return alist; }
155 void show_all_control_points ();
156 void hide_all_but_selected_control_points ();
158 bool is_last_point (ControlPoint &);
159 bool is_first_point (ControlPoint &);
164 uint32_t _line_color;
165 ARDOUR::AutomationList& alist;
168 bool _vc_uses_gain_mapping : 1;
169 bool terminal_points_can_slide : 1;
170 bool update_pending : 1;
172 bool points_visible : 1;
174 Gnome::Canvas::Group& _parent_group;
175 Gnome::Canvas::Group* group;
176 Gnome::Canvas::Line* line; /* line */
177 Gnome::Canvas::Points line_points; /* coordinates for canvas line */
178 vector<ControlPoint*> control_points; /* visible control points */
183 ALPoint (double xx, double yy) : x(xx), y(yy) {}
186 typedef std::vector<ALPoint> ALPoints;
188 static void invalidate_point (ALPoints&, uint32_t index);
189 static bool invalid_point (ALPoints&, uint32_t index);
191 void determine_visible_control_points (ALPoints&);
192 void sync_model_from (ControlPoint&);
193 void sync_model_with_view_point (ControlPoint&);
194 void sync_model_with_view_line (uint32_t, uint32_t);
195 void modify_view (ControlPoint&, double, double, bool with_push);
197 virtual void change_model (ARDOUR::AutomationList::iterator, double x, double y);
198 virtual void change_model_range (ARDOUR::AutomationList::iterator,ARDOUR::AutomationList::iterator, double delta, float ydelta);
200 void reset_callback (const ARDOUR::AutomationList&);
201 void list_changed (ARDOUR::Change);
203 UndoAction get_memento();
205 virtual bool event_handler (GdkEvent*);
209 double first_drag_fraction;
210 double last_drag_fraction;
211 uint32_t line_drag_cp1;
212 uint32_t line_drag_cp2;
214 void modify_view_point(ControlPoint&, double, double, bool with_push);
215 void reset_line_coords (ControlPoint&);
218 struct ModelRepresentation {
219 ARDOUR::AutomationList::iterator start;
220 ARDOUR::AutomationList::iterator end;
231 void model_representation (ControlPoint&, ModelRepresentation&);
233 friend class AudioRegionGainLine;
236 #endif /* __ardour_automation_line_h__ */