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"
21 #include "automation_line.h"
22 #include "ardour_ui.h"
23 #include "public_editor.h"
25 #include "canvas/rectangle.h"
30 using namespace ARDOUR;
33 PBD::Signal1<void, ControlPoint *> ControlPoint::CatchDeletion;
35 ControlPoint::ControlPoint (AutomationLine& al)
38 _model = al.the_list()->end();
46 _item = new ArdourCanvas::Rectangle (&_line.canvas_group());
47 _item->set_fill (true);
48 _item->set_fill_color (ARDOUR_UI::config()->get_canvasvar_ControlPointFill());
49 _item->set_outline_color (ARDOUR_UI::config()->get_canvasvar_ControlPointOutline());
50 _item->set_data ("control_point", this);
51 _item->Event.connect (sigc::mem_fun (this, &ControlPoint::event_handler));
56 ControlPoint::ControlPoint (const ControlPoint& other, bool /*dummy_arg_to_force_special_copy_constructor*/)
63 _model = other._model;
64 _view_index = other._view_index;
65 _can_slide = other._can_slide;
68 _shape = other._shape;
71 _item = new ArdourCanvas::Rectangle (&_line.canvas_group());
72 _item->set_fill (true);
73 _item->set_outline_color (ARDOUR_UI::config()->get_canvasvar_ControlPointOutline());
75 /* NOTE: no event handling in copied ControlPoints */
80 ControlPoint::~ControlPoint ()
82 CatchDeletion (this); /* EMIT SIGNAL */
88 ControlPoint::event_handler (GdkEvent* event)
90 return PublicEditor::instance().canvas_control_point_event (event, _item, this);
106 ControlPoint::visible () const
108 return _item->visible ();
112 ControlPoint::reset (double x, double y, AutomationList::iterator mi, uint32_t vi, ShapeType shape)
116 move_to (x, y, shape);
120 ControlPoint::set_color ()
125 color = ARDOUR_UI::config()->get_canvasvar_ControlPointSelected();
127 color = ARDOUR_UI::config()->get_canvasvar_ControlPointOutline();
130 _item->set_outline_color (color);
131 _item->set_fill_color (ARDOUR_UI::config()->get_canvasvar_ControlPointFill());
135 ControlPoint::set_size (double sz)
138 move_to (_x, _y, _shape);
142 ControlPoint::move_to (double x, double y, ShapeType shape)
146 double half_size = rint(_size/2.0);
163 _item->set (ArdourCanvas::Rect (x1, y - half_size, x2, y + half_size));
171 ControlPoint::item() const