2007-07-06 23:19:04 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2007-2014 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2007-07-06 23:19:04 -04:00
|
|
|
|
|
|
|
#include "control_point.h"
|
|
|
|
#include "automation_line.h"
|
|
|
|
#include "public_editor.h"
|
2015-01-02 09:44:54 -05:00
|
|
|
#include "ui_config.h"
|
2007-07-06 23:19:04 -04:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/rectangle.h"
|
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2007-07-06 23:19:04 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
|
2012-04-22 10:03:07 -04:00
|
|
|
PBD::Signal1<void, ControlPoint *> ControlPoint::CatchDeletion;
|
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
ControlPoint::ControlPoint (AutomationLine& al)
|
|
|
|
: _line (al)
|
|
|
|
{
|
|
|
|
_model = al.the_list()->end();
|
|
|
|
_view_index = 0;
|
|
|
|
_can_slide = true;
|
|
|
|
_x = 0;
|
|
|
|
_y = 0;
|
|
|
|
_shape = Full;
|
|
|
|
_size = 4.0;
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_item = new ArdourCanvas::Rectangle (&_line.canvas_group());
|
2014-01-07 20:55:26 -05:00
|
|
|
_item->set_fill (true);
|
2015-01-02 09:44:54 -05:00
|
|
|
_item->set_fill_color (UIConfiguration::instance().color ("control point fill"));
|
|
|
|
_item->set_outline_color (UIConfiguration::instance().color ("control point outline"));
|
2007-07-06 23:19:04 -04:00
|
|
|
_item->set_data ("control_point", this);
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->Event.connect (sigc::mem_fun (this, &ControlPoint::event_handler));
|
2007-07-06 23:19:04 -04:00
|
|
|
|
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
2009-07-21 11:55:17 -04:00
|
|
|
ControlPoint::ControlPoint (const ControlPoint& other, bool /*dummy_arg_to_force_special_copy_constructor*/)
|
2007-07-06 23:19:04 -04:00
|
|
|
: _line (other._line)
|
|
|
|
{
|
|
|
|
if (&other == this) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_model = other._model;
|
|
|
|
_view_index = other._view_index;
|
|
|
|
_can_slide = other._can_slide;
|
|
|
|
_x = other._x;
|
|
|
|
_y = other._y;
|
|
|
|
_shape = other._shape;
|
|
|
|
_size = other._size;
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_item = new ArdourCanvas::Rectangle (&_line.canvas_group());
|
2014-01-07 20:55:26 -05:00
|
|
|
_item->set_fill (true);
|
2015-01-02 09:44:54 -05:00
|
|
|
_item->set_outline_color (UIConfiguration::instance().color ("control point outline"));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
/* NOTE: no event handling in copied ControlPoints */
|
|
|
|
|
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlPoint::~ControlPoint ()
|
|
|
|
{
|
2012-04-22 10:03:07 -04:00
|
|
|
CatchDeletion (this); /* EMIT SIGNAL */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
delete _item;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ControlPoint::event_handler (GdkEvent* event)
|
|
|
|
{
|
|
|
|
return PublicEditor::instance().canvas_control_point_event (event, _item, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlPoint::hide ()
|
|
|
|
{
|
|
|
|
_item->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlPoint::show()
|
|
|
|
{
|
|
|
|
_item->show();
|
|
|
|
}
|
|
|
|
|
2010-01-02 19:08:58 -05:00
|
|
|
bool
|
|
|
|
ControlPoint::visible () const
|
|
|
|
{
|
2013-12-31 11:55:30 -05:00
|
|
|
return _item->visible ();
|
2010-01-02 19:08:58 -05:00
|
|
|
}
|
|
|
|
|
2007-07-06 23:19:04 -04:00
|
|
|
void
|
|
|
|
ControlPoint::reset (double x, double y, AutomationList::iterator mi, uint32_t vi, ShapeType shape)
|
|
|
|
{
|
|
|
|
_model = mi;
|
|
|
|
_view_index = vi;
|
|
|
|
move_to (x, y, shape);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-02 19:08:58 -05:00
|
|
|
ControlPoint::set_color ()
|
2007-07-06 23:19:04 -04:00
|
|
|
{
|
2010-01-02 19:08:58 -05:00
|
|
|
if (_selected) {
|
2015-01-02 09:44:54 -05:00
|
|
|
_item->set_outline_color(UIConfiguration::instance().color ("control point selected outline"));;
|
|
|
|
_item->set_fill_color(UIConfiguration::instance().color ("control point selected fill"));
|
2007-07-06 23:19:04 -04:00
|
|
|
} else {
|
2015-01-02 09:44:54 -05:00
|
|
|
_item->set_outline_color(UIConfiguration::instance().color ("control point outline"));
|
|
|
|
_item->set_fill_color(UIConfiguration::instance().color ("control point fill"));
|
2007-07-06 23:19:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlPoint::set_size (double sz)
|
|
|
|
{
|
|
|
|
_size = sz;
|
2022-10-25 13:10:32 -04:00
|
|
|
move_to (_x, _y);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlPoint::move_to (double x, double y)
|
|
|
|
{
|
|
|
|
move_to (x, y, _shape);
|
2007-07-06 23:19:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlPoint::move_to (double x, double y, ShapeType shape)
|
|
|
|
{
|
|
|
|
double x1 = 0;
|
|
|
|
double x2 = 0;
|
|
|
|
double half_size = rint(_size/2.0);
|
|
|
|
|
|
|
|
switch (shape) {
|
|
|
|
case Full:
|
|
|
|
x1 = x - half_size;
|
|
|
|
x2 = x + half_size;
|
|
|
|
break;
|
|
|
|
case Start:
|
|
|
|
x1 = x;
|
|
|
|
x2 = x + half_size;
|
|
|
|
break;
|
|
|
|
case End:
|
|
|
|
x1 = x - half_size;
|
|
|
|
x2 = x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_item->set (ArdourCanvas::Rect (x1, y - half_size, x2, y + half_size));
|
2007-07-06 23:19:04 -04:00
|
|
|
|
|
|
|
_x = x;
|
|
|
|
_y = y;
|
|
|
|
_shape = shape;
|
|
|
|
}
|
|
|
|
|
2014-06-26 15:04:22 -04:00
|
|
|
ArdourCanvas::Item&
|
2015-10-04 14:51:05 -04:00
|
|
|
ControlPoint::item() const
|
2010-01-02 19:08:58 -05:00
|
|
|
{
|
2014-06-26 15:04:22 -04:00
|
|
|
return *_item;
|
2010-01-02 19:08:58 -05:00
|
|
|
}
|