1 ### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 3
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # ##### END GPL LICENSE BLOCK #####
19 from bpy
.props
import (
28 from bpy
.app
.translations
import contexts
as i18n_contexts
33 class SnapUtilitiesPreferences(bpy
.types
.AddonPreferences
):
34 # this must match the addon name, use '__package__'
35 # when defining this in a submodule of a python package.
36 bl_idname
= __package__
38 intersect
: BoolProperty(name
="Intersect",
39 description
="intersects created line with the existing edges, even if the lines do not intersect",
42 create_face
: BoolProperty(name
="Create faces",
43 description
="Create faces defined by enclosed edges",
46 outer_verts
: BoolProperty(name
="Snap to outer vertices",
47 description
="The vertices of the objects are not activated also snapped",
50 increments_grid
: BoolProperty(name
="Increments of Grid",
51 description
="Snap to increments of grid",
54 auto_constrain
: BoolProperty(name
="Automatic Constraint",
55 description
="Detects a direction to constrain depending on the position of the mouse.",
58 incremental
: FloatProperty(name
="Incremental",
59 description
="Snap in defined increments",
65 relative_scale
: FloatProperty(name
="Relative Scale",
66 description
="Value that divides the global scale",
72 out_color
: FloatVectorProperty(name
="Floor",
73 default
=(0.0, 0.0, 0.0, 0.5),
79 face_color
: FloatVectorProperty(name
="Face Highlighted",
80 default
=(1.0, 0.8, 0.0, 0.5),
86 edge_color
: FloatVectorProperty(name
="Edge Highlighted",
87 default
=(0.0, 0.8, 1.0, 0.5),
93 vert_color
: FloatVectorProperty(name
="Vertex Highlighted",
94 default
=(1.0, 0.5, 0.0, 0.5),
95 size
=4, subtype
="COLOR",
99 center_color
: FloatVectorProperty(name
="Middle of the Edge",
100 default
=(1.0, 0.0, 1.0, 1.0),
106 perpendicular_color
: FloatVectorProperty(name
="Perpendicular Point",
107 default
=(0.1, 0.5, 0.5, 1.0),
113 constrain_shift_color
: FloatVectorProperty(name
="Shift Constrain",
114 default
=(0.8, 0.5, 0.4, 1.0),
120 tabs
: EnumProperty(name
="Tabs",
121 items
= [("GENERAL", "General", ""),
122 ("KEYMAPS", "Keymaps", ""),
123 ("COLORS", "Colors", ""),
124 ("HELP", "Links", ""),],
127 def draw(self
, context
):
132 row
.prop(self
, "tabs", expand
=True)
136 if self
.tabs
== "GENERAL":
137 self
.draw_general(box
)
139 elif self
.tabs
== "COLORS":
140 self
.draw_snap_utilities_colors(box
)
142 elif self
.tabs
== "KEYMAPS":
143 self
.draw_snap_utilities_keymaps(context
, box
)
145 elif self
.tabs
== "HELP":
146 self
.draw_snap_utilities_help(box
)
148 def draw_general(self
, layout
):
152 col
.label(text
="Snap Properties:")
153 col
.prop(self
, "incremental")
154 col
.prop(self
, "increments_grid")
155 if self
.increments_grid
:
156 col
.prop(self
, "relative_scale")
158 col
.prop(self
, "outer_verts")
162 col
.label(text
="Line Tool:")
163 col
.prop(self
, "intersect")
164 col
.prop(self
, "create_face")
166 def draw_snap_utilities_colors(self
, layout
):
167 layout
.use_property_split
= True
169 flow
= layout
.grid_flow(row_major
=False, columns
=0, even_columns
=True, even_rows
=False, align
=False)
171 flow
.prop(self
, "out_color")
172 flow
.prop(self
, "constrain_shift_color")
173 flow
.prop(self
, "face_color")
174 flow
.prop(self
, "edge_color")
175 flow
.prop(self
, "vert_color")
176 flow
.prop(self
, "center_color")
177 flow
.prop(self
, "perpendicular_color")
179 def draw_snap_utilities_help(self
, layout
):
180 #layout.operator("wm.url_open", text="Gumroad Page", icon='HELP',).url = "https://gum.co/IaqQf"
181 #layout.operator("wm.url_open", text="Blender Market Page", icon='HELP',).url = "https://blendermarket.com/products/snap-utilities"
182 layout
.operator("wm.url_open", text
="Wiki", icon
='HELP',).url
= "https://github.com/Mano-Wii/Addon-Snap-Utilities-Line/wiki"
183 layout
.operator("wm.url_open", text
="Forum", icon
='HELP',).url
= "https://blenderartists.org/t/cad-snap-utilities"
186 def draw_snap_utilities_keymaps(self
, context
, layout
):
188 generate_snap_utilities_global_keymaps
,
189 generate_snap_utilities_tools_keymaps
,
192 wm
= context
.window_manager
193 #kc = wm.keyconfigs.addon
194 kc
= wm
.keyconfigs
.user
196 layout
.label(text
="Global:")
198 for km_name
, km_args
, km_content
in generate_snap_utilities_global_keymaps():
199 km
= kc
.keymaps
.get(km_name
)
201 self
.draw_snap_utilities_km(kc
, km
, layout
)
203 layout
.label(text
="Tools:")
205 for km_name
, km_args
, km_content
in generate_snap_utilities_tools_keymaps():
206 km
= kc
.keymaps
.get(km_name
)
208 self
.draw_snap_utilities_km(kc
, km
, layout
)
211 def draw_snap_utilities_km(kc
, km
, layout
):
212 layout
.context_pointer_set("keymap", km
)
215 row
.prop(km
, "show_expanded_items", text
="", emboss
=False)
216 row
.label(text
=km
.name
, text_ctxt
=i18n_contexts
.id_windowmanager
)
218 if km
.show_expanded_items
:
219 col
= layout
.column()
221 for kmi
in km
.keymap_items
:
222 if "snap_utilities" in kmi
.idname
:
223 rna_keymap_ui
.draw_kmi(["ADDON", "USER", "DEFAULT"], kc
, km
, kmi
, col
, 0)