2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000 Paul Davis
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
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>
|
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
#include "canvas/canvas.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "utils.h"
|
2010-11-16 09:53:16 -05:00
|
|
|
#include "editor_cursors.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "editor.h"
|
|
|
|
|
|
|
|
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*))
|
2013-04-04 00:32:52 -04:00
|
|
|
: _editor (ed)
|
|
|
|
, _time_bars_canvas_item (_editor._time_bars_canvas->root ())
|
|
|
|
, _track_canvas_item (_editor._track_canvas->root ())
|
|
|
|
, _length (1.0)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
_time_bars_canvas_item.set_outline_width (1);
|
|
|
|
_track_canvas_item.set_outline_width (1);
|
|
|
|
|
2013-04-10 10:24:17 -04:00
|
|
|
_time_bars_canvas_item.set_show_head (0, true);
|
|
|
|
_time_bars_canvas_item.set_head_height (0, 9);
|
|
|
|
_time_bars_canvas_item.set_head_width (0, 16);
|
|
|
|
_time_bars_canvas_item.set_head_outward (0, false);
|
|
|
|
_time_bars_canvas_item.set_show_head (1, false); // head only
|
2013-04-04 00:32:52 -04:00
|
|
|
|
|
|
|
_time_bars_canvas_item.set_data ("cursor", this);
|
|
|
|
_track_canvas_item.set_data ("cursor", this);
|
|
|
|
|
|
|
|
_time_bars_canvas_item.Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), &_time_bars_canvas_item));
|
|
|
|
_track_canvas_item.Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), &_track_canvas_item));
|
|
|
|
|
|
|
|
_time_bars_canvas_item.set_y1 (ArdourCanvas::COORD_MAX);
|
|
|
|
_track_canvas_item.set_y1 (ArdourCanvas::COORD_MAX);
|
|
|
|
|
|
|
|
_current_frame = 1; /* force redraw at 0 */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-05-30 14:25:59 -04:00
|
|
|
EditorCursor::~EditorCursor ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-09-17 14:20:37 -04:00
|
|
|
EditorCursor::set_position (framepos_t frame)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-06-16 20:29:56 -04:00
|
|
|
PositionChanged (frame);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-04-12 11:15:45 -04:00
|
|
|
double const new_pos = _editor.sample_to_pixel (frame);
|
2005-11-30 14:34:09 -05:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
if (new_pos != _time_bars_canvas_item.x ()) {
|
|
|
|
_time_bars_canvas_item.set_x (new_pos);
|
|
|
|
}
|
2005-12-04 23:11:08 -05:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
if (new_pos != _track_canvas_item.x0 ()) {
|
|
|
|
_track_canvas_item.set_x0 (new_pos);
|
|
|
|
_track_canvas_item.set_x1 (new_pos);
|
2005-11-30 14:34:09 -05:00
|
|
|
}
|
2013-04-04 00:32:52 -04:00
|
|
|
|
|
|
|
_current_frame = frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorCursor::show ()
|
|
|
|
{
|
|
|
|
_time_bars_canvas_item.show ();
|
|
|
|
_track_canvas_item.show ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-04-04 00:32:52 -04:00
|
|
|
EditorCursor::hide ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
_time_bars_canvas_item.hide ();
|
|
|
|
_track_canvas_item.hide ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
void
|
2013-04-04 00:32:52 -04:00
|
|
|
EditorCursor::set_color (ArdourCanvas::Color color)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2013-04-04 00:32:52 -04:00
|
|
|
_time_bars_canvas_item.set_color (color);
|
|
|
|
_track_canvas_item.set_outline_color (color);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|