mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
remove all unit-based methods from (Public)Editor; rationalize Editor::event_frame() to clearly identify whether the passed-in GdkEvent has window units or canvas units (the latter will be true for all events that are handled by the canvas and then passed to Editor
This commit is contained in:
parent
fcb423f3f6
commit
ecfd2a7455
17 changed files with 130 additions and 162 deletions
|
|
@ -243,7 +243,7 @@ AutomationLine::modify_point_y (ControlPoint& cp, double y)
|
|||
y = min (1.0, y);
|
||||
y = _height - (y * _height);
|
||||
|
||||
double const x = trackview.editor().frame_to_unit_unrounded (_time_converter->to((*cp.model())->when) - _offset);
|
||||
double const x = trackview.editor().frame_to_pixel_unrounded (_time_converter->to((*cp.model())->when) - _offset);
|
||||
|
||||
trackview.editor().session()->begin_reversible_command (_("automation event move"));
|
||||
trackview.editor().session()->add_command (
|
||||
|
|
@ -739,10 +739,10 @@ AutomationLine::sync_model_with_view_point (ControlPoint& cp)
|
|||
|
||||
/* if xval has not changed, set it directly from the model to avoid rounding errors */
|
||||
|
||||
if (view_x == trackview.editor().frame_to_unit_unrounded (_time_converter->to ((*cp.model())->when)) - _offset) {
|
||||
if (view_x == trackview.editor().frame_to_pixel_unrounded (_time_converter->to ((*cp.model())->when)) - _offset) {
|
||||
view_x = (*cp.model())->when - _offset;
|
||||
} else {
|
||||
view_x = trackview.editor().unit_to_frame (view_x);
|
||||
view_x = trackview.editor().pixel_to_frame (view_x);
|
||||
view_x = _time_converter->from (view_x + _offset);
|
||||
}
|
||||
|
||||
|
|
@ -760,7 +760,7 @@ AutomationLine::control_points_adjacent (double xval, uint32_t & before, uint32_
|
|||
ControlPoint *acp = 0;
|
||||
double unit_xval;
|
||||
|
||||
unit_xval = trackview.editor().frame_to_unit_unrounded (xval);
|
||||
unit_xval = trackview.editor().frame_to_pixel_unrounded (xval);
|
||||
|
||||
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
|
||||
|
||||
|
|
@ -947,7 +947,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events)
|
|||
* zoom and scroll into account).
|
||||
*/
|
||||
|
||||
tx = trackview.editor().frame_to_unit_unrounded (tx);
|
||||
tx = trackview.editor().frame_to_pixel_unrounded (tx);
|
||||
|
||||
/* convert from canonical view height (0..1.0) to actual
|
||||
* height coordinates (using X11's top-left rooted system)
|
||||
|
|
|
|||
|
|
@ -2833,12 +2833,12 @@ Editor::snap_to_internal (framepos_t& start, int32_t direction, bool for_mark)
|
|||
case SnapMagnetic:
|
||||
|
||||
if (presnap > start) {
|
||||
if (presnap > (start + unit_to_frame(snap_threshold))) {
|
||||
if (presnap > (start + pixel_to_frame(snap_threshold))) {
|
||||
start = presnap;
|
||||
}
|
||||
|
||||
} else if (presnap < start) {
|
||||
if (presnap < (start - unit_to_frame(snap_threshold))) {
|
||||
if (presnap < (start - pixel_to_frame(snap_threshold))) {
|
||||
start = presnap;
|
||||
}
|
||||
}
|
||||
|
|
@ -4400,7 +4400,7 @@ Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_men
|
|||
EditPoint ep = _edit_point;
|
||||
|
||||
if (from_context_menu && (ep == EditAtMouse)) {
|
||||
return event_frame (&context_click_event, 0, 0);
|
||||
return window_event_frame (&context_click_event, 0, 0);
|
||||
}
|
||||
|
||||
if (entered_marker) {
|
||||
|
|
|
|||
|
|
@ -220,24 +220,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
void separate_regions_using_location (ARDOUR::Location&);
|
||||
void transition_to_rolling (bool forward);
|
||||
|
||||
/* undo related */
|
||||
|
||||
framepos_t unit_to_frame (double unit) const {
|
||||
return (framepos_t) rint (unit * frames_per_pixel);
|
||||
}
|
||||
|
||||
double frame_to_unit (framepos_t frame) const {
|
||||
return rint ((double) frame / (double) frames_per_pixel);
|
||||
}
|
||||
|
||||
double frame_to_unit_unrounded (framepos_t frame) const {
|
||||
return frame / frames_per_pixel;
|
||||
}
|
||||
|
||||
double frame_to_unit (double frame) const {
|
||||
return rint (frame / frames_per_pixel);
|
||||
}
|
||||
|
||||
/* NOTE: these functions assume that the "pixel" coordinate is
|
||||
the result of using the world->canvas affine transform on a
|
||||
world coordinate. These coordinates already take into
|
||||
|
|
@ -260,8 +242,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
}
|
||||
}
|
||||
|
||||
gulong frame_to_pixel (framepos_t frame) const {
|
||||
return (gulong) rint (frame / frames_per_pixel);
|
||||
double frame_to_pixel (framepos_t frame) const {
|
||||
return rint (frame / frames_per_pixel);
|
||||
}
|
||||
|
||||
double frame_to_pixel_unrounded (framepos_t frame) const {
|
||||
return frame / frames_per_pixel;
|
||||
}
|
||||
|
||||
void flush_canvas ();
|
||||
|
|
@ -1885,7 +1871,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
|
||||
void duplicate_range (bool with_dialog);
|
||||
|
||||
framepos_t event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
|
||||
/** computes the timeline frame (sample) of an event whose coordinates
|
||||
* are in canvas units (pixels, scroll offset included).
|
||||
*/
|
||||
framepos_t canvas_event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
|
||||
|
||||
/** computes the timeline frame (sample) of an event whose coordinates
|
||||
* are in window units (pixels, no scroll offset).
|
||||
*/
|
||||
framepos_t window_event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
|
||||
|
||||
/* returns false if mouse pointer is not in track or marker canvas
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -422,8 +422,6 @@ Editor::drop_paths (const RefPtr<Gdk::DragContext>& context,
|
|||
vector<string> paths;
|
||||
GdkEvent ev;
|
||||
framepos_t frame;
|
||||
double wx;
|
||||
double wy;
|
||||
double cy;
|
||||
|
||||
if (convert_drop_to_paths (paths, context, x, y, data, info, time) == 0) {
|
||||
|
|
@ -431,13 +429,11 @@ Editor::drop_paths (const RefPtr<Gdk::DragContext>& context,
|
|||
/* D-n-D coordinates are window-relative, so convert to "world" coordinates
|
||||
*/
|
||||
|
||||
_track_canvas_viewport->window_to_canvas (x, y, wx, wy);
|
||||
|
||||
ev.type = GDK_BUTTON_RELEASE;
|
||||
ev.button.x = wx;
|
||||
ev.button.y = wy;
|
||||
ev.button.x = x;
|
||||
ev.button.y = y;
|
||||
|
||||
frame = event_frame (&ev, 0, &cy);
|
||||
frame = window_event_frame (&ev, 0, &cy);
|
||||
|
||||
snap_to (frame);
|
||||
|
||||
|
|
@ -916,7 +912,7 @@ Editor::update_canvas_now ()
|
|||
double
|
||||
Editor::horizontal_position () const
|
||||
{
|
||||
return frame_to_unit (leftmost_frame);
|
||||
return frame_to_pixel (leftmost_frame);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1003,8 +1003,6 @@ Editor::canvas_note_event (GdkEvent *event, ArdourCanvas::Item* item)
|
|||
bool
|
||||
Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context, int x, int y, guint time)
|
||||
{
|
||||
ArdourCanvas::Coord wx;
|
||||
ArdourCanvas::Coord wy;
|
||||
boost::shared_ptr<Region> region;
|
||||
boost::shared_ptr<Region> region_copy;
|
||||
RouteTimeAxisView* rtav;
|
||||
|
|
@ -1018,15 +1016,13 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
|
|||
return false;
|
||||
}
|
||||
|
||||
_track_canvas_viewport->window_to_canvas (x, y, wx, wy);
|
||||
|
||||
event.type = GDK_MOTION_NOTIFY;
|
||||
event.button.x = wx;
|
||||
event.button.y = wy;
|
||||
event.button.x = x;
|
||||
event.button.y = y;
|
||||
/* assume we're dragging with button 1 */
|
||||
event.motion.state = Gdk::BUTTON1_MASK;
|
||||
|
||||
(void) event_frame (&event, &px, &py);
|
||||
(void) window_event_frame (&event, &px, &py);
|
||||
|
||||
std::pair<TimeAxisView*, int> const tv = trackview_by_y_position (py);
|
||||
bool can_drop = false;
|
||||
|
|
@ -1096,8 +1092,6 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
|
|||
const SelectionData& /*data*/,
|
||||
guint /*info*/, guint /*time*/)
|
||||
{
|
||||
double wx;
|
||||
double wy;
|
||||
boost::shared_ptr<Region> region;
|
||||
boost::shared_ptr<Region> region_copy;
|
||||
RouteTimeAxisView* rtav;
|
||||
|
|
@ -1105,15 +1099,13 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
|
|||
double px;
|
||||
double py;
|
||||
|
||||
_track_canvas_viewport->window_to_canvas (x, y, wx, wy);
|
||||
|
||||
event.type = GDK_MOTION_NOTIFY;
|
||||
event.button.x = wx;
|
||||
event.button.y = wy;
|
||||
event.button.x = x;
|
||||
event.button.y = y;
|
||||
/* assume we're dragging with button 1 */
|
||||
event.motion.state = Gdk::BUTTON1_MASK;
|
||||
|
||||
framepos_t const pos = event_frame (&event, &px, &py);
|
||||
framepos_t const pos = window_event_frame (&event, &px, &py);
|
||||
|
||||
std::pair<TimeAxisView*, int> const tv = trackview_by_y_position (py);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ EditorCursor::set_position (framepos_t frame)
|
|||
{
|
||||
PositionChanged (frame);
|
||||
|
||||
double const new_pos = _editor.frame_to_unit (frame);
|
||||
double const new_pos = _editor.frame_to_pixel (frame);
|
||||
|
||||
if (new_pos != _time_bars_canvas_item.x ()) {
|
||||
_time_bars_canvas_item.set_x (new_pos);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ DragManager::start_grab (GdkEvent* e, Gdk::Cursor* c)
|
|||
_old_follow_playhead = _editor->follow_playhead ();
|
||||
_editor->set_follow_playhead (false);
|
||||
|
||||
_current_pointer_frame = _editor->event_frame (e, &_current_pointer_x, &_current_pointer_y);
|
||||
_current_pointer_frame = _editor->canvas_event_frame (e, &_current_pointer_x, &_current_pointer_y);
|
||||
|
||||
for (list<Drag*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
|
||||
(*i)->start_grab (e, c);
|
||||
|
|
@ -165,7 +165,7 @@ DragManager::motion_handler (GdkEvent* e, bool from_autoscroll)
|
|||
{
|
||||
bool r = false;
|
||||
|
||||
_current_pointer_frame = _editor->event_frame (e, &_current_pointer_x, &_current_pointer_y);
|
||||
_current_pointer_frame = _editor->canvas_event_frame (e, &_current_pointer_x, &_current_pointer_y);
|
||||
|
||||
for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
|
||||
bool const t = (*i)->motion_handler (e, from_autoscroll);
|
||||
|
|
@ -232,7 +232,7 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
|
|||
_y_constrained = false;
|
||||
}
|
||||
|
||||
_raw_grab_frame = _editor->event_frame (event, &_grab_x, &_grab_y);
|
||||
_raw_grab_frame = _editor->canvas_event_frame (event, &_grab_x, &_grab_y);
|
||||
setup_pointer_frame_offset ();
|
||||
_grab_frame = adjusted_frame (_raw_grab_frame, event);
|
||||
_last_pointer_frame = _grab_frame;
|
||||
|
|
@ -1896,7 +1896,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
|
|||
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
||||
distance = _drags->current_pointer_x() - grab_x();
|
||||
len = ar->fade_in()->back()->when;
|
||||
new_length = len - _editor->unit_to_frame (distance);
|
||||
new_length = len - _editor->pixel_to_frame (distance);
|
||||
new_length = ar->verify_xfade_bounds (new_length, true /*START*/ );
|
||||
arv->reset_fade_in_shape_width (ar, new_length); //the grey shape
|
||||
}
|
||||
|
|
@ -1916,7 +1916,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
|
|||
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
||||
distance = grab_x() - _drags->current_pointer_x();
|
||||
len = ar->fade_out()->back()->when;
|
||||
new_length = len - _editor->unit_to_frame (distance);
|
||||
new_length = len - _editor->pixel_to_frame (distance);
|
||||
new_length = ar->verify_xfade_bounds (new_length, false /*END*/ );
|
||||
arv->reset_fade_out_shape_width (ar, new_length); //the grey shape
|
||||
}
|
||||
|
|
@ -1990,7 +1990,7 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
|
|||
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
||||
distance = _drags->current_pointer_x() - grab_x();
|
||||
len = ar->fade_in()->back()->when;
|
||||
new_length = len - _editor->unit_to_frame (distance);
|
||||
new_length = len - _editor->pixel_to_frame (distance);
|
||||
new_length = ar->verify_xfade_bounds (new_length, true /*START*/ );
|
||||
ar->set_fade_in_length(new_length);
|
||||
}
|
||||
|
|
@ -2007,7 +2007,7 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred)
|
|||
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
|
||||
distance = _drags->current_pointer_x() - grab_x();
|
||||
len = ar->fade_out()->back()->when;
|
||||
new_length = len - _editor->unit_to_frame (distance);
|
||||
new_length = len - _editor->pixel_to_frame (distance);
|
||||
new_length = ar->verify_xfade_bounds (new_length, false /*END*/ );
|
||||
ar->set_fade_out_length(new_length);
|
||||
}
|
||||
|
|
@ -2387,7 +2387,7 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
|
|||
|
||||
_grab_zoom = _editor->frames_per_pixel;
|
||||
|
||||
framepos_t where = _editor->event_frame (event, 0, 0);
|
||||
framepos_t where = _editor->canvas_event_frame (event, 0, 0);
|
||||
_editor->snap_to_with_modifier (where, event);
|
||||
|
||||
_editor->_dragging_playhead = true;
|
||||
|
|
@ -3140,7 +3140,7 @@ ControlPointDrag::motion (GdkEvent* event, bool)
|
|||
cy = max (0.0, cy);
|
||||
cy = min ((double) _point->line().height(), cy);
|
||||
|
||||
framepos_t cx_frames = _editor->unit_to_frame (cx);
|
||||
framepos_t cx_frames = _editor->pixel_to_frame (cx);
|
||||
|
||||
if (!_x_constrained) {
|
||||
_editor->snap_to_with_modifier (cx_frames, event);
|
||||
|
|
@ -3150,7 +3150,7 @@ ControlPointDrag::motion (GdkEvent* event, bool)
|
|||
|
||||
float const fraction = 1.0 - (cy / _point->line().height());
|
||||
|
||||
_point->line().drag_motion (_editor->frame_to_unit_unrounded (cx_frames), fraction, false, _pushing, _final_index);
|
||||
_point->line().drag_motion (_editor->frame_to_pixel_unrounded (cx_frames), fraction, false, _pushing, _final_index);
|
||||
|
||||
_editor->verbose_cursor()->set_text (_point->line().get_verbose_cursor_string (fraction));
|
||||
}
|
||||
|
|
@ -4279,7 +4279,7 @@ frameoffset_t
|
|||
NoteDrag::total_dx () const
|
||||
{
|
||||
/* dx in frames */
|
||||
frameoffset_t const dx = _editor->unit_to_frame (_drags->current_pointer_x() - grab_x());
|
||||
frameoffset_t const dx = _editor->pixel_to_frame (_drags->current_pointer_x() - grab_x());
|
||||
|
||||
/* primary note time */
|
||||
frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ());
|
||||
|
|
@ -4319,7 +4319,7 @@ NoteDrag::motion (GdkEvent *, bool)
|
|||
int8_t const dy = total_dy ();
|
||||
|
||||
/* Now work out what we have to do to the note canvas items to set this new drag delta */
|
||||
double const tdx = _editor->frame_to_unit (dx) - _cumulative_dx;
|
||||
double const tdx = _editor->frame_to_pixel (dx) - _cumulative_dx;
|
||||
double const tdy = -dy * _note_height - _cumulative_dy;
|
||||
|
||||
if (tdx || tdy) {
|
||||
|
|
@ -4641,7 +4641,7 @@ PatchChangeDrag::motion (GdkEvent* ev, bool)
|
|||
f = min (f, r->last_frame ());
|
||||
|
||||
framecnt_t const dxf = f - grab_frame(); // permitted dx in frames
|
||||
double const dxu = _editor->frame_to_unit (dxf); // permitted fx in units
|
||||
double const dxu = _editor->frame_to_pixel (dxf); // permitted fx in units
|
||||
_patch_change->move (ArdourCanvas::Duple (dxu - _cumulative_dx, 0));
|
||||
_cumulative_dx = dxu;
|
||||
}
|
||||
|
|
@ -4905,7 +4905,7 @@ CrossfadeEdgeDrag::motion (GdkEvent*, bool)
|
|||
|
||||
/* how long should it be ? */
|
||||
|
||||
new_length = len + _editor->unit_to_frame (distance);
|
||||
new_length = len + _editor->pixel_to_frame (distance);
|
||||
|
||||
/* now check with the region that this is legal */
|
||||
|
||||
|
|
@ -4935,7 +4935,7 @@ CrossfadeEdgeDrag::finished (GdkEvent*, bool)
|
|||
len = ar->fade_out()->back()->when;
|
||||
}
|
||||
|
||||
new_length = ar->verify_xfade_bounds (len + _editor->unit_to_frame (distance), start);
|
||||
new_length = ar->verify_xfade_bounds (len + _editor->pixel_to_frame (distance), start);
|
||||
|
||||
_editor->begin_reversible_command ("xfade trim");
|
||||
ar->playlist()->clear_owned_changes ();
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@ Editor::markerview_drag_motion_callback(ArdourCanvas::Item*, GdkEvent* event)
|
|||
framepos_t pending_region_position ;
|
||||
framepos_t pointer_frame ;
|
||||
|
||||
pointer_frame = event_frame(event, &cx, &cy) ;
|
||||
pointer_frame = canvas_event_frame(event, &cx, &cy) ;
|
||||
|
||||
snap_to(pointer_frame) ;
|
||||
|
||||
|
|
@ -539,7 +539,7 @@ Editor::imageframe_drag_motion_callback(ArdourCanvas::Item*, GdkEvent* event)
|
|||
framepos_t pending_region_position;
|
||||
framepos_t pointer_frame;
|
||||
|
||||
pointer_frame = event_frame(event, &cx, &cy) ;
|
||||
pointer_frame = canvas_event_frame(event, &cx, &cy) ;
|
||||
|
||||
snap_to(pointer_frame) ;
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ Editor::imageframe_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent*
|
|||
|
||||
framepos_t start = 0 ;
|
||||
framepos_t end = 0 ;
|
||||
framepos_t pointer_frame = event_frame(event) ;
|
||||
framepos_t pointer_frame = canvas_event_frame(event) ;
|
||||
|
||||
// chekc th eposition of the item is not locked
|
||||
if(!ifv->get_position_locked()) {
|
||||
|
|
@ -765,7 +765,7 @@ Editor::imageframe_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* ev
|
|||
|
||||
framepos_t start = 0 ;
|
||||
framepos_t end = 0 ;
|
||||
framepos_t pointer_frame = event_frame(event) ;
|
||||
framepos_t pointer_frame = canvas_event_frame(event) ;
|
||||
framepos_t new_dur_val = 0 ;
|
||||
|
||||
snap_to(pointer_frame) ;
|
||||
|
|
@ -890,7 +890,7 @@ Editor::markerview_start_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent*
|
|||
|
||||
framepos_t start = 0 ;
|
||||
framepos_t end = 0 ;
|
||||
framepos_t pointer_frame = event_frame(event) ;
|
||||
framepos_t pointer_frame = canvas_event_frame(event) ;
|
||||
|
||||
// chekc th eposition of the item is not locked
|
||||
if(!mv->get_position_locked())
|
||||
|
|
@ -982,7 +982,7 @@ Editor::markerview_end_handle_trim_motion(ArdourCanvas::Item* item, GdkEvent* ev
|
|||
|
||||
framepos_t start = 0 ;
|
||||
framepos_t end = 0 ;
|
||||
framepos_t pointer_frame = event_frame(event) ;
|
||||
framepos_t pointer_frame = canvas_event_frame(event) ;
|
||||
framepos_t new_dur_val = 0 ;
|
||||
|
||||
snap_to(pointer_frame) ;
|
||||
|
|
|
|||
|
|
@ -102,86 +102,81 @@ Editor::mouse_frame (framepos_t& where, bool& in_track_canvas) const
|
|||
}
|
||||
|
||||
int x, y;
|
||||
double wx, wy;
|
||||
Gdk::ModifierType mask;
|
||||
Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->_track_canvas_viewport->get_window();
|
||||
Glib::RefPtr<const Gdk::Window> pointer_window;
|
||||
Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->_track_canvas->get_window();
|
||||
|
||||
if (!canvas_window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pointer_window = canvas_window->get_pointer (x, y, mask);
|
||||
Glib::RefPtr<const Gdk::Window> pointer_window = Gdk::Display::get_default()->get_window_at_pointer (x, y);
|
||||
|
||||
if (pointer_window == _track_canvas->get_window()) {
|
||||
wx = x;
|
||||
wy = y;
|
||||
in_track_canvas = true;
|
||||
} else {
|
||||
if (!pointer_window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pointer_window != canvas_window && pointer_window != _time_bars_canvas->get_window()) {
|
||||
in_track_canvas = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
in_track_canvas = true;
|
||||
|
||||
GdkEvent event;
|
||||
event.type = GDK_BUTTON_RELEASE;
|
||||
event.button.x = wx;
|
||||
event.button.y = wy;
|
||||
event.button.x = x;
|
||||
event.button.y = y;
|
||||
|
||||
where = window_event_frame (&event, 0, 0);
|
||||
|
||||
where = event_frame (&event, 0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
framepos_t
|
||||
Editor::event_frame (GdkEvent const * event, double* pcx, double* pcy) const
|
||||
Editor::window_event_frame (GdkEvent const * event, double* pcx, double* pcy) const
|
||||
{
|
||||
using ArdourCanvas::Duple;
|
||||
Duple d;
|
||||
double cx, cy;
|
||||
double x;
|
||||
double y;
|
||||
|
||||
if (pcx == 0) {
|
||||
pcx = &cx;
|
||||
}
|
||||
if (pcy == 0) {
|
||||
pcy = &cy;
|
||||
if (!gdk_event_get_coords (event, &x, &y)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*pcx = 0;
|
||||
*pcy = 0;
|
||||
|
||||
/* The event coordinates will be window coordinates and we need canvas
|
||||
* coordinates (units are pixels as with the window, but scrolling is taken into account)
|
||||
/* event coordinates are in window units, so convert to canvas
|
||||
* (i.e. account for scrolling)
|
||||
*/
|
||||
|
||||
switch (event->type) {
|
||||
case GDK_BUTTON_RELEASE:
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_2BUTTON_PRESS:
|
||||
case GDK_3BUTTON_PRESS:
|
||||
d = _track_canvas->window_to_canvas (Duple (event->button.x, event->button.y));
|
||||
ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (x, y));
|
||||
|
||||
if (pcx) {
|
||||
*pcx = d.x;
|
||||
}
|
||||
|
||||
if (pcy) {
|
||||
*pcy = d.y;
|
||||
break;
|
||||
case GDK_MOTION_NOTIFY:
|
||||
d = _track_canvas->window_to_canvas (Duple (event->motion.x, event->motion.y));
|
||||
*pcx = d.x;
|
||||
*pcy = d.y;
|
||||
break;
|
||||
case GDK_ENTER_NOTIFY:
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
d = _track_canvas->window_to_canvas (Duple (event->crossing.x, event->crossing.y));
|
||||
*pcx = d.x;
|
||||
*pcy = d.y;
|
||||
break;
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
// need to get pointer for this to work
|
||||
// d = _track_canvas->window_to_canvas (Duple (event->key.x, event->key.y));
|
||||
*pcx = 0;
|
||||
*pcy = 0;
|
||||
break;
|
||||
default:
|
||||
warning << string_compose (_("Editor::event_frame() used on unhandled event type %1"), event->type) << endmsg;
|
||||
break;
|
||||
}
|
||||
|
||||
return pixel_to_frame (d.x);
|
||||
}
|
||||
|
||||
framepos_t
|
||||
Editor::canvas_event_frame (GdkEvent const * event, double* pcx, double* pcy) const
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
|
||||
/* event coordinates are already in canvas units */
|
||||
|
||||
if (!gdk_event_get_coords (event, &x, &y)) {
|
||||
cerr << "!NO c COORDS for event type " << event->type << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pcx) {
|
||||
*pcx = x;
|
||||
}
|
||||
|
||||
if (pcy) {
|
||||
*pcy = y;
|
||||
}
|
||||
|
||||
/* note that pixel_to_frame() never returns less than zero, so even if the pixel
|
||||
|
|
@ -189,7 +184,7 @@ Editor::event_frame (GdkEvent const * event, double* pcx, double* pcy) const
|
|||
the frame location is always positive.
|
||||
*/
|
||||
|
||||
return pixel_to_frame (*pcx);
|
||||
return pixel_to_frame (x);
|
||||
}
|
||||
|
||||
Gdk::Cursor*
|
||||
|
|
@ -1086,7 +1081,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
_drags->set (new RegionCreateDrag (this, item, parent), event);
|
||||
} else {
|
||||
/* See if there's a region before the click that we can extend, and extend it if so */
|
||||
framepos_t const t = event_frame (event);
|
||||
framepos_t const t = canvas_event_frame (event);
|
||||
boost::shared_ptr<Region> prev = pl->find_next_region (t, End, -1);
|
||||
if (!prev) {
|
||||
_drags->set (new RegionCreateDrag (this, item, parent), event);
|
||||
|
|
@ -1124,7 +1119,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
boost::shared_ptr<Playlist> pl = t->playlist ();
|
||||
if (pl) {
|
||||
|
||||
boost::shared_ptr<Region> r = pl->top_region_at (event_frame (event));
|
||||
boost::shared_ptr<Region> r = pl->top_region_at (canvas_event_frame (event));
|
||||
if (r) {
|
||||
RegionView* rv = rtv->view()->find_view (r);
|
||||
clicked_selection = select_range (rv->region()->position(),
|
||||
|
|
@ -1316,9 +1311,9 @@ Editor::button_press_handler_2 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
|
||||
case MouseZoom:
|
||||
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
|
||||
temporal_zoom_to_frame (false, event_frame (event));
|
||||
temporal_zoom_to_frame (false, canvas_event_frame (event));
|
||||
} else {
|
||||
temporal_zoom_to_frame (true, event_frame(event));
|
||||
temporal_zoom_to_frame (true, canvas_event_frame(event));
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
|
|
@ -1411,7 +1406,7 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
|
|||
|
||||
//not rolling, range mode click + join_play_range : locate the PH here
|
||||
if ( !_drags->active () && !_session->transport_rolling() && ( effective_mouse_mode() == MouseRange ) && Config->get_always_play_range() ) {
|
||||
framepos_t where = event_frame (event, 0, 0);
|
||||
framepos_t where = canvas_event_frame (event, 0, 0);
|
||||
snap_to(where);
|
||||
_session->request_locate (where, false);
|
||||
}
|
||||
|
|
@ -1460,7 +1455,7 @@ Editor::button_release_dispatch (GdkEventButton* ev)
|
|||
bool
|
||||
Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
||||
{
|
||||
framepos_t where = event_frame (event, 0, 0);
|
||||
framepos_t where = canvas_event_frame (event, 0, 0);
|
||||
AutomationTimeAxisView* atv = 0;
|
||||
|
||||
if (pre_press_cursor) {
|
||||
|
|
|
|||
|
|
@ -1964,20 +1964,17 @@ Editor::unhide_ranges ()
|
|||
void
|
||||
Editor::insert_region_list_drag (boost::shared_ptr<Region> region, int x, int y)
|
||||
{
|
||||
double wx, wy;
|
||||
double cx, cy;
|
||||
framepos_t where;
|
||||
RouteTimeAxisView *rtv = 0;
|
||||
boost::shared_ptr<Playlist> playlist;
|
||||
|
||||
_track_canvas_viewport->window_to_canvas (x, y, wx, wy);
|
||||
|
||||
GdkEvent event;
|
||||
event.type = GDK_BUTTON_RELEASE;
|
||||
event.button.x = wx;
|
||||
event.button.y = wy;
|
||||
event.button.x = x;
|
||||
event.button.y = y;
|
||||
|
||||
where = event_frame (&event, &cx, &cy);
|
||||
where = window_event_frame (&event, &cx, &cy);
|
||||
|
||||
if (where < leftmost_frame || where > leftmost_frame + current_page_frames()) {
|
||||
/* clearly outside canvas area */
|
||||
|
|
@ -2009,19 +2006,16 @@ Editor::insert_region_list_drag (boost::shared_ptr<Region> region, int x, int y)
|
|||
void
|
||||
Editor::insert_route_list_drag (boost::shared_ptr<Route> route, int x, int y)
|
||||
{
|
||||
double wx, wy;
|
||||
double cx, cy;
|
||||
RouteTimeAxisView *dest_rtv = 0;
|
||||
RouteTimeAxisView *source_rtv = 0;
|
||||
|
||||
_track_canvas_viewport->window_to_canvas (x, y, wx, wy);
|
||||
|
||||
GdkEvent event;
|
||||
event.type = GDK_BUTTON_RELEASE;
|
||||
event.button.x = wx;
|
||||
event.button.y = wy;
|
||||
event.button.x = x;
|
||||
event.button.y = y;
|
||||
|
||||
event_frame (&event, &cx, &cy);
|
||||
window_event_frame (&event, &cx, &cy);
|
||||
|
||||
std::pair<TimeAxisView*, int> const tv = trackview_by_y_position (cy);
|
||||
if (tv.first == 0) {
|
||||
|
|
|
|||
|
|
@ -778,7 +778,7 @@ EditorSummary::set_editor_x (pair<double, double> x)
|
|||
|
||||
double const nx = (
|
||||
((x.second - x.first) / _x_scale) /
|
||||
_editor->frame_to_unit (_editor->current_page_frames())
|
||||
_editor->frame_to_pixel (_editor->current_page_frames())
|
||||
);
|
||||
|
||||
if (nx != _editor->get_current_zoom ()) {
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ Editor::update_video_timeline (bool flush)
|
|||
#if DEBUG
|
||||
framepos_t rightmost_frame = leftmost_frame + current_page_frames();
|
||||
std::cout << "VIDEO SCROLL: " << leftmost_frame << " -- " << rightmost_frame << std::endl;
|
||||
std::cout << "SCROLL UNITS: " << frame_to_unit(leftmost_frame) << " -- " << frame_to_unit(rightmost_frame)
|
||||
<< " = " << frame_to_unit(rightmost_frame) - frame_to_unit(leftmost_frame)
|
||||
std::cout << "SCROLL UNITS: " << frame_to_pixel(leftmost_frame) << " -- " << frame_to_pixel(rightmost_frame)
|
||||
<< " = " << frame_to_pixel(rightmost_frame) - frame_to_pixel(leftmost_frame)
|
||||
<< std::endl;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con
|
|||
}
|
||||
|
||||
frame_position = frame;
|
||||
unit_position = editor.frame_to_unit (frame);
|
||||
unit_position = editor.frame_to_pixel (frame);
|
||||
unit_position -= _shift;
|
||||
|
||||
group = new ArdourCanvas::Group (&parent, ArdourCanvas::Duple (unit_position, 0));
|
||||
|
|
@ -429,7 +429,7 @@ Marker::setup_name_display ()
|
|||
void
|
||||
Marker::set_position (framepos_t frame)
|
||||
{
|
||||
unit_position = editor.frame_to_unit (frame) - _shift;
|
||||
unit_position = editor.frame_to_pixel (frame) - _shift;
|
||||
group->set_x_position (unit_position);
|
||||
frame_position = frame;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,12 +198,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible {
|
|||
virtual void separate_region_from_selection () = 0;
|
||||
|
||||
virtual void transition_to_rolling (bool fwd) = 0;
|
||||
virtual framepos_t unit_to_frame (double unit) const = 0;
|
||||
virtual double frame_to_unit (framepos_t frame) const = 0;
|
||||
virtual double frame_to_unit (double frame) const = 0;
|
||||
virtual double frame_to_unit_unrounded (framepos_t frame) const = 0;
|
||||
virtual framepos_t pixel_to_frame (double pixel) const = 0;
|
||||
virtual gulong frame_to_pixel (framepos_t frame) const = 0;
|
||||
virtual double frame_to_pixel (framepos_t frame) const = 0;
|
||||
virtual double frame_to_pixel_unrounded (framepos_t frame) const = 0;
|
||||
virtual Selection& get_selection () const = 0;
|
||||
virtual Selection& get_cut_buffer () const = 0;
|
||||
virtual void track_mixer_selection () = 0;
|
||||
|
|
|
|||
|
|
@ -856,8 +856,8 @@ TimeAxisView::show_selection (TimeSelection& ts)
|
|||
|
||||
rect = get_selection_rect ((*i).id);
|
||||
|
||||
x1 = _editor.frame_to_unit (start);
|
||||
x2 = _editor.frame_to_unit (start + cnt - 1);
|
||||
x1 = _editor.frame_to_pixel (start);
|
||||
x2 = _editor.frame_to_pixel (start + cnt - 1);
|
||||
y2 = current_height();
|
||||
|
||||
rect->rect->set (ArdourCanvas::Rect (x1, 1, x2, y2));
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ VideoImageFrame::VideoImageFrame (PublicEditor& ed, ArdourCanvas::Group& parent,
|
|||
printf("New VideoImageFrame (%ix%i) %s - %s\n", w, h, vsurl.c_str(), vfn.c_str());
|
||||
#endif
|
||||
|
||||
unit_position = editor.frame_to_unit (frame_position);
|
||||
unit_position = editor.frame_to_pixel (frame_position);
|
||||
group = new ArdourCanvas::Group (_parent, ArdourCanvas::Duple(unit_position, 1.0));
|
||||
img_pixbuf = new ArdourCanvas::Pixbuf(group);
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ VideoImageFrame::~VideoImageFrame ()
|
|||
void
|
||||
VideoImageFrame::set_position (framepos_t frame)
|
||||
{
|
||||
double new_unit_position = editor.frame_to_unit (frame);
|
||||
double new_unit_position = editor.frame_to_pixel (frame);
|
||||
group->move (ArdourCanvas::Duple (new_unit_position - unit_position, 0.0));
|
||||
frame_position = frame;
|
||||
unit_position = new_unit_position;
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ VideoTimeLine::update_video_timeline()
|
|||
if (_session->timecode_frames_per_second() == 0 ) return;
|
||||
}
|
||||
|
||||
double frames_per_unit = editor->unit_to_frame(1.0);
|
||||
double frames_per_unit = editor->pixel_to_frame(1.0);
|
||||
framepos_t leftmost_frame = editor->leftmost_position();
|
||||
|
||||
/* Outline:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue