Node Wrangler: do not add reroutes to unavailable outputs
[blender-addons.git] / storypencil / ui.py
blob3eecdc52b82b6ee78171f6b48444dc95c49f014f
1 # SPDX-FileCopyrightText: 2022-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 import bpy
7 from bpy.types import (
8 Menu,
9 Panel,
12 from .synchro import get_main_window, validate_sync, window_id
15 # ------------------------------------------------------
16 # Defines UI panel
17 # ------------------------------------------------------
18 # ------------------------------------------------------------------
19 # Define panel class for manual switch parameters.
20 # ------------------------------------------------------------------
21 class STORYPENCIL_PT_Settings(Panel):
22 bl_idname = "STORYPENCIL_PT_Settings"
23 bl_label = "Settings"
24 bl_space_type = 'SEQUENCE_EDITOR'
25 bl_region_type = 'UI'
26 bl_category = 'Storypencil'
28 @classmethod
29 def poll(cls, context):
30 if context.space_data.view_type != 'SEQUENCER':
31 return False
33 return True
35 # ------------------------------
36 # Draw UI
37 # ------------------------------
38 def draw(self, context):
39 layout = self.layout
40 layout.use_property_split = True
41 layout.use_property_decorate = False
44 class STORYPENCIL_PT_General(Panel):
45 bl_idname = "STORYPENCIL_PT_General"
46 bl_label = "General"
47 bl_space_type = 'SEQUENCE_EDITOR'
48 bl_region_type = 'UI'
49 bl_category = 'Storypencil'
50 bl_options = {'DEFAULT_CLOSED'}
51 bl_parent_id = "STORYPENCIL_PT_Settings"
53 @classmethod
54 def poll(cls, context):
55 if context.space_data.view_type != 'SEQUENCER':
56 return False
58 return True
60 # ------------------------------
61 # Draw UI
62 # ------------------------------
63 def draw(self, context):
64 layout = self.layout
65 layout.use_property_split = True
66 layout.use_property_decorate = False
67 scene = context.scene
69 setup_ready = scene.storypencil_main_workspace is not None
70 row = layout.row()
71 row.alert = not setup_ready
72 row.prop(scene, "storypencil_main_workspace", text="VSE Workspace")
74 row = layout.row()
75 if scene.storypencil_main_scene is None:
76 row.alert = True
77 row.prop(scene, "storypencil_main_scene", text="VSE Scene")
79 layout.separator()
81 row = layout.row()
82 if scene.storypencil_main_workspace and scene.storypencil_edit_workspace:
83 if scene.storypencil_main_workspace.name == scene.storypencil_edit_workspace.name:
84 row.alert = True
85 if scene.storypencil_edit_workspace is None:
86 row.alert = True
87 row.prop(scene, "storypencil_edit_workspace", text="Drawing Workspace")
90 class STORYPENCIL_PT_RenderPanel(Panel):
91 bl_label = "Render Strips"
92 bl_space_type = 'SEQUENCE_EDITOR'
93 bl_region_type = 'UI'
94 bl_category = 'Storypencil'
95 bl_parent_id = "STORYPENCIL_PT_Settings"
97 @classmethod
98 def poll(cls, context):
99 if context.space_data.view_type != 'SEQUENCER':
100 return False
102 return True
104 def draw(self, context):
105 layout = self.layout
106 layout.use_property_split = True
107 layout.use_property_decorate = False
109 scene = context.scene
110 settings = scene.render.image_settings
112 is_video = settings.file_format in {'FFMPEG', 'AVI_JPEG', 'AVI_RAW'}
113 row = layout.row()
114 if scene.storypencil_render_render_path is None:
115 row.alert = True
116 row.prop(scene, "storypencil_render_render_path")
118 row = layout.row()
119 row.prop(scene, "storypencil_render_onlyselected")
121 row = layout.row()
122 row.prop(scene.render.image_settings, "file_format")
124 if settings.file_format == 'FFMPEG':
125 row = layout.row()
126 row.prop(scene.render.ffmpeg, "format")
128 row = layout.row()
129 row.enabled = is_video
130 row.prop(scene.render.ffmpeg, "audio_codec")
132 row = layout.row()
133 row.prop(scene, "storypencil_add_render_strip")
135 row = layout.row()
136 row.enabled = scene.storypencil_add_render_strip
137 row.prop(scene, "storypencil_render_channel")
139 if not is_video:
140 row = layout.row()
141 row.prop(scene, "storypencil_render_step")
143 row = layout.row()
144 row.prop(scene, "storypencil_render_numbering")
146 row = layout.row()
147 row.prop(scene, "storypencil_add_render_byfolder")
150 # ------------------------------------------------------------------
151 # Define panel class for new base scene creation.
152 # ------------------------------------------------------------------
153 class STORYPENCIL_PT_SettingsNew(Panel):
154 bl_idname = "STORYPENCIL_PT_SettingsNew"
155 bl_label = "New Scenes"
156 bl_space_type = 'SEQUENCE_EDITOR'
157 bl_region_type = 'UI'
158 bl_category = 'Storypencil'
159 bl_parent_id = "STORYPENCIL_PT_Settings"
161 @classmethod
162 def poll(cls, context):
163 if context.space_data.view_type != 'SEQUENCER':
164 return False
166 return True
168 # ------------------------------
169 # Draw UI
170 # ------------------------------
171 def draw(self, context):
172 layout = self.layout
173 layout.use_property_split = True
174 layout.use_property_decorate = False
175 scene = context.scene
176 row = layout.row()
177 row.prop(scene, "storypencil_name_prefix", text="Name Prefix")
178 row = layout.row()
179 row.prop(scene, "storypencil_name_suffix", text="Name Suffix")
180 row = layout.row()
181 row.prop(scene, "storypencil_scene_duration", text="Frames")
183 row = layout.row()
184 if scene.storypencil_base_scene is None:
185 row.alert = True
186 row.prop(scene, "storypencil_base_scene", text="Template Scene")
189 class STORYPENCIL_PT_ModePanel(Panel):
190 bl_label = "Edit Scenes"
191 bl_space_type = 'SEQUENCE_EDITOR'
192 bl_region_type = 'UI'
193 bl_category = 'Storypencil'
194 bl_parent_id = "STORYPENCIL_PT_Settings"
196 @classmethod
197 def poll(cls, context):
198 if context.space_data.view_type != 'SEQUENCER':
199 return False
201 return True
203 def draw(self, context):
204 layout = self.layout
205 layout.use_property_split = True
206 layout.use_property_decorate = False
208 wm = bpy.context.window_manager
209 scene = context.scene
210 win_id = window_id(context.window)
212 col = layout.column(align=True)
213 col.prop(scene, "storypencil_mode", text="Mode")
215 col.prop(wm.storypencil_settings,
216 "show_main_strip_range", text="Show Strip Range")
219 if scene.storypencil_mode == 'WINDOW':
220 if not validate_sync(window_manager=wm) or win_id == wm.storypencil_settings.main_window_id:
221 col.prop(wm.storypencil_settings, "active",
222 text="Timeline Synchronization")
224 if scene.storypencil_mode == 'SWITCH':
225 col.separator()
226 col = layout.column(heading="Audio", align=True)
227 col.prop(scene, "storypencil_copy_sounds", text="Copy to Scene")
229 subcol = col.column(align=True)
230 subcol.prop(scene, 'storypencil_skip_sound_mute')
231 subcol.enabled = scene.storypencil_copy_sounds is True or scene.storypencil_mode == 'WINDOW'