Fix vertical canvas autoscroll when dragging track heights. Fixes #3240.

git-svn-id: svn://localhost/ardour2/branches/3.0@7327 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-06-29 19:08:19 +00:00
parent bebeb5abec
commit 7898aabcaa
9 changed files with 38 additions and 19 deletions

View File

@ -384,7 +384,6 @@ Editor::Editor ()
for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) {
_global_port_matrix[*i] = 0;
}
allow_vertical_scroll = false;
no_save_visual = false;
resize_idle_id = -1;

View File

@ -447,6 +447,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void begin_reversible_command (std::string cmd_name);
void commit_reversible_command ();
DragManager* drags () const {
return _drags;
}
void maybe_autoscroll (bool, bool);
/* handy cursors for everyone to use */
static Gdk::Cursor* cross_hair_cursor;
@ -941,8 +947,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
int _scroll_callbacks;
double _canvas_width;
double _canvas_height;
double full_canvas_height;
double _canvas_height; ///< height of the visible area of the track canvas
double full_canvas_height; ///< full height of the canvas
bool track_canvas_map_handler (GdkEventAny*);
@ -1685,8 +1691,6 @@ public:
bool autoscroll_canvas ();
void start_canvas_autoscroll (int x, int y);
void stop_canvas_autoscroll ();
void maybe_autoscroll (GdkEventMotion*, bool);
bool allow_vertical_scroll;
/* trimming */
void point_trim (GdkEvent *, nframes64_t);

View File

@ -546,37 +546,35 @@ Editor::drop_regions (const RefPtr<Gdk::DragContext>& /*context*/,
}
void
Editor::maybe_autoscroll (GdkEventMotion* event, bool allow_vert)
Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert)
{
nframes64_t rightmost_frame = leftmost_frame + current_page_frames();
bool startit = false;
double ty = _drags->current_pointer_y() - get_trackview_group_vertical_offset ();
autoscroll_y = 0;
autoscroll_x = 0;
if (event->y < canvas_timebars_vsize && allow_vert) {
if (ty < canvas_timebars_vsize && allow_vert) {
autoscroll_y = -1;
startit = true;
} else if (event->y > _canvas_height) {
} else if (ty > _canvas_height && allow_vert) {
autoscroll_y = 1;
startit = true;
}
if (_drags->current_pointer_frame() > rightmost_frame) {
if (_drags->current_pointer_frame() > rightmost_frame && allow_horiz) {
if (rightmost_frame < max_frames) {
autoscroll_x = 1;
startit = true;
}
} else if (_drags->current_pointer_frame() < leftmost_frame) {
} else if (_drags->current_pointer_frame() < leftmost_frame && allow_horiz) {
if (leftmost_frame > 0) {
autoscroll_x = -1;
startit = true;
}
}
if (!allow_vertical_scroll) {
autoscroll_y = 0;
}
if ((autoscroll_x != last_autoscroll_x) || (autoscroll_y != last_autoscroll_y) || (autoscroll_x == 0 && autoscroll_y == 0)) {
stop_canvas_autoscroll ();
}
@ -739,7 +737,6 @@ Editor::start_canvas_autoscroll (int dx, int dy)
void
Editor::stop_canvas_autoscroll ()
{
if (autoscroll_timeout_tag >= 0) {
g_source_remove (autoscroll_timeout_tag);
autoscroll_timeout_tag = -1;

View File

@ -111,6 +111,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
current_stepping_trackview->step_height (false);
return true;
} else {
cout << "down line\n";
scroll_tracks_down_line ();
return true;
}

View File

@ -303,7 +303,7 @@ Drag::motion_handler (GdkEvent* event, bool from_autoscroll)
if (event->motion.state & Gdk::BUTTON1_MASK || event->motion.state & Gdk::BUTTON2_MASK) {
if (!from_autoscroll) {
_editor->maybe_autoscroll (&event->motion, allow_vertical_autoscroll ());
_editor->maybe_autoscroll (true, allow_vertical_autoscroll ());
}
motion (event, _move_threshold_passed != old_move_threshold_passed);

View File

@ -24,6 +24,7 @@
#include <gdk/gdk.h>
#include <stdint.h>
#include <bitset>
#include "ardour/types.h"

View File

@ -1038,9 +1038,6 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
if (pointer_window == track_canvas->get_bin_window()) {
track_canvas->window_to_world (x, y, wx, wy);
allow_vertical_scroll = true;
} else {
allow_vertical_scroll = false;
}
}

View File

@ -79,6 +79,7 @@ class MarkerTimeAxis;
class ImageFrameView;
class ImageFrameTimeAxis;
class MarkerView;
class DragManager;
/// Representation of the interface of the Editor class
@ -360,6 +361,10 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible {
virtual Gtkmm2ext::TearOff* mouse_mode_tearoff () const = 0;
virtual Gtkmm2ext::TearOff* tools_tearoff () const = 0;
virtual DragManager* drags () const = 0;
virtual void maybe_autoscroll (bool, bool) = 0;
virtual void stop_canvas_autoscroll () = 0;
/// Singleton instance, set up by Editor::Editor()
static PublicEditor* _instance;

View File

@ -52,6 +52,7 @@
#include "rgb_macros.h"
#include "utils.h"
#include "streamview.h"
#include "editor_drag.h"
#include "i18n.h"
@ -1242,6 +1243,7 @@ TimeAxisView::resizer_button_press (GdkEventButton* event)
bool
TimeAxisView::resizer_button_release (GdkEventButton*)
{
_editor.stop_canvas_autoscroll ();
_resize_drag_start = -1;
return true;
}
@ -1256,6 +1258,19 @@ bool
TimeAxisView::resizer_motion (GdkEventMotion* ev)
{
if (_resize_drag_start >= 0) {
/* (ab)use the DragManager to do autoscrolling; adjust the event coordinates
into the trackview space that DragManager::motion_handler is expecting,
and then fake a DragManager motion event so that when maybe_autoscroll
asks DragManager for the current pointer position it will get the correct
answers.
*/
int tx, ty;
resizer.translate_coordinates (*control_parent, ev->x, ev->y, tx, ty);
ev->y = ty + _editor.get_canvas_timebars_vsize ();
_editor.drags()->motion_handler ((GdkEvent *) ev, false);
_editor.maybe_autoscroll (false, true);
/* now do the actual TAV resize */
int32_t const delta = (int32_t) floor (ev->y_root - _resize_drag_start);
_editor.add_to_idle_resize (this, delta);
_resize_drag_start = ev->y_root;