-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathui.py
280 lines (202 loc) · 8.86 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# SPDX-FileCopyrightText: 2014-2024 Mikhail Rachinskiy
# SPDX-License-Identifier: GPL-3.0-or-later
from bpy.types import Menu, Panel
# Menus
# ---------------------------
def draw_commotion_menu(self, context):
layout = self.layout
layout.separator()
layout.menu("VIEW3D_MT_commotion")
class VIEW3D_MT_commotion(Menu):
bl_label = "Commotion"
def draw(self, context):
layout = self.layout
layout.operator_context = "INVOKE_DEFAULT"
layout.operator("wm.call_panel", text="Animation Offset", icon="WINDOW").name = "VIEW3D_PT_commotion_animation_offset"
layout.separator()
layout.operator("anim.commotion_animation_copy", text="Copy", icon="COPYDOWN")
layout.operator("anim.commotion_animation_link", text="Link", icon="LINKED")
layout.operator_menu_enum("anim.commotion_animation_convert", "ad_type")
layout.separator()
layout.operator("wm.call_panel", text="Shape Keys", icon="WINDOW").name = "VIEW3D_PT_commotion_shape_keys"
layout.separator()
layout.operator("wm.call_panel", text="Proximity Effector", icon="WINDOW").name = "VIEW3D_PT_commotion_proxy_effector"
# Panels
# ---------------------------
class SidebarSetup:
bl_category = "Commotion"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_context = "objectmode"
class VIEW3D_PT_commotion_shape_keys(SidebarSetup, Panel):
bl_label = "Shape Keys"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
layout = self.layout
if self.is_popover:
layout.label(text="Shape Keys")
layout.separator()
layout.use_property_split = True
layout.use_property_decorate = False
layout.operator("object.commotion_sk_coll_refresh")
try:
sk = context.object.data.shape_keys
kbs = sk.key_blocks
except AttributeError:
return
skcoll = context.window_manager.commotion.skcoll
if len(kbs) == len(skcoll):
prop_name = "value" if sk.use_relative else "interpolation"
col = layout.column(align=True)
col.use_property_split = False
for i, kb in enumerate(kbs):
kb_sel = skcoll[i]
row = col.column().row(align=True) # Additional column to prevent vertical align
row.prop(kb_sel, "selected", text=kb.name)
if kb_sel.selected:
row.prop(kb, prop_name, text="")
else:
row.label()
if not sk.use_relative:
layout.prop(sk, "eval_time", text="Time")
layout.operator_menu_enum("object.commotion_sk_interpolation_set", "interp")
layout.operator("anim.commotion_sk_generate_keyframes", text="Generate Keyframes", icon="IPO_BEZIER")
class VIEW3D_PT_commotion_animation_offset(SidebarSetup, Panel):
bl_label = "Animation Offset"
def draw(self, context):
layout = self.layout
if self.is_popover:
layout.label(text="Animation Offset")
layout.use_property_split = True
layout.use_property_decorate = False
props = context.scene.commotion
is_proxy = props.offset_sort_method == "MULTI" and props.offset_use_proxy
col = layout.column(heading="Data")
sub = col.column(align=True)
sub.prop(props, "offset_use_ob")
sub.prop(props, "offset_use_data")
sub.prop(props, "offset_use_sk")
sub.prop(props, "offset_use_mat")
sub = col.column()
sub.active = not is_proxy
sub.prop(props, "offset_offset")
sub.prop(props, "offset_threshold")
sub = col.column(align=True)
sub.prop(props, "offset_use_select")
sub = sub.column()
sub.active = not is_proxy
sub.prop(props, "offset_use_reverse")
col.prop(props, "offset_sort_method")
if props.offset_sort_method == "MULTI":
col.prop(props, "offset_coll_animated")
col.prop(props, "offset_coll_effectors")
col.prop(props, "offset_use_proxy")
elif props.offset_sort_method == "RANDOM":
col.prop(props, "offset_seed")
row = layout.row(align=True)
row.operator("anim.commotion_animation_offset", icon="FORCE_HARMONIC")
row.operator("anim.commotion_animation_offset_eyedropper", text="", icon="EYEDROPPER")
class VIEW3D_PT_commotion_animation_utils(SidebarSetup, Panel):
bl_label = "Animation Utils"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
layout = self.layout
col = layout.column()
row = col.row(align=True)
row.operator("anim.commotion_animation_copy", text="Copy", icon="COPYDOWN")
row.operator("anim.commotion_animation_link", text="Link", icon="LINKED")
col.operator_menu_enum("anim.commotion_animation_convert", "ad_type")
class VIEW3D_PT_commotion_proxy_effector(SidebarSetup, Panel):
bl_label = "Proximity Effector"
bl_options = {"DEFAULT_CLOSED"}
def draw_header(self, context):
layout = self.layout
layout.prop(context.window_manager.commotion, "use_proxy", text="")
def draw(self, context):
layout = self.layout
if self.is_popover:
row = layout.row(align=True)
row.prop(context.window_manager.commotion, "use_proxy", text="")
row.label(text="Proximity Effector")
layout.separator()
layout.use_property_split = True
layout.use_property_decorate = False
layout.active = context.window_manager.commotion.use_proxy
props = context.scene.commotion
col = layout.column()
col.prop(props, "proxy_coll_animated")
col.prop(props, "proxy_coll_effectors")
col.prop(props, "proxy_falloff")
sub = col.column(heading="Trail")
row = sub.row()
row.prop(props, "proxy_use_trail", text="")
subrow = row.row()
subrow.active = props.proxy_use_trail
subrow.prop(props, "proxy_trail_fade", text="")
# Popover subpanels
layout.use_property_split = False
class VIEW3D_PT_commotion_proxy_effector_loc(SidebarSetup, Panel):
bl_label = "Location"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
def draw_header(self, context):
layout = self.layout
layout.prop(context.scene.commotion, "proxy_use_loc", text="")
def draw(self, context):
props = context.scene.commotion
layout = self.layout
layout.active = props.proxy_use_loc
row = layout.row()
row.column().prop(props, "proxy_start_loc", text="")
row.column().prop(props, "proxy_final_loc", text="")
class VIEW3D_PT_commotion_proxy_effector_rot(SidebarSetup, Panel):
bl_label = "Rotation"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
def draw_header(self, context):
layout = self.layout
layout.prop(context.scene.commotion, "proxy_use_rot", text="")
def draw(self, context):
props = context.scene.commotion
layout = self.layout
layout.active = props.proxy_use_rot
row = layout.row()
row.column().prop(props, "proxy_start_rot", text="")
row.column().prop(props, "proxy_final_rot", text="")
class VIEW3D_PT_commotion_proxy_effector_sca(SidebarSetup, Panel):
bl_label = "Scale"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
def draw_header(self, context):
layout = self.layout
layout.prop(context.scene.commotion, "proxy_use_sca", text="")
def draw(self, context):
props = context.scene.commotion
layout = self.layout
layout.active = props.proxy_use_sca
row = layout.row()
row.column().prop(props, "proxy_start_sca", text="")
row.column().prop(props, "proxy_final_sca", text="")
class VIEW3D_PT_commotion_proxy_effector_sk(SidebarSetup, Panel):
bl_label = "Shape Keys"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
def draw_header(self, context):
layout = self.layout
layout.prop(context.scene.commotion, "proxy_use_sk", text="")
def draw(self, context):
props = context.scene.commotion
layout = self.layout
layout.active = props.proxy_use_sk
row = layout.row()
row.column().prop(props, "proxy_start_sk", text="")
row.column().prop(props, "proxy_final_sk", text="")
class VIEW3D_PT_commotion_proxy_effector_bake(SidebarSetup, Panel):
bl_label = "Bake"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
def draw(self, context):
layout = self.layout
row = layout.row(align=True)
row.operator("anim.commotion_bake", text="Bake")
row.operator("anim.commotion_bake_remove")