Merge branch 'blender-v3.6-release'
[blender-addons.git] / storypencil / ui.py
blob6855dcde00f8b5b0dd7e5c6bb986cc99a16f5787
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 import bpy
5 from bpy.types import (
6 Menu,
7 Panel,
10 from .synchro import get_main_window, validate_sync, window_id
13 # ------------------------------------------------------
14 # Defines UI panel
15 # ------------------------------------------------------
16 # ------------------------------------------------------------------
17 # Define panel class for manual switch parameters.
18 # ------------------------------------------------------------------
19 class STORYPENCIL_PT_Settings(Panel):
20 bl_idname = "STORYPENCIL_PT_Settings"
21 bl_label = "Settings"
22 bl_space_type = 'SEQUENCE_EDITOR'
23 bl_region_type = 'UI'
24 bl_category = 'Storypencil'
26 @classmethod
27 def poll(cls, context):
28 if context.space_data.view_type != 'SEQUENCER':
29 return False
31 return True
33 # ------------------------------
34 # Draw UI
35 # ------------------------------
36 def draw(self, context):
37 layout = self.layout
38 layout.use_property_split = True
39 layout.use_property_decorate = False
42 class STORYPENCIL_PT_General(Panel):
43 bl_idname = "STORYPENCIL_PT_General"
44 bl_label = "General"
45 bl_space_type = 'SEQUENCE_EDITOR'
46 bl_region_type = 'UI'
47 bl_category = 'Storypencil'
48 bl_options = {'DEFAULT_CLOSED'}
49 bl_parent_id = "STORYPENCIL_PT_Settings"
51 @classmethod
52 def poll(cls, context):
53 if context.space_data.view_type != 'SEQUENCER':
54 return False
56 return True
58 # ------------------------------
59 # Draw UI
60 # ------------------------------
61 def draw(self, context):
62 layout = self.layout
63 layout.use_property_split = True
64 layout.use_property_decorate = False
65 scene = context.scene
67 setup_ready = scene.storypencil_main_workspace is not None
68 row = layout.row()
69 row.alert = not setup_ready
70 row.prop(scene, "storypencil_main_workspace", text="VSE Workspace")
72 row = layout.row()
73 if scene.storypencil_main_scene is None:
74 row.alert = True
75 row.prop(scene, "storypencil_main_scene", text="VSE Scene")
77 layout.separator()
79 row = layout.row()
80 if scene.storypencil_main_workspace and scene.storypencil_edit_workspace:
81 if scene.storypencil_main_workspace.name == scene.storypencil_edit_workspace.name:
82 row.alert = True
83 if scene.storypencil_edit_workspace is None:
84 row.alert = True
85 row.prop(scene, "storypencil_edit_workspace", text="Drawing Workspace")
88 class STORYPENCIL_PT_RenderPanel(Panel):
89 bl_label = "Render Strips"
90 bl_space_type = 'SEQUENCE_EDITOR'
91 bl_region_type = 'UI'
92 bl_category = 'Storypencil'
93 bl_parent_id = "STORYPENCIL_PT_Settings"
95 @classmethod
96 def poll(cls, context):
97 if context.space_data.view_type != 'SEQUENCER':
98 return False
100 return True
102 def draw(self, context):
103 layout = self.layout
104 layout.use_property_split = True
105 layout.use_property_decorate = False
107 scene = context.scene
108 settings = scene.render.image_settings
110 is_video = settings.file_format in {'FFMPEG', 'AVI_JPEG', 'AVI_RAW'}
111 row = layout.row()
112 if scene.storypencil_render_render_path is None:
113 row.alert = True
114 row.prop(scene, "storypencil_render_render_path")
116 row = layout.row()
117 row.prop(scene, "storypencil_render_onlyselected")
119 row = layout.row()
120 row.prop(scene.render.image_settings, "file_format")
122 if settings.file_format == 'FFMPEG':
123 row = layout.row()
124 row.prop(scene.render.ffmpeg, "format")
126 row = layout.row()
127 row.enabled = is_video
128 row.prop(scene.render.ffmpeg, "audio_codec")
130 row = layout.row()
131 row.prop(scene, "storypencil_add_render_strip")
133 row = layout.row()
134 row.enabled = scene.storypencil_add_render_strip
135 row.prop(scene, "storypencil_render_channel")
137 if not is_video:
138 row = layout.row()
139 row.prop(scene, "storypencil_render_step")
141 row = layout.row()
142 row.prop(scene, "storypencil_render_numbering")
144 row = layout.row()
145 row.prop(scene, "storypencil_add_render_byfolder")
148 # ------------------------------------------------------------------
149 # Define panel class for new base scene creation.
150 # ------------------------------------------------------------------
151 class STORYPENCIL_PT_SettingsNew(Panel):
152 bl_idname = "STORYPENCIL_PT_SettingsNew"
153 bl_label = "New Scenes"
154 bl_space_type = 'SEQUENCE_EDITOR'
155 bl_region_type = 'UI'
156 bl_category = 'Storypencil'
157 bl_parent_id = "STORYPENCIL_PT_Settings"
159 @classmethod
160 def poll(cls, context):
161 if context.space_data.view_type != 'SEQUENCER':
162 return False
164 return True
166 # ------------------------------
167 # Draw UI
168 # ------------------------------
169 def draw(self, context):
170 layout = self.layout
171 layout.use_property_split = True
172 layout.use_property_decorate = False
173 scene = context.scene
174 row = layout.row()
175 row.prop(scene, "storypencil_name_prefix", text="Name Prefix")
176 row = layout.row()
177 row.prop(scene, "storypencil_name_suffix", text="Name Suffix")
178 row = layout.row()
179 row.prop(scene, "storypencil_scene_duration", text="Frames")
181 row = layout.row()
182 if scene.storypencil_base_scene is None:
183 row.alert = True
184 row.prop(scene, "storypencil_base_scene", text="Template Scene")
187 class STORYPENCIL_PT_ModePanel(Panel):
188 bl_label = "Edit Scenes"
189 bl_space_type = 'SEQUENCE_EDITOR'
190 bl_region_type = 'UI'
191 bl_category = 'Storypencil'
192 bl_parent_id = "STORYPENCIL_PT_Settings"
194 @classmethod
195 def poll(cls, context):
196 if context.space_data.view_type != 'SEQUENCER':
197 return False
199 return True
201 def draw(self, context):
202 layout = self.layout
203 layout.use_property_split = True
204 layout.use_property_decorate = False
206 wm = bpy.context.window_manager
207 scene = context.scene
208 win_id = window_id(context.window)
210 col = layout.column(align=True)
211 col.prop(scene, "storypencil_mode", text="Mode")
213 col.prop(wm.storypencil_settings,
214 "show_main_strip_range", text="Show Strip Range")
217 if scene.storypencil_mode == 'WINDOW':
218 if not validate_sync(window_manager=wm) or win_id == wm.storypencil_settings.main_window_id:
219 col.prop(wm.storypencil_settings, "active",
220 text="Timeline Synchronization")
222 if scene.storypencil_mode == 'SWITCH':
223 col.separator()
224 col = layout.column(heading="Audio", align=True)
225 col.prop(scene, "storypencil_copy_sounds", text="Copy to Scene")
227 subcol = col.column(align=True)
228 subcol.prop(scene, 'storypencil_skip_sound_mute')
229 subcol.enabled = scene.storypencil_copy_sounds is True or scene.storypencil_mode == 'WINDOW'