openshot.code team mailing list archive
-
openshot.code team
-
Mailing list archive
-
Message #00596
[Branch ~openshot.code/openshot/main] Rev 702: Removed "stored_x" from the clip and transition classes, since it duplicates the drag_x and drag_...
------------------------------------------------------------
revno: 702
committer: Jonathan Thomas <Jonathan.Oomph@xxxxxxxxx>
branch nick: openshot
timestamp: Sun 2012-09-09 20:52:06 -0500
message:
Removed "stored_x" from the clip and transition classes, since it duplicates the drag_x and drag_y variables. Also, fixed some compatibility issues between OpenShot 1.4.2 OSP files. And, fixed a bug related to all this, with auto resizing transitions finding the wrong edge to snap to.
modified:
openshot/classes/clip.py
openshot/classes/transition.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 2012-09-10 00:29:58 +0000
+++ openshot/classes/clip.py 2012-09-10 01:52:06 +0000
@@ -71,6 +71,10 @@
# init effects dictionary
self.effects = []
+
+ # init vars for drag n drop
+ self.drag_x = 0.0
+ self.drag_y = 0.0
# For example: imagine a clip that is 30 seconds long. If we wanted to only play a 10 second section (from 15 to 25
# second range) of this clip, and we wanted the 10 second section to start playing 3 seconds into the tracks timeline,
@@ -1804,8 +1808,6 @@
# change the cursor for the drag n drop operation
fleur = gtk.gdk.Cursor (gtk.gdk.FLEUR)
canvas = item.get_canvas ()
- self.stored_x = item.get_bounds().x1
- self.stored_y = item.get_bounds().y1
canvas.pointer_grab (item, gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_RELEASE_MASK, fleur, event.time)
@@ -2105,7 +2107,7 @@
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)):
+ if ((self.drag_x == item.get_bounds().x1) and (self.drag_y == item.get_bounds().y1)):
# The clip was not moved
type_of_event = None
else:
@@ -2311,8 +2313,10 @@
state['video_fade_in_amount'] = 2.0
if 'video_fade_out_amount' not in state:
state['video_fade_out_amount'] = 2.0
- if 'stored_x' not in state:
- state['stored_x'] = 0.0
+ if 'drag_x' not in state:
+ state['drag_x'] = 0.0
+ if 'drag_y' not in state:
+ state['drag_y'] = 0.0
# update the state object with new schema changes
self.__dict__.update(state)
=== modified file 'openshot/classes/transition.py'
--- openshot/classes/transition.py 2012-09-10 00:29:58 +0000
+++ openshot/classes/transition.py 2012-09-10 01:52:06 +0000
@@ -41,18 +41,26 @@
# mask settings
self.type = type # transition or mask
self.mask_value = mask_value # 0.0 to 1.0
-
+
+ # init vars for drag n drop
+ self.drag_x = 0.0
+ self.drag_y = 0.0
#----------------------------------------------------------------------
def __setstate__(self, state):
""" This method is called when an OpenShot project file is un-pickled (i.e. opened). It can
- be used to update the structure of old clip classes, to make old project files compatable with
+ be used to update the structure of old classes, to make old project files compatable with
newer versions of OpenShot. """
# Check for missing DEBUG attribute (which means it's an old project format)
- if 'stored_x' not in state:
- state['stored_x'] = 0.0
-
+ if 'drag_x' not in state:
+ state['drag_x'] = 0.0
+ if 'drag_y' not in state:
+ state['drag_y'] = 0.0
+
+ # update the state object with new schema changes
+ self.__dict__.update(state)
+
def Render(self, exiting_item=None, x_offset = 0):
@@ -251,8 +259,6 @@
# change the cursor for the drag n drop operation
fleur = gtk.gdk.Cursor (gtk.gdk.FLEUR)
canvas = item.get_canvas ()
- self.stored_x = item.get_bounds().x1
- self.stored_y = item.get_bounds().y1
canvas.pointer_grab (item, gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_RELEASE_MASK, fleur, event.time)
# RESIZE MODE
@@ -261,8 +267,6 @@
# remember the original length and position before resizing starts
self.original_length = self.length
self.original_start_pos = self.position_on_track
- self.stored_x = item.get_bounds().x1
- self.stored_y = item.get_bounds().y1
# SNAP MODE
elif isSnap:
@@ -496,16 +500,15 @@
bottom_track = self.parent.parent.tracks[track_index + 1]
# get distance from nearby clips (to the Right)
- edges = [self.get_edge_of_clip(new_position_on_track, "right", self.parent, 10.0) * pixels_per_second]
+ edges = [self.get_edge_of_clip(new_position_on_track, "right", self.parent, 10.0)]
if bottom_track:
- edges.append(self.get_edge_of_clip(new_position_on_track, "right", bottom_track, 10.0) * pixels_per_second)
+ edges.append(self.get_edge_of_clip(new_position_on_track, "right", bottom_track, 10.0))
# Change length
- if sorted(edges)[0] > new_position_on_track + self.length:
- new_length = (sorted(edges)[0] - (new_position_on_track * pixels_per_second)) / pixels_per_second
- length_diff = new_length - self.length
-
- if distance_from_clip:
+ if sorted(edges)[0] > new_position_on_track:
+ new_length = sorted(edges)[0] - new_position_on_track
+
+ if distance_from_clip and self.length != new_length:
# re-render transition (at correct width)
self.length = new_length
@@ -528,7 +531,7 @@
self.parent.parent.project.form.MyCanvas.window.set_cursor(None)
# 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 and not isResize:
+ if self.drag_x == item.get_bounds().x1 and self.drag_y == item.get_bounds().y1 and not isResize:
type_of_event = None
elif isResize:
type_of_event = _("Resized transition")
@@ -676,7 +679,7 @@
next_edge = float(clip.position_on_track) + float(clip.length())
# if clip within 1 second distance
- if abs(current_position - next_edge) <= threashold:
+ if next_edge > current_position and abs(current_position - next_edge) <= threashold:
edge = next_edge
break