Insert and Remove Channel
This commit is contained in:
@@ -204,6 +204,9 @@ class VSETB_OT_remove_template(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
classes = (
|
||||
VSETB_OT_reload_addon,
|
||||
VSETB_OT_load_settings,
|
||||
|
||||
+88
-1
@@ -2,7 +2,7 @@ from os.path import expandvars, abspath
|
||||
from pathlib import Path
|
||||
import bpy
|
||||
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,
|
||||
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)
|
||||
|
||||
|
||||
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):
|
||||
"""Toggle Split sequencer view"""
|
||||
|
||||
@@ -530,6 +615,8 @@ classes = (
|
||||
VSETB_OT_next_shot,
|
||||
VSETB_OT_open_strip_folder,
|
||||
VSETB_OT_collect_files,
|
||||
VSETB_OT_insert_channel,
|
||||
VSETB_OT_remove_channel,
|
||||
WM_OT_split_view
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user