-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddonPreferences.py
627 lines (458 loc) · 22.1 KB
/
addonPreferences.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# Update "Tab Category Name" inspired by "Meta-Androcto's" "Edit Mesh Tools" Add-on
# recommended by "cytoo"
import bpy
from rna_keymap_ui import draw_kmi
from . miscPt import VIEW3D_PT_ntzbu_sidebar_panel
from . import miscLay
from . import miscFunc
from bpy.props import (StringProperty, BoolProperty, IntProperty, FloatProperty, FloatVectorProperty, EnumProperty, PointerProperty)
from bpy.types import (Panel, Operator, AddonPreferences, PropertyGroup)
# Define Panel classes for updating
panels = (
VIEW3D_PT_ntzbu_sidebar_panel,
)
def update_panel(self, context):
addonPrefs = context.preferences.addons[__package__].preferences
message = "Neltulz - Edge Curve: Updating Panel locations has failed"
try:
for panel in panels:
if "bl_rna" in panel.__dict__:
bpy.utils.unregister_class(panel)
#Whatever the user typed into the text box in the add-ons settings, set that as the addon's tab category name
for panel in panels:
if addonPrefs.sbPnlSize == "HIDE":
panel.bl_category = ""
panel.bl_region_type = "WINDOW"
else:
if addonPrefs.sbPnlSize == "DEFAULT":
panel.bUseCompactSidebarPanel = False
else:
panel.bUseCompactSidebarPanel = True
panel.bl_category = addonPrefs.category
panel.bl_region_type = "UI"
if addonPrefs.popPiePnlSize == "DEFAULT":
panel.bUseCompactPopupAndPiePanel = False
else:
panel.bUseCompactPopupAndPiePanel = True
bpy.utils.register_class(panel)
except Exception as e:
print("\n[{}]\n{}\n\nError:\n{}".format(__package__, message, e))
pass
class VIEW3D_OT_ntzbu_addon_prefs(AddonPreferences):
# this must match the addon name, use '__package__'
# when defining this in a submodule of a python package.
bl_idname = __package__
preventInfiniteRecursion : BoolProperty (default=False)
navTabs_List = [
("UILAY", "UI Layout", "", "MENU_PANEL", 0),
("KM", "Keymaps", "", "KEYINGSET", 1),
("OBJ", "Object", "", "OBJECT_ORIGIN", 2),
("MESH", "Mesh", "", "OUTLINER_OB_MESH", 3),
#("MDFRS", "Modifiers", "", "MODIFIER", 4),
#("CURS", "3D Cursor", "", "CURSOR", 5),
]
navTabs : EnumProperty (
items = navTabs_List,
name = "Navigation Tabs",
default = "OBJ",
)
category: StringProperty(
name="Tab Category",
description="Choose a name for the category of the panel",
default="Neltulz",
update=update_panel,
)
sbPnlSize_List = [
("DEFAULT", "Default", "", "", 0),
#("COMPACT", "Compact", "", "", 1),
("HIDE", "Hide", "", "", 2),
]
sbPnlSize : EnumProperty (
items = sbPnlSize_List,
name = "Sidebar Panel Size",
description = "Sidebar Panel Size",
default = "DEFAULT",
update=update_panel,
)
popPiePnlSize_List = [
("DEFAULT", "Default", "", "", 0),
("COMPACT", "Compact", "", "", 1),
]
popPiePnlSize : EnumProperty (
items = popPiePnlSize_List,
name = "Popup & Pie Panel Size",
description = "Popup & Pie Panel Size",
default = "COMPACT",
update=update_panel,
)
show_AIOToolSettings_addonPrefs : BoolProperty (
name = "Show All-in-One Tool Settings Add-on Preferences",
default = True,
)
aioToolSettings_showOKButton_List = [
("YES", "Yes", "", "", 0),
("NO", "No", "", "", 1),
]
aioToolSettings_showOKButton : EnumProperty (
items = aioToolSettings_showOKButton_List,
name = "Show OK Button",
description = 'Adds an "OK" button to the popup. Pro: prevents the popup from disappearing until you explicitly click OK or click outside of the popup. Con: Requires an extra click',
default = "NO",
)
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Delete Unselected Objects
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
show_deleteUnselObjs_addonPrefs : BoolProperty (
name = 'Show "Delete Unselected Objects" Add-on Preferences',
default = True,
)
delUnselObjs_useConfirmDiag_List = [
("YES", "Yes", "", "", 0),
("NO", "No", "", "", 1),
]
delUnselObjs_useConfirmDiag : EnumProperty (
items = delUnselObjs_useConfirmDiag_List,
name = 'Use Confirm Dialog',
description = 'Prevents you from causing "Instant Chaos" by prompting you before deleting all unselected objects',
default = "YES",
)
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Group With Empty
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
show_groupWithEmpty_addonPrefs : BoolProperty (
name = 'Show "Group with Empty" Add-on Preferences',
default = True,
)
groupWithEmpty_showOperatorOptions_List = [
("EXPAND", "Expand", "", "", 0),
("COLLAPSE", "Collapse", "", "", 1),
]
groupWithEmpty_showOperatorOptions : EnumProperty (
items = groupWithEmpty_showOperatorOptions_List,
name = 'Show Operator Options',
description = 'Shows additional operator options',
default = "COLLAPSE",
)
def groupWithEmpty_emptyName_deactivate(self, context):
miscFunc.deactivateProp(self, context, propName='groupWithEmpty_emptyName')
def groupWithEmpty_emptyName_activate(self, context):
miscFunc.activateProp(self, context, propName='groupWithEmpty_emptyName')
groupWithEmpty_emptyName_active : BoolProperty (
name = 'Deactivate & Reset "Empty Name"',
default = False,
update = groupWithEmpty_emptyName_deactivate,
)
groupWithEmpty_emptyName : StringProperty (
name = 'Empty Name',
default = "Group",
update = groupWithEmpty_emptyName_activate
)
def groupWithEmpty_emptyLocation_deactivate(self, context):
miscFunc.deactivateProp(self, context, propName='groupWithEmpty_emptyLocation')
def groupWithEmpty_emptyLocation_activate(self, context):
miscFunc.activateProp(self, context, propName='groupWithEmpty_emptyLocation')
groupWithEmpty_emptyLocation_active : BoolProperty (
name = 'Deactivate & Reset "Empty Location"',
default = False,
update = groupWithEmpty_emptyLocation_deactivate,
)
groupWithEmpty_emptyLocation_List = [
("MEDIAN_POINT", "Median", "Median Point", "", 0),
("BOUNDING_BOX_CENTER", "Bound", "Bounding Box Center", "", 1),
("ACTIVE_ELEMENT", "Active", "Active Element", "", 2),
("WORIGIN", "Origin", "World Orign", "", 3),
]
groupWithEmpty_emptyLocation : EnumProperty (
items = groupWithEmpty_emptyLocation_List,
name = "Empty Location",
default = "MEDIAN_POINT",
update = groupWithEmpty_emptyLocation_activate,
)
def groupWithEmpty_emptySize_deactivate(self, context):
miscFunc.deactivateProp(self, context, propName='groupWithEmpty_emptySize')
def groupWithEmpty_emptySize_activate(self, context):
miscFunc.activateProp(self, context, propName='groupWithEmpty_emptySize')
groupWithEmpty_emptySize_active : BoolProperty (
name = 'Deactivate & Reset "Empty Size"',
default = False,
update = groupWithEmpty_emptySize_deactivate,
)
groupWithEmpty_emptySize_List = [
("1", "1", "", "", 0),
("0.01", "0.01", "", "", 1),
("0.0001", "0.0001", "", "", 2),
]
groupWithEmpty_emptySize : EnumProperty (
items = groupWithEmpty_emptySize_List,
name = "Empty Location",
default = "0.01",
update = groupWithEmpty_emptySize_activate,
)
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Smart Instance Collection
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
show_smartInstColl_addonPrefs : BoolProperty (
name = 'Show "Smart Instance Collection" Add-on Preferences',
default = True,
)
smartInstColl_showOperatorOptions_List = [
("EXPAND", "Expand", "", "", 0),
("COLLAPSE", "Collapse", "", "", 1),
]
smartInstColl_showOperatorOptions : EnumProperty (
items = smartInstColl_showOperatorOptions_List,
name = 'Show Operator Options',
description = 'Shows additional operator options',
default = "EXPAND",
)
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Select Contiguous Edges
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
show_selContigEdg_addonPrefs : BoolProperty (
name = 'Show "Select Contiguous Edges" Add-on Preferences',
default = True,
)
def selContigEdg_maxAngle_deactivate(self, context):
miscFunc.deactivateProp(self, context, propName='selContigEdg_maxAngle')
def selContigEdg_maxAngle_activate(self, context):
miscFunc.activateProp(self, context, propName='selContigEdg_maxAngle')
selContigEdg_maxAngle_active : BoolProperty (
name = 'Deactivate & Reset "Max Angle"',
default = False,
update = selContigEdg_maxAngle_deactivate,
)
selContigEdg_maxAngle : IntProperty (
name = "Max Angle",
default = 15,
min = 0,
max = 360,
update = selContigEdg_maxAngle_activate
)
def selContigEdg_maxEdges_deactivate(self, context):
miscFunc.deactivateProp(self, context, propName='selContigEdg_maxEdges')
def selContigEdg_maxEdges_activate(self, context):
miscFunc.activateProp(self, context, propName='selContigEdg_maxEdges')
selContigEdg_maxEdges_active : BoolProperty (
name = 'Deactivate & Reset "Max Edges"',
default = False,
update = selContigEdg_maxEdges_deactivate,
)
selContigEdg_maxEdges : IntProperty(
name = "Max Edges",
default = 0,
min = 0,
soft_max = 50,
update = selContigEdg_maxEdges_activate,
)
def selContigEdg_direction_deactivate(self, context):
miscFunc.deactivateProp(self, context, propName='selContigEdg_direction')
def selContigEdg_direction_activate(self, context):
miscFunc.activateProp(self, context, propName='selContigEdg_direction')
selContigEdg_direction_active : BoolProperty (
name = 'Deactivate & Reset "Direction"',
default = False,
update = selContigEdg_direction_deactivate,
)
selContigEdg_direction_List = (
('BACKWARD', "Backward", "", "", 0),
('BOTH', "Both", "", "", 1),
('FORWARD', "Forward", "", "", 2),
)
selContigEdg_direction : EnumProperty (
items = selContigEdg_direction_List,
name = "Direction",
description = "Search Direction",
default = 'BOTH',
update = selContigEdg_direction_activate,
)
def draw(self, context):
lay = self.layout.column(align=True)
if self.sbPnlSize == "HIDE":
bTabCatEnabled = False
else:
bTabCatEnabled = True
navRow = lay.row(align=True)
navRow.scale_y = 1.25
navRow.prop(self, 'navTabs', expand=True)
if self.navTabs == "UILAY":
box = lay.box().column(align=True)
box2 = box.row(align=False)
spacer = box2.row(align=True)
boxInner = box2.column(align=True)
rightSpacer = box2.row(align=True)
boxInner.separator()
section = boxInner.column(align=True)
miscLay.createProp_or_Op(self, context, section,
labelTxt = "Sidebar Panel",
propName = "sbPnlSize",
)
section.separator()
miscLay.createProp_or_Op(self, context, section,
labelTxt = "Tab Category",
propName = "category",
propText = "",
)
section.separator()
miscLay.createProp_or_Op(self, context, section,
labelTxt = "Popup & Pie Panel",
propName = "popPiePnlSize",
)
boxInner.separator()
boxInner.separator()
section = boxInner.column(align=True)
miscLay.createSectionToggleOperator(self, context,
lay = section,
height = 1.25,
data = self,
dataStr = 'addonPrefs',
sectionBool = 'show_AIOToolSettings_addonPrefs',
text = 'All-in-One - Tool Settings Popup'
)
if self.show_AIOToolSettings_addonPrefs:
sectionBox = section.box().column(align=True)
miscLay.createProp_or_Op(self, context, sectionBox,
labelTxt = "Show OK Button",
propName = "aioToolSettings_showOKButton",
)
boxInner.separator()
elif self.navTabs == "KM":
box = lay.box().column()
miscLay.forceJustifyText(lay=box, text='To customize these keymaps, go to your keymaps', icon='QUESTION')
miscLay.forceJustifyText(lay=box, text='tab on the left and do a search for "NTZBU"')
box.separator()
miscLay.forceJustifyText(lay=box, text='If your keymaps are not working,')
miscLay.forceJustifyText(lay=box, text='check for conflicting add-ons and keymaps.')
#--------------------------------------------------------------------------------
# NTZBU : Headers
#--------------------------------------------------------------------------------
row = lay.grid_flow(align=True, row_major=True, columns=2, even_columns=True)
rowTitleContainer = row.box().column(align=True)
rowTitle1 = rowTitleContainer.row(align=True)
rowTitle1.scale_y = 0.0000001
rowTitle1.alignment="EXPAND"
rowTitle1.label(text=' ')
rowTitle2 = rowTitleContainer.row(align=True)
rowTitle2.alignment="CENTER"
rowTitle2.label(text='Operator')
rowKeybindContainer = row.box().column(align=True)
keybind1 = rowKeybindContainer.row(align=True)
keybind1.scale_y = 0.0000001
keybind1.alignment="EXPAND"
keybind1.label(text=' ')
keybind2 = rowKeybindContainer.row(align=True)
keybind2.alignment="CENTER"
keybind2.label(text='Default Keyboard Shortcut')
#--------------------------------------------------------------------------------
# NTZBU : All-in-One Tool Settings
#--------------------------------------------------------------------------------
row = lay.grid_flow(align=True, row_major=True, columns=2, even_columns=True)
rowTitleContainer = row.box().column(align=True)
rowTitle1 = rowTitleContainer.row(align=True)
rowTitle1.scale_y = 0.0000001
rowTitle1.alignment="EXPAND"
rowTitle1.label(text=' ')
rowTitle2 = rowTitleContainer.row(align=True)
rowTitle2.alignment="CENTER"
rowTitle2.label(text='NTZBU : All-in-One Tool Settings')
rowKeybindContainer = row.box().column(align=True)
keybind1 = rowKeybindContainer.row(align=True)
keybind1.scale_y = 0.0000001
keybind1.alignment="EXPAND"
keybind1.label(text=' ')
keybind2 = rowKeybindContainer.row(align=True)
keybind2.alignment="CENTER"
keybind2.label(text='ALT + Q')
#--------------------------------------------------------------------------------
# NTZBU : Modifier Tools Pie
#--------------------------------------------------------------------------------
row = lay.grid_flow(align=True, row_major=True, columns=2, even_columns=True)
rowTitleContainer = row.box().column(align=True)
rowTitle1 = rowTitleContainer.row(align=True)
rowTitle1.scale_y = 0.0000001
rowTitle1.alignment="EXPAND"
rowTitle1.label(text=' ')
rowTitle2 = rowTitleContainer.row(align=True)
rowTitle2.alignment="CENTER"
rowTitle2.label(text='NTZBU : Modifier Tools Pie')
rowKeybindContainer = row.box().column(align=True)
keybind1 = rowKeybindContainer.row(align=True)
keybind1.scale_y = 0.0000001
keybind1.alignment="EXPAND"
keybind1.label(text=' ')
keybind2 = rowKeybindContainer.row(align=True)
keybind2.alignment="CENTER"
keybind2.label(text='SHIFT + CTRL + Q')
elif self.navTabs == "OBJ":
box = lay.box().column(align=True)
box2 = box.row(align=False)
spacer = box2.row(align=True)
boxInner = box2.column(align=True)
rightSpacer = box2.row(align=True)
boxInner.separator()
section = boxInner.column(align=True)
miscLay.createSectionToggleOperator(self, context,
lay = section,
height = 1.25,
data = self,
dataStr = 'addonPrefs',
sectionBool = 'show_deleteUnselObjs_addonPrefs',
text = 'Delete Unselected Objects'
)
if self.show_deleteUnselObjs_addonPrefs:
sectionBox = section.box()
miscLay.delUnselObjs_options(self, context, lay=sectionBox)
boxInner.separator()
section = boxInner.column(align=True)
section.separator()
miscLay.createSectionToggleOperator(self, context,
lay = section,
height = 1.25,
data = self,
dataStr = 'addonPrefs',
sectionBool = 'show_groupWithEmpty_addonPrefs',
text = 'Group with Empty'
)
if self.show_groupWithEmpty_addonPrefs:
sectionBox = section.box().column(align=True)
miscLay.groupWithEmpty_options(self, context, lay=sectionBox)
boxInner.separator()
section = boxInner.column(align=True)
section.separator()
miscLay.createSectionToggleOperator(self, context,
lay = section,
height = 1.25,
data = self,
dataStr = 'addonPrefs',
sectionBool = 'show_smartInstColl_addonPrefs',
text = 'Smart Instance Collection'
)
if self.show_smartInstColl_addonPrefs:
sectionBox = section.box().column(align=True)
miscLay.smartInstColl_options(self, context, lay=sectionBox)
boxInner.separator()
elif self.navTabs == "MESH":
box = lay.box().column(align=True)
box2 = box.row(align=False)
spacer = box2.row(align=True)
boxInner = box2.column(align=True)
rightSpacer = box2.row(align=True)
boxInner.separator()
section = boxInner.column(align=True)
miscLay.createSectionToggleOperator(self, context,
lay = section,
height = 1.25,
data = self,
dataStr = 'addonPrefs',
sectionBool = 'show_selContigEdg_addonPrefs',
text = 'Select Contiguous Edges'
)
if self.show_selContigEdg_addonPrefs:
sectionBox = section.box().column(align=True)
miscLay.selContigEdg_options(self, context, lay=sectionBox)
boxInner.separator()
elif self.navTabs == "MDFRS":
box = lay.box().column(align=True)
box.label(text="No Options")
elif self.navTabs == "CURS":
box = lay.box().column(align=True)
box.label(text="No Options")