*/
+#ifdef COMPILER_MSVC
+#include <float.h>
+/* isinf() & isnan() are C99 standards, which older MSVC doesn't provide */
+#define isinf(val) !((bool)_finite((double)val))
+#define isnan(val) (bool)_isnan((double)val)
+#endif
+
#include <cmath>
#include <climits>
#include <vector>
#include "evoral/Curve.hpp"
-#include "simplerect.h"
+#include "canvas/debug.h"
+
#include "automation_line.h"
#include "control_point.h"
#include "gui_thread.h"
using namespace ARDOUR;
using namespace PBD;
using namespace Editing;
-using namespace Gnome; // for Canvas
/** @param converter A TimeConverter whose origin_b is the start time of the AutomationList in session frames.
* This will not be deleted by AutomationLine.
terminal_points_can_slide = true;
_height = 0;
- group = new ArdourCanvas::Group (parent);
- group->property_x() = 0.0;
- group->property_y() = 0.0;
+ group = new ArdourCanvas::Group (&parent);
+ CANVAS_DEBUG_NAME (group, "region gain envelope group");
- line = new ArdourCanvas::Line (*group);
- line->property_width_pixels() = (guint)1;
+ line = new ArdourCanvas::PolyLine (group);
+ CANVAS_DEBUG_NAME (line, "region gain envelope line");
line->set_data ("line", this);
+ line->set_outline_width (2.0);
- line->signal_event().connect (sigc::mem_fun (*this, &AutomationLine::event_handler));
+ line->Event.connect (sigc::mem_fun (*this, &AutomationLine::event_handler));
trackview.session()->register_with_memento_command_factory(alist->id(), this);
}
} else {
line->hide();
+ /* if the line is not visible, then no control points should be visible */
+ for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
+ (*i)->hide ();
+ }
+ return;
}
if (_visible & ControlPoints) {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
- (*i)->set_visible (true);
(*i)->show ();
}
} else if (_visible & SelectedControlPoints) {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
- (*i)->set_visible ((*i)->get_selected());
+ if ((*i)->get_selected()) {
+ (*i)->show ();
+ } else {
+ (*i)->hide ();
+ }
}
} else {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
- (*i)->set_visible (false);
+ (*i)->hide ();
}
}
}
void
AutomationLine::hide ()
{
- set_visibility (VisibleAspects (0));
+ /* leave control points setting unchanged, we are just hiding the
+ overall line
+ */
+
+ set_visibility (AutomationLine::VisibleAspects (_visible & ~Line));
}
double
AutomationLine::set_line_color (uint32_t color)
{
_line_color = color;
- line->property_fill_color_rgba() = color;
+ line->set_outline_color (color);
}
void
y = min (1.0, y);
y = _height - (y * _height);
- double const x = trackview.editor().frame_to_unit_unrounded (_time_converter->to((*cp.model())->when) - _offset);
+ double const x = trackview.editor().sample_to_pixel_unrounded (_time_converter->to((*cp.model())->when) - _offset);
trackview.editor().session()->begin_reversible_command (_("automation event move"));
trackview.editor().session()->add_command (
reset_line_coords (cp);
if (line_points.size() > 1) {
- line->property_points() = line_points;
+ line->set (line_points);
}
alist->freeze ();
AutomationLine::reset_line_coords (ControlPoint& cp)
{
if (cp.view_index() < line_points.size()) {
- line_points[cp.view_index()].set_x (cp.get_x());
- line_points[cp.view_index()].set_y (cp.get_y());
+ line_points[cp.view_index()].x = cp.get_x ();
+ line_points[cp.view_index()].y = cp.get_y ();
}
}
*/
if (line_points.size() > 1) {
- line->property_points() = line_points;
+ line->set (line_points);
}
}
/* if xval has not changed, set it directly from the model to avoid rounding errors */
- if (view_x == trackview.editor().frame_to_unit_unrounded (_time_converter->to ((*cp.model())->when)) - _offset) {
+ if (view_x == trackview.editor().sample_to_pixel_unrounded (_time_converter->to ((*cp.model())->when)) - _offset) {
view_x = (*cp.model())->when - _offset;
} else {
- view_x = trackview.editor().unit_to_frame (view_x);
+ view_x = trackview.editor().pixel_to_sample (view_x);
view_x = _time_converter->from (view_x + _offset);
}
ControlPoint *acp = 0;
double unit_xval;
- unit_xval = trackview.editor().frame_to_unit_unrounded (xval);
+ unit_xval = trackview.editor().sample_to_pixel_unrounded (xval);
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
void AutomationLine::set_colors ()
{
- set_line_color (ARDOUR_UI::config()->canvasvar_AutomationLine.get());
+ set_line_color (ARDOUR_UI::config()->get_canvasvar_AutomationLine());
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->set_color ();
}
model_to_view_coord (tx, ty);
- if (std::isnan (tx) || std::isnan (ty)) {
+ if (isnan (tx) || isnan (ty)) {
warning << string_compose (_("Ignoring illegal points on AutomationLine \"%1\""),
_name) << endmsg;
continue;
* zoom and scroll into account).
*/
- tx = trackview.editor().frame_to_unit_unrounded (tx);
+ tx = trackview.editor().sample_to_pixel_unrounded (tx);
/* convert from canonical view height (0..1.0) to actual
* height coordinates (using X11's top-left rooted system)
/* reset the line coordinates given to the CanvasLine */
while (line_points.size() < vp) {
- line_points.push_back (Art::Point (0,0));
+ line_points.push_back (ArdourCanvas::Duple (0,0));
}
while (line_points.size() > vp) {
}
for (uint32_t n = 0; n < vp; ++n) {
- line_points[n].set_x (control_points[n]->get_x());
- line_points[n].set_y (control_points[n]->get_y());
+ line_points[n].x = control_points[n]->get_x();
+ line_points[n].y = control_points[n]->get_y();
}
- line->property_points() = line_points;
+ line->set (line_points);
if (_visible && alist->interpolation() != AutomationList::Discrete) {
line->show();
void
AutomationLine::add_visibility (VisibleAspects va)
{
+ VisibleAspects old = _visible;
+
_visible = VisibleAspects (_visible | va);
- show ();
+
+ if (old != _visible) {
+ show ();
+ }
}
void
AutomationLine::set_visibility (VisibleAspects va)
{
- _visible = va;
- show ();
+ if (_visible != va) {
+ _visible = va;
+ show ();
+ }
}
void
AutomationLine::remove_visibility (VisibleAspects va)
{
+ VisibleAspects old = _visible;
+
_visible = VisibleAspects (_visible & ~va);
- show ();
+
+ if (old != _visible) {
+ show ();
+ }
}
void
if (_visible & ControlPoints) {
control_points[view_index]->show ();
- control_points[view_index]->set_visible (true);
} else {
- control_points[view_index]->set_visible (false);
+ control_points[view_index]->hide ();
}
}