forked from waylow/boneWidget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.py
129 lines (106 loc) · 3.9 KB
/
prefs.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
import bpy
from bpy.types import AddonPreferences
from bpy.props import StringProperty, BoolProperty, FloatProperty
from .bl_class_registry import BlClassRegistry
from .panels import BONEWIDGET_PT_bw_panel_main
from .operators import BONEWIDGET_OT_resetDefaultImages
@BlClassRegistry()
class BoneWidgetPreferences(AddonPreferences):
bl_idname = __package__
#Use Rigify Defaults
use_rigify_defaults: BoolProperty(
name="Use Rigify Defaults",
description="Use the same naming convention for widget creation (disable if you prefer your naming convention)",
default=True,
)
# widget prefix
widget_prefix: StringProperty(
name="Bone Widget prefix",
description="Choose a prefix for the widget objects",
default="WGT-",
)
# symmetry suffix
symmetry_suffix: StringProperty(
name="Bone Widget symmetry suffix",
description="Choose a naming convention for the symmetrical widgets, seperate by semicolon.",
default="L; R",
)
# collection name
bonewidget_collection_name: StringProperty(
name="Bone Widget collection name",
description="Choose a name for the collection the widgets will appear",
default="WGTS",
)
def panel_category_update_fn(self, context):
has_panel = hasattr(bpy.types, BONEWIDGET_PT_bw_panel_main.bl_idname)
if has_panel:
try:
bpy.utils.unregister_class(BONEWIDGET_PT_bw_panel_main)
except:
pass
BONEWIDGET_PT_bw_panel_main.bl_category = self.panel_category
bpy.utils.register_class(BONEWIDGET_PT_bw_panel_main)
panel_category: StringProperty(
name="Panel Category",
description="Category to show Bone-Widgets panel",
default="Rigging",
update=panel_category_update_fn,
)
preview_panel_size: FloatProperty(
name="Preview Panel Size",
description="Size of the Preview Panel",
default=6.0,
min=1.0,
max=10.0,
precision=1,
)
preview_popup_size: FloatProperty(
name="Preview Popup Size",
description="Size of the Preview Popup Thumbnails",
default=3.5,
min=1.0,
max=10.0,
precision=1,
)
preview_default: BoolProperty(
name="Default Preview State",
description="Default state of preview panel",
default=True,
)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(self, "use_rigify_defaults", text="Use Rigify Defaults")
row = layout.row()
col = row.column()
col.prop(self, "widget_prefix", text="Widget Prefix")
col.prop(self, "bonewidget_collection_name", text="Collection name")
row.enabled = not self.use_rigify_defaults
row = layout.row()
row = layout.row()
row.prop(self, "symmetry_suffix", text="Symmetry suffix")
row = layout.row()
row = layout.row()
col = row.column()
col.label(text="Set the name of the tab where the Bone-Widget addon will show:")
col.prop(self, "panel_category")
# preview area
row = layout.row()
row = layout.row()
row.label(text="Thumbnail Previews:")
row = layout.row()
row.prop(self, "preview_default", text="Display Previews by Default")
row = layout.row()
col = row.column()
col.label(text="Preview Panel Size:")
row.prop(self, "preview_panel_size", text="")
row = layout.row()
col = row.column()
col.label(text="Preview Popup Size:")
row.prop(self, "preview_popup_size", text="")
row = layout.row()
layout.separator()
row = layout.row()
row = row.split(factor=.75)
row.label(text="Reset Default Widget Thumbnails")
row.operator("bonewidget.reset_default_images", icon="ERROR")