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.
20 #ifndef __ardour_automation_line_h__
21 #define __ardour_automation_line_h__
26 #include <sys/types.h>
28 #include <libgnomecanvasmm/line.h>
29 #include <sigc++/signal.h>
31 #include "simplerect.h"
34 #include <pbd/statefuldestructible.h>
36 #include <ardour/automation_list.h>
43 class AutomationTimeAxisView;
53 class AutomationLine : public sigc::trackable, public PBD::StatefulThingWithGoingAway
56 AutomationLine (const string & name, TimeAxisView&, ArdourCanvas::Group&, boost::shared_ptr<ARDOUR::AutomationList>);
57 virtual ~AutomationLine ();
63 void set_selected_points (PointSelection&);
64 void get_selectables (nframes_t& start, nframes_t& end,
65 double botfrac, double topfrac,
66 std::list<Selectable*>& results);
67 void get_inverted_selectables (Selection&, std::list<Selectable*>& results);
69 virtual void remove_point (ControlPoint&);
70 bool control_points_adjacent (double xval, uint32_t& before, uint32_t& after);
74 virtual void start_drag (ControlPoint*, nframes_t x, float fraction);
75 virtual void point_drag(ControlPoint&, nframes_t x, float, bool with_push);
76 virtual void end_drag (ControlPoint*);
77 virtual void line_drag(uint32_t i1, uint32_t i2, float, bool with_push);
79 ControlPoint* nth (uint32_t);
80 uint32_t npoints() const { return control_points.size(); }
82 string name() const { return _name; }
83 bool visible() const { return _visible; }
84 guint32 height() const { return _height; }
86 void set_line_color (uint32_t);
87 uint32_t get_line_color() const { return _line_color; }
89 void set_interpolation(ARDOUR::AutomationList::InterpolationStyle style);
93 void set_height (guint32);
94 void set_uses_gain_mapping (bool yn);
95 bool get_uses_gain_mapping () const { return _uses_gain_mapping; }
97 TimeAxisView& trackview;
99 ArdourCanvas::Group& canvas_group() const { return *group; }
100 ArdourCanvas::Item& parent_group() const { return _parent_group; }
101 ArdourCanvas::Item& grab_item() const { return *line; }
103 void show_selection();
104 void hide_selection ();
106 string get_verbose_cursor_string (double) const;
107 string fraction_to_string (double) const;
108 double string_to_fraction (string const &) const;
109 void view_to_model_y (double&) const;
110 void model_to_view_y (double&) const;
112 void set_list(boost::shared_ptr<ARDOUR::AutomationList> list);
113 boost::shared_ptr<ARDOUR::AutomationList> the_list() const { return alist; }
115 void show_all_control_points ();
116 void hide_all_but_selected_control_points ();
118 void track_entered();
121 bool is_last_point (ControlPoint &);
122 bool is_first_point (ControlPoint &);
124 XMLNode& get_state (void);
125 int set_state (const XMLNode&);
128 void modify_point_y (ControlPoint&, double);
134 uint32_t _line_color;
135 boost::shared_ptr<ARDOUR::AutomationList> alist;
138 bool _uses_gain_mapping : 1;
139 bool terminal_points_can_slide : 1;
140 bool update_pending : 1;
142 bool points_visible : 1;
145 ArdourCanvas::Group& _parent_group;
146 ArdourCanvas::Group* group;
147 ArdourCanvas::Line* line; /* line */
148 ArdourCanvas::Points line_points; /* coordinates for canvas line */
149 std::vector<ControlPoint*> control_points; /* visible control points */
154 ALPoint (double xx, double yy) : x(xx), y(yy) {}
157 typedef std::vector<ALPoint> ALPoints;
159 static void invalidate_point (ALPoints&, uint32_t index);
160 static bool invalid_point (ALPoints&, uint32_t index);
162 void determine_visible_control_points (ALPoints&);
163 void sync_model_with_view_point (ControlPoint&, bool did_push, int64_t distance);
164 void sync_model_with_view_line (uint32_t, uint32_t);
166 virtual void change_model (ARDOUR::AutomationList::iterator, double x, double y);
168 void reset_callback (const Evoral::ControlList&);
169 void list_changed ();
171 virtual bool event_handler (GdkEvent*);
172 virtual void add_model_point (ALPoints& tmp_points, double frame, double yfract);
176 double first_drag_fraction;
177 double last_drag_fraction;
178 uint32_t line_drag_cp1;
179 uint32_t line_drag_cp2;
181 int64_t drag_distance;
183 ARDOUR::AutomationList::InterpolationStyle _interpolation;
185 void modify_view_point (ControlPoint&, double, double, bool with_push);
186 void reset_line_coords (ControlPoint&);
188 double control_point_box_size ();
190 struct ModelRepresentation {
191 ARDOUR::AutomationList::iterator start;
192 ARDOUR::AutomationList::iterator end;
203 void model_representation (ControlPoint&, ModelRepresentation&);
205 friend class AudioRegionGainLine;
208 #endif /* __ardour_automation_line_h__ */