From 4216d201fb8d9e29c4760d07a41b129753a71c8b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 4 May 2011 14:56:24 +0000 Subject: Fix offset of verbose cursor when dragging fade-ins (#4010). git-svn-id: svn://localhost/ardour2/branches/3.0@9473 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_drag.cc | 14 +++++++------- gtk2_ardour/editor_drag.h | 2 +- gtk2_ardour/verbose_cursor.cc | 24 +++++++++++++++++++++--- gtk2_ardour/verbose_cursor.h | 4 +++- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index ed821c8f15..e1c7332133 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -369,27 +369,27 @@ Drag::show_verbose_cursor_time (framepos_t frame) } void -Drag::show_verbose_cursor_duration (framepos_t start, framepos_t end) +Drag::show_verbose_cursor_duration (framepos_t start, framepos_t end, double xoffset) { + _editor->verbose_cursor()->show (xoffset); + _editor->verbose_cursor()->set_duration ( start, end, _drags->current_pointer_x() + 10 - _editor->horizontal_position(), _drags->current_pointer_y() + 10 - _editor->vertical_adjustment.get_value() + _editor->canvas_timebars_vsize ); - - _editor->verbose_cursor()->show (); } void Drag::show_verbose_cursor_text (string const & text) { + _editor->verbose_cursor()->show (); + _editor->verbose_cursor()->set ( text, _drags->current_pointer_x() + 10 - _editor->horizontal_position(), _drags->current_pointer_y() + 10 - _editor->vertical_adjustment.get_value() + _editor->canvas_timebars_vsize ); - - _editor->verbose_cursor()->show (); } @@ -2165,7 +2165,7 @@ FadeInDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) AudioRegionView* arv = dynamic_cast (_primary); boost::shared_ptr const r = arv->audio_region (); - show_verbose_cursor_duration (r->position(), r->position() + r->fade_in()->back()->when); + show_verbose_cursor_duration (r->position(), r->position() + r->fade_in()->back()->when, 32); arv->show_fade_line((framepos_t) r->fade_in()->back()->when); } @@ -2207,7 +2207,7 @@ FadeInDrag::motion (GdkEvent* event, bool) tmp->show_fade_line((framecnt_t) fade_length); } - show_verbose_cursor_duration (region->position(), region->position() + fade_length); + show_verbose_cursor_duration (region->position(), region->position() + fade_length, 32); } void diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index e40975b5a5..b1e99890e7 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -213,7 +213,7 @@ protected: } void show_verbose_cursor_time (framepos_t); - void show_verbose_cursor_duration (framepos_t, framepos_t); + void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0); void show_verbose_cursor_text (std::string const &); Editor* _editor; ///< our editor diff --git a/gtk2_ardour/verbose_cursor.cc b/gtk2_ardour/verbose_cursor.cc index 9380b36c1a..f63e518332 100644 --- a/gtk2_ardour/verbose_cursor.cc +++ b/gtk2_ardour/verbose_cursor.cc @@ -19,6 +19,7 @@ #include #include +#include "pbd/stacktrace.h" #include "ardour/profile.h" #include "editor.h" #include "ardour_ui.h" @@ -34,6 +35,8 @@ using namespace ARDOUR; VerboseCursor::VerboseCursor (Editor* editor) : _editor (editor) , _visible (false) + , _xoffset (0) + , _yoffset (0) { Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor")); @@ -63,9 +66,20 @@ VerboseCursor::set_text (string const & text) _canvas_item->property_text() = text.c_str(); } +/** @param xoffset x offset to be applied on top of any set_position() call + * before the next show (). + * @param yoffset y offset as above. + */ void -VerboseCursor::show () +VerboseCursor::show (double xoffset, double yoffset) { + _xoffset = xoffset; + _yoffset = yoffset; + + if (_visible) { + return; + } + _canvas_item->raise_to_top (); _canvas_item->show (); _visible = true; @@ -244,11 +258,15 @@ VerboseCursor::set_color (uint32_t color) _canvas_item->property_fill_color_rgba() = color; } +/** Set the position of the verbose cursor. Any x/y offsets + * passed to the last call to show() will be applied to the + * coordinates passed in here. + */ void VerboseCursor::set_position (double x, double y) { - _canvas_item->property_x() = clamp_x (x); - _canvas_item->property_y() = clamp_y (y); + _canvas_item->property_x() = clamp_x (x + _xoffset); + _canvas_item->property_y() = clamp_y (y + _yoffset); } bool diff --git a/gtk2_ardour/verbose_cursor.h b/gtk2_ardour/verbose_cursor.h index 26b21bfe57..8c53120005 100644 --- a/gtk2_ardour/verbose_cursor.h +++ b/gtk2_ardour/verbose_cursor.h @@ -40,7 +40,7 @@ public: void set_time (framepos_t, double, double); void set_duration (framepos_t, framepos_t, double, double); - void show (); + void show (double xoffset = 0, double yoffset = 0); void hide (); private: @@ -50,4 +50,6 @@ private: Editor* _editor; ArdourCanvas::NoEventText* _canvas_item; bool _visible; + double _xoffset; + double _yoffset; }; -- cgit v1.2.3