2 * Copyright (C) 2007-2014 David Robillard <d@drobilla.net>
3 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
4 * Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "control_point.h"
22 #include "automation_line.h"
23 #include "public_editor.h"
24 #include "ui_config.h"
26 #include "canvas/rectangle.h"
31 using namespace ARDOUR;
34 PBD::Signal1<void, ControlPoint *> ControlPoint::CatchDeletion;
36 ControlPoint::ControlPoint (AutomationLine& al)
39 _model = al.the_list()->end();
47 _item = new ArdourCanvas::Rectangle (&_line.canvas_group());
48 _item->set_fill (true);
49 _item->set_fill_color (UIConfiguration::instance().color ("control point fill"));
50 _item->set_outline_color (UIConfiguration::instance().color ("control point outline"));
51 _item->set_data ("control_point", this);
52 _item->Event.connect (sigc::mem_fun (this, &ControlPoint::event_handler));
57 ControlPoint::ControlPoint (const ControlPoint& other, bool /*dummy_arg_to_force_special_copy_constructor*/)
64 _model = other._model;
65 _view_index = other._view_index;
66 _can_slide = other._can_slide;
69 _shape = other._shape;
72 _item = new ArdourCanvas::Rectangle (&_line.canvas_group());
73 _item->set_fill (true);
74 _item->set_outline_color (UIConfiguration::instance().color ("control point outline"));
76 /* NOTE: no event handling in copied ControlPoints */
81 ControlPoint::~ControlPoint ()
83 CatchDeletion (this); /* EMIT SIGNAL */
89 ControlPoint::event_handler (GdkEvent* event)
91 return PublicEditor::instance().canvas_control_point_event (event, _item, this);
107 ControlPoint::visible () const
109 return _item->visible ();
113 ControlPoint::reset (double x, double y, AutomationList::iterator mi, uint32_t vi, ShapeType shape)
117 move_to (x, y, shape);
121 ControlPoint::set_color ()
124 _item->set_outline_color(UIConfiguration::instance().color ("control point selected outline"));;
125 _item->set_fill_color(UIConfiguration::instance().color ("control point selected fill"));
127 _item->set_outline_color(UIConfiguration::instance().color ("control point outline"));
128 _item->set_fill_color(UIConfiguration::instance().color ("control point fill"));
133 ControlPoint::set_size (double sz)
136 move_to (_x, _y, _shape);
140 ControlPoint::move_to (double x, double y, ShapeType shape)
144 double half_size = rint(_size/2.0);
161 _item->set (ArdourCanvas::Rect (x1, y - half_size, x2, y + half_size));
169 ControlPoint::item() const