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
This commit is contained in:
Carl Hetherington 2011-05-04 14:56:24 +00:00
parent 378ea3430f
commit 4216d201fb
4 changed files with 32 additions and 12 deletions

View file

@ -369,27 +369,27 @@ Drag::show_verbose_cursor_time (framepos_t frame)
} }
void 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 ( _editor->verbose_cursor()->set_duration (
start, end, start, end,
_drags->current_pointer_x() + 10 - _editor->horizontal_position(), _drags->current_pointer_x() + 10 - _editor->horizontal_position(),
_drags->current_pointer_y() + 10 - _editor->vertical_adjustment.get_value() + _editor->canvas_timebars_vsize _drags->current_pointer_y() + 10 - _editor->vertical_adjustment.get_value() + _editor->canvas_timebars_vsize
); );
_editor->verbose_cursor()->show ();
} }
void void
Drag::show_verbose_cursor_text (string const & text) Drag::show_verbose_cursor_text (string const & text)
{ {
_editor->verbose_cursor()->show ();
_editor->verbose_cursor()->set ( _editor->verbose_cursor()->set (
text, text,
_drags->current_pointer_x() + 10 - _editor->horizontal_position(), _drags->current_pointer_x() + 10 - _editor->horizontal_position(),
_drags->current_pointer_y() + 10 - _editor->vertical_adjustment.get_value() + _editor->canvas_timebars_vsize _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); AudioRegionView* arv = dynamic_cast<AudioRegionView*> (_primary);
boost::shared_ptr<AudioRegion> const r = arv->audio_region (); 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); 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); 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 void

View file

@ -213,7 +213,7 @@ protected:
} }
void show_verbose_cursor_time (framepos_t); 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 &); void show_verbose_cursor_text (std::string const &);
Editor* _editor; ///< our editor Editor* _editor; ///< our editor

View file

@ -19,6 +19,7 @@
#include <string> #include <string>
#include <gtkmm/enums.h> #include <gtkmm/enums.h>
#include "pbd/stacktrace.h"
#include "ardour/profile.h" #include "ardour/profile.h"
#include "editor.h" #include "editor.h"
#include "ardour_ui.h" #include "ardour_ui.h"
@ -34,6 +35,8 @@ using namespace ARDOUR;
VerboseCursor::VerboseCursor (Editor* editor) VerboseCursor::VerboseCursor (Editor* editor)
: _editor (editor) : _editor (editor)
, _visible (false) , _visible (false)
, _xoffset (0)
, _yoffset (0)
{ {
Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor")); 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(); _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 void
VerboseCursor::show () VerboseCursor::show (double xoffset, double yoffset)
{ {
_xoffset = xoffset;
_yoffset = yoffset;
if (_visible) {
return;
}
_canvas_item->raise_to_top (); _canvas_item->raise_to_top ();
_canvas_item->show (); _canvas_item->show ();
_visible = true; _visible = true;
@ -244,11 +258,15 @@ VerboseCursor::set_color (uint32_t color)
_canvas_item->property_fill_color_rgba() = 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 void
VerboseCursor::set_position (double x, double y) VerboseCursor::set_position (double x, double y)
{ {
_canvas_item->property_x() = clamp_x (x); _canvas_item->property_x() = clamp_x (x + _xoffset);
_canvas_item->property_y() = clamp_y (y); _canvas_item->property_y() = clamp_y (y + _yoffset);
} }
bool bool

View file

@ -40,7 +40,7 @@ public:
void set_time (framepos_t, double, double); void set_time (framepos_t, double, double);
void set_duration (framepos_t, 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 (); void hide ();
private: private:
@ -50,4 +50,6 @@ private:
Editor* _editor; Editor* _editor;
ArdourCanvas::NoEventText* _canvas_item; ArdourCanvas::NoEventText* _canvas_item;
bool _visible; bool _visible;
double _xoffset;
double _yoffset;
}; };