← Back to team overview

openshot.code team mailing list archive

[Branch ~openshot.code/openshot/main] Rev 663: Removed some duplicated code - is_valid_drop & get_valid_drop are exactly the same, so changed th...

 

------------------------------------------------------------
revno: 663
committer: Andy Finch <we.rocked.in79@xxxxxxxxx>
branch nick: openshot
timestamp: Sun 2012-05-06 21:50:56 +0100
message:
  Removed some duplicated code - is_valid_drop & get_valid_drop are exactly the same, so changed the few calls to is_valid_drop with get_valid_drop.
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	2012-05-01 22:21:32 +0000
+++ openshot/classes/clip.py	2012-05-06 20:50:56 +0000
@@ -1570,7 +1570,7 @@
 					total_x_diff = 0.0 - float(item.get_bounds().x1)
 
 				# be sure that the clip is being dragged over a valid drop target (i.e. a track)
-				if self.is_valid_drop(item.get_bounds().x1 + total_x_diff, item.get_bounds().y1 + total_y_diff):
+				if self.get_valid_drop(item.get_bounds().x1 + total_x_diff, item.get_bounds().y1 + total_y_diff):
 					# mark project as modified
 					self.parent.parent.project.set_project_modified(is_modified=True, refresh_xml=True)
 
@@ -2140,30 +2140,7 @@
 		# reset the cursor
 		self.parent.parent.project.form.MyCanvas.window.set_cursor(None)
 
-
-
-	def is_valid_drop(self, x1, y1):
-		""" Check to see if the current position is a valid drop position """
-
-		# loop through each track
-		for track in self.parent.parent.tracks:
-
-			# get the top y and bottom y of each track
-			y_top = track.y_top
-			y_bottom = track.y_bottom
-
-			# get the middle of the clip
-			half_height_of_clip = 26
-			middle_position = half_height_of_clip + y1
-
-			# determine if middle of clip is contained inside this track
-			if middle_position > y_top and middle_position < y_bottom:
-				return True
-
-		# return false if no valid track found
-		return False
-
-
+	
 	def get_valid_drop(self, x1, y1):
 		""" A clip must be dropped on a track.  This method returns the track 
 		object that is under the clip's current position """

=== modified file 'openshot/windows/MainGTK.py'
--- openshot/windows/MainGTK.py	2012-05-01 21:07:11 +0000
+++ openshot/windows/MainGTK.py	2012-05-06 20:50:56 +0000
@@ -1252,7 +1252,7 @@
 				total_x_diff = 0 - self.new_clip.get_bounds().x1
 			
 			# be sure that the clip is being dragged over a valid drop target (i.e. a track)
-			if self.new_clip_object.is_valid_drop(self.new_clip.get_bounds().x1 + total_x_diff, self.new_clip.get_bounds().y1 + new_y - 25):
+			if self.new_clip_object.get_valid_drop(self.new_clip.get_bounds().x1 + total_x_diff, self.new_clip.get_bounds().y1 + new_y - 25):
 
 				# move the clip based on the event data
 				self.new_clip.translate (total_x_diff, new_y - 25)