more use of int64_t to fix frame offset values

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@1931 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-05-30 17:46:33 +00:00
parent 1493c901e9
commit 1fedefc785
6 changed files with 40 additions and 44 deletions

View file

@ -39,11 +39,11 @@ struct DragInfo {
ArdourCanvas::Item* item;
ItemType item_type;
void* data;
nframes_t last_frame_position;
int64_t pointer_frame_offset;
nframes_t grab_frame;
nframes_t last_pointer_frame;
nframes_t current_pointer_frame;
nframes64_t last_frame_position;
nframes64_t pointer_frame_offset;
nframes64_t grab_frame;
nframes64_t last_pointer_frame;
nframes64_t current_pointer_frame;
double grab_x, grab_y;
double cumulative_x_drag;
double cumulative_y_drag;

View file

@ -2236,7 +2236,7 @@ Editor::trackview_by_y_position (double y)
}
void
Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
{
Location* before = 0;
Location* after = 0;
@ -2245,11 +2245,11 @@ Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
return;
}
const nframes_t one_second = session->frame_rate();
const nframes_t one_minute = session->frame_rate() * 60;
const nframes_t one_smpte_second = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
nframes_t one_smpte_minute = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
nframes_t presnap = start;
const nframes64_t one_second = session->frame_rate();
const nframes64_t one_minute = session->frame_rate() * 60;
const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
nframes64_t presnap = start;
switch (snap_type) {
case SnapToFrame:

View file

@ -1288,7 +1288,14 @@ class Editor : public PublicEditor
void tempo_map_changed (ARDOUR::Change);
void redisplay_tempo (bool immediate_redraw);
void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false);
void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false) {
/* XXX remove this function when everything moves to 64 bit frame counts */
nframes64_t first64 = first;
snap_to (first64, direction, for_mark);
first = (nframes_t) first64;
}
uint32_t bbt_beat_subdivision;
/* toolbar */

View file

@ -1449,9 +1449,9 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item
*/
if (!drag_info.move_threshold_passed) {
bool x_threshold_passed = (abs ((int64_t) (drag_info.current_pointer_x - drag_info.grab_x)) > 4LL);
bool y_threshold_passed = (abs ((int64_t) (drag_info.current_pointer_y - drag_info.grab_y)) > 4LL);
bool x_threshold_passed = (abs ((nframes64_t) (drag_info.current_pointer_x - drag_info.grab_x)) > 4LL);
bool y_threshold_passed = (abs ((nframes64_t) (drag_info.current_pointer_y - drag_info.grab_y)) > 4LL);
drag_info.move_threshold_passed = (x_threshold_passed || y_threshold_passed);
// and change the initial grab loc/frame if this drag info wants us to
@ -1563,7 +1563,7 @@ Editor::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
drag_info.y_constrained = false;
}
drag_info.grab_frame = event_frame(event, &drag_info.grab_x, &drag_info.grab_y);
drag_info.grab_frame = event_frame (event, &drag_info.grab_x, &drag_info.grab_y);
drag_info.last_pointer_frame = drag_info.grab_frame;
drag_info.current_pointer_frame = drag_info.grab_frame;
drag_info.current_pointer_x = drag_info.grab_x;
@ -1814,10 +1814,9 @@ Editor::fade_out_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event
nframes_t pos;
nframes_t fade_length;
if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
}
else {
} else {
pos = 0;
}
@ -2062,8 +2061,7 @@ Editor::marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
nframes_t newframe;
if (drag_info.pointer_frame_offset <= drag_info.current_pointer_frame) {
newframe = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
}
else {
} else {
newframe = 0;
}
@ -2995,7 +2993,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
int32_t sync_dir;
pending_region_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
sync_offset = rv->region()->sync_offset (sync_dir);
sync_frame = rv->region()->adjust_to_sync (pending_region_position);
@ -3033,7 +3031,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
} else {
x_delta = -((double) (drag_info.last_frame_position - pending_region_position) / frames_per_unit);
}
drag_info.last_frame_position = pending_region_position;
} else {
@ -3057,6 +3055,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
return;
}
if (x_delta < 0) {
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
@ -3183,6 +3182,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
x_delta = max_frames - rv->region()->last_frame();
}
if (drag_info.first_move) {
/* hide any dependent views */

View file

@ -268,8 +268,7 @@ Editor::ruler_mouse_motion (GdkEventMotion* ev)
nframes_t where = leftmost_frame + pixel_to_frame (x);
/// ripped from maybe_autoscroll, and adapted to work here
nframes_t one_page = (nframes_t) rint (canvas_width * frames_per_unit);
nframes_t rightmost_frame = leftmost_frame + one_page;
nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
if (autoscroll_timeout_tag < 0) {
if (where > rightmost_frame) {
@ -728,12 +727,7 @@ Editor::update_just_smpte ()
return;
}
/* XXX Note the potential loss of accuracy here as we convert from
an uint32_t (or larger) to a float ... what to do ?
*/
nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
nframes_t rightmost_frame = leftmost_frame + page;
nframes_t rightmost_frame = leftmost_frame + current_page_frames();
if (ruler_shown[ruler_metric_smpte]) {
gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_smpte_ruler), leftmost_frame, rightmost_frame,
@ -750,17 +744,11 @@ Editor::update_fixed_rulers ()
return;
}
/* XXX Note the potential loss of accuracy here as we convert from
an uint32_t (or larger) to a float ... what to do ?
*/
nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
ruler_metrics[ruler_metric_smpte].units_per_pixel = frames_per_unit;
ruler_metrics[ruler_metric_frames].units_per_pixel = frames_per_unit;
ruler_metrics[ruler_metric_minsec].units_per_pixel = frames_per_unit;
rightmost_frame = leftmost_frame + page;
rightmost_frame = leftmost_frame + current_page_frames ();
/* these force a redraw, which in turn will force execution of the metric callbacks
to compute the relevant ticks to display.
@ -789,15 +777,10 @@ Editor::update_tempo_based_rulers ()
return;
}
/* XXX Note the potential loss of accuracy here as we convert from
an uint32_t (or larger) to a float ... what to do ?
*/
nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
ruler_metrics[ruler_metric_bbt].units_per_pixel = frames_per_unit;
if (ruler_shown[ruler_metric_bbt]) {
gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_bbt_ruler), leftmost_frame, leftmost_frame+page,
gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_bbt_ruler), leftmost_frame, leftmost_frame+current_page_frames(),
leftmost_frame, session->current_end_frame());
}
}

View file

@ -47,6 +47,12 @@ typedef int intptr_t;
typedef uint32_t nframes_t;
/* eventually, we'd like everything (including JACK) to
move to this. for now, its a dedicated type.
*/
typedef int64_t nframes64_t;
namespace ARDOUR {
class Source;