summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-05-18 02:19:27 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-05-18 02:19:27 +0000
commit60fbeedb5f819b42fdca1f8175319aa2a9bca4c1 (patch)
tree53f2768aff3fa2d94d03b6a4c953f67b5141a0c2 /gtk2_ardour
parentb3b383faa5ca4e2a101314612d69b05184edc422 (diff)
a) basic prototype of OSC control
b) various changes to ControlProtocol model/implementation c) more attempts to get autoscroll to work nicely (unfinished) d) move editor item types into their own header git-svn-id: svn://localhost/trunk/ardour2@506 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/draginfo.h3
-rw-r--r--gtk2_ardour/editor.cc46
-rw-r--r--gtk2_ardour/editor.h53
-rw-r--r--gtk2_ardour/editor_mouse.cc54
4 files changed, 69 insertions, 87 deletions
diff --git a/gtk2_ardour/draginfo.h b/gtk2_ardour/draginfo.h
index 3db8bab1e8..a86f7362cc 100644
--- a/gtk2_ardour/draginfo.h
+++ b/gtk2_ardour/draginfo.h
@@ -5,6 +5,8 @@
#include <stdint.h>
#include "canvas.h"
+#include "editor_items.h"
+
#include <ardour/types.h>
namespace ARDOUR {
@@ -16,6 +18,7 @@ class TimeAxisView;
struct DragInfo {
ArdourCanvas::Item* item;
+ ItemType item_type;
void* data;
jack_nframes_t last_frame_position;
int32_t pointer_frame_offset;
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 2c6e981bd7..5df36c91b1 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -2844,6 +2844,10 @@ 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) {
@@ -2851,42 +2855,62 @@ Editor::autoscroll_canvas ()
} else {
new_frame = leftmost_frame - autoscroll_distance;
}
+ ev.x = drag_info.current_pointer_x - autoscroll_distance;
} else {
- if (leftmost_frame > max_frames - autoscroll_distance) {
- new_frame = max_frames;
+ 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);
}
- if (new_frame == 0 || new_frame == max_frames) {
+ /* 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;
}
+ return false;
+
autoscroll_cnt++;
if (autoscroll_cnt == 1) {
/* connect the timeout so that we get called repeatedly */
-
- autoscroll_timeout_tag = gtk_timeout_add (40, _autoscroll_canvas, this);
- } else if (autoscroll_cnt > 10 && autoscroll_cnt < 20) {
+ 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_timeout_tag = gtk_timeout_add (20, _autoscroll_canvas, this);
+ autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/50.0f);
+ cerr << "change distance to " << autoscroll_distance << endl;
- } else if (autoscroll_cnt >= 30) {
+ } 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 (0.5 * current_page_frames());
+ autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/10.0f);
+ cerr << "change distance to " << autoscroll_distance << endl;
}
@@ -2903,7 +2927,7 @@ Editor::start_canvas_autoscroll (int dir)
stop_canvas_autoscroll ();
autoscroll_direction = dir;
- autoscroll_distance = (jack_nframes_t) floor ((canvas_width * frames_per_unit)/50.0);
+ autoscroll_distance = (jack_nframes_t) floor (current_page_frames()/100.0);
autoscroll_cnt = 0;
/* do it right now, which will start the repeated callbacks */
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 8770c6c93f..91f2bc9810 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -53,6 +53,7 @@
#include "public_editor.h"
#include "editing.h"
#include "enums.h"
+#include "editor_items.h"
#include "region_selection.h"
#include "canvas.h"
#include "draginfo.h"
@@ -347,56 +348,6 @@ class Editor : public PublicEditor
PlaylistSelector* _playlist_selector;
- enum ItemType {
- RegionItem,
- StreamItem,
- PlayheadCursorItem,
- EditCursorItem,
- MarkerItem,
- MarkerBarItem,
- RangeMarkerBarItem,
- TransportMarkerBarItem,
- SelectionItem,
- GainControlPointItem,
- GainLineItem,
- GainAutomationControlPointItem,
- GainAutomationLineItem,
- PanAutomationControlPointItem,
- PanAutomationLineItem,
- RedirectAutomationControlPointItem,
- RedirectAutomationLineItem,
- MeterMarkerItem,
- TempoMarkerItem,
- MeterBarItem,
- TempoBarItem,
- AudioRegionViewNameHighlight,
- AudioRegionViewName,
- StartSelectionTrimItem,
- EndSelectionTrimItem,
- AutomationTrackItem,
- FadeInItem,
- FadeInHandleItem,
- FadeOutItem,
- FadeOutHandleItem,
-
- /* <CMT Additions> */
- MarkerViewItem,
- MarkerTimeAxisItem,
- MarkerViewHandleStartItem,
- MarkerViewHandleEndItem,
- ImageFrameItem,
- ImageFrameTimeAxisItem,
- ImageFrameHandleStartItem,
- ImageFrameHandleEndItem,
- /* </CMT Additions> */
-
- CrossfadeViewItem,
-
- /* don't remove this */
-
- NoItem
- };
-
void set_frames_per_unit (double);
void frames_per_unit_modified ();
@@ -861,7 +812,7 @@ class Editor : public PublicEditor
bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
- bool motion_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
+ bool motion_handler (ArdourCanvas::Item*, GdkEvent*, ItemType, bool from_autoscroll = false);
bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc
index 79053a2e52..21e99ae202 100644
--- a/gtk2_ardour/editor_mouse.cc
+++ b/gtk2_ardour/editor_mouse.cc
@@ -1107,26 +1107,23 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
void
Editor::maybe_autoscroll (GdkEvent* event)
{
- jack_nframes_t one_page = (jack_nframes_t) rint (canvas_width * frames_per_unit);
- jack_nframes_t rightmost_frame = leftmost_frame + one_page;
+ jack_nframes_t rightmost_frame = leftmost_frame + current_page_frames();
jack_nframes_t frame = drag_info.current_pointer_frame;
- if (autoscroll_timeout_tag < 0) {
- if (frame > rightmost_frame) {
- if (rightmost_frame < max_frames) {
- start_canvas_autoscroll (1);
- }
- } else if (frame < leftmost_frame) {
- if (leftmost_frame > 0) {
- start_canvas_autoscroll (-1);
- }
- }
- } else {
- if (frame >= leftmost_frame && frame < rightmost_frame) {
- stop_canvas_autoscroll ();
+ 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
@@ -1469,7 +1466,7 @@ Editor::left_automation_track ()
}
bool
-Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
+Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type, bool from_autoscroll)
{
gint x, y;
@@ -1495,10 +1492,11 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item
return true;
}
+ drag_info.item_type = item_type;
drag_info.current_pointer_frame = event_frame (event, &drag_info.current_pointer_x,
&drag_info.current_pointer_y);
- if (drag_info.item) {
+ if (!from_autoscroll && drag_info.item) {
/* item != 0 is the best test i can think of for
dragging.
*/
@@ -1544,12 +1542,14 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item
/* </CMT Additions> */
if (drag_info.item && (event->motion.state & Gdk::BUTTON1_MASK ||
(event->motion.state & Gdk::BUTTON2_MASK))) {
- maybe_autoscroll (event);
- (this->*(drag_info.motion_callback)) (item, event);
- goto handled;
- }
- goto not_handled;
-
+ if (!from_autoscroll) {
+ maybe_autoscroll (event);
+ }
+ (this->*(drag_info.motion_callback)) (item, event);
+ goto handled;
+ }
+ goto not_handled;
+
default:
break;
}
@@ -1561,7 +1561,9 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item
case MouseTimeFX:
if (drag_info.item && (event->motion.state & GDK_BUTTON1_MASK ||
(event->motion.state & GDK_BUTTON2_MASK))) {
- maybe_autoscroll (event);
+ if (!from_autoscroll) {
+ maybe_autoscroll (event);
+ }
(this->*(drag_info.motion_callback)) (item, event);
goto handled;
}
@@ -2770,6 +2772,8 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
vector<int32_t> height_list(512) ;
vector<int32_t>::iterator j;
+ cerr << "region motion to " << drag_info.current_pointer_frame << endl;
+
/* Which trackview is this ? */
TimeAxisView* tvp = trackview_by_y_position (drag_info.current_pointer_y);