2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "canvas/canvas.h"
24 #include "canvas/debug.h"
25 #include "canvas/scroll_group.h"
27 #include "editor_cursors.h"
30 using namespace ARDOUR;
34 EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
36 , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group()))
39 CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas editor cursor");
41 _track_canvas_item->set_show_head (0, true);
42 _track_canvas_item->set_head_height (0, 9);
43 _track_canvas_item->set_head_width (0, 16);
44 _track_canvas_item->set_head_outward (0, false);
45 _track_canvas_item->set_show_head (1, false); // head only
46 _track_canvas_item->set_data ("cursor", this);
48 _track_canvas_item->Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), _track_canvas_item));
50 _track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX);
52 _current_frame = 1; /* force redraw at 0 */
55 EditorCursor::EditorCursor (Editor& ed)
57 , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group()))
60 CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas cursor");
62 _track_canvas_item->set_show_head (0, false);
63 _track_canvas_item->set_show_head (1, false);
64 _track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX);
65 _track_canvas_item->set_ignore_events (true);
67 _current_frame = 1; /* force redraw at 0 */
70 EditorCursor::~EditorCursor ()
72 delete _track_canvas_item;
76 EditorCursor::set_position (framepos_t frame)
78 PositionChanged (frame);
80 double const new_pos = _editor.sample_to_pixel_unrounded (frame);
82 if (new_pos != _track_canvas_item->x ()) {
83 _track_canvas_item->set_x (new_pos);
86 _current_frame = frame;
92 _track_canvas_item->show ();
98 _track_canvas_item->hide ();
102 EditorCursor::set_color (ArdourCanvas::Color color)
104 _track_canvas_item->set_color (color);
108 EditorCursor::set_sensitive (bool yn)
110 _track_canvas_item->set_ignore_events (!yn);