Import_3ds: Improved distance cue chunk import
[blender-addons.git] / mesh_snap_utilities_line / preferences.py
blob33952b80413d045d51cf13b6ef364c836f6a4c96
1 # SPDX-FileCopyrightText: 2018-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 import bpy
7 from bpy.props import (
8 EnumProperty,
9 StringProperty,
10 BoolProperty,
11 IntProperty,
12 FloatVectorProperty,
13 FloatProperty,
16 from bpy.app.translations import contexts as i18n_contexts
18 import rna_keymap_ui
21 class SnapUtilitiesPreferences(bpy.types.AddonPreferences):
22 # this must match the addon name, use '__package__'
23 # when defining this in a submodule of a python package.
24 bl_idname = __package__
26 intersect: BoolProperty(
27 name="Intersect",
28 description="intersects created line with the existing edges, even if the lines do not intersect",
29 default=True)
31 create_face: BoolProperty(name="Create faces",
32 description="Create faces defined by enclosed edges",
33 default=False)
35 outer_verts: BoolProperty(name="Snap to outer vertices",
36 description="The vertices of the objects are not activated also snapped",
37 default=True)
39 increments_grid: BoolProperty(name="Increments of Grid",
40 description="Snap to increments of grid",
41 default=False)
43 auto_constrain: BoolProperty(name="Automatic Constraint",
44 description="Detects a direction to constrain depending on the position of the mouse",
45 default=False)
47 incremental: FloatProperty(name="Incremental",
48 description="Snap in defined increments",
49 default=0,
50 min=0,
51 step=1,
52 precision=3)
54 relative_scale: FloatProperty(name="Relative Scale",
55 description="Value that divides the global scale",
56 default=1,
57 min=0,
58 step=1,
59 precision=3)
61 out_color: FloatVectorProperty(name="Floor",
62 default=(0.0, 0.0, 0.0, 0.5),
63 size=4,
64 subtype="COLOR",
65 min=0,
66 max=1)
68 face_color: FloatVectorProperty(name="Face Highlighted",
69 default=(1.0, 0.8, 0.0, 0.5),
70 size=4,
71 subtype="COLOR",
72 min=0,
73 max=1)
75 edge_color: FloatVectorProperty(name="Edge Highlighted",
76 default=(0.0, 0.8, 1.0, 0.5),
77 size=4,
78 subtype="COLOR",
79 min=0,
80 max=1)
82 vert_color: FloatVectorProperty(name="Vertex Highlighted",
83 default=(1.0, 0.5, 0.0, 0.5),
84 size=4, subtype="COLOR",
85 min=0,
86 max=1)
88 center_color: FloatVectorProperty(name="Middle of the Edge",
89 default=(1.0, 0.0, 1.0, 1.0),
90 size=4,
91 subtype="COLOR",
92 min=0,
93 max=1)
95 perpendicular_color: FloatVectorProperty(name="Perpendicular Point",
96 default=(0.1, 0.5, 0.5, 1.0),
97 size=4,
98 subtype="COLOR",
99 min=0,
100 max=1)
102 constrain_shift_color: FloatVectorProperty(name="Shift Constrain",
103 default=(0.8, 0.5, 0.4, 1.0),
104 size=4,
105 subtype="COLOR",
106 min=0,
107 max=1)
109 tabs: EnumProperty(name="Tabs",
110 items=[("GENERAL", "General", ""),
111 ("KEYMAPS", "Keymaps", ""),
112 ("COLORS", "Colors", ""),
113 ("HELP", "Links", ""), ],
114 default="GENERAL")
116 def draw(self, context):
117 layout = self.layout
119 # TAB BAR
120 row = layout.row()
121 row.prop(self, "tabs", expand=True)
123 box = layout.box()
125 if self.tabs == "GENERAL":
126 self.draw_general(box)
128 elif self.tabs == "COLORS":
129 self.draw_snap_utilities_colors(box)
131 elif self.tabs == "KEYMAPS":
132 self.draw_snap_utilities_keymaps(context, box)
134 elif self.tabs == "HELP":
135 self.draw_snap_utilities_help(box)
137 def draw_general(self, layout):
138 row = layout.row()
139 col = row.column()
141 col.label(text="Snap Properties:")
142 col.prop(self, "incremental")
143 col.prop(self, "increments_grid")
144 if self.increments_grid:
145 col.prop(self, "relative_scale")
147 col.prop(self, "outer_verts")
148 row.separator()
150 col = row.column()
151 col.label(text="Line Tool:")
152 col.prop(self, "intersect")
153 col.prop(self, "create_face")
155 def draw_snap_utilities_colors(self, layout):
156 layout.use_property_split = True
158 flow = layout.grid_flow(
159 row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
161 flow.prop(self, "out_color")
162 flow.prop(self, "constrain_shift_color")
163 flow.prop(self, "face_color")
164 flow.prop(self, "edge_color")
165 flow.prop(self, "vert_color")
166 flow.prop(self, "center_color")
167 flow.prop(self, "perpendicular_color")
169 def draw_snap_utilities_help(self, layout):
170 # layout.operator("wm.url_open", text="Gumroad Page", icon='HELP',).url = "https://gum.co/IaqQf"
171 # layout.operator("wm.url_open", text="Blender Market Page", icon='HELP',).url = "https://blendermarket.com/products/snap-utilities"
172 layout.operator("wm.url_open", text="Wiki", icon='HELP',
173 ).url = "https://github.com/Mano-Wii/Addon-Snap-Utilities-Line/wiki"
174 layout.operator("wm.url_open", text="Forum", icon='HELP',
175 ).url = "https://blenderartists.org/t/cad-snap-utilities"
177 def draw_snap_utilities_keymaps(self, context, layout):
178 from .keys import (
179 generate_snap_utilities_global_keymaps,
180 generate_snap_utilities_tools_keymaps,
183 wm = context.window_manager
184 # kc = wm.keyconfigs.addon
185 kc = wm.keyconfigs.user
187 layout.label(text="Global:")
189 for km_name, km_args, km_content in generate_snap_utilities_global_keymaps():
190 km = kc.keymaps.get(km_name)
191 if km:
192 self.draw_snap_utilities_km(kc, km, layout)
194 layout.label(text="Tools:")
196 for km_name, km_args, km_content in generate_snap_utilities_tools_keymaps():
197 km = kc.keymaps.get(km_name)
198 if km:
199 self.draw_snap_utilities_km(kc, km, layout)
201 @staticmethod
202 def draw_snap_utilities_km(kc, km, layout):
203 layout.context_pointer_set("keymap", km)
205 row = layout.row()
206 row.prop(km, "show_expanded_items", text="", emboss=False)
207 row.label(text=km.name, text_ctxt=i18n_contexts.id_windowmanager)
209 if km.show_expanded_items:
210 col = layout.column()
212 for kmi in km.keymap_items:
213 if "snap_utilities" in kmi.idname:
214 rna_keymap_ui.draw_kmi(
215 ["ADDON", "USER", "DEFAULT"], kc, km, kmi, col, 0)