mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 23:35:03 +01:00
changes to autoscroll behaviour. not perfect, but probably better
git-svn-id: svn://localhost/trunk/ardour2@533 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ce6c41c060
commit
b7757ddd70
4 changed files with 165 additions and 152 deletions
|
|
@ -568,15 +568,12 @@ else:
|
||||||
'gtk2_ardour'
|
'gtk2_ardour'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
surface_subdirs = []
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# always build the LGPL control protocol lib, since we link against it ourselves
|
# always build the LGPL control protocol lib, since we link against it ourselves
|
||||||
# ditto for generic MIDI
|
# ditto for generic MIDI
|
||||||
|
#
|
||||||
|
|
||||||
surface_subdirs += [ 'libs/surfaces/control_protocol', 'libs/surfaces/generic_midi' ]
|
surface_subdirs = [ 'libs/surfaces/control_protocol', 'libs/surfaces/generic_midi' ]
|
||||||
|
|
||||||
if env['SURFACES']:
|
if env['SURFACES']:
|
||||||
if have_libusb:
|
if have_libusb:
|
||||||
|
|
@ -859,7 +856,7 @@ env.AddPostAction (srcdist, Action ('rm -rf ' + str (File (env['DISTTREE']))))
|
||||||
for subdir in coredirs:
|
for subdir in coredirs:
|
||||||
SConscript (subdir + '/SConscript')
|
SConscript (subdir + '/SConscript')
|
||||||
|
|
||||||
for sublistdir in [subdirs, gtk_subdirs, surface_subdirs]:
|
for sublistdir in [ subdirs, gtk_subdirs, surface_subdirs ]:
|
||||||
for subdir in sublistdir:
|
for subdir in sublistdir:
|
||||||
SConscript (subdir + '/SConscript')
|
SConscript (subdir + '/SConscript')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -815,15 +815,6 @@ Editor::set_entered_track (TimeAxisView* tav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
|
||||||
Editor::left_track_canvas (GdkEventCrossing *ev)
|
|
||||||
{
|
|
||||||
set_entered_track (0);
|
|
||||||
set_entered_regionview (0);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::show_window ()
|
Editor::show_window ()
|
||||||
{
|
{
|
||||||
|
|
@ -2838,117 +2829,6 @@ Editor::setup_toolbar ()
|
||||||
toolbar_frame.add (toolbar_base);
|
toolbar_frame.add (toolbar_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
|
||||||
Editor::_autoscroll_canvas (void *arg)
|
|
||||||
{
|
|
||||||
return ((Editor *) arg)->autoscroll_canvas ();
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
Editor::autoscroll_canvas ()
|
|
||||||
{
|
|
||||||
jack_nframes_t new_frame;
|
|
||||||
bool keep_calling = true;
|
|
||||||
jack_nframes_t limit = max_frames - current_page_frames();
|
|
||||||
GdkEventMotion ev;
|
|
||||||
|
|
||||||
autoscroll_distance = current_page_frames() * 3 / 4;
|
|
||||||
|
|
||||||
if (autoscroll_direction < 0) {
|
|
||||||
if (leftmost_frame < autoscroll_distance) {
|
|
||||||
new_frame = 0;
|
|
||||||
} else {
|
|
||||||
new_frame = leftmost_frame - autoscroll_distance;
|
|
||||||
}
|
|
||||||
ev.x = drag_info.current_pointer_x - autoscroll_distance;
|
|
||||||
} else {
|
|
||||||
if (leftmost_frame > limit - autoscroll_distance) {
|
|
||||||
new_frame = limit;
|
|
||||||
} else {
|
|
||||||
new_frame = leftmost_frame + autoscroll_distance;
|
|
||||||
}
|
|
||||||
ev.x = drag_info.current_pointer_x + autoscroll_distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_frame != leftmost_frame) {
|
|
||||||
cerr << "move to " << new_frame << " which is " << autoscroll_distance << " away" << endl;
|
|
||||||
reposition_x_origin (new_frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now fake a motion event to get the object that is being dragged to move too */
|
|
||||||
|
|
||||||
ev.type = GDK_MOTION_NOTIFY;
|
|
||||||
ev.x = frame_to_unit (ev.x);
|
|
||||||
ev.y = frame_to_unit (drag_info.current_pointer_y);
|
|
||||||
motion_handler (drag_info.item, (GdkEvent*) &ev, drag_info.item_type, true);
|
|
||||||
|
|
||||||
if (new_frame == 0 || new_frame == limit) {
|
|
||||||
/* we are done */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
autoscroll_cnt++;
|
|
||||||
|
|
||||||
if (autoscroll_cnt == 1) {
|
|
||||||
|
|
||||||
/* connect the timeout so that we get called repeatedly */
|
|
||||||
|
|
||||||
autoscroll_timeout_tag = gtk_timeout_add (20, _autoscroll_canvas, this);
|
|
||||||
keep_calling = false;
|
|
||||||
|
|
||||||
} else if (autoscroll_cnt == 50) { /* 0.5 seconds */
|
|
||||||
|
|
||||||
/* after about a while, speed up a bit by changing the timeout interval */
|
|
||||||
|
|
||||||
autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/50.0f);
|
|
||||||
cerr << "change distance to " << autoscroll_distance << endl;
|
|
||||||
|
|
||||||
} else if (autoscroll_cnt == 75) { /* 1.0 seconds */
|
|
||||||
|
|
||||||
autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/20.0f);
|
|
||||||
cerr << "change distance to " << autoscroll_distance << endl;
|
|
||||||
|
|
||||||
} else if (autoscroll_cnt == 100) { /* 1.5 seconds */
|
|
||||||
|
|
||||||
/* after about another while, speed up by increasing the shift per callback */
|
|
||||||
|
|
||||||
autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/10.0f);
|
|
||||||
cerr << "change distance to " << autoscroll_distance << endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return keep_calling;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Editor::start_canvas_autoscroll (int dir)
|
|
||||||
{
|
|
||||||
if (!session) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_canvas_autoscroll ();
|
|
||||||
|
|
||||||
autoscroll_direction = dir;
|
|
||||||
autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/100.0);
|
|
||||||
autoscroll_cnt = 0;
|
|
||||||
|
|
||||||
/* do it right now, which will start the repeated callbacks */
|
|
||||||
|
|
||||||
autoscroll_canvas ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Editor::stop_canvas_autoscroll ()
|
|
||||||
{
|
|
||||||
if (autoscroll_timeout_tag >= 0) {
|
|
||||||
gtk_timeout_remove (autoscroll_timeout_tag);
|
|
||||||
autoscroll_timeout_tag = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Editor::convert_drop_to_paths (vector<ustring>& paths,
|
Editor::convert_drop_to_paths (vector<ustring>& paths,
|
||||||
const RefPtr<Gdk::DragContext>& context,
|
const RefPtr<Gdk::DragContext>& context,
|
||||||
|
|
|
||||||
|
|
@ -495,3 +495,162 @@ Editor::drop_regions (const RefPtr<Gdk::DragContext>& context,
|
||||||
context->drag_finish (true, false, time);
|
context->drag_finish (true, false, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Editor::maybe_autoscroll (GdkEvent* event)
|
||||||
|
{
|
||||||
|
jack_nframes_t rightmost_frame = leftmost_frame + current_page_frames();
|
||||||
|
jack_nframes_t frame = drag_info.current_pointer_frame;
|
||||||
|
bool startit = false;
|
||||||
|
|
||||||
|
static int last_autoscroll_direction = 0;
|
||||||
|
|
||||||
|
if (frame > rightmost_frame) {
|
||||||
|
|
||||||
|
if (rightmost_frame < max_frames) {
|
||||||
|
autoscroll_direction = 1;
|
||||||
|
startit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (frame < leftmost_frame) {
|
||||||
|
|
||||||
|
if (leftmost_frame > 0) {
|
||||||
|
autoscroll_direction = -1;
|
||||||
|
startit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (drag_info.last_pointer_frame > drag_info.current_pointer_frame) {
|
||||||
|
autoscroll_direction = -1;
|
||||||
|
} else {
|
||||||
|
autoscroll_direction = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (autoscroll_direction != last_autoscroll_direction) {
|
||||||
|
stop_canvas_autoscroll ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startit && autoscroll_timeout_tag < 0) {
|
||||||
|
start_canvas_autoscroll (autoscroll_direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
last_autoscroll_direction = autoscroll_direction;
|
||||||
|
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
Editor::_autoscroll_canvas (void *arg)
|
||||||
|
{
|
||||||
|
return ((Editor *) arg)->autoscroll_canvas ();
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
Editor::autoscroll_canvas ()
|
||||||
|
{
|
||||||
|
jack_nframes_t new_frame;
|
||||||
|
bool keep_calling = true;
|
||||||
|
jack_nframes_t limit = max_frames - current_page_frames();
|
||||||
|
GdkEventMotion ev;
|
||||||
|
jack_nframes_t target_frame;
|
||||||
|
|
||||||
|
if (autoscroll_direction < 0) {
|
||||||
|
if (leftmost_frame < autoscroll_distance) {
|
||||||
|
new_frame = 0;
|
||||||
|
} else {
|
||||||
|
new_frame = leftmost_frame - autoscroll_distance;
|
||||||
|
}
|
||||||
|
target_frame = drag_info.current_pointer_frame - autoscroll_distance;
|
||||||
|
} else {
|
||||||
|
if (leftmost_frame > limit - autoscroll_distance) {
|
||||||
|
new_frame = limit;
|
||||||
|
} else {
|
||||||
|
new_frame = leftmost_frame + autoscroll_distance;
|
||||||
|
}
|
||||||
|
target_frame = drag_info.current_pointer_frame + autoscroll_distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_frame != leftmost_frame) {
|
||||||
|
reposition_x_origin (new_frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now fake a motion event to get the object that is being dragged to move too */
|
||||||
|
|
||||||
|
ev.type = GDK_MOTION_NOTIFY;
|
||||||
|
ev.state &= Gdk::BUTTON1_MASK;
|
||||||
|
ev.x = frame_to_unit (target_frame);
|
||||||
|
ev.y = drag_info.current_pointer_y;
|
||||||
|
motion_handler (drag_info.item, (GdkEvent*) &ev, drag_info.item_type, true);
|
||||||
|
|
||||||
|
if (new_frame == 0 || new_frame == limit) {
|
||||||
|
/* we are done */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
autoscroll_cnt++;
|
||||||
|
|
||||||
|
if (autoscroll_cnt == 1) {
|
||||||
|
|
||||||
|
/* connect the timeout so that we get called repeatedly */
|
||||||
|
|
||||||
|
autoscroll_timeout_tag = gtk_timeout_add (20, _autoscroll_canvas, this);
|
||||||
|
keep_calling = false;
|
||||||
|
|
||||||
|
} else if (autoscroll_cnt == 50) { /* 0.5 seconds */
|
||||||
|
|
||||||
|
/* after about a while, speed up a bit by changing the timeout interval */
|
||||||
|
|
||||||
|
autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/50.0f);
|
||||||
|
|
||||||
|
} else if (autoscroll_cnt == 75) { /* 1.0 seconds */
|
||||||
|
|
||||||
|
autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/20.0f);
|
||||||
|
|
||||||
|
} else if (autoscroll_cnt == 100) { /* 1.5 seconds */
|
||||||
|
|
||||||
|
/* after about another while, speed up by increasing the shift per callback */
|
||||||
|
|
||||||
|
autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/10.0f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return keep_calling;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Editor::start_canvas_autoscroll (int dir)
|
||||||
|
{
|
||||||
|
if (!session) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_canvas_autoscroll ();
|
||||||
|
|
||||||
|
autoscroll_direction = dir;
|
||||||
|
autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/100.0);
|
||||||
|
autoscroll_cnt = 0;
|
||||||
|
|
||||||
|
/* do it right now, which will start the repeated callbacks */
|
||||||
|
|
||||||
|
autoscroll_canvas ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Editor::stop_canvas_autoscroll ()
|
||||||
|
{
|
||||||
|
if (autoscroll_timeout_tag >= 0) {
|
||||||
|
gtk_timeout_remove (autoscroll_timeout_tag);
|
||||||
|
autoscroll_timeout_tag = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
Editor::left_track_canvas (GdkEventCrossing *ev)
|
||||||
|
{
|
||||||
|
set_entered_track (0);
|
||||||
|
set_entered_regionview (0);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1104,28 +1104,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Editor::maybe_autoscroll (GdkEvent* event)
|
|
||||||
{
|
|
||||||
jack_nframes_t rightmost_frame = leftmost_frame + current_page_frames();
|
|
||||||
|
|
||||||
jack_nframes_t frame = drag_info.current_pointer_frame;
|
|
||||||
|
|
||||||
cerr << "maybe autoscroll @ " << frame << " left = " << leftmost_frame << " right = " << rightmost_frame << endl;
|
|
||||||
|
|
||||||
if (frame > rightmost_frame) {
|
|
||||||
if (rightmost_frame < max_frames) {
|
|
||||||
autoscroll_direction = 1;
|
|
||||||
autoscroll_canvas ();
|
|
||||||
}
|
|
||||||
} else if (frame < leftmost_frame) {
|
|
||||||
if (leftmost_frame > 0) {
|
|
||||||
autoscroll_direction = -1;
|
|
||||||
autoscroll_canvas ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
|
||||||
{
|
{
|
||||||
|
|
@ -1497,13 +1475,14 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item
|
||||||
&drag_info.current_pointer_y);
|
&drag_info.current_pointer_y);
|
||||||
|
|
||||||
if (!from_autoscroll && drag_info.item) {
|
if (!from_autoscroll && drag_info.item) {
|
||||||
/* item != 0 is the best test i can think of for
|
/* item != 0 is the best test i can think of for dragging.
|
||||||
dragging.
|
|
||||||
*/
|
*/
|
||||||
if (!drag_info.move_threshold_passsed) {
|
if (!drag_info.move_threshold_passsed) {
|
||||||
|
|
||||||
drag_info.move_threshold_passsed = (abs ((int) (drag_info.current_pointer_x - drag_info.grab_x)) > 4);
|
drag_info.move_threshold_passsed = (abs ((int) (drag_info.current_pointer_x - drag_info.grab_x)) > 4);
|
||||||
|
|
||||||
// and change the initial grab loc/frame if this drag info wants us to
|
// and change the initial grab loc/frame if this drag info wants us to
|
||||||
|
|
||||||
if (drag_info.want_move_threshold && drag_info.move_threshold_passsed) {
|
if (drag_info.want_move_threshold && drag_info.move_threshold_passsed) {
|
||||||
drag_info.grab_frame = drag_info.current_pointer_frame;
|
drag_info.grab_frame = drag_info.current_pointer_frame;
|
||||||
drag_info.grab_x = drag_info.current_pointer_x;
|
drag_info.grab_x = drag_info.current_pointer_x;
|
||||||
|
|
@ -2785,8 +2764,6 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
|
||||||
vector<int32_t> height_list(512) ;
|
vector<int32_t> height_list(512) ;
|
||||||
vector<int32_t>::iterator j;
|
vector<int32_t>::iterator j;
|
||||||
|
|
||||||
cerr << "region motion to " << drag_info.current_pointer_frame << endl;
|
|
||||||
|
|
||||||
/* Which trackview is this ? */
|
/* Which trackview is this ? */
|
||||||
|
|
||||||
TimeAxisView* tvp = trackview_by_y_position (drag_info.current_pointer_y);
|
TimeAxisView* tvp = trackview_by_y_position (drag_info.current_pointer_y);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue