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_event.h>
46 class AutomationTimeAxisView
;
59 ControlPoint (AutomationLine
& al
);
60 ControlPoint (const ControlPoint
&, bool dummy_arg_to_force_special_copy_constructor
);
61 virtual ~ControlPoint ();
69 void move_to (double x
, double y
, ShapeType
);
70 void reset (double x
, double y
, ARDOUR::AutomationList::iterator
, uint32_t, ShapeType
);
71 double get_x() const { return _x
; }
72 double get_y() const { return _y
; }
76 void show_color (bool entered
, bool hide_too
);
78 void set_size (double);
79 void set_visible (bool);
81 ArdourCanvas::SimpleRect
* item
;
84 ARDOUR::AutomationList::iterator model
;
89 virtual bool event_handler (GdkEvent
*);
98 class AutomationLine
: public sigc::trackable
, public PBD::StatefulThingWithGoingAway
101 AutomationLine (const string
& name
, TimeAxisView
&, ArdourCanvas::Group
&, ARDOUR::AutomationList
&);
102 virtual ~AutomationLine ();
108 void set_selected_points (PointSelection
&);
109 void get_selectables (nframes_t
& start
, nframes_t
& end
,
110 double botfrac
, double topfrac
,
111 list
<Selectable
*>& results
);
112 void get_inverted_selectables (Selection
&, list
<Selectable
*>& results
);
114 virtual void remove_point (ControlPoint
&);
115 bool control_points_adjacent (double xval
, uint32_t& before
, uint32_t& after
);
119 virtual void start_drag (ControlPoint
*, nframes_t x
, float fraction
);
120 virtual void point_drag(ControlPoint
&, nframes_t x
, float, bool with_push
);
121 virtual void end_drag (ControlPoint
*);
122 virtual void line_drag(uint32_t i1
, uint32_t i2
, float, bool with_push
);
124 ControlPoint
* nth (uint32_t);
125 uint32_t npoints() const { return control_points
.size(); }
127 string
name() const { return _name
; }
128 bool visible() const { return _visible
; }
129 guint32
height() const { return _height
; }
131 void set_line_color (uint32_t);
132 uint32_t get_line_color() const { return _line_color
; }
136 void set_height (guint32
);
137 void set_verbose_cursor_uses_gain_mapping (bool yn
);
139 TimeAxisView
& trackview
;
141 ArdourCanvas::Group
& canvas_group() const { return *group
; }
142 ArdourCanvas::Item
& parent_group() const { return _parent_group
; }
143 ArdourCanvas::Item
& grab_item() const { return *line
; }
145 void show_selection();
146 void hide_selection ();
148 virtual string
get_verbose_cursor_string (float);
149 virtual void view_to_model_y (double&) = 0;
150 virtual void model_to_view_y (double&) = 0;
152 ARDOUR::AutomationList
& the_list() const { return alist
; }
154 void show_all_control_points ();
155 void hide_all_but_selected_control_points ();
157 bool is_last_point (ControlPoint
&);
158 bool is_first_point (ControlPoint
&);
160 XMLNode
& get_state (void);
161 int set_state (const XMLNode
&);
168 uint32_t _line_color
;
169 ARDOUR::AutomationList
& alist
;
172 bool _vc_uses_gain_mapping
: 1;
173 bool terminal_points_can_slide
: 1;
174 bool update_pending
: 1;
175 bool auto_is_boolean
: 1;
176 bool points_visible
: 1;
179 ArdourCanvas::Group
& _parent_group
;
180 ArdourCanvas::Group
* group
;
181 ArdourCanvas::Line
* line
; /* line */
182 ArdourCanvas::Points line_points
; /* coordinates for canvas line */
183 vector
<ControlPoint
*> control_points
; /* visible control points */
188 ALPoint (double xx
, double yy
) : x(xx
), y(yy
) {}
191 typedef std::vector
<ALPoint
> ALPoints
;
193 static void invalidate_point (ALPoints
&, uint32_t index
);
194 static bool invalid_point (ALPoints
&, uint32_t index
);
196 void determine_visible_control_points (ALPoints
&);
197 void sync_model_with_view_point (ControlPoint
&, bool did_push
, int64_t distance
);
198 void sync_model_with_view_line (uint32_t, uint32_t);
200 virtual void change_model (ARDOUR::AutomationList::iterator
, double x
, double y
);
201 virtual void change_model_range (ARDOUR::AutomationList::iterator
,ARDOUR::AutomationList::iterator
, double delta
, float ydelta
);
203 void reset_callback (const ARDOUR::AutomationList
&);
204 void list_changed ();
206 virtual bool event_handler (GdkEvent
*);
207 virtual void add_model_point (ALPoints
& tmp_points
, double frame
, double yfract
);
211 double first_drag_fraction
;
212 double last_drag_fraction
;
213 uint32_t line_drag_cp1
;
214 uint32_t line_drag_cp2
;
216 int64_t drag_distance
;
218 void modify_view_point(ControlPoint
&, double, double, bool with_push
);
219 void reset_line_coords (ControlPoint
&);
221 double control_point_box_size ();
223 struct ModelRepresentation
{
224 ARDOUR::AutomationList::iterator start
;
225 ARDOUR::AutomationList::iterator end
;
236 void model_representation (ControlPoint
&, ModelRepresentation
&);
238 friend class AudioRegionGainLine
;
242 #endif /* __ardour_automation_line_h__ */