mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-21 14:16:31 +01:00
make control_scroll handle wheel events properly
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2160 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
4c12c98e33
commit
cf90cfa4c1
2 changed files with 43 additions and 15 deletions
|
|
@ -23,6 +23,8 @@
|
|||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/none.hpp>
|
||||
|
||||
#include <sigc++/bind.h>
|
||||
|
||||
#include <pbd/convert.h>
|
||||
|
|
@ -175,7 +177,6 @@ check_adjustment (Gtk::Adjustment* adj)
|
|||
Editor::Editor ()
|
||||
:
|
||||
/* time display buttons */
|
||||
|
||||
minsec_label (_("Mins:Secs")),
|
||||
bbt_label (_("Bars:Beats")),
|
||||
smpte_label (_("Timecode")),
|
||||
|
|
@ -886,40 +887,62 @@ Editor::control_scroll (float fraction)
|
|||
}
|
||||
|
||||
double step = fraction * current_page_frames();
|
||||
nframes_t target;
|
||||
/*
|
||||
_control_scroll_target is an optional<T>
|
||||
|
||||
if ((fraction < 0.0f) && (session->transport_frame() < (nframes_t) fabs(step))) {
|
||||
target = 0;
|
||||
} else if ((fraction > 0.0f) && (max_frames - session->transport_frame() < step)) {
|
||||
target = (max_frames - (current_page_frames()*2)); // allow room for slop in where the PH is on the screen
|
||||
it acts like a pointer to an nframes_t, with a operator conversion to boolean
|
||||
to check that it has a value
|
||||
could possibly use playhead_cursor->current_frame to store
|
||||
the value and a boolean in the class to know when it's out of date
|
||||
*/
|
||||
if ( !_control_scroll_target )
|
||||
{
|
||||
_control_scroll_target = session->transport_frame();
|
||||
_dragging_playhead = true;
|
||||
}
|
||||
|
||||
if ((fraction < 0.0f) && (*_control_scroll_target < (nframes_t) fabs(step))) {
|
||||
*_control_scroll_target = 0;
|
||||
} else if ((fraction > 0.0f) && (max_frames - *_control_scroll_target < step)) {
|
||||
*_control_scroll_target = max_frames - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
|
||||
} else {
|
||||
target = (session->transport_frame() + (nframes_t) floor ((fraction * current_page_frames())));
|
||||
*_control_scroll_target += (nframes_t) floor (step);
|
||||
}
|
||||
|
||||
/* move visuals, we'll catch up with it later */
|
||||
|
||||
playhead_cursor->set_position (target);
|
||||
playhead_cursor->set_position (*_control_scroll_target);
|
||||
UpdateAllTransportClocks (*_control_scroll_target);
|
||||
|
||||
if (target > (current_page_frames() / 2)) {
|
||||
if (*_control_scroll_target > (current_page_frames() / 2)) {
|
||||
/* try to center PH in window */
|
||||
reset_x_origin (target - (current_page_frames()/2));
|
||||
reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
|
||||
} else {
|
||||
reset_x_origin (0);
|
||||
}
|
||||
|
||||
/* cancel the existing */
|
||||
/*
|
||||
Now we do a timeout to actually bring the session to the right place
|
||||
according to the playhead. This is to avoid reading disk buffers on every
|
||||
call to control_scroll, which is driven by ScrollTimeline and therefore
|
||||
probably by a control surface wheel which can generate lots of events.
|
||||
*/
|
||||
/* cancel the existing timeout */
|
||||
|
||||
control_scroll_connection.disconnect ();
|
||||
|
||||
/* add the next one */
|
||||
/* add the next timeout */
|
||||
|
||||
control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), target), 50);
|
||||
control_scroll_connection = Glib::signal_timeout().connect (bind (mem_fun (*this, &Editor::deferred_control_scroll), *_control_scroll_target), 250);
|
||||
}
|
||||
|
||||
bool
|
||||
Editor::deferred_control_scroll (nframes_t target)
|
||||
{
|
||||
session->request_locate (target);
|
||||
session->request_locate (*_control_scroll_target, session->transport_rolling());
|
||||
// reset for next stream
|
||||
_control_scroll_target = boost::none;
|
||||
_dragging_playhead = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
#include <string>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <libgnomecanvasmm/canvas.h>
|
||||
#include <libgnomecanvasmm/group.h>
|
||||
#include <libgnomecanvasmm/line.h>
|
||||
|
|
@ -350,6 +352,9 @@ class Editor : public PublicEditor
|
|||
ARDOUR::Session *session;
|
||||
bool constructed;
|
||||
|
||||
// to keep track of the playhead position for control_scroll
|
||||
boost::optional<nframes_t> _control_scroll_target;
|
||||
|
||||
PlaylistSelector* _playlist_selector;
|
||||
|
||||
void set_frames_per_unit (double);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue