X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_cursors.cc;h=3df7761007a09c46da17b799932c64c2403d58e8;hb=103ef2ba08e59c21f84899450f04a062ac60334e;hp=907a215e5ba3a691a2936abf4a775fa382c018f3;hpb=5696199daffbd40e82aa7f0a754e36b2adf6726e;p=ardour.git diff --git a/gtk2_ardour/editor_cursors.cc b/gtk2_ardour/editor_cursors.cc index 907a215e5b..3df7761007 100644 --- a/gtk2_ardour/editor_cursors.cc +++ b/gtk2_ardour/editor_cursors.cc @@ -22,8 +22,8 @@ #include "canvas/canvas.h" #include "canvas/debug.h" +#include "canvas/scroll_group.h" -#include "utils.h" #include "editor_cursors.h" #include "editor.h" @@ -33,8 +33,7 @@ using namespace Gtk; EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*)) : _editor (ed) - , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_track_canvas_group())) - , _length (1.0) + , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_cursor_scroll_group())) { CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas editor cursor"); @@ -48,27 +47,45 @@ EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,Ardour _track_canvas_item->Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), _track_canvas_item)); _track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX); - - _current_frame = 1; /* force redraw at 0 */ + + _track_canvas_item->set_x (0); + + _current_sample = 1; /* force redraw at 0 */ +} + +EditorCursor::EditorCursor (Editor& ed) + : _editor (ed) + , _track_canvas_item (new ArdourCanvas::Arrow (_editor.get_hscroll_group())) +{ + 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); + + _track_canvas_item->set_x (0); + + _current_sample = 1; /* force redraw at 0 */ } EditorCursor::~EditorCursor () { - + delete _track_canvas_item; } void -EditorCursor::set_position (framepos_t frame) +EditorCursor::set_position (samplepos_t sample) { - PositionChanged (frame); + if (_current_sample != sample) { PositionChanged (sample); } - double const new_pos = _editor.sample_to_pixel_unrounded (frame); + double const new_pos = _editor.sample_to_pixel_unrounded (sample); - if (new_pos != _track_canvas_item->x ()) { - _track_canvas_item->set_x (new_pos); + if (rint(new_pos) != rint(_track_canvas_item->x ())) { + _track_canvas_item->set_x (new_pos-0.5); //accommodate the 1/2 pixel "line" offset in cairo } - _current_frame = frame; + _current_sample = sample; } void @@ -84,7 +101,13 @@ EditorCursor::hide () } void -EditorCursor::set_color (ArdourCanvas::Color color) +EditorCursor::set_color (Gtkmm2ext::Color color) { _track_canvas_item->set_color (color); } + +void +EditorCursor::set_sensitive (bool yn) +{ + _track_canvas_item->set_ignore_events (!yn); +}