26 #define isnan_local(val) (bool)_isnan((double)val)
28 #define isnan_local std::isnan
35 #include "boost/shared_ptr.hpp"
44 #include "ardour/debug.h"
50 #include "canvas/debug.h"
79 ArdourCanvas::Item& parent,
86 , _time_converter (converter ? converter : new
Evoral::IdentityConverter<double,
framepos_t>)
87 , _parent_group (parent)
108 group =
new ArdourCanvas::Container (&parent, ArdourCanvas::Duple(0, 1.5));
109 CANVAS_DEBUG_NAME (
group,
"region gain envelope group");
111 line =
new ArdourCanvas::PolyLine (
group);
112 CANVAS_DEBUG_NAME (
line,
"region gain envelope line");
113 line->set_data (
"line",
this);
114 line->set_outline_width (2.0);
115 line->set_covers_threshold (4.0);
124 desc.
unit == ParameterDescriptor::DB) {
176 if ((*i)->get_selected()) {
231 (*i)->set_size (bsz);
242 line->set_outline_color (color);
327 for (list<ControlPoint*>::iterator i = cp.begin(); i != cp.end(); ++i) {
380 if (fraction == 0.0) {
381 snprintf (buf,
sizeof (buf),
"-inf");
388 snprintf (buf,
sizeof (buf),
"%.1f", lower_db + fraction * range_db);
409 if (original == fraction) {
414 if (original == 0.0) {
419 }
else if (fraction == 0.0) {
420 snprintf (buf,
sizeof (buf),
"-inf");
424 snprintf (buf,
sizeof (buf),
"%.1f", new_db - old_db);
447 sscanf (s.c_str(),
"%lf", &v);
501 for (uint32_t i = i1; i <= i2; i++) {
534 : line (al), before_x (0), after_x (DBL_MAX)
541 uint32_t sz = size();
543 if (sz > 0 && sz <
line.npoints()) {
550 if (front()->view_index() > 0) {
551 before_x =
line.nth (front()->view_index() - 1)->get_x();
554 const Meter& meter = map.meter_at (pos);
559 before_x += one_tick_in_pixels;
566 if (back()->view_index() < (
line.npoints() - 1)) {
567 after_x =
line.nth (back()->view_index() + 1)->get_x();
570 const Meter& meter = map.meter_at (pos);
575 after_x -= one_tick_in_pixels;
601 tx = cp->
get_x() + dx;
602 tx = max (tx, before_x);
603 tx = min (tx, after_x);
604 return tx - cp->
get_x ();
610 for (std::list<ControlPoint*>::iterator i = begin(); i != end(); ++i) {
612 line.reset_line_coords (**i);
644 return pair<double,float> (x,fraction);
647 double dx = ignore_x ? 0 : (x -
_drag_x);
662 uint32_t expected_view_index = 0;
666 if (i ==
_drag_points.begin() || (*i)->view_index() != expected_view_index) {
670 contig->push_back (*i);
671 expected_view_index = (*i)->view_index() + 1;
691 if (dx < 0 || ((dx > 0) && !with_push)) {
693 double dxt = (*ccp)->clamp_dx (dx);
694 if (fabs (dxt) < fabs (dx)) {
717 (*ccp)->move (dx, dy);
722 uint32_t i = final_index;
740 _last_drag_fraction = fraction;
744 return pair<double, float> (
_drag_x + dx, _last_drag_fraction + dy);
760 uint32_t i = final_index;
794 double view_x = cp.
get_x();
815 if (point_y != cp.
get_y()) {
835 if ((*i)->get_x() <= unit_xval) {
842 }
else if ((*i)->get_x() > unit_xval) {
861 AutomationList::const_iterator i =
alist->
end();
864 if (cp.
model() == i) {
914 double const model_when = (*(*i)->model())->when;
922 if (session_frames_when >= start && session_frames_when <= end && (*i)->get_y() >= bot_track && (*i)->get_y() <= top_track) {
923 results.push_back (*i);
938 (*i)->set_selected (
false);
941 for (PointSelection::const_iterator i = points.begin(); i != points.end(); ++i) {
942 (*i)->set_selected (
true);
945 if (points.empty()) {
980 if (events.
empty()) {
1000 for (AutomationList::iterator ai = e.
begin(); ai != e.
end(); ++ai, ++pi) {
1002 double tx = (*ai)->when;
1003 double ty = (*ai)->value;
1052 line_points.push_back (ArdourCanvas::Duple (0,0));
1059 for (uint32_t n = 0; n < vp; ++n) {
1097 Glib::signal_timeout().connect (sigc::bind_return (sigc::mem_fun (*
this, &
AutomationLine::reset),
false), 250);
1221 y = (y > 0.5) ? 1.0 : 0.0;
1267 AutomationList::iterator model, uint32_t
npoints)
1289 }
else if (pi == npoints - 1) {
1301 control_points[view_index]->reset (tx, ty, model, view_index, shape);
1345 pair<framepos_t, framepos_t>
1350 for (AutomationList::const_iterator i =
the_list()->begin(); i !=
the_list()->
end(); ++i) {
void interpolation_changed(ARDOUR::AutomationList::InterpolationStyle)
std::vector< CCP > contiguous_points
bool transport_rolling() const
bool control_points_adjacent(double xval, uint32_t &before, uint32_t &after)
virtual bool canvas_line_event(GdkEvent *event, ArdourCanvas::Item *, AutomationLine *)=0
ControlPoint * nth(uint32_t)
void modify_point_y(ControlPoint &, double)
virtual A from(B b) const =0
float lower
Minimum value (in Hz, for frequencies)
PublicEditor & editor() const
PBD::ScopedConnectionList _list_connections
double _last_drag_fraction
last y position of the drag, as a fraction
void add_visibility(VisibleAspects)
virtual void start_drag_single(ControlPoint *, double, float)
std::pair< ARDOUR::framepos_t, ARDOUR::framepos_t > get_point_x_range() const
virtual void end_drag(bool with_push, uint32_t final_index)
void view_to_model_coord(double &x, double &y) const
boost::shared_ptr< ARDOUR::AutomationList > the_list() const
LIBARDOUR_API double slider_position_to_gain_with_max(double g, double max_gain=2.0)
int set_state(const XMLNode &, int version)
std::string value_as_string(const ARDOUR::ParameterDescriptor &desc, double v)
Lists of selected things.
void model_to_view_coord_y(double &) const
void add_command(Command *const cmd)
Representation of the interface of the Editor class.
virtual B to(A a) const =0
std::vector< ControlPoint * > control_points
LIBPBD_API Transmitter warning
int set_state(const XMLNode &, int version)
void move(double dx, double dy)
void set_uses_gain_mapping(bool yn)
std::ostream & endmsg(std::ostream &ostr)
void add_visible_control_point(uint32_t, uint32_t, double, double, ARDOUR::AutomationList::iterator, uint32_t)
void start_drag_common(double, float)
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
uint32_t current_height() const
uint32_t view_index() const
framecnt_t frame_rate() const
void move_to(double x, double y, ShapeType)
static bool floateq(float a, float b, int max_ulps_diff)
std::string fraction_to_relative_string(double, double) const
std::string get_verbose_cursor_relative_string(double, double) const
static float accurate_coefficient_to_dB(float coeff)
double control_point_box_size()
bool sync_model_with_view_points(std::list< ControlPoint * >)
const ARDOUR::ParameterDescriptor _desc
ArdourCanvas::PolyLine * line
LIBARDOUR_API uint64_t Automation
void modify(iterator, double, double)
virtual void remove_point(ControlPoint &)
bool _drag_had_movement
true if the drag has seen movement, otherwise false
LIBARDOUR_API RCConfiguration * Config
void set_offset(ARDOUR::framecnt_t)
float upper
Maximum value (in Hz, for frequencies)
bool sync_model_with_view_point(ControlPoint &)
virtual std::string get_verbose_cursor_string(double) const
XMLNode & get_state(void)
ArdourCanvas::Container * group
const PBD::ID & id() const
ARDOUR::Session * session() const
virtual std::pair< double, float > drag_motion(double, float, bool, bool with_push, uint32_t &final_index)
virtual void begin_reversible_command(std::string cmd_name)=0
framepos_t session_position(ARDOUR::AutomationList::const_iterator) const
virtual void commit_reversible_command()=0
#define DEBUG_TRACE(bits, str)
virtual ~AutomationLine()
virtual Selection & get_selection() const =0
Evoral::TimeConverter< double, ARDOUR::framepos_t > * _time_converter
bool automation_write() const
ARDOUR::framecnt_t _offset
void apply_to_points(T &obj, void(T::*method)(const ControlList &))
void view_to_model_coord_y(double &) const
bool get_selected() const
EventList::size_type size() const
double clamp_dx(double dx)
PBD::Signal1< void, InterpolationStyle > InterpolationChanged
const Parameter & parameter() const
void call_slot(EventLoop::InvalidationRecord *, const boost::function< void()> &)
virtual void start_drag_multiple(std::list< ControlPoint * >, float, XMLNode *)
double _drag_distance
total x movement of the drag, in canvas units
bool is_last_point(ControlPoint &)
static PublicEditor & instance()
double _drag_x
last x position of the drag, in units
std::string fraction_to_string(double) const
PBD::Signal0< void > StateChanged
LIBARDOUR_API double gain_to_slider_position_with_max(double g, double max_gain=2.0)
InterpolationStyle interpolation() const
boost::shared_ptr< ARDOUR::AutomationList > alist
void model_to_view_coord(double &x, double &y) const
void reset_callback(const Evoral::ControlList &)
bool is_first_point(ControlPoint &)
AutomationLine(const std::string &name, TimeAxisView &tv, ArdourCanvas::Item &parent, boost::shared_ptr< ARDOUR::AutomationList > al, const ARDOUR::ParameterDescriptor &desc, Evoral::TimeConverter< double, ARDOUR::framepos_t > *converter=0)
virtual MementoCommandBinder< ARDOUR::AutomationList > * memento_command_binder()
bool toggled
True iff parameter is boolean.
void get_selectables(ARDOUR::framepos_t, ARDOUR::framepos_t, double, double, std::list< Selectable * > &)
static UIConfiguration * config()
ARDOUR::AutomationList::iterator model() const
double divisions_per_bar() const
void set_maximum_time(ARDOUR::framecnt_t)
virtual framepos_t pixel_to_sample(double pixel) const =0
bool operator()(ControlPoint const *a, ControlPoint const *b) const
void get_inverted_selectables(Selection &, std::list< Selectable * > &results)
static float dB_to_coefficient(float dB)
void set_line_color(uint32_t)
static const framepos_t max_framepos
double frames_per_bar(const Tempo &, framecnt_t sr) const
static uint32_t preset_height(Height)
virtual bool event_handler(GdkEvent *)
ARDOUR::framecnt_t _maximum_time
virtual double sample_to_pixel_unrounded(framepos_t frame) const =0
ContiguousControlPoints(AutomationLine &al)
double string_to_fraction(std::string const &) const
bool terminal_points_can_slide
void set_list(boost::shared_ptr< ARDOUR::AutomationList > list)
void remove_visibility(VisibleAspects)
ArdourCanvas::Points line_points
void register_with_memento_command_factory(PBD::ID, PBD::StatefulDestructible *)
void reset_line_coords(ControlPoint &)
std::string string_compose(const std::string &fmt, const T1 &o1)
virtual void start_drag_line(uint32_t, uint32_t, float)
void set_visibility(VisibleAspects)
void compute_x_bounds(PublicEditor &e)
void set_selected_points(PointSelection const &)
std::list< ControlPoint * > _drag_points
points we are dragging
virtual ARDOUR::Session * session() const =0
LIBARDOUR_API PBD::PropertyDescriptor< bool > color