← Back to team overview

openshot.code team mailing list archive

[Branch ~openshot.code/openshot/main] Rev 690: When dragging a clip to another track, it is too easy to move it left or right. To constrain the ...

 

------------------------------------------------------------
revno: 690
fixes bug: https://launchpad.net/bugs/1047050
committer: Andy Finch <we.rocked.in79@xxxxxxxxx>
branch nick: openshot
timestamp: Thu 2012-09-06 22:06:48 +0100
message:
  When dragging a clip to another track, it is too easy to move it left or right. To constrain the vertical movement, hold down the 'ALT GR' key while dragging the clip. This will show an indication line that aligns with the starting position of the clip.
  
  The clip will snap to this line/ original starting position provided it is within a reasonable distnce of the line when the clip is released.
modified:
  openshot/classes/clip.py
  openshot/classes/sequences.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-23 14:58:02 +0000
+++ openshot/classes/clip.py	2012-09-06 21:06:48 +0000
@@ -1174,7 +1174,7 @@
 										      x = x + pixbuf_x,
 										      y = y)  
 					image2.set_data ("id", "small_middle")
-
+										
 					# Add a translucent blue rectangle
 					rec2 = goocanvas.Rect (parent = GroupClip,
 										   x = x + pixbuf_x,
@@ -1793,6 +1793,24 @@
 					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)
+					
+					if self.parent.parent.project.form._ALT == True:
+						
+						# show the clip x position indicator when dragging clips
+						theme = self.parent.parent.project.theme
+	
+						# Get theme settings
+						theme_settings = self.parent.parent.project.theme_settings.settings
+			
+						imgTrack_Track = gtk.image_new_from_file("%s/openshot/themes/%s/Track_Middle.png" % (self.parent.parent.project.form.openshot_path, theme))
+						imgTrack_Track_Height = imgTrack_Track.get_pixbuf().get_height()
+						Size_Of_Line = len(self.parent.parent.tracks) * imgTrack_Track_Height + (len(self.parent.parent.tracks) * theme_settings["track"]["padding"]) + 2
+						
+						self.parent.parent.snap_line.props.visibility = goocanvas.ITEM_VISIBLE
+						# the + 2 is to compensate for the initial -2 position to hide the line
+						self.parent.parent.snap_line.props.x = self.stored_x + 2 
+						self.parent.parent.snap_line.props.height = Size_Of_Line + theme_settings["timeline"]["ruler"]["playhead_line"]["length_offset"]
+						
 
 				if (event.state == gtk.gdk.CONTROL_MASK) or (event.state == gtk.gdk.CONTROL_MASK | gtk.gdk.MOD2_MASK):
 					self.request_show_properties = True
@@ -1848,6 +1866,7 @@
 		self.parent.parent.raise_transitions()
 		self.parent.parent.play_head.raise_(None)
 		self.parent.parent.play_head_line.raise_(None)
+		self.parent.parent.snap_line.raise_(None)
 
 		return False
 
@@ -2029,8 +2048,13 @@
 			distance_from_clip = distance_from_right_clip
 		elif distance_from_playhead != 0:
 			distance_from_clip = distance_from_playhead
-
-		# return the # of pixesl to snap the clip
+		
+		# return the # of pixels to snap the clip
+		if clip_object.parent.parent.project.form._ALT == True:
+			# snap to snap_line
+			if abs(self.stored_x - canvas_item.get_bounds().x1) <= 15:
+				distance_from_clip = (self.stored_x) - canvas_item.get_bounds().x1
+			
 		return distance_from_clip
 
 
@@ -2108,7 +2132,10 @@
 
 					# Mark clip as modified
 					self.parent.parent.project.set_project_modified(is_modified=True, refresh_xml=True, type = type_of_event)
-
+				
+				self.parent.parent.snap_line.props.visibility = goocanvas.ITEM_INVISIBLE
+				#self.parent.parent.project.form.lblStatus.set_label('')
+					
 
 				if self.request_show_properties:
 					self.show_properties(item, 0)

=== modified file 'openshot/classes/sequences.py'
--- openshot/classes/sequences.py	2012-01-09 13:38:31 +0000
+++ openshot/classes/sequences.py	2012-09-06 21:06:48 +0000
@@ -58,6 +58,7 @@
 		self.ruler_time = None
 		self.play_head_line = None
 		self.enable_animated_playhead = True
+		self.snap_line = None
 
 
 	def AddMarker(self, marker_name, position_on_track):
@@ -606,6 +607,17 @@
 				                  x = x + (imgTrack_PlayHead_Width / 2) * -1,
 				                  y = imgTrack_Ruler_Height - imgTrack_PlayHead_Height + y_top - 2)
 
+		GroupTrack3 = goocanvas.Group (parent = track_root_right)
+		self.snap_line = GroupTrack3
+		# add the snap indicator
+		snap_indicator = goocanvas.Rect(parent=GroupTrack3,
+		                                x=-2, 
+		                                y=0, 
+		                                width = 0.5,
+		                                height = Size_Of_Line + theme_settings["timeline"]["ruler"]["playhead_line"]["length_offset"],
+		                                line_width = theme_settings["timeline"]["ruler"]["playhead_line"]["line_width"],
+		                                stroke_color_rgba = 0x000fffff)
+		
 		# Connect signals to play head to allow drag and drop
 		GroupTrack.connect ("motion_notify_event", self.on_motion_notify_x)
 		GroupTrack.connect ("button_press_event", self.on_button_press_x)
@@ -901,6 +913,9 @@
 		# Check for missing DEBUG attribute (which means it's an old project format)
 		if 'enable_animated_playhead' not in state:
 			state['enable_animated_playhead'] = False
+			
+		if 'snap_line' not in state:
+			state['snap_line'] = None
 
 		# update the state object with new schema changes
 		self.__dict__.update(state)

=== modified file 'openshot/windows/MainGTK.py'
--- openshot/windows/MainGTK.py	2012-08-28 19:01:47 +0000
+++ openshot/windows/MainGTK.py	2012-09-06 21:06:48 +0000
@@ -66,6 +66,7 @@
 		self.import_files_dialog = None
 		self.import_image_seq_dialog = None
 		self._SHIFT = False
+		self._ALT = False
 		
 		# variable for file filtering
 		self.filter_category = "Show All"
@@ -2248,6 +2249,11 @@
 				#set the shift mode to true
 				self._SHIFT = True
 				return True
+			
+			# gtk.keysyms.Alt_R doesn't seem to be working, so use the actual keyname
+			elif keyname == 'iso_level3_shift':
+				self._ALT = True
+				return True
 				
 	def on_frmMain_key_release_event(self, widget, event):
 		keyname = str.lower(gtk.gdk.keyval_name(event.keyval))
@@ -2258,6 +2264,10 @@
 				# Release shift mode
 				self._SHIFT = False
 				return True
+			
+			elif keyname == 'iso_level3_shift':
+				self._ALT = False
+				return True
 		
 					
 	def toggle_mode(self):