1 # SPDX-License-Identifier: GPL-2.0-or-later
5 from bpy
.props
import (
14 from bpy
.app
.translations
import contexts
as i18n_contexts
19 class SnapUtilitiesPreferences(bpy
.types
.AddonPreferences
):
20 # this must match the addon name, use '__package__'
21 # when defining this in a submodule of a python package.
22 bl_idname
= __package__
24 intersect
: BoolProperty(
26 description
="intersects created line with the existing edges, even if the lines do not intersect",
29 create_face
: BoolProperty(name
="Create faces",
30 description
="Create faces defined by enclosed edges",
33 outer_verts
: BoolProperty(name
="Snap to outer vertices",
34 description
="The vertices of the objects are not activated also snapped",
37 increments_grid
: BoolProperty(name
="Increments of Grid",
38 description
="Snap to increments of grid",
41 auto_constrain
: BoolProperty(name
="Automatic Constraint",
42 description
="Detects a direction to constrain depending on the position of the mouse",
45 incremental
: FloatProperty(name
="Incremental",
46 description
="Snap in defined increments",
52 relative_scale
: FloatProperty(name
="Relative Scale",
53 description
="Value that divides the global scale",
59 out_color
: FloatVectorProperty(name
="Floor",
60 default
=(0.0, 0.0, 0.0, 0.5),
66 face_color
: FloatVectorProperty(name
="Face Highlighted",
67 default
=(1.0, 0.8, 0.0, 0.5),
73 edge_color
: FloatVectorProperty(name
="Edge Highlighted",
74 default
=(0.0, 0.8, 1.0, 0.5),
80 vert_color
: FloatVectorProperty(name
="Vertex Highlighted",
81 default
=(1.0, 0.5, 0.0, 0.5),
82 size
=4, subtype
="COLOR",
86 center_color
: FloatVectorProperty(name
="Middle of the Edge",
87 default
=(1.0, 0.0, 1.0, 1.0),
93 perpendicular_color
: FloatVectorProperty(name
="Perpendicular Point",
94 default
=(0.1, 0.5, 0.5, 1.0),
100 constrain_shift_color
: FloatVectorProperty(name
="Shift Constrain",
101 default
=(0.8, 0.5, 0.4, 1.0),
107 tabs
: EnumProperty(name
="Tabs",
108 items
=[("GENERAL", "General", ""),
109 ("KEYMAPS", "Keymaps", ""),
110 ("COLORS", "Colors", ""),
111 ("HELP", "Links", ""), ],
114 def draw(self
, context
):
119 row
.prop(self
, "tabs", expand
=True)
123 if self
.tabs
== "GENERAL":
124 self
.draw_general(box
)
126 elif self
.tabs
== "COLORS":
127 self
.draw_snap_utilities_colors(box
)
129 elif self
.tabs
== "KEYMAPS":
130 self
.draw_snap_utilities_keymaps(context
, box
)
132 elif self
.tabs
== "HELP":
133 self
.draw_snap_utilities_help(box
)
135 def draw_general(self
, layout
):
139 col
.label(text
="Snap Properties:")
140 col
.prop(self
, "incremental")
141 col
.prop(self
, "increments_grid")
142 if self
.increments_grid
:
143 col
.prop(self
, "relative_scale")
145 col
.prop(self
, "outer_verts")
149 col
.label(text
="Line Tool:")
150 col
.prop(self
, "intersect")
151 col
.prop(self
, "create_face")
153 def draw_snap_utilities_colors(self
, layout
):
154 layout
.use_property_split
= True
156 flow
= layout
.grid_flow(
157 row_major
=False, columns
=0, even_columns
=True, even_rows
=False, align
=False)
159 flow
.prop(self
, "out_color")
160 flow
.prop(self
, "constrain_shift_color")
161 flow
.prop(self
, "face_color")
162 flow
.prop(self
, "edge_color")
163 flow
.prop(self
, "vert_color")
164 flow
.prop(self
, "center_color")
165 flow
.prop(self
, "perpendicular_color")
167 def draw_snap_utilities_help(self
, layout
):
168 # layout.operator("wm.url_open", text="Gumroad Page", icon='HELP',).url = "https://gum.co/IaqQf"
169 # layout.operator("wm.url_open", text="Blender Market Page", icon='HELP',).url = "https://blendermarket.com/products/snap-utilities"
170 layout
.operator("wm.url_open", text
="Wiki", icon
='HELP',
171 ).url
= "https://github.com/Mano-Wii/Addon-Snap-Utilities-Line/wiki"
172 layout
.operator("wm.url_open", text
="Forum", icon
='HELP',
173 ).url
= "https://blenderartists.org/t/cad-snap-utilities"
175 def draw_snap_utilities_keymaps(self
, context
, layout
):
177 generate_snap_utilities_global_keymaps
,
178 generate_snap_utilities_tools_keymaps
,
181 wm
= context
.window_manager
182 # kc = wm.keyconfigs.addon
183 kc
= wm
.keyconfigs
.user
185 layout
.label(text
="Global:")
187 for km_name
, km_args
, km_content
in generate_snap_utilities_global_keymaps():
188 km
= kc
.keymaps
.get(km_name
)
190 self
.draw_snap_utilities_km(kc
, km
, layout
)
192 layout
.label(text
="Tools:")
194 for km_name
, km_args
, km_content
in generate_snap_utilities_tools_keymaps():
195 km
= kc
.keymaps
.get(km_name
)
197 self
.draw_snap_utilities_km(kc
, km
, layout
)
200 def draw_snap_utilities_km(kc
, km
, layout
):
201 layout
.context_pointer_set("keymap", km
)
204 row
.prop(km
, "show_expanded_items", text
="", emboss
=False)
205 row
.label(text
=km
.name
, text_ctxt
=i18n_contexts
.id_windowmanager
)
207 if km
.show_expanded_items
:
208 col
= layout
.column()
210 for kmi
in km
.keymap_items
:
211 if "snap_utilities" in kmi
.idname
:
212 rna_keymap_ui
.draw_kmi(
213 ["ADDON", "USER", "DEFAULT"], kc
, km
, kmi
, col
, 0)