~nagos/openshot/nagos

« back to all changes in this revision

Viewing changes to openshot/windows/MainGTK.py

  • Committer: Jonathan Thomas
  • Date: 2010-02-03 06:15:51 UTC
  • Revision ID: jonathan@jonathan64-20100203061551-0xlytm6f1b5jc0v4
Added a new feature to quickly tile a set of overlapping
clips.  In the right click Layout menu > Show All is now 
an option.

It does all the math, and moves each overlapping clip to 
it's own "tile".  It works best if you use a perfect square
number of clips, for example 4, 9, 16, etc...

Show diffs side-by-side

added added

removed removed

Lines of Context:
2587
2587
                elif position_name == "mnu_center_1_4":
2588
2588
                        start.set_all(50.0, 50.0, 25.0, 25.0, None)
2589
2589
                        end.set_all(50.0, 50.0, 25.0, 25.0, None)
 
2590
                        
 
2591
                elif position_name == "mnu_show_all_stretch":
 
2592
                        # Show All Clips at the same time
 
2593
                        self.show_all_clips(stretch=True)
 
2594
                        
 
2595
                elif position_name == "mnu_show_all_nostretch":
 
2596
                        # Show All Clips at the same time
 
2597
                        self.show_all_clips(stretch=False)
2590
2598
 
2591
2599
                # update clip properties
2592
2600
                self.selected_clip.halign = halign
2594
2602
                
2595
2603
                # mark project as modified
2596
2604
                self.project.set_project_modified(is_modified=True, refresh_xml=True, type="Changed clip layout")
2597
 
                                
 
2605
                
 
2606
        def show_all_clips(self, stretch=False):
 
2607
                """ Show all clips  """
 
2608
                from math import sqrt
 
2609
                
 
2610
                # get starting position
 
2611
                start_position = self.selected_clip.position_on_track
 
2612
                available_clips = []
 
2613
                
 
2614
                # Get the number of clips that start near the start of this clip (on any track)
 
2615
                for track in self.project.sequences[0].tracks:
 
2616
                        # loop through clips
 
2617
                        for clip in track.clips:
 
2618
                                # only look at images, videos, and image sequences
 
2619
                                if clip.file_object.file_type in ["image", "video", "image sequence"]:
 
2620
                                        # only look at clips that start near this clip
 
2621
                                        if clip.position_on_track >= (start_position - 0.5) and clip.position_on_track <= (start_position + 0.5):
 
2622
                                                # add to list
 
2623
                                                available_clips.append(clip)
 
2624
                                                
 
2625
                # Get the number of rows
 
2626
                number_of_clips = len(available_clips)
 
2627
                number_of_rows = int(sqrt(number_of_clips))
 
2628
                max_clips_on_row = float(number_of_clips) / float(number_of_rows)
 
2629
                
 
2630
                # Determine how many clips per row
 
2631
                if max_clips_on_row > float(int(max_clips_on_row)):
 
2632
                        max_clips_on_row = int(max_clips_on_row + 1)
 
2633
                else:
 
2634
                        max_clips_on_row = int(max_clips_on_row)
 
2635
                        
 
2636
                # Calculate Height & Width
 
2637
                height = 100.0 / float(number_of_rows)
 
2638
                width = 100.0 / float(max_clips_on_row)
 
2639
                
 
2640
                clip_index = 0
 
2641
                
 
2642
                # Loop through each row of clips
 
2643
                for row in range(0, number_of_rows):
 
2644
 
 
2645
                        # Loop through clips on this row
 
2646
                        column_string = " - - - "
 
2647
                        for col in range(0, max_clips_on_row):
 
2648
                                if clip_index < number_of_clips:
 
2649
                                        # Calculate X & Y
 
2650
                                        X = float(col) * width
 
2651
                                        Y = float(row) * height
 
2652
                                        
 
2653
                                        # Modify clip layout settings
 
2654
                                        selected_clip = available_clips[clip_index]
 
2655
                                        selected_clip.halign = "centre"
 
2656
                                        selected_clip.valign = "centre"
 
2657
                                        
 
2658
                                        if stretch:
 
2659
                                                selected_clip.distort = True
 
2660
                                                selected_clip.fill = True
 
2661
                                        else:
 
2662
                                                selected_clip.distort = False
 
2663
                                                selected_clip.fill = True                                               
 
2664
                                        
 
2665
                                        start = selected_clip.keyframes["start"]
 
2666
                                        end = selected_clip.keyframes["end"]
 
2667
                                        start.set_all(height, width, X, Y, None)
 
2668
                                        end.set_all(height, width, X, Y, None)
 
2669
                        
 
2670
                                        # Increment Clip Index
 
2671
                                        clip_index += 1
 
2672
                
 
2673
                
2598
2674
                
2599
2675
                
2600
2676
class mnuClip(SimpleGladeApp):