Fix offset of verbose cursor when dragging fade-ins (#4010).
authorCarl Hetherington <carl@carlh.net>
Wed, 4 May 2011 14:56:24 +0000 (14:56 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 4 May 2011 14:56:24 +0000 (14:56 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9473 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_drag.h
gtk2_ardour/verbose_cursor.cc
gtk2_ardour/verbose_cursor.h

index ed821c8f151a491e6ba36294a3fe58e451d4c55a..e1c73321334b6a775311106c4da614e418d3ebe7 100644 (file)
@@ -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<AudioRegionView*> (_primary);
        boost::shared_ptr<AudioRegion> 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
index e40975b5a5250c4947c4513cbfcad8570c396001..b1e99890e720cdd3e8c0c7e5a59fb77f0c4102ab 100644 (file)
@@ -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
index 9380b36c1af4ab8030d664bb9b294c3895350103..f63e518332307caf9a39c0dbdff7fd60f6d8c8af 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <string>
 #include <gtkmm/enums.h>
+#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
index 26b21bfe5736e7d47d8bc3ad7f5a80b239ec6c72..8c53120005435d5ab317afca866e3a6286239706 100644 (file)
@@ -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;
 };