Ardour  9.0-pre0-350-gf17a656217
automation_line.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
4  * Copyright (C) 2005 Nick Mainsbridge <mainsbridge@gmail.com>
5  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
6  * Copyright (C) 2006 Hans Fugal <hans@fugal.net>
7  * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
8  * Copyright (C) 2007-2015 David Robillard <d@drobilla.net>
9  * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #ifndef __gtk2_ardour_automation_line_base_h__
27 #define __gtk2_ardour_automation_line_base_h__
28 
29 #include <vector>
30 #include <list>
31 #include <string>
32 #include <sys/types.h>
33 
34 #include <sigc++/signal.h>
35 
36 #include "pbd/undo.h"
38 #include "pbd/memento_command.h"
39 
40 #include "ardour/automation_list.h"
42 #include "ardour/types.h"
43 
44 #include "canvas/types.h"
45 #include "canvas/container.h"
46 #include "canvas/poly_line.h"
47 
48 #include "selectable.h"
49 
50 namespace ArdourCanvas {
51  class Rectangle;
52 }
53 
55 class ControlPoint;
56 class PointSelection;
57 class TimeAxisView;
59 class Selection;
60 class EditingContext;
61 
63 class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible, public SelectableOwner
64 {
65 public:
67  Line = 0x1,
70  };
71 
72  AutomationLine (const std::string& name,
73  EditingContext& ec,
74  ArdourCanvas::Item& parent,
76  std::shared_ptr<ARDOUR::AutomationList> al,
77  const ARDOUR::ParameterDescriptor& desc);
78 
79  virtual ~AutomationLine ();
80 
81  virtual Temporal::timepos_t get_origin () const;
82 
84 
85  void queue_reset ();
86  void reset ();
87  void clear ();
88  void set_fill (bool f) { _fill = f; } // owner needs to call set_height
89 
91  void _get_selectables (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<Selectable*>&, bool within);
92  void get_inverted_selectables (Selection&, std::list<Selectable*>& results);
93 
94  virtual void remove_point (ControlPoint&);
95  bool control_points_adjacent (double xval, uint32_t& before, uint32_t& after);
96 
97  /* dragging API */
98  virtual void start_drag_single (ControlPoint*, double, float);
99  virtual void start_drag_line (uint32_t, uint32_t, float);
100  virtual void start_drag_multiple (std::list<ControlPoint*>, float, XMLNode *);
101  virtual std::pair<float, float> drag_motion (Temporal::timecnt_t const &, float, bool, bool with_push, uint32_t& final_index);
102  virtual void end_drag (bool with_push, uint32_t final_index);
103  virtual void end_draw_merge () {}
104 
105  ControlPoint* nth (uint32_t);
106  ControlPoint const * nth (uint32_t) const;
107  uint32_t npoints() const { return control_points.size(); }
108 
109  std::string name() const { return _name; }
110  bool visible() const { return _visible != VisibleAspects(0); }
111  guint32 height() const { return _height; }
112 
113  void set_line_color (std::string color, std::string mod = "");
114  uint32_t get_line_color() const;
115 
119 
120  void hide ();
121  void set_height (guint32);
122 
123  bool get_uses_gain_mapping () const;
125 
128  ArdourCanvas::Item& grab_item() const { return *line; }
129 
130  virtual std::string get_verbose_cursor_string (double) const;
131  std::string get_verbose_cursor_relative_string (double, double) const;
132  std::string fraction_to_string (double) const;
133  std::string delta_to_string (double) const;
134  double string_to_fraction (std::string const &) const;
135 
136  void view_to_model_coord_y (double &) const;
137 
138  double model_to_view_coord_y (double) const;
140 
141  double compute_delta (double from, double to) const;
142  void apply_delta (double& val, double delta) const;
143 
144  void set_list(std::shared_ptr<ARDOUR::AutomationList> list);
145  std::shared_ptr<ARDOUR::AutomationList> the_list() const { return alist; }
146 
148  void track_exited();
149 
152 
153  XMLNode& get_state () const;
154  int set_state (const XMLNode&, int version);
155  void set_colors();
156 
157  void modify_points_y (std::vector<ControlPoint*> const&, double);
158 
160 
161  std::pair<Temporal::timepos_t, Temporal::timepos_t> get_point_x_range () const;
162 
165  return _maximum_time;
166  }
167 
171 
173  void dump (std::ostream&) const;
174 
176 
177  ARDOUR::ParameterDescriptor const & param() const { return _desc; }
179 
180  void add (std::shared_ptr<ARDOUR::AutomationControl>, GdkEvent*, Temporal::timepos_t const &, double y, bool with_guard_points);
181 
182 protected:
183 
184  std::string _name;
185  guint32 _height;
186  std::string _line_color;
187  std::string _line_color_mod;
189  std::shared_ptr<ARDOUR::AutomationList> alist;
190 
192 
196  bool no_draw;
199  bool did_push;
200 
206  ArdourCanvas::Points line_points; /* coordinates for canvas line */
207  std::vector<ControlPoint*> control_points; /* visible control points */
208 
209  class ContiguousControlPoints : public std::list<ControlPoint*> {
210  public:
213  void move (Temporal::timecnt_t const &, double dvalue);
215  private:
219  };
220 
222 
223  typedef std::shared_ptr<ContiguousControlPoints> CCP;
224  std::vector<CCP> contiguous_points;
225 
227  bool sync_model_with_view_points (std::list<ControlPoint*>);
228  void start_drag_common (double, float);
229 
231  void list_changed ();
232 
233  virtual bool event_handler (GdkEvent*) = 0;
234 
235 private:
236  std::list<ControlPoint*> _drag_points;
237  std::list<ControlPoint*> _push_points;
244 
245  bool is_stepped() const;
248  void add_visible_control_point (uint32_t, uint32_t, double, double, ARDOUR::AutomationList::iterator, uint32_t);
252 
254 
257 
258  bool _fill;
259 
261 
262  friend class AudioRegionGainLine;
263  friend class RegionFxLine;
264 };
265 
266 #endif /* __gtk2_ardour_automation_line_base_h__ */
267 
void move(Temporal::timecnt_t const &, double dvalue)
ContiguousControlPoints(AutomationLine &al)
Temporal::timecnt_t clamp_dt(Temporal::timecnt_t const &dx, Temporal::timepos_t const &region_limit)
virtual MementoCommandBinder< ARDOUR::AutomationList > * memento_command_binder()
guint32 height() const
void start_drag_common(double, float)
ArdourCanvas::Rectangle * drag_base() const
std::string delta_to_string(double) const
std::list< ControlPoint * > _drag_points
points we are dragging
void track_exited()
virtual void end_drag(bool with_push, uint32_t final_index)
bool sync_model_with_view_points(std::list< ControlPoint * >)
void reset_callback(const Evoral::ControlList &)
void add_visible_control_point(uint32_t, uint32_t, double, double, ARDOUR::AutomationList::iterator, uint32_t)
void set_width(Temporal::timecnt_t const &)
void set_list(std::shared_ptr< ARDOUR::AutomationList > list)
AutomationLine(const std::string &name, EditingContext &ec, ArdourCanvas::Item &parent, ArdourCanvas::Rectangle *drag_base, std::shared_ptr< ARDOUR::AutomationList > al, const ARDOUR::ParameterDescriptor &desc)
bool get_uses_gain_mapping() const
virtual ~AutomationLine()
void set_line_color(std::string color, std::string mod="")
int set_state(const XMLNode &, int version)
EditingContext & editing_context() const
double model_to_view_coord_y(double) const
ArdourCanvas::Points line_points
std::string fraction_to_string(double) const
bool visible() const
std::string name() const
double _last_drag_fraction
last y position of the drag, as a fraction
void remove_visibility(VisibleAspects)
bool sync_model_with_view_point(ControlPoint &)
ArdourCanvas::Item & grab_item() const
bool is_first_point(ControlPoint &)
virtual void start_drag_single(ControlPoint *, double, float)
void track_entered()
double compute_delta(double from, double to) const
void get_inverted_selectables(Selection &, std::list< Selectable * > &results)
virtual void start_drag_multiple(std::list< ControlPoint * >, float, XMLNode *)
const ARDOUR::ParameterDescriptor _desc
VisibleAspects _visible
virtual bool event_handler(GdkEvent *)=0
void connect_to_list()
std::shared_ptr< ARDOUR::AutomationList > the_list() const
void dump(std::ostream &) const
std::pair< Temporal::timepos_t, Temporal::timepos_t > get_point_x_range() const
ArdourCanvas::PolyLine * line
virtual Temporal::timepos_t get_origin() const
std::vector< CCP > contiguous_points
void set_visibility(VisibleAspects)
void modify_points_y(std::vector< ControlPoint * > const &, double)
void add_visibility(VisibleAspects)
bool is_stepped() const
void set_maximum_time(Temporal::timepos_t const &)
double string_to_fraction(std::string const &) const
void list_changed()
Temporal::timepos_t session_position(Temporal::timepos_t const &) const
Temporal::timepos_t maximum_time() const
Temporal::timecnt_t model_to_view_coord_x(Temporal::timepos_t const &) const
bool _drag_had_movement
true if the drag has seen movement, otherwise false
void queue_reset()
void set_selected_points(PointSelection const &)
ArdourCanvas::Item & _parent_group
virtual std::pair< float, float > drag_motion(Temporal::timecnt_t const &, float, bool, bool with_push, uint32_t &final_index)
virtual void end_draw_merge()
ArdourCanvas::Container & canvas_group() const
void set_height(guint32)
std::list< ControlPoint * > _push_points
additional points we are dragging if "push" is enabled
Temporal::timepos_t offset()
std::string get_verbose_cursor_relative_string(double, double) const
ArdourCanvas::Container * group
void set_fill(bool f)
void update_visibility()
double control_point_box_size()
virtual void remove_point(ControlPoint &)
ArdourCanvas::Item & parent_group() const
std::shared_ptr< ContiguousControlPoints > CCP
std::string _name
std::shared_ptr< ARDOUR::AutomationList > alist
virtual void start_drag_line(uint32_t, uint32_t, float)
Temporal::timepos_t _offset
void reset_line_coords(ControlPoint &)
ControlPoint const * nth(uint32_t) const
double dt_to_dx(Temporal::timepos_t const &, Temporal::timecnt_t const &)
void view_to_model_coord_y(double &) const
void _get_selectables(Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list< Selectable * > &, bool within)
EditingContext & _editing_context
void interpolation_changed(ARDOUR::AutomationList::InterpolationStyle)
void add(std::shared_ptr< ARDOUR::AutomationControl >, GdkEvent *, Temporal::timepos_t const &, double y, bool with_guard_points)
std::vector< ControlPoint * > control_points
void apply_delta(double &val, double delta) const
bool control_points_adjacent(double xval, uint32_t &before, uint32_t &after)
uint32_t npoints() const
XMLNode & get_state() const
bool is_last_point(ControlPoint &)
virtual std::string get_verbose_cursor_string(double) const
uint32_t get_line_color() const
PBD::ScopedConnectionList _list_connections
ArdourCanvas::Rectangle * _drag_base
void tempo_map_changed()
ControlPoint * nth(uint32_t)
std::string _line_color
Temporal::timepos_t _maximum_time
void set_offset(Temporal::timepos_t const &)
ARDOUR::ParameterDescriptor const & param() const
uint32_t _view_index_offset
std::string _line_color_mod
bool terminal_points_can_slide
EventList::iterator iterator
Definition: ControlList.h:93
Lists of selected things.
Definition: xml++.h:114
PBD::PropertyDescriptor< uint32_t > color
std::vector< Duple > Points