2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000 Paul Davis
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
|
|
|
|
2005-09-25 18:26:56 -04:00
|
|
|
#include <libgnomecanvas/libgnomecanvas.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
#include "editor.h"
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
|
2005-11-22 00:10:12 -05:00
|
|
|
: editor (ed),
|
|
|
|
canvas_item (*editor.cursor_group),
|
|
|
|
length(1.0)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2008-12-12 09:43:24 -05:00
|
|
|
points.push_back(Gnome::Art::Point(-1.0, 0.0)); // first x-coord needs to be a non-normal value
|
2008-09-10 17:27:39 -04:00
|
|
|
points.push_back(Gnome::Art::Point(1.0, 1.0));
|
2005-11-12 22:53:51 -05:00
|
|
|
|
2005-11-27 15:07:16 -05:00
|
|
|
canvas_item.property_points() = points;
|
|
|
|
canvas_item.property_width_pixels() = 1;
|
|
|
|
canvas_item.property_first_arrowhead() = TRUE;
|
|
|
|
canvas_item.property_last_arrowhead() = TRUE;
|
|
|
|
canvas_item.property_arrow_shape_a() = 11.0;
|
|
|
|
canvas_item.property_arrow_shape_b() = 0.0;
|
|
|
|
canvas_item.property_arrow_shape_c() = 9.0;
|
2005-11-12 17:07:07 -05:00
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
canvas_item.set_data ("cursor", this);
|
|
|
|
canvas_item.signal_event().connect (bind (mem_fun (ed, callbck), &canvas_item));
|
2005-09-25 14:42:24 -04:00
|
|
|
current_frame = 1; /* force redraw at 0 */
|
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
EditorCursor::~EditorCursor ()
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
EditorCursor::set_position (nframes64_t frame)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-06-16 20:29:56 -04:00
|
|
|
PositionChanged (frame);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
double new_pos = editor.frame_to_unit (frame);
|
|
|
|
|
2005-11-30 14:34:09 -05:00
|
|
|
if (new_pos != points.front().get_x()) {
|
|
|
|
|
|
|
|
points.front().set_x (new_pos);
|
|
|
|
points.back().set_x (new_pos);
|
2005-12-04 23:11:08 -05:00
|
|
|
|
|
|
|
canvas_item.property_points() = points;
|
2005-11-30 14:34:09 -05:00
|
|
|
}
|
2008-09-20 05:06:49 -04:00
|
|
|
current_frame = frame;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
EditorCursor::set_length (double units)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
length = units;
|
2005-11-30 14:34:09 -05:00
|
|
|
points.back().set_y (points.front().get_y() + length);
|
2005-11-27 15:07:16 -05:00
|
|
|
canvas_item.property_points() = points;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-05-30 14:25:59 -04:00
|
|
|
EditorCursor::set_y_axis (double position)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-22 00:10:12 -05:00
|
|
|
points.front().set_y (position);
|
2005-11-30 14:34:09 -05:00
|
|
|
points.back().set_y (position + length);
|
2005-11-27 15:07:16 -05:00
|
|
|
canvas_item.property_points() = points;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|