Insert and Remove Channel
This commit is contained in:
		
							parent
							
								
									dbc92922b5
								
							
						
					
					
						commit
						a53ceaf134
					
				@ -204,6 +204,9 @@ class VSETB_OT_remove_template(Operator):
 | 
				
			|||||||
        return {'FINISHED'}
 | 
					        return {'FINISHED'}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
classes = (
 | 
					classes = (
 | 
				
			||||||
    VSETB_OT_reload_addon,
 | 
					    VSETB_OT_reload_addon,
 | 
				
			||||||
    VSETB_OT_load_settings,
 | 
					    VSETB_OT_load_settings,
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@ from os.path import expandvars, abspath
 | 
				
			|||||||
from pathlib import Path
 | 
					from pathlib import Path
 | 
				
			||||||
import bpy
 | 
					import bpy
 | 
				
			||||||
from bpy.types import Operator
 | 
					from bpy.types import Operator
 | 
				
			||||||
from bpy.props import (BoolProperty, StringProperty)
 | 
					from bpy.props import (BoolProperty, StringProperty, EnumProperty)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from vse_toolbox.sequencer_utils import (get_strips, rename_strips, set_channels,
 | 
					from vse_toolbox.sequencer_utils import (get_strips, rename_strips, set_channels,
 | 
				
			||||||
    get_channel_index, new_text_strip, get_strip_at, get_channel_name)
 | 
					    get_channel_index, new_text_strip, get_strip_at, get_channel_name)
 | 
				
			||||||
@ -412,6 +412,91 @@ class VSETB_OT_collect_files(Operator):
 | 
				
			|||||||
        return context.window_manager.invoke_props_dialog(self)
 | 
					        return context.window_manager.invoke_props_dialog(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class VSETB_OT_insert_channel(Operator):
 | 
				
			||||||
 | 
					    bl_idname = "vse_toolbox.insert_channel"
 | 
				
			||||||
 | 
					    bl_label = "Insert Channel"
 | 
				
			||||||
 | 
					    bl_description = "Insert a Channel bellow the active strip"
 | 
				
			||||||
 | 
					    bl_options = {"REGISTER", "UNDO"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @classmethod
 | 
				
			||||||
 | 
					    def poll(cls, context):
 | 
				
			||||||
 | 
					        return context.active_sequence_strip
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def execute(self, context):
 | 
				
			||||||
 | 
					        scn = context.scene
 | 
				
			||||||
 | 
					        channel_index = context.active_sequence_strip.channel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        strips = list(scn.sequence_editor.sequences)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for strip in sorted(strips, key=lambda x: x.channel, reverse=True):
 | 
				
			||||||
 | 
					            if strip.channel >= channel_index:
 | 
				
			||||||
 | 
					                strip.channel += 1
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        channels = {i: (c.name, c.lock, c.mute) for i, c in enumerate(scn.sequence_editor.channels)}
 | 
				
			||||||
 | 
					        for i in sorted(channels.keys()):
 | 
				
			||||||
 | 
					            channel = scn.sequence_editor.channels[i]
 | 
				
			||||||
 | 
					            #i = list(scn.sequence_editor.channels).index(i)
 | 
				
			||||||
 | 
					            prev_channel = channels.get(i-1)
 | 
				
			||||||
 | 
					            if i == channel_index:
 | 
				
			||||||
 | 
					                channel.name = "Channel"
 | 
				
			||||||
 | 
					                channel.lock = False
 | 
				
			||||||
 | 
					                channel.mute = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            elif i >= channel_index and prev_channel is not None:
 | 
				
			||||||
 | 
					                prev_name, prev_lock, prev_mute = prev_channel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                channel.name = prev_name
 | 
				
			||||||
 | 
					                if channel.lock != prev_lock:
 | 
				
			||||||
 | 
					                    channel.lock = prev_lock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if channel.mute != prev_mute:
 | 
				
			||||||
 | 
					                    channel.mute = prev_mute
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return {'FINISHED'}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class VSETB_OT_remove_channel(Operator):
 | 
				
			||||||
 | 
					    bl_idname = "vse_toolbox.remove_channel"
 | 
				
			||||||
 | 
					    bl_label = "Remove Channel"
 | 
				
			||||||
 | 
					    bl_description = "Remove Channel bellow the active strip"
 | 
				
			||||||
 | 
					    bl_options = {"REGISTER", "UNDO"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @classmethod
 | 
				
			||||||
 | 
					    def poll(cls, context):
 | 
				
			||||||
 | 
					        return context.active_sequence_strip
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def execute(self, context):
 | 
				
			||||||
 | 
					        scn = context.scene
 | 
				
			||||||
 | 
					        channel_index = context.active_sequence_strip.channel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if [s for s in scn.sequence_editor.sequences if s.channel == channel_index-1]:
 | 
				
			||||||
 | 
					            self.report({"WARNING"}, "Channel Bellow not empty")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        strips = list(scn.sequence_editor.sequences)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for strip in sorted(strips, key=lambda x: x.channel):
 | 
				
			||||||
 | 
					            if strip.channel >= channel_index:
 | 
				
			||||||
 | 
					                strip.channel -= 1
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        channels = {i: (c.name, c.lock, c.mute) for i, c in enumerate(scn.sequence_editor.channels)}
 | 
				
			||||||
 | 
					        for i in sorted(channels.keys(), reverse=True):
 | 
				
			||||||
 | 
					            channel = scn.sequence_editor.channels[i]
 | 
				
			||||||
 | 
					            #i = list(scn.sequence_editor.channels).index(i)
 | 
				
			||||||
 | 
					            prev_channel = channels.get(i+1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if i >= channel_index-1 and prev_channel is not None:
 | 
				
			||||||
 | 
					                prev_name, prev_lock, prev_mute = prev_channel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                channel.name = prev_name
 | 
				
			||||||
 | 
					                if channel.lock != prev_lock:
 | 
				
			||||||
 | 
					                    channel.lock = prev_lock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if channel.mute != prev_mute:
 | 
				
			||||||
 | 
					                    channel.mute = prev_mute
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return {'FINISHED'}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class WM_OT_split_view(Operator):
 | 
					class WM_OT_split_view(Operator):
 | 
				
			||||||
    """Toggle Split sequencer view"""
 | 
					    """Toggle Split sequencer view"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -530,6 +615,8 @@ classes = (
 | 
				
			|||||||
    VSETB_OT_next_shot,
 | 
					    VSETB_OT_next_shot,
 | 
				
			||||||
    VSETB_OT_open_strip_folder,
 | 
					    VSETB_OT_open_strip_folder,
 | 
				
			||||||
    VSETB_OT_collect_files,
 | 
					    VSETB_OT_collect_files,
 | 
				
			||||||
 | 
					    VSETB_OT_insert_channel,
 | 
				
			||||||
 | 
					    VSETB_OT_remove_channel,
 | 
				
			||||||
    WM_OT_split_view
 | 
					    WM_OT_split_view
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -160,7 +160,7 @@ class VSETB_PT_sequencer(VSETB_main, Panel):
 | 
				
			|||||||
    def draw_header_preset(self, context):
 | 
					    def draw_header_preset(self, context):
 | 
				
			||||||
        settings = get_scene_settings()
 | 
					        settings = get_scene_settings()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        audio_strips = get_strips('Audio')
 | 
					        audio_strips = [s for s in get_strips('Audio') if s.type == "SOUND"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        depress = any(s.show_waveform for s in audio_strips)
 | 
					        depress = any(s.show_waveform for s in audio_strips)
 | 
				
			||||||
        self.layout.operator('vse_toolbox.show_waveform', text="", icon="IPO_ELASTIC", depress=depress).enabled = not depress
 | 
					        self.layout.operator('vse_toolbox.show_waveform', text="", icon="IPO_ELASTIC", depress=depress).enabled = not depress
 | 
				
			||||||
@ -448,6 +448,10 @@ class VSETB_MT_main_menu(Menu):
 | 
				
			|||||||
        layout.operator("wm.split_view", icon="ARROW_LEFTRIGHT")
 | 
					        layout.operator("wm.split_view", icon="ARROW_LEFTRIGHT")
 | 
				
			||||||
        layout.operator('vse_toolbox.open_strip_folder', text='Open Strip Folder', icon='FILE_FOLDER')
 | 
					        layout.operator('vse_toolbox.open_strip_folder', text='Open Strip Folder', icon='FILE_FOLDER')
 | 
				
			||||||
        layout.operator('vse_toolbox.open_shot_on_tracker', text='Open Shot on Tracker', icon='URL')
 | 
					        layout.operator('vse_toolbox.open_shot_on_tracker', text='Open Shot on Tracker', icon='URL')
 | 
				
			||||||
 | 
					        layout.separator()
 | 
				
			||||||
 | 
					        layout.operator('vse_toolbox.insert_channel', text='Insert Channel', icon='TRIA_UP_BAR')
 | 
				
			||||||
 | 
					        layout.operator('vse_toolbox.remove_channel', text='Remove Channel', icon='TRIA_DOWN_BAR')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def draw_vse_toolbox_menu(self, context):
 | 
					def draw_vse_toolbox_menu(self, context):
 | 
				
			||||||
    self.layout.menu("VSETB_MT_main_menu")
 | 
					    self.layout.menu("VSETB_MT_main_menu")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user