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"
|
2013-04-17 10:53:17 -04:00
|
|
|
#include "canvas/debug.h"
|
2014-06-21 11:44:22 -04:00
|
|
|
#include "canvas/scroll_group.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
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)
|
2014-05-21 19:15:08 -04:00
|
|
|
, _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group()))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2014-02-12 15:13:11 -05:00
|
|
|
CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas editor cursor");
|
2013-04-17 10:53:17 -04:00
|
|
|
|
2014-05-21 11:12:57 -04:00
|
|
|
_track_canvas_item->set_show_head (0, true);
|
|
|
|
_track_canvas_item->set_head_height (0, 9);
|
|
|
|
_track_canvas_item->set_head_width (0, 16);
|
|
|
|
_track_canvas_item->set_head_outward (0, false);
|
|
|
|
_track_canvas_item->set_show_head (1, false); // head only
|
2014-02-12 15:13:11 -05:00
|
|
|
_track_canvas_item->set_data ("cursor", this);
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2014-02-12 15:13:11 -05:00
|
|
|
_track_canvas_item->Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), _track_canvas_item));
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2014-02-12 15:13:11 -05:00
|
|
|
_track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX);
|
2014-09-15 07:28:13 -04:00
|
|
|
|
2014-12-11 09:04:26 -05:00
|
|
|
_track_canvas_item->set_x (0);
|
2013-04-04 00:32:52 -04:00
|
|
|
|
|
|
|
_current_frame = 1; /* force redraw at 0 */
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2014-07-07 08:16:57 -04:00
|
|
|
EditorCursor::EditorCursor (Editor& ed)
|
|
|
|
: _editor (ed)
|
|
|
|
, _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group()))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2014-07-07 08:16:57 -04:00
|
|
|
CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas cursor");
|
|
|
|
|
|
|
|
_track_canvas_item->set_show_head (0, false);
|
|
|
|
_track_canvas_item->set_show_head (1, false);
|
|
|
|
_track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX);
|
|
|
|
_track_canvas_item->set_ignore_events (true);
|
2013-04-04 00:32:52 -04:00
|
|
|
|
2014-12-11 09:04:26 -05:00
|
|
|
_track_canvas_item->set_x (0);
|
2014-09-15 07:28:13 -04:00
|
|
|
|
2014-07-07 08:16:57 -04:00
|
|
|
_current_frame = 1; /* force redraw at 0 */
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorCursor::~EditorCursor ()
|
|
|
|
{
|
|
|
|
delete _track_canvas_item;
|
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
|
|
|
|
2014-02-12 15:13:11 -05:00
|
|
|
double const new_pos = _editor.sample_to_pixel_unrounded (frame);
|
2005-11-30 14:34:09 -05:00
|
|
|
|
2014-05-21 11:12:57 -04:00
|
|
|
if (new_pos != _track_canvas_item->x ()) {
|
|
|
|
_track_canvas_item->set_x (new_pos);
|
2005-11-30 14:34:09 -05:00
|
|
|
}
|
2014-02-12 15:13:11 -05:00
|
|
|
|
2013-04-04 00:32:52 -04:00
|
|
|
_current_frame = frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EditorCursor::show ()
|
|
|
|
{
|
2014-02-12 15:13:11 -05:00
|
|
|
_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
|
|
|
{
|
2014-02-12 15:13:11 -05:00
|
|
|
_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
|
|
|
{
|
2014-05-21 11:12:57 -04:00
|
|
|
_track_canvas_item->set_color (color);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2014-06-30 16:32:38 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
EditorCursor::set_sensitive (bool yn)
|
|
|
|
{
|
|
|
|
_track_canvas_item->set_ignore_events (!yn);
|
|
|
|
}
|