2 Copyright (C) 2002-2007 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 #include "control_point.h"
22 #include "automation_line.h"
23 #include "ardour_ui.h"
24 #include "public_editor.h"
29 using namespace ARDOUR;
31 using namespace Gnome; // for Canvas
33 PBD::Signal1<void, ControlPoint *> ControlPoint::CatchDeletion;
35 ControlPoint::ControlPoint (AutomationLine& al)
38 _model = al.the_list()->end();
46 _item = new Canvas::SimpleRect (_line.canvas_group());
47 _item->property_draw() = true;
48 _item->property_fill() = false;
49 _item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ControlPointFill.get();
50 _item->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_ControlPointOutline.get();
51 _item->property_outline_pixels() = 1;
52 _item->set_data ("control_point", this);
53 _item->signal_event().connect (sigc::mem_fun (this, &ControlPoint::event_handler));
59 ControlPoint::ControlPoint (const ControlPoint& other, bool /*dummy_arg_to_force_special_copy_constructor*/)
66 _model = other._model;
67 _view_index = other._view_index;
68 _can_slide = other._can_slide;
71 _shape = other._shape;
74 _item = new Canvas::SimpleRect (_line.canvas_group());
75 _item->property_fill() = false;
76 _item->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_ControlPointOutline.get();
77 _item->property_outline_pixels() = 1;
79 /* NOTE: no event handling in copied ControlPoints */
85 ControlPoint::~ControlPoint ()
87 CatchDeletion (this); /* EMIT SIGNAL */
93 ControlPoint::event_handler (GdkEvent* event)
95 return PublicEditor::instance().canvas_control_point_event (event, _item, this);
111 ControlPoint::set_visible (bool yn)
113 _item->property_draw() = (gboolean) yn;
117 ControlPoint::visible () const
119 return _item->property_draw ();
123 ControlPoint::reset (double x, double y, AutomationList::iterator mi, uint32_t vi, ShapeType shape)
125 /* If this is too big, libart will confuse itself and segfault after it casts the bounding box
126 of this automation line to ints. Sigh.
135 move_to (x, y, shape);
139 ControlPoint::set_color ()
144 color = ARDOUR_UI::config()->canvasvar_ControlPointSelected.get();
146 color = ARDOUR_UI::config()->canvasvar_ControlPointOutline.get();
149 _item->property_outline_color_rgba() = color;
150 _item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ControlPointFill.get();
154 ControlPoint::set_size (double sz)
157 move_to (_x, _y, _shape);
161 ControlPoint::move_to (double x, double y, ShapeType shape)
165 double half_size = rint(_size/2.0);
182 _item->property_x1() = x1;
183 _item->property_x2() = x2;
184 _item->property_y1() = y - half_size;
185 _item->property_y2() = y + half_size;
193 ControlPoint::i2w (double& x, double& y) const