openshot.code team mailing list archive
-
openshot.code team
-
Mailing list archive
-
Message #00043
[Branch ~openshot.code/openshot/main] Rev 536: Added a new feature to move the timeline / canvas when the middle mouse button is pressed and dra...
------------------------------------------------------------
revno: 536
fixes bug(s): https://launchpad.net/bugs/838600
committer: Jonathan Thomas <Jonathan.Oomph@xxxxxxxxx>
branch nick: openshot
timestamp: Thu 2011-09-01 01:16:50 -0500
message:
Added a new feature to move the timeline / canvas when the middle mouse button is pressed and dragged, similiar to other graphic programs.
modified:
openshot/classes/clip.py
openshot/windows/MainGTK.py
--
lp:openshot
https://code.launchpad.net/~openshot.code/openshot/main
Your team OpenShot Code is subscribed to branch lp:openshot.
To unsubscribe from this branch go to https://code.launchpad.net/~openshot.code/openshot/main/+edit-subscription
=== modified file 'openshot/classes/clip.py'
--- openshot/classes/clip.py 2011-09-01 04:24:58 +0000
+++ openshot/classes/clip.py 2011-09-01 06:16:50 +0000
@@ -1713,7 +1713,7 @@
""" This method initializes some variables needed for dragging and dropping a clip """
# raise the group up to the top level
item.raise_(None)
-
+
# set the x and y where the cursor started dragging from
self.drag_x = float(event.x)
self.drag_y = float(event.y)
@@ -2045,65 +2045,71 @@
(isArrow, isRazor, isSnap, isResize) = self.parent.parent.project.form.get_toolbar_options()
if isArrow:
-
- # get new parent track
- drop_track = self.get_valid_drop(item.get_bounds().x1, item.get_bounds().y1)
- # update clip's settings to reflect the new x, y position (and update the parent track)
- self.update(item.get_bounds().x1, item.get_bounds().y1, drop_track)
- drop_track.reorder_clips()
-
- # determine the direction of the drag
- if isSnap:
- distance_from_clip = self.get_snap_difference(self, item)
- else:
- distance_from_clip = 0.0
+ # only respond to the first mouse button
+ if event.button == 1:
- # check if clip has been really moved or not
- if ((self.stored_x == item.get_bounds().x1) and (self.stored_y == item.get_bounds().y1)):
- # The clip was not moved
- type_of_event = None
- else:
- # The clip has moved
- type_of_event = _("Moved clip")
-
- # Animate the clip to it's new position
- item.animate(distance_from_clip, drop_track.y_top - item.get_bounds().y1 + 2, 1.0, 0.0, False, 200, 4, goocanvas.ANIMATE_FREEZE)
-
- # move the clip object on the timeline to correct position (snapping to the y and x of the track)
- item.translate (distance_from_clip, drop_track.y_top - item.get_bounds().y1 + 2)
-
- # update clip's settings again (since the snapping could have moved them a bit)
+ # get new parent track
+ drop_track = self.get_valid_drop(item.get_bounds().x1, item.get_bounds().y1)
+
+ # update clip's settings to reflect the new x, y position (and update the parent track)
self.update(item.get_bounds().x1, item.get_bounds().y1, drop_track)
-
- # Mark clip as modified
- self.parent.parent.project.set_project_modified(is_modified=True, refresh_xml=True, type = type_of_event)
-
-
- if self.request_show_properties:
- self.show_properties(item, 0)
+ drop_track.reorder_clips()
+
+ # determine the direction of the drag
+ if isSnap:
+ distance_from_clip = self.get_snap_difference(self, item)
+ else:
+ distance_from_clip = 0.0
+
+ # check if clip has been really moved or not
+ if ((self.stored_x == item.get_bounds().x1) and (self.stored_y == item.get_bounds().y1)):
+ # The clip was not moved
+ type_of_event = None
+ else:
+ # The clip has moved
+ type_of_event = _("Moved clip")
+
+ # Animate the clip to it's new position
+ item.animate(distance_from_clip, drop_track.y_top - item.get_bounds().y1 + 2, 1.0, 0.0, False, 200, 4, goocanvas.ANIMATE_FREEZE)
+
+ # move the clip object on the timeline to correct position (snapping to the y and x of the track)
+ item.translate (distance_from_clip, drop_track.y_top - item.get_bounds().y1 + 2)
+
+ # update clip's settings again (since the snapping could have moved them a bit)
+ self.update(item.get_bounds().x1, item.get_bounds().y1, drop_track)
+
+ # Mark clip as modified
+ self.parent.parent.project.set_project_modified(is_modified=True, refresh_xml=True, type = type_of_event)
+
+
+ if self.request_show_properties:
+ self.show_properties(item, 0)
elif isResize:
- # remove clip from goocanvas
- parent = item.get_parent()
- child_num = parent.find_child (item)
- parent.remove_child (child_num)
-
- # Initialize variables
- pixels_per_second = self.parent.parent.get_pixels_per_second()
- center_of_clip = (self.position_on_track * pixels_per_second) + ((self.length() * pixels_per_second) / 2)
-
- # If the clip was dragged on the left side, update the thumbnail to reflect the changes
- if event.x_root < center_of_clip:
- self.update_thumbnail()
-
- # re-render the clip at it's new size
- self.RenderClip()
-
- # switch video window back to 'view' mode (i.e. remove preview clip mode)
- self.set_view_mode()
- self.parent.parent.project.set_project_modified(is_modified=True, refresh_xml=True, type = _("Resized clip"))
+ # only respond to the first mouse button
+ if event.button == 1:
+
+ # remove clip from goocanvas
+ parent = item.get_parent()
+ child_num = parent.find_child (item)
+ parent.remove_child (child_num)
+
+ # Initialize variables
+ pixels_per_second = self.parent.parent.get_pixels_per_second()
+ center_of_clip = (self.position_on_track * pixels_per_second) + ((self.length() * pixels_per_second) / 2)
+
+ # If the clip was dragged on the left side, update the thumbnail to reflect the changes
+ if event.x_root < center_of_clip:
+ self.update_thumbnail()
+
+ # re-render the clip at it's new size
+ self.RenderClip()
+
+ # switch video window back to 'view' mode (i.e. remove preview clip mode)
+ self.set_view_mode()
+ self.parent.parent.project.set_project_modified(is_modified=True, refresh_xml=True, type = _("Resized clip"))
# raise the play-head line, so it's not covered up
self.parent.parent.raise_transitions()
=== modified file 'openshot/windows/MainGTK.py'
--- openshot/windows/MainGTK.py 2011-09-01 03:59:41 +0000
+++ openshot/windows/MainGTK.py 2011-09-01 06:16:50 +0000
@@ -81,6 +81,11 @@
self.dragging = False
self.timeline_clip_y = 0
+ # variable for middle mouse clicking / dragging the timeline
+ self.is_timeline_scrolling = False
+ self.timeline_scroll_start_x = 0
+ self.timeline_scroll_start_y = 0
+
# Init Effects List
self.effect_list = effect.get_effects(self.project)
self.blender_list = effect.get_effects(self.project, self.project.BLENDER_DIR)
@@ -105,6 +110,9 @@
self.MyCanvas = goocanvas.Canvas()
self.MyCanvas.connect("scroll-event", self.on_scrolledwindow_Right_scroll_event)
+ self.MyCanvas.connect("motion-notify-event", self.on_scrolledwindow_Right_motion)
+ self.MyCanvas.connect("button-press-event", self.on_scrolledwindow_Right_press)
+ self.MyCanvas.connect("button-release-event", self.on_scrolledwindow_Right_release)
hboxTimeline.set_border_width(0)
self.MyCanvas.show()
@@ -115,6 +123,9 @@
self.TimelineCanvas_Right = goocanvas.Canvas()
self.TimelineCanvas_Right.connect("scroll-event", self.on_scrolledwindow_Right_scroll_event)
+ #self.TimelineCanvas_Right.connect("motion-notify-event", self.on_scrolledwindow_Right_motion)
+ #self.TimelineCanvas_Right.connect("button-press-event", self.on_scrolledwindow_Right_press)
+ #self.TimelineCanvas_Right.connect("button-release-event", self.on_scrolledwindow_Right_release)
self.TimelineCanvas_Right.show()
self.scrolled_win = self.scrolledwindow_Left
@@ -2597,12 +2608,47 @@
self.MyCanvas.scroll_to(horizontal_value, vertical_value)
self.MyCanvas_Left.scroll_to(0, vertical_value)
-
-
# Don't bubble up the scroll event. This prevents the scroll wheel from
# scrolling the individual canvas.
return True
+ def on_scrolledwindow_Right_motion(self, item, event, *args):
+ #print "on_scrolledwindow_Right_motion"
+
+ # Is the middle mouse button pressed?
+ if self.is_timeline_scrolling:
+
+ # determine how much to move the canvas
+ x_diff = self.timeline_scroll_start_x - event.x
+ y_diff = self.timeline_scroll_start_y - event.y
+
+ # Update vertical scrollbar value
+ vertical_scrollbar = self.vscrollbar2
+ vertical_value = vertical_scrollbar.get_value()
+ vertical_scrollbar.set_value(vertical_value + y_diff)
+
+ # Update horizontal scrollbar value
+ horizontal_scrollbar = self.hscrollbar2
+ horizontal_value = horizontal_scrollbar.get_value()
+ horizontal_scrollbar.set_value(horizontal_value + x_diff)
+
+ return False
+
+ def on_scrolledwindow_Right_press(self, item, event, *args):
+ # toggle timeline dragging ON
+ if event.button == 2:
+ self.is_timeline_scrolling = True
+ self.timeline_scroll_start_x = event.x
+ self.timeline_scroll_start_y = event.y
+
+ return False
+
+ def on_scrolledwindow_Right_release(self, item, event, *args):
+ # toggle timeline dragging OFF
+ if event.button == 2:
+ self.is_timeline_scrolling = False
+
+ return False
def on_vscrollbar2_value_changed(self, widget, *args):