along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
#include <cmath>
#include <pbd/stl_delete.h>
#include <pbd/memento_command.h>
+#include <pbd/stacktrace.h>
#include <ardour/automation_event.h>
#include <ardour/curve.h>
item = new Canvas::SimpleRect (line.canvas_group());
item->property_draw() = true;
item->property_fill() = false;
- item->property_fill_color_rgba() = color_map[cControlPointFill];
- item->property_outline_color_rgba() = color_map[cControlPointOutline];
+ item->property_fill_color_rgba() = Config->canvasvar_ControlPointFill.get();
+ item->property_outline_color_rgba() = Config->canvasvar_ControlPointOutline.get();
item->property_outline_pixels() = 1;
item->set_data ("control_point", this);
item->signal_event().connect (mem_fun (this, &ControlPoint::event_handler));
item = new Canvas::SimpleRect (line.canvas_group());
item->property_fill() = false;
- item->property_outline_color_rgba() = color_map[cEnteredControlPointOutline];
+ item->property_outline_color_rgba() = Config->canvasvar_EnteredControlPointOutline.get();
item->property_outline_pixels() = 1;
/* NOTE: no event handling in copied ControlPoints */
{
if (entered) {
if (selected) {
- item->property_outline_color_rgba() = color_map[cEnteredControlPointSelected];
+ item->property_outline_color_rgba() = Config->canvasvar_EnteredControlPointSelected.get();
set_visible(true);
} else {
- item->property_outline_color_rgba() = color_map[cEnteredControlPoint];
+ item->property_outline_color_rgba() = Config->canvasvar_EnteredControlPoint.get();
if (hide_too) {
set_visible(false);
}
} else {
if (selected) {
- item->property_outline_color_rgba() = color_map[cControlPointSelected];
+ item->property_outline_color_rgba() = Config->canvasvar_ControlPointSelected.get();
set_visible(true);
} else {
- item->property_outline_color_rgba() = color_map[cControlPoint];
+ item->property_outline_color_rgba() = Config->canvasvar_ControlPoint.get();
if (hide_too) {
set_visible(false);
}
no_draw = false;
_visible = true;
terminal_points_can_slide = true;
+ _y_position = 0;
_height = 0;
group = new ArdourCanvas::Group (parent);
}
void
-AutomationLine::set_height (guint32 h)
+AutomationLine::set_y_position_and_height (guint32 y, guint32 h)
{
+ bool changed = false;
+
+ if (y != _y_position) {
+ _y_position = y;
+ changed = true;
+ }
+
if (h != _height) {
_height = h;
- double bsz = control_point_box_size();
+ double const bsz = control_point_box_size();
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
(*i)->set_size (bsz);
}
+ changed = true;
+ }
+ if (changed) {
reset ();
}
}
y = max (0.0, y);
y = min (1.0, y);
- y = _height - (y * _height);
+ y = _y_position + _height - (y * _height);
if (cp.can_slide) {
*/
mr.xval = (nframes_t) floor (cp.get_x());
- mr.yval = 1.0 - (cp.get_y() / _height);
+ mr.yval = 1.0 - ( (cp.get_y() - _y_position) / _height);
/* if xval has not changed, set it directly from the model to avoid rounding errors */
view_index = 0;
- ofstream oout ("orig_coordinates");
-
for (model = alist.begin(), pi = 0; pi < npoints; ++model, ++pi) {
double tx = points[pi].x;
double ty = points[pi].y;
- oout << tx << ' ' << ty << endl;
-
/* now ensure that the control_points vector reflects the current curve
state, but don't plot control points too close together. also, don't
plot a series of points all with the same value.
if (view_index && pi != npoints && /* not the first, not the last */
(((this_rx == prev_rx) && (this_ry == prev_ry)) || /* same point */
- (this_rx == prev_rx) || /* identical x coordinate */
(((this_rx - prev_rx) < (box_size + 2)) && /* not identical, but still too close horizontally */
- ((abs ((int)(this_ry - prev_ry)) < (int) (box_size + 2)))))) { /* too close vertically */
+ (abs ((int)(this_ry - prev_ry)) < (int) (box_size + 2))))) { /* too close vertically */
continue;
- }
+ }
/* ok, we should display this point */
view_index++;
}
- oout.close ();
-
/* discard extra CP's to avoid confusing ourselves */
while (control_points.size() > view_index) {
void
AutomationLine::line_drag (uint32_t i1, uint32_t i2, float fraction, bool with_push)
{
- double ydelta = fraction - last_drag_fraction;
+ double const ydelta = fraction - last_drag_fraction;
did_push = with_push;
for (uint32_t i = i1 ; i <= i2; i++) {
cp = nth (i);
- modify_view_point (*cp, trackview.editor.unit_to_frame (cp->get_x()), ((_height - cp->get_y()) /_height) + ydelta, with_push);
+ modify_view_point (*cp, trackview.editor.unit_to_frame (cp->get_x()), ((_height - cp->get_y() + _y_position) /_height) + ydelta, with_push);
}
if (line_points.size() > 1) {
/* Curse X11 and its inverted coordinate system! */
- bot = (1.0 - topfrac) * _height;
- top = (1.0 - botfrac) * _height;
+ bot = _y_position + (1.0 - topfrac) * _height;
+ top = _y_position + (1.0 - botfrac) * _height;
nstart = max_frames;
nend = 0;
/* Curse X11 and its inverted coordinate system! */
- bot = (1.0 - (*r).high_fract) * _height;
- top = (1.0 - (*r).low_fract) * _height;
+ bot = _y_position + (1.0 - (*r).high_fract) * _height;
+ top = _y_position + (1.0 - (*r).low_fract) * _height;
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
}
+void AutomationLine::set_colors() {
+ set_line_color( Config->canvasvar_AutomationLine.get() );
+ for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
+ (*i)->show_color (false, !points_visible);
+ }
+}
+
void
AutomationLine::show_selection ()
{
model_to_view_y (translated_y);
tmp_points.push_back (ALPoint (trackview.editor.frame_to_unit ((*ai)->when),
- _height - (translated_y * _height)));
+ _y_position + _height - (translated_y * _height)));
}
determine_visible_control_points (tmp_points);