space_userpref.py 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  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 2
  6. # of the License, or (at your option) any later version.
  7. #
  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.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. import bpy
  20. from bpy.types import (
  21. Header,
  22. Menu,
  23. Panel,
  24. )
  25. from bpy.app.translations import pgettext_iface as iface_
  26. from bpy.app.translations import contexts as i18n_contexts
  27. class USERPREF_HT_header(Header):
  28. bl_space_type = 'PREFERENCES'
  29. @staticmethod
  30. def draw_buttons(layout, context):
  31. prefs = context.preferences
  32. layout.scale_x = 1.0
  33. layout.scale_y = 1.0
  34. layout.operator_context = 'EXEC_AREA'
  35. row = layout.row()
  36. row.menu("USERPREF_MT_save_load", text="", icon='COLLAPSEMENU')
  37. if prefs.use_preferences_save and (not bpy.app.use_userpref_skip_save_on_exit):
  38. pass
  39. else:
  40. sub = row.row(align=True)
  41. sub.active = prefs.is_dirty
  42. sub.operator("wm.save_userpref")
  43. def draw(self, context):
  44. layout = self.layout
  45. layout.operator_context = 'EXEC_AREA'
  46. layout.template_header()
  47. layout.separator_spacer()
  48. self.draw_buttons(layout, context)
  49. class USERPREF_PT_navigation_bar(Panel):
  50. bl_label = "Preferences Navigation"
  51. bl_space_type = 'PREFERENCES'
  52. bl_region_type = 'NAVIGATION_BAR'
  53. bl_options = {'HIDE_HEADER'}
  54. def draw(self, context):
  55. layout = self.layout
  56. prefs = context.preferences
  57. col = layout.column()
  58. col.scale_x = 1.3
  59. col.scale_y = 1.3
  60. col.prop(prefs, "active_section", expand=True)
  61. class USERPREF_MT_save_load(Menu):
  62. bl_label = "Save & Load"
  63. def draw(self, context):
  64. layout = self.layout
  65. prefs = context.preferences
  66. layout.prop(prefs, "use_preferences_save", text="Auto-Save Preferences")
  67. layout.separator()
  68. layout.operator_context = 'EXEC_AREA'
  69. if prefs.use_preferences_save:
  70. layout.operator("wm.save_userpref", text="Save Preferences")
  71. sub_revert = layout.column(align=True)
  72. sub_revert.active = prefs.is_dirty
  73. sub_revert.operator("wm.read_userpref", text="Revert to Saved Preferences")
  74. layout.operator_context = 'INVOKE_AREA'
  75. layout.operator("wm.read_factory_userpref", text="Load Factory Preferences")
  76. class USERPREF_PT_save_preferences(Panel):
  77. bl_label = "Save Preferences"
  78. bl_space_type = 'PREFERENCES'
  79. bl_region_type = 'EXECUTE'
  80. bl_options = {'HIDE_HEADER'}
  81. @classmethod
  82. def poll(cls, context):
  83. # Hide when header is visible
  84. for region in context.area.regions:
  85. if region.type == 'HEADER' and region.height <= 1:
  86. return True
  87. return False
  88. def draw(self, context):
  89. layout = self.layout
  90. layout.operator_context = 'EXEC_AREA'
  91. layout.scale_x = 1.3
  92. layout.scale_y = 1.3
  93. USERPREF_HT_header.draw_buttons(layout, context)
  94. # Panel mix-in.
  95. class PreferencePanel:
  96. """
  97. Base class for panels to center align contents with some horizontal margin.
  98. Deriving classes need to implement a ``draw_props(context, layout)`` function.
  99. """
  100. bl_space_type = 'PREFERENCES'
  101. bl_region_type = 'WINDOW'
  102. def draw(self, context):
  103. layout = self.layout
  104. width = context.region.width
  105. ui_scale = context.preferences.system.ui_scale
  106. layout.use_property_split = True
  107. layout.use_property_decorate = False # No animation.
  108. row = layout.row()
  109. if width > (350 * ui_scale): # No horizontal margin if region is rather small.
  110. row.label() # Needed so col below is centered.
  111. col = row.column()
  112. col.ui_units_x = 50
  113. # draw_props implemented by deriving classes.
  114. self.draw_props(context, col)
  115. if width > (350 * ui_scale): # No horizontal margin if region is rather small.
  116. row.label() # Needed so col above is centered.
  117. class USERPREF_PT_interface_display(PreferencePanel, Panel):
  118. bl_label = "Display"
  119. @classmethod
  120. def poll(cls, context):
  121. prefs = context.preferences
  122. return (prefs.active_section == 'INTERFACE')
  123. def draw_props(self, context, layout):
  124. prefs = context.preferences
  125. view = prefs.view
  126. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  127. flow.prop(view, "ui_scale", text="Resolution Scale")
  128. flow.prop(view, "ui_line_width", text="Line Width")
  129. layout.separator()
  130. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  131. flow.prop(view, "show_splash", text="Splash Screen")
  132. flow.prop(view, "show_tooltips")
  133. flow.prop(view, "show_tooltips_python")
  134. flow.prop(view, "show_developer_ui")
  135. flow.prop(view, "show_large_cursors")
  136. class USERPREF_PT_interface_text(PreferencePanel, Panel):
  137. bl_label = "Text Rendering"
  138. bl_options = {'DEFAULT_CLOSED'}
  139. @classmethod
  140. def poll(cls, context):
  141. prefs = context.preferences
  142. return (prefs.active_section == 'INTERFACE')
  143. def draw_props(self, context, layout):
  144. prefs = context.preferences
  145. view = prefs.view
  146. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  147. flow.prop(view, "use_text_antialiasing", text="Anti-aliasing")
  148. sub = flow.column()
  149. sub.active = view.use_text_antialiasing
  150. sub.prop(view, "text_hinting", text="Hinting")
  151. flow.prop(view, "font_path_ui")
  152. flow.prop(view, "font_path_ui_mono")
  153. class USERPREF_PT_interface_translation(PreferencePanel, Panel):
  154. bl_label = "Translation"
  155. bl_translation_context = i18n_contexts.id_windowmanager
  156. @classmethod
  157. def poll(cls, context):
  158. prefs = context.preferences
  159. return (prefs.active_section == 'INTERFACE') and bpy.app.build_options.international
  160. def draw_header(self, context):
  161. prefs = context.preferences
  162. view = prefs.view
  163. self.layout.prop(view, "use_international_fonts", text="")
  164. def draw_props(self, context, layout):
  165. prefs = context.preferences
  166. view = prefs.view
  167. layout.active = view.use_international_fonts
  168. layout.prop(view, "language")
  169. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  170. flow.prop(view, "use_translate_tooltips", text="Tooltips")
  171. flow.prop(view, "use_translate_interface", text="Interface")
  172. flow.prop(view, "use_translate_new_dataname", text="New Data")
  173. class USERPREF_PT_interface_editors(PreferencePanel, Panel):
  174. bl_label = "Editors"
  175. @classmethod
  176. def poll(cls, context):
  177. prefs = context.preferences
  178. return (prefs.active_section == 'INTERFACE')
  179. def draw_props(self, context, layout):
  180. prefs = context.preferences
  181. view = prefs.view
  182. system = prefs.system
  183. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  184. flow.prop(system, "use_region_overlap")
  185. flow.prop(view, "show_layout_ui", text="Corner Splitting")
  186. flow.prop(view, "show_navigate_ui")
  187. flow.prop(view, "color_picker_type")
  188. flow.row().prop(view, "header_align")
  189. flow.prop(view, "factor_display_type")
  190. class USERPREF_PT_interface_menus(Panel):
  191. bl_space_type = 'PREFERENCES'
  192. bl_region_type = 'WINDOW'
  193. bl_label = "Menus"
  194. bl_options = {'DEFAULT_CLOSED'}
  195. @classmethod
  196. def poll(cls, context):
  197. prefs = context.preferences
  198. return (prefs.active_section == 'INTERFACE')
  199. def draw(self, context):
  200. pass
  201. class USERPREF_PT_interface_menus_mouse_over(PreferencePanel, Panel):
  202. bl_label = "Open on Mouse Over"
  203. bl_parent_id = "USERPREF_PT_interface_menus"
  204. def draw_header(self, context):
  205. prefs = context.preferences
  206. view = prefs.view
  207. self.layout.prop(view, "use_mouse_over_open", text="")
  208. def draw_props(self, context, layout):
  209. prefs = context.preferences
  210. view = prefs.view
  211. layout.active = view.use_mouse_over_open
  212. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  213. flow.prop(view, "open_toplevel_delay", text="Top Level")
  214. flow.prop(view, "open_sublevel_delay", text="Sub Level")
  215. class USERPREF_PT_interface_menus_pie(PreferencePanel, Panel):
  216. bl_label = "Pie Menus"
  217. bl_parent_id = "USERPREF_PT_interface_menus"
  218. def draw_props(self, context, layout):
  219. prefs = context.preferences
  220. view = prefs.view
  221. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  222. flow.prop(view, "pie_animation_timeout")
  223. flow.prop(view, "pie_tap_timeout")
  224. flow.prop(view, "pie_initial_timeout")
  225. flow.prop(view, "pie_menu_radius")
  226. flow.prop(view, "pie_menu_threshold")
  227. flow.prop(view, "pie_menu_confirm")
  228. class USERPREF_PT_edit_objects(Panel):
  229. bl_label = "Objects"
  230. bl_space_type = 'PREFERENCES'
  231. bl_region_type = 'WINDOW'
  232. @classmethod
  233. def poll(cls, context):
  234. prefs = context.preferences
  235. return (prefs.active_section == 'EDITING')
  236. def draw(self, context):
  237. pass
  238. class USERPREF_PT_edit_objects_new(PreferencePanel, Panel):
  239. bl_label = "New Objects"
  240. bl_parent_id = "USERPREF_PT_edit_objects"
  241. def draw_props(self, context, layout):
  242. prefs = context.preferences
  243. edit = prefs.edit
  244. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  245. flow.prop(edit, "material_link", text="Link Materials to")
  246. flow.prop(edit, "object_align", text="Align to")
  247. flow.prop(edit, "use_enter_edit_mode", text="Enter Edit Mode")
  248. class USERPREF_PT_edit_objects_duplicate_data(PreferencePanel, Panel):
  249. bl_label = "Duplicate Data"
  250. bl_parent_id = "USERPREF_PT_edit_objects"
  251. def draw_props(self, context, layout):
  252. prefs = context.preferences
  253. edit = prefs.edit
  254. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
  255. col = flow.column()
  256. col.prop(edit, "use_duplicate_action", text="Action")
  257. col.prop(edit, "use_duplicate_armature", text="Armature")
  258. col.prop(edit, "use_duplicate_curve", text="Curve")
  259. # col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
  260. col.prop(edit, "use_duplicate_light", text="Light")
  261. col.prop(edit, "use_duplicate_lightprobe", text="Light Probe")
  262. col = flow.column()
  263. col.prop(edit, "use_duplicate_material", text="Material")
  264. col.prop(edit, "use_duplicate_mesh", text="Mesh")
  265. col.prop(edit, "use_duplicate_metaball", text="Metaball")
  266. col.prop(edit, "use_duplicate_particle", text="Particle")
  267. col = flow.column()
  268. col.prop(edit, "use_duplicate_surface", text="Surface")
  269. col.prop(edit, "use_duplicate_text", text="Text")
  270. col.prop(edit, "use_duplicate_texture", text="Texture")
  271. col.prop(edit, "use_duplicate_grease_pencil", text="Grease Pencil")
  272. class USERPREF_PT_edit_cursor(PreferencePanel, Panel):
  273. bl_label = "3D Cursor"
  274. @classmethod
  275. def poll(cls, context):
  276. prefs = context.preferences
  277. return (prefs.active_section == 'EDITING')
  278. def draw_props(self, context, layout):
  279. prefs = context.preferences
  280. edit = prefs.edit
  281. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  282. flow.prop(edit, "use_mouse_depth_cursor")
  283. flow.prop(edit, "use_cursor_lock_adjust")
  284. class USERPREF_PT_edit_gpencil(PreferencePanel, Panel):
  285. bl_label = "Grease Pencil"
  286. bl_options = {'DEFAULT_CLOSED'}
  287. @classmethod
  288. def poll(cls, context):
  289. prefs = context.preferences
  290. return (prefs.active_section == 'EDITING')
  291. def draw_props(self, context, layout):
  292. prefs = context.preferences
  293. edit = prefs.edit
  294. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  295. flow.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
  296. flow.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
  297. class USERPREF_PT_edit_annotations(PreferencePanel, Panel):
  298. bl_label = "Annotations"
  299. @classmethod
  300. def poll(cls, context):
  301. prefs = context.preferences
  302. return (prefs.active_section == 'EDITING')
  303. def draw_props(self, context, layout):
  304. prefs = context.preferences
  305. edit = prefs.edit
  306. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  307. flow.prop(edit, "grease_pencil_default_color", text="Default Color")
  308. flow.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
  309. flow.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
  310. class USERPREF_PT_edit_weight_paint(PreferencePanel, Panel):
  311. bl_label = "Weight Paint"
  312. bl_options = {'DEFAULT_CLOSED'}
  313. @classmethod
  314. def poll(cls, context):
  315. prefs = context.preferences
  316. return (prefs.active_section == 'EDITING')
  317. def draw_props(self, context, layout):
  318. prefs = context.preferences
  319. view = prefs.view
  320. layout.prop(view, "use_weight_color_range", text="Use Custom Colors")
  321. col = layout.column()
  322. col.active = view.use_weight_color_range
  323. col.template_color_ramp(view, "weight_color_range", expand=True)
  324. class USERPREF_PT_edit_misc(PreferencePanel, Panel):
  325. bl_label = "Miscellaneous"
  326. bl_options = {'DEFAULT_CLOSED'}
  327. @classmethod
  328. def poll(cls, context):
  329. prefs = context.preferences
  330. return (prefs.active_section == 'EDITING')
  331. def draw_props(self, context, layout):
  332. prefs = context.preferences
  333. edit = prefs.edit
  334. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  335. flow.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
  336. flow.prop(edit, "node_margin", text="Node Auto-offset Margin")
  337. class USERPREF_PT_animation_timeline(PreferencePanel, Panel):
  338. bl_label = "Timeline"
  339. @classmethod
  340. def poll(cls, context):
  341. prefs = context.preferences
  342. return (prefs.active_section == 'ANIMATION')
  343. def draw_props(self, context, layout):
  344. prefs = context.preferences
  345. view = prefs.view
  346. edit = prefs.edit
  347. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  348. flow.prop(edit, "use_negative_frames")
  349. layout.separator()
  350. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  351. flow.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
  352. flow.prop(view, "timecode_style")
  353. flow.prop(view, "view_frame_type")
  354. if view.view_frame_type == 'SECONDS':
  355. flow.prop(view, "view_frame_seconds")
  356. elif view.view_frame_type == 'KEYFRAMES':
  357. flow.prop(view, "view_frame_keyframes")
  358. class USERPREF_PT_animation_keyframes(PreferencePanel, Panel):
  359. bl_label = "Keyframes"
  360. @classmethod
  361. def poll(cls, context):
  362. prefs = context.preferences
  363. return (prefs.active_section == 'ANIMATION')
  364. def draw_props(self, context, layout):
  365. prefs = context.preferences
  366. edit = prefs.edit
  367. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  368. flow.prop(edit, "use_visual_keying")
  369. flow.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed")
  370. class USERPREF_PT_animation_autokey(PreferencePanel, Panel):
  371. bl_label = "Auto-Keyframing"
  372. bl_parent_id = "USERPREF_PT_animation_keyframes"
  373. def draw_props(self, context, layout):
  374. prefs = context.preferences
  375. edit = prefs.edit
  376. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  377. flow.prop(edit, "use_auto_keying_warning", text="Show Warning")
  378. flow.prop(edit, "use_keyframe_insert_available", text="Only Insert Available")
  379. flow.prop(edit, "use_auto_keying", text="Enable in New Scenes")
  380. class USERPREF_PT_animation_fcurves(PreferencePanel, Panel):
  381. bl_label = "F-Curves"
  382. @classmethod
  383. def poll(cls, context):
  384. prefs = context.preferences
  385. return (prefs.active_section == 'ANIMATION')
  386. def draw_props(self, context, layout):
  387. prefs = context.preferences
  388. edit = prefs.edit
  389. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  390. flow.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
  391. flow.prop(edit, "keyframe_new_interpolation_type", text="Default Interpolation")
  392. flow.prop(edit, "keyframe_new_handle_type", text="Default Handles")
  393. flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
  394. class USERPREF_PT_system_sound(PreferencePanel, Panel):
  395. bl_label = "Sound"
  396. @classmethod
  397. def poll(cls, context):
  398. prefs = context.preferences
  399. return (prefs.active_section == 'SYSTEM')
  400. def draw_props(self, context, layout):
  401. prefs = context.preferences
  402. system = prefs.system
  403. layout.prop(system, "audio_device", expand=False)
  404. sub = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False)
  405. sub.active = system.audio_device not in {'NONE', 'Null'}
  406. sub.prop(system, "audio_channels", text="Channels")
  407. sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
  408. sub.prop(system, "audio_sample_rate", text="Sample Rate")
  409. sub.prop(system, "audio_sample_format", text="Sample Format")
  410. class USERPREF_PT_system_cycles_devices(PreferencePanel, Panel):
  411. bl_label = "Cycles Render Devices"
  412. @classmethod
  413. def poll(cls, context):
  414. prefs = context.preferences
  415. return (prefs.active_section == 'SYSTEM')
  416. def draw_props(self, context, layout):
  417. prefs = context.preferences
  418. col = layout.column()
  419. col.use_property_split = False
  420. if bpy.app.build_options.cycles:
  421. addon = prefs.addons.get("cycles")
  422. if addon is not None:
  423. addon.preferences.draw_impl(col, context)
  424. del addon
  425. # NOTE: Disabled for until GPU side of OpenSubdiv is brought back.
  426. # system = prefs.system
  427. # if hasattr(system, "opensubdiv_compute_type"):
  428. # col.label(text="OpenSubdiv compute:")
  429. # col.row().prop(system, "opensubdiv_compute_type", text="")
  430. class USERPREF_PT_viewport_display(PreferencePanel, Panel):
  431. bl_label = "Display"
  432. @classmethod
  433. def poll(cls, context):
  434. prefs = context.preferences
  435. return (prefs.active_section == 'VIEWPORT')
  436. def draw_props(self, context, layout):
  437. prefs = context.preferences
  438. view = prefs.view
  439. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  440. flow.prop(view, "show_object_info", text="Object Info")
  441. flow.prop(view, "show_view_name", text="View Name")
  442. flow.prop(view, "show_playback_fps", text="Playback FPS")
  443. layout.separator()
  444. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  445. col = flow.column()
  446. col.prop(view, "gizmo_size")
  447. col.prop(view, "lookdev_sphere_size")
  448. flow.separator()
  449. col = flow.column()
  450. col.prop(view, "mini_axis_type", text="3D Viewport Axis")
  451. if view.mini_axis_type == 'MINIMAL':
  452. col.prop(view, "mini_axis_size", text="Size")
  453. col.prop(view, "mini_axis_brightness", text="Brightness")
  454. class USERPREF_PT_viewport_quality(PreferencePanel, Panel):
  455. bl_label = "Quality"
  456. @classmethod
  457. def poll(cls, context):
  458. prefs = context.preferences
  459. return (prefs.active_section == 'VIEWPORT')
  460. def draw_props(self, context, layout):
  461. prefs = context.preferences
  462. system = prefs.system
  463. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  464. flow.prop(system, "viewport_aa")
  465. flow.prop(system, "multi_sample", text="Multisampling")
  466. flow.prop(system, "gpencil_multi_sample", text="Grease Pencil Multisampling")
  467. flow.prop(system, "use_edit_mode_smooth_wire")
  468. class USERPREF_PT_viewport_textures(PreferencePanel, Panel):
  469. bl_label = "Textures"
  470. @classmethod
  471. def poll(cls, context):
  472. prefs = context.preferences
  473. return (prefs.active_section == 'VIEWPORT')
  474. def draw_props(self, context, layout):
  475. prefs = context.preferences
  476. system = prefs.system
  477. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  478. flow.prop(system, "gl_texture_limit", text="Limit Size")
  479. flow.prop(system, "anisotropic_filter")
  480. flow.prop(system, "gl_clip_alpha", slider=True)
  481. flow.prop(system, "image_draw_method", text="Image Display Method")
  482. class USERPREF_PT_viewport_selection(PreferencePanel, Panel):
  483. bl_label = "Selection"
  484. bl_options = {'DEFAULT_CLOSED'}
  485. @classmethod
  486. def poll(cls, context):
  487. prefs = context.preferences
  488. return (prefs.active_section == 'VIEWPORT')
  489. def draw_props(self, context, layout):
  490. prefs = context.preferences
  491. system = prefs.system
  492. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  493. flow.prop(system, "use_select_pick_depth")
  494. class USERPREF_PT_system_memory(PreferencePanel, Panel):
  495. bl_label = "Memory & Limits"
  496. @classmethod
  497. def poll(cls, context):
  498. prefs = context.preferences
  499. return (prefs.active_section == 'SYSTEM')
  500. def draw_props(self, context, layout):
  501. prefs = context.preferences
  502. system = prefs.system
  503. edit = prefs.edit
  504. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  505. flow.prop(edit, "undo_steps", text="Undo Steps")
  506. flow.prop(edit, "undo_memory_limit", text="Undo Memory Limit")
  507. flow.prop(edit, "use_global_undo")
  508. layout.separator()
  509. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  510. flow.prop(system, "memory_cache_limit", text="Sequencer Cache Limit")
  511. flow.prop(system, "scrollback", text="Console Scrollback Lines")
  512. layout.separator()
  513. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  514. flow.prop(system, "texture_time_out", text="Texture Time Out")
  515. flow.prop(system, "texture_collection_rate", text="Garbage Collection Rate")
  516. layout.separator()
  517. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  518. flow.prop(system, "vbo_time_out", text="Vbo Time Out")
  519. flow.prop(system, "vbo_collection_rate", text="Garbage Collection Rate")
  520. class USERPREF_MT_interface_theme_presets(Menu):
  521. bl_label = "Presets"
  522. preset_subdir = "interface_theme"
  523. preset_operator = "script.execute_preset"
  524. preset_type = 'XML'
  525. preset_xml_map = (
  526. ("preferences.themes[0]", "Theme"),
  527. ("preferences.ui_styles[0]", "ThemeStyle"),
  528. )
  529. draw = Menu.draw_preset
  530. @staticmethod
  531. def reset_cb(context):
  532. bpy.ops.preferences.reset_default_theme()
  533. class USERPREF_PT_theme(Panel):
  534. bl_space_type = 'PREFERENCES'
  535. bl_label = "Themes"
  536. bl_region_type = 'WINDOW'
  537. bl_options = {'HIDE_HEADER'}
  538. @classmethod
  539. def poll(cls, context):
  540. prefs = context.preferences
  541. return (prefs.active_section == 'THEMES')
  542. def draw(self, _context):
  543. layout = self.layout
  544. split = layout.split(factor=0.6)
  545. row = split.row(align=True)
  546. row.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
  547. row.operator("wm.interface_theme_preset_add", text="", icon='ADD')
  548. row.operator("wm.interface_theme_preset_add", text="", icon='REMOVE').remove_active = True
  549. row = split.row(align=True)
  550. row.operator("preferences.theme_install", text="Install...", icon='IMPORT')
  551. row.operator("preferences.reset_default_theme", text="Reset", icon='LOOP_BACK')
  552. class USERPREF_PT_theme_user_interface(PreferencePanel, Panel):
  553. bl_space_type = 'PREFERENCES'
  554. bl_region_type = 'WINDOW'
  555. bl_label = "User Interface"
  556. bl_options = {'DEFAULT_CLOSED'}
  557. @classmethod
  558. def poll(cls, context):
  559. prefs = context.preferences
  560. return (prefs.active_section == 'THEMES')
  561. def draw_header(self, _context):
  562. layout = self.layout
  563. layout.label(icon='WORKSPACE')
  564. def draw(self, context):
  565. pass
  566. # Base class for dynamically defined widget color panels.
  567. class PreferenceThemeWidgetColorPanel:
  568. bl_space_type = 'PREFERENCES'
  569. bl_region_type = 'WINDOW'
  570. bl_parent_id = "USERPREF_PT_theme_user_interface"
  571. def draw(self, context):
  572. theme = context.preferences.themes[0]
  573. ui = theme.user_interface
  574. widget_style = getattr(ui, self.wcol)
  575. layout = self.layout
  576. layout.use_property_split = True
  577. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  578. col = flow.column()
  579. col.prop(widget_style, "outline")
  580. col.prop(widget_style, "item", slider=True)
  581. col.prop(widget_style, "inner", slider=True)
  582. col.prop(widget_style, "inner_sel", slider=True)
  583. col = flow.column()
  584. col.prop(widget_style, "text")
  585. col.prop(widget_style, "text_sel")
  586. col.prop(widget_style, "roundness")
  587. col = flow.column()
  588. col.prop(widget_style, "show_shaded")
  589. colsub = col.column()
  590. colsub.active = widget_style.show_shaded
  591. colsub.prop(widget_style, "shadetop")
  592. colsub.prop(widget_style, "shadedown")
  593. @classmethod
  594. def poll(cls, context):
  595. prefs = context.preferences
  596. return (prefs.active_section == 'THEMES')
  597. class USERPREF_PT_theme_interface_state(PreferencePanel, Panel):
  598. bl_label = "State"
  599. bl_options = {'DEFAULT_CLOSED'}
  600. bl_parent_id = "USERPREF_PT_theme_user_interface"
  601. def draw_props(self, context, layout):
  602. theme = context.preferences.themes[0]
  603. ui_state = theme.user_interface.wcol_state
  604. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  605. col = flow.column(align=True)
  606. col.prop(ui_state, "inner_anim")
  607. col.prop(ui_state, "inner_anim_sel")
  608. col = flow.column(align=True)
  609. col.prop(ui_state, "inner_driven")
  610. col.prop(ui_state, "inner_driven_sel")
  611. col = flow.column(align=True)
  612. col.prop(ui_state, "inner_key")
  613. col.prop(ui_state, "inner_key_sel")
  614. col = flow.column(align=True)
  615. col.prop(ui_state, "inner_overridden")
  616. col.prop(ui_state, "inner_overridden_sel")
  617. col = flow.column(align=True)
  618. col.prop(ui_state, "inner_changed")
  619. col.prop(ui_state, "inner_changed_sel")
  620. col = flow.column(align=True)
  621. col.prop(ui_state, "blend")
  622. class USERPREF_PT_theme_interface_styles(PreferencePanel, Panel):
  623. bl_label = "Styles"
  624. bl_options = {'DEFAULT_CLOSED'}
  625. bl_parent_id = "USERPREF_PT_theme_user_interface"
  626. def draw_props(self, context, layout):
  627. theme = context.preferences.themes[0]
  628. ui = theme.user_interface
  629. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  630. flow.prop(ui, "menu_shadow_fac")
  631. flow.prop(ui, "icon_alpha")
  632. flow.prop(ui, "icon_saturation")
  633. flow.prop(ui, "editor_outline")
  634. flow.prop(ui, "menu_shadow_width")
  635. flow.prop(ui, "widget_emboss")
  636. class USERPREF_PT_theme_interface_gizmos(PreferencePanel, Panel):
  637. bl_label = "Axis & Gizmo Colors"
  638. bl_options = {'DEFAULT_CLOSED'}
  639. bl_parent_id = "USERPREF_PT_theme_user_interface"
  640. def draw_props(self, context, layout):
  641. theme = context.preferences.themes[0]
  642. ui = theme.user_interface
  643. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=True, align=False)
  644. col = flow.column(align=True)
  645. col.prop(ui, "axis_x", text="Axis X")
  646. col.prop(ui, "axis_y", text="Y")
  647. col.prop(ui, "axis_z", text="Z")
  648. col = flow.column()
  649. col.prop(ui, "gizmo_primary")
  650. col.prop(ui, "gizmo_secondary")
  651. col = flow.column()
  652. col.prop(ui, "gizmo_a")
  653. col.prop(ui, "gizmo_b")
  654. class USERPREF_PT_theme_interface_icons(PreferencePanel, Panel):
  655. bl_label = "Icon Colors"
  656. bl_options = {'DEFAULT_CLOSED'}
  657. bl_parent_id = "USERPREF_PT_theme_user_interface"
  658. def draw_props(self, context, layout):
  659. theme = context.preferences.themes[0]
  660. ui = theme.user_interface
  661. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  662. flow.prop(ui, "icon_scene")
  663. flow.prop(ui, "icon_collection")
  664. flow.prop(ui, "icon_object")
  665. flow.prop(ui, "icon_object_data")
  666. flow.prop(ui, "icon_modifier")
  667. flow.prop(ui, "icon_shading")
  668. flow.prop(ui, "icon_border_intensity")
  669. class USERPREF_PT_theme_text_style(PreferencePanel, Panel):
  670. bl_label = "Text Style"
  671. bl_options = {'DEFAULT_CLOSED'}
  672. @classmethod
  673. def poll(cls, context):
  674. prefs = context.preferences
  675. return (prefs.active_section == 'THEMES')
  676. @staticmethod
  677. def _ui_font_style(layout, font_style):
  678. layout.use_property_split = True
  679. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
  680. col = flow.column()
  681. col.row().prop(font_style, "font_kerning_style", expand=True)
  682. col.prop(font_style, "points")
  683. col = flow.column(align=True)
  684. col.prop(font_style, "shadow_offset_x", text="Shadow Offset X")
  685. col.prop(font_style, "shadow_offset_y", text="Y")
  686. col = flow.column()
  687. col.prop(font_style, "shadow")
  688. col.prop(font_style, "shadow_alpha")
  689. col.prop(font_style, "shadow_value")
  690. def draw_header(self, _context):
  691. layout = self.layout
  692. layout.label(icon='FONTPREVIEW')
  693. def draw_props(self, context, layout):
  694. style = context.preferences.ui_styles[0]
  695. layout.label(text="Panel Title")
  696. self._ui_font_style(layout, style.panel_title)
  697. layout.separator()
  698. layout.label(text="Widget")
  699. self._ui_font_style(layout, style.widget)
  700. layout.separator()
  701. layout.label(text="Widget Label")
  702. self._ui_font_style(layout, style.widget_label)
  703. class USERPREF_PT_theme_bone_color_sets(PreferencePanel, Panel):
  704. bl_label = "Bone Color Sets"
  705. bl_options = {'DEFAULT_CLOSED'}
  706. @classmethod
  707. def poll(cls, context):
  708. prefs = context.preferences
  709. return (prefs.active_section == 'THEMES')
  710. def draw_header(self, _context):
  711. layout = self.layout
  712. layout.label(icon='COLOR')
  713. def draw_props(self, context, layout):
  714. theme = context.preferences.themes[0]
  715. layout.use_property_split = True
  716. for i, ui in enumerate(theme.bone_color_sets, 1):
  717. layout.label(text=iface_(f"Color Set {i:d}"), translate=False)
  718. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  719. flow.prop(ui, "normal")
  720. flow.prop(ui, "select")
  721. flow.prop(ui, "active")
  722. flow.prop(ui, "show_colored_constraints")
  723. # Base class for dynamically defined theme-space panels.
  724. class PreferenceThemeSpacePanel:
  725. bl_space_type = 'PREFERENCES'
  726. bl_region_type = 'WINDOW'
  727. # not essential, hard-coded UI delimiters for the theme layout
  728. ui_delimiters = {
  729. 'VIEW_3D': {
  730. "text_grease_pencil",
  731. "text_keyframe",
  732. "speaker",
  733. "freestyle_face_mark",
  734. "split_normal",
  735. "bone_solid",
  736. "paint_curve_pivot",
  737. },
  738. 'GRAPH_EDITOR': {
  739. "handle_vertex_select",
  740. },
  741. 'IMAGE_EDITOR': {
  742. "paint_curve_pivot",
  743. },
  744. 'NODE_EDITOR': {
  745. "layout_node",
  746. },
  747. 'CLIP_EDITOR': {
  748. "handle_vertex_select",
  749. }
  750. }
  751. # TODO theme_area should be deprecated
  752. @staticmethod
  753. def _theme_generic(layout, themedata, theme_area):
  754. layout.use_property_split = True
  755. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  756. props_type = {}
  757. for prop in themedata.rna_type.properties:
  758. if prop.identifier == "rna_type":
  759. continue
  760. props_type.setdefault((prop.type, prop.subtype), []).append(prop)
  761. th_delimiters = PreferenceThemeSpacePanel.ui_delimiters.get(theme_area)
  762. for props_type, props_ls in sorted(props_type.items()):
  763. if props_type[0] == 'POINTER':
  764. continue
  765. if th_delimiters is None:
  766. # simple, no delimiters
  767. for prop in props_ls:
  768. flow.prop(themedata, prop.identifier)
  769. else:
  770. for prop in props_ls:
  771. flow.prop(themedata, prop.identifier)
  772. def draw_header(self, _context):
  773. if hasattr(self, "icon") and self.icon != 'NONE':
  774. layout = self.layout
  775. layout.label(icon=self.icon)
  776. def draw(self, context):
  777. layout = self.layout
  778. theme = context.preferences.themes[0]
  779. datapath_list = self.datapath.split(".")
  780. data = theme
  781. for datapath_item in datapath_list:
  782. data = getattr(data, datapath_item)
  783. PreferenceThemeSpacePanel._theme_generic(layout, data, self.theme_area)
  784. @classmethod
  785. def poll(cls, context):
  786. prefs = context.preferences
  787. return (prefs.active_section == 'THEMES')
  788. class ThemeGenericClassGenerator():
  789. @staticmethod
  790. def generate_panel_classes_for_wcols():
  791. wcols = [
  792. ("Regular", "wcol_regular"),
  793. ("Tool", "wcol_tool"),
  794. ("Toolbar Item", "wcol_toolbar_item"),
  795. ("Radio Buttons", "wcol_radio"),
  796. ("Text", "wcol_text"),
  797. ("Option", "wcol_option"),
  798. ("Toggle", "wcol_toggle"),
  799. ("Number Field", "wcol_num"),
  800. ("Value Slider", "wcol_numslider"),
  801. ("Box", "wcol_box"),
  802. ("Menu", "wcol_menu"),
  803. ("Pie Menu", "wcol_pie_menu"),
  804. ("Pulldown", "wcol_pulldown"),
  805. ("Menu Back", "wcol_menu_back"),
  806. ("Tooltip", "wcol_tooltip"),
  807. ("Menu Item", "wcol_menu_item"),
  808. ("Scroll Bar", "wcol_scroll"),
  809. ("Progress Bar", "wcol_progress"),
  810. ("List Item", "wcol_list_item"),
  811. ("Tab", "wcol_tab"),
  812. ]
  813. for (name, wcol) in wcols:
  814. panel_id = "USERPREF_PT_theme_interface_" + wcol
  815. yield type(panel_id, (PreferenceThemeWidgetColorPanel, Panel), {
  816. "bl_label": name,
  817. "bl_options": {'DEFAULT_CLOSED'},
  818. "draw": PreferenceThemeWidgetColorPanel.draw,
  819. "wcol": wcol,
  820. })
  821. @staticmethod
  822. def generate_theme_area_child_panel_classes(parent_id, rna_type, theme_area, datapath):
  823. def generate_child_panel_classes_recurse(parent_id, rna_type, theme_area, datapath):
  824. props_type = {}
  825. for prop in rna_type.properties:
  826. if prop.identifier == "rna_type":
  827. continue
  828. props_type.setdefault((prop.type, prop.subtype), []).append(prop)
  829. for props_type, props_ls in sorted(props_type.items()):
  830. if props_type[0] == 'POINTER':
  831. for prop in props_ls:
  832. new_datapath = datapath + "." + prop.identifier if datapath else prop.identifier
  833. panel_id = parent_id + "_" + prop.identifier
  834. yield type(panel_id, (PreferenceThemeSpacePanel, Panel), {
  835. "bl_label": rna_type.properties[prop.identifier].name,
  836. "bl_parent_id": parent_id,
  837. "bl_options": {'DEFAULT_CLOSED'},
  838. "draw": PreferenceThemeSpacePanel.draw,
  839. "theme_area": theme_area.identifier,
  840. "datapath": new_datapath,
  841. })
  842. yield from generate_child_panel_classes_recurse(panel_id, prop.fixed_type, theme_area, new_datapath)
  843. yield from generate_child_panel_classes_recurse(parent_id, rna_type, theme_area, datapath)
  844. @staticmethod
  845. def generate_panel_classes_from_theme_areas():
  846. from bpy.types import Theme
  847. for theme_area in Theme.bl_rna.properties['theme_area'].enum_items_static:
  848. if theme_area.identifier in {'USER_INTERFACE', 'STYLE', 'BONE_COLOR_SETS'}:
  849. continue
  850. panel_id = "USERPREF_PT_theme_" + theme_area.identifier.lower()
  851. # Generate panel-class from theme_area
  852. yield type(panel_id, (PreferenceThemeSpacePanel, Panel), {
  853. "bl_label": theme_area.name,
  854. "bl_options": {'DEFAULT_CLOSED'},
  855. "draw_header": PreferenceThemeSpacePanel.draw_header,
  856. "draw": PreferenceThemeSpacePanel.draw,
  857. "theme_area": theme_area.identifier,
  858. "icon": theme_area.icon,
  859. "datapath": theme_area.identifier.lower(),
  860. })
  861. yield from ThemeGenericClassGenerator.generate_theme_area_child_panel_classes(
  862. panel_id, Theme.bl_rna.properties[theme_area.identifier.lower()].fixed_type,
  863. theme_area, theme_area.identifier.lower())
  864. # Panel mix-in.
  865. class FilePathsPanel:
  866. bl_space_type = 'PREFERENCES'
  867. bl_region_type = 'WINDOW'
  868. @classmethod
  869. def poll(cls, context):
  870. prefs = context.preferences
  871. return (prefs.active_section == 'FILE_PATHS')
  872. def draw(self, context):
  873. layout = self.layout
  874. layout.use_property_split = True
  875. layout.use_property_decorate = False
  876. self.draw_props(context, layout)
  877. class USERPREF_PT_file_paths_data(FilePathsPanel, Panel):
  878. bl_label = "Data"
  879. def draw_props(self, context, _layout):
  880. paths = context.preferences.filepaths
  881. col = self.layout.column()
  882. col.prop(paths, "font_directory", text="Fonts")
  883. col.prop(paths, "texture_directory", text="Textures")
  884. col.prop(paths, "script_directory", text="Scripts")
  885. col.prop(paths, "sound_directory", text="Sounds")
  886. col.prop(paths, "temporary_directory", text="Temporary Files")
  887. class USERPREF_PT_file_paths_render(FilePathsPanel, Panel):
  888. bl_label = "Render"
  889. def draw_props(self, context, _layout):
  890. paths = context.preferences.filepaths
  891. col = self.layout.column()
  892. col.prop(paths, "render_output_directory", text="Render Output")
  893. col.prop(paths, "render_cache_directory", text="Render Cache")
  894. class USERPREF_PT_file_paths_applications(FilePathsPanel, Panel):
  895. bl_label = "Applications"
  896. def draw_props(self, context, layout):
  897. paths = context.preferences.filepaths
  898. col = layout.column()
  899. col.prop(paths, "image_editor", text="Image Editor")
  900. col.prop(paths, "animation_player_preset", text="Animation Player")
  901. if paths.animation_player_preset == 'CUSTOM':
  902. col.prop(paths, "animation_player", text="Player")
  903. class USERPREF_PT_file_paths_development(FilePathsPanel, Panel):
  904. bl_label = "Development"
  905. @classmethod
  906. def poll(cls, context):
  907. prefs = context.preferences
  908. return (prefs.active_section == 'FILE_PATHS') and prefs.view.show_developer_ui
  909. def draw_props(self, context, layout):
  910. paths = context.preferences.filepaths
  911. layout.prop(paths, "i18n_branches_directory", text="I18n Branches")
  912. class USERPREF_PT_saveload_autorun(PreferencePanel, Panel):
  913. bl_label = "Auto Run Python Scripts"
  914. bl_parent_id = "USERPREF_PT_saveload_blend"
  915. def draw_header(self, context):
  916. prefs = context.preferences
  917. paths = prefs.filepaths
  918. self.layout.prop(paths, "use_scripts_auto_execute", text="")
  919. def draw(self, context):
  920. layout = self.layout
  921. prefs = context.preferences
  922. paths = prefs.filepaths
  923. layout.use_property_split = True
  924. layout.use_property_decorate = False # No animation.
  925. layout.active = paths.use_scripts_auto_execute
  926. box = layout.box()
  927. row = box.row()
  928. row.label(text="Excluded Paths:")
  929. row.operator("wm.userpref_autoexec_path_add", text="", icon='ADD', emboss=False)
  930. for i, path_cmp in enumerate(prefs.autoexec_paths):
  931. row = box.row()
  932. row.prop(path_cmp, "path", text="")
  933. row.prop(path_cmp, "use_glob", text="", icon='FILTER')
  934. row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i
  935. class USERPREF_PT_saveload_blend(PreferencePanel, Panel):
  936. bl_label = "Blend Files"
  937. @classmethod
  938. def poll(cls, context):
  939. prefs = context.preferences
  940. return (prefs.active_section == 'SAVE_LOAD')
  941. def draw_props(self, context, layout):
  942. prefs = context.preferences
  943. paths = prefs.filepaths
  944. view = prefs.view
  945. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  946. flow.prop(paths, "use_relative_paths")
  947. flow.prop(paths, "use_file_compression")
  948. flow.prop(paths, "use_load_ui")
  949. flow.prop(paths, "use_save_preview_images")
  950. flow.prop(paths, "use_tabs_as_spaces")
  951. flow.prop(view, "use_save_prompt")
  952. layout.separator()
  953. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  954. flow.prop(paths, "save_version")
  955. flow.prop(paths, "recent_files")
  956. class USERPREF_PT_saveload_blend_autosave(PreferencePanel, Panel):
  957. bl_label = "Auto Save"
  958. bl_parent_id = "USERPREF_PT_saveload_blend"
  959. def draw_props(self, context, layout):
  960. prefs = context.preferences
  961. paths = prefs.filepaths
  962. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  963. flow.prop(paths, "use_auto_save_temporary_files")
  964. sub = flow.column()
  965. sub.active = paths.use_auto_save_temporary_files
  966. sub.prop(paths, "auto_save_time", text="Timer (mins)")
  967. class USERPREF_PT_saveload_file_browser(PreferencePanel, Panel):
  968. bl_label = "File Browser"
  969. @classmethod
  970. def poll(cls, context):
  971. prefs = context.preferences
  972. return (prefs.active_section == 'SAVE_LOAD')
  973. def draw_props(self, context, layout):
  974. prefs = context.preferences
  975. paths = prefs.filepaths
  976. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  977. flow.prop(paths, "use_filter_files")
  978. flow.prop(paths, "show_hidden_files_datablocks")
  979. flow.prop(paths, "hide_recent_locations")
  980. flow.prop(paths, "hide_system_bookmarks")
  981. flow.prop(paths, "show_thumbnails")
  982. class USERPREF_MT_ndof_settings(Menu):
  983. # accessed from the window key-bindings in C (only)
  984. bl_label = "3D Mouse Settings"
  985. def draw(self, context):
  986. layout = self.layout
  987. input_prefs = context.preferences.inputs
  988. is_view3d = context.space_data.type == 'VIEW_3D'
  989. layout.prop(input_prefs, "ndof_sensitivity")
  990. layout.prop(input_prefs, "ndof_orbit_sensitivity")
  991. layout.prop(input_prefs, "ndof_deadzone")
  992. if is_view3d:
  993. layout.separator()
  994. layout.prop(input_prefs, "ndof_show_guide")
  995. layout.separator()
  996. layout.label(text="Orbit Style")
  997. layout.row().prop(input_prefs, "ndof_view_navigate_method", text="")
  998. layout.row().prop(input_prefs, "ndof_view_rotate_method", text="")
  999. layout.separator()
  1000. layout.label(text="Orbit Options")
  1001. layout.prop(input_prefs, "ndof_rotx_invert_axis")
  1002. layout.prop(input_prefs, "ndof_roty_invert_axis")
  1003. layout.prop(input_prefs, "ndof_rotz_invert_axis")
  1004. # view2d use pan/zoom
  1005. layout.separator()
  1006. layout.label(text="Pan Options")
  1007. layout.prop(input_prefs, "ndof_panx_invert_axis")
  1008. layout.prop(input_prefs, "ndof_pany_invert_axis")
  1009. layout.prop(input_prefs, "ndof_panz_invert_axis")
  1010. layout.prop(input_prefs, "ndof_pan_yz_swap_axis")
  1011. layout.label(text="Zoom Options")
  1012. layout.prop(input_prefs, "ndof_zoom_invert")
  1013. if is_view3d:
  1014. layout.separator()
  1015. layout.label(text="Fly/Walk Options")
  1016. layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
  1017. layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
  1018. class USERPREF_PT_input_keyboard(PreferencePanel, Panel):
  1019. bl_label = "Keyboard"
  1020. @classmethod
  1021. def poll(cls, context):
  1022. prefs = context.preferences
  1023. return (prefs.active_section == 'INPUT')
  1024. def draw_props(self, context, layout):
  1025. prefs = context.preferences
  1026. inputs = prefs.inputs
  1027. layout.prop(inputs, "use_emulate_numpad")
  1028. layout.prop(inputs, "use_numeric_input_advanced")
  1029. class USERPREF_PT_input_mouse(PreferencePanel, Panel):
  1030. bl_label = "Mouse"
  1031. @classmethod
  1032. def poll(cls, context):
  1033. prefs = context.preferences
  1034. return (prefs.active_section == 'INPUT')
  1035. def draw_props(self, context, layout):
  1036. prefs = context.preferences
  1037. inputs = prefs.inputs
  1038. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  1039. flow.prop(inputs, "use_mouse_emulate_3_button")
  1040. flow.prop(inputs, "use_mouse_continuous")
  1041. flow.prop(inputs, "use_drag_immediately")
  1042. flow.prop(inputs, "mouse_double_click_time", text="Double Click Speed")
  1043. flow.prop(inputs, "drag_threshold_mouse")
  1044. flow.prop(inputs, "drag_threshold_tablet")
  1045. flow.prop(inputs, "drag_threshold")
  1046. flow.prop(inputs, "move_threshold")
  1047. class USERPREF_PT_navigation_orbit(PreferencePanel, Panel):
  1048. bl_label = "Orbit & Pan"
  1049. @classmethod
  1050. def poll(cls, context):
  1051. prefs = context.preferences
  1052. return (prefs.active_section == 'NAVIGATION')
  1053. def draw_props(self, context, layout):
  1054. import sys
  1055. prefs = context.preferences
  1056. inputs = prefs.inputs
  1057. view = prefs.view
  1058. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  1059. flow.row().prop(inputs, "view_rotate_method", expand=True)
  1060. flow.prop(inputs, "use_rotate_around_active")
  1061. flow.prop(inputs, "use_auto_perspective")
  1062. flow.prop(inputs, "use_mouse_depth_navigate")
  1063. if sys.platform == "darwin":
  1064. flow.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
  1065. flow.separator()
  1066. flow.prop(view, "smooth_view")
  1067. flow.prop(view, "rotation_angle")
  1068. class USERPREF_PT_navigation_zoom(PreferencePanel, Panel):
  1069. bl_label = "Zoom"
  1070. @classmethod
  1071. def poll(cls, context):
  1072. prefs = context.preferences
  1073. return (prefs.active_section == 'NAVIGATION')
  1074. def draw_props(self, context, layout):
  1075. prefs = context.preferences
  1076. inputs = prefs.inputs
  1077. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  1078. flow.row().prop(inputs, "view_zoom_method", text="Zoom Method", expand=True)
  1079. if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
  1080. flow.row().prop(inputs, "view_zoom_axis", expand=True)
  1081. flow.prop(inputs, "invert_mouse_zoom", text="Invert Mouse Zoom Direction")
  1082. flow.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
  1083. # sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
  1084. flow.prop(inputs, "use_zoom_to_mouse")
  1085. class USERPREF_PT_navigation_fly_walk(PreferencePanel, Panel):
  1086. bl_label = "Fly & Walk"
  1087. @classmethod
  1088. def poll(cls, context):
  1089. prefs = context.preferences
  1090. return (prefs.active_section == 'NAVIGATION')
  1091. def draw_props(self, context, layout):
  1092. prefs = context.preferences
  1093. inputs = prefs.inputs
  1094. layout.row().prop(inputs, "navigation_mode", expand=True)
  1095. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  1096. flow.prop(inputs, "use_camera_lock_parent")
  1097. class USERPREF_PT_navigation_fly_walk_navigation(PreferencePanel, Panel):
  1098. bl_label = "Walk"
  1099. bl_parent_id = "USERPREF_PT_navigation_fly_walk"
  1100. bl_options = {'DEFAULT_CLOSED'}
  1101. @classmethod
  1102. def poll(cls, context):
  1103. prefs = context.preferences
  1104. return prefs.inputs.navigation_mode == 'WALK'
  1105. def draw_props(self, context, layout):
  1106. prefs = context.preferences
  1107. inputs = prefs.inputs
  1108. walk = inputs.walk_navigation
  1109. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  1110. flow.prop(walk, "use_mouse_reverse")
  1111. flow.prop(walk, "mouse_speed")
  1112. flow.prop(walk, "teleport_time")
  1113. sub = flow.column(align=True)
  1114. sub.prop(walk, "walk_speed")
  1115. sub.prop(walk, "walk_speed_factor")
  1116. class USERPREF_PT_navigation_fly_walk_gravity(PreferencePanel, Panel):
  1117. bl_label = "Gravity"
  1118. bl_parent_id = "USERPREF_PT_navigation_fly_walk"
  1119. bl_options = {'DEFAULT_CLOSED'}
  1120. @classmethod
  1121. def poll(cls, context):
  1122. prefs = context.preferences
  1123. return prefs.inputs.navigation_mode == 'WALK'
  1124. def draw_header(self, context):
  1125. prefs = context.preferences
  1126. inputs = prefs.inputs
  1127. walk = inputs.walk_navigation
  1128. self.layout.prop(walk, "use_gravity", text="")
  1129. def draw_props(self, context, layout):
  1130. prefs = context.preferences
  1131. inputs = prefs.inputs
  1132. walk = inputs.walk_navigation
  1133. layout.active = walk.use_gravity
  1134. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  1135. flow.prop(walk, "view_height")
  1136. flow.prop(walk, "jump_height")
  1137. class USERPREF_PT_input_tablet(PreferencePanel, Panel):
  1138. bl_label = "Tablet"
  1139. @classmethod
  1140. def poll(cls, context):
  1141. prefs = context.preferences
  1142. return prefs.active_section == 'INPUT'
  1143. def draw_props(self, context, layout):
  1144. prefs = context.preferences
  1145. inputs = prefs.inputs
  1146. import sys
  1147. if sys.platform[:3] == "win":
  1148. layout.prop(inputs, "tablet_api")
  1149. layout.separator()
  1150. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  1151. flow.prop(inputs, "pressure_threshold_max")
  1152. flow.prop(inputs, "pressure_softness")
  1153. class USERPREF_PT_input_ndof(PreferencePanel, Panel):
  1154. bl_label = "NDOF"
  1155. bl_options = {'DEFAULT_CLOSED'}
  1156. @classmethod
  1157. def poll(cls, context):
  1158. prefs = context.preferences
  1159. inputs = prefs.inputs
  1160. return prefs.active_section == 'INPUT' and inputs.use_ndof
  1161. def draw_props(self, context, layout):
  1162. prefs = context.preferences
  1163. inputs = prefs.inputs
  1164. flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
  1165. flow.prop(inputs, "ndof_sensitivity", text="Pan Sensitivity")
  1166. flow.prop(inputs, "ndof_orbit_sensitivity", text="Orbit Sensitivity")
  1167. flow.prop(inputs, "ndof_deadzone", text="Deadzone")
  1168. layout.separator()
  1169. flow.row().prop(inputs, "ndof_view_navigate_method", expand=True)
  1170. flow.row().prop(inputs, "ndof_view_rotate_method", expand=True)
  1171. class USERPREF_MT_keyconfigs(Menu):
  1172. bl_label = "KeyPresets"
  1173. preset_subdir = "keyconfig"
  1174. preset_operator = "preferences.keyconfig_activate"
  1175. def draw(self, context):
  1176. Menu.draw_preset(self, context)
  1177. class USERPREF_PT_keymap(Panel):
  1178. bl_space_type = 'PREFERENCES'
  1179. bl_label = "Keymap"
  1180. bl_region_type = 'WINDOW'
  1181. bl_options = {'HIDE_HEADER'}
  1182. @classmethod
  1183. def poll(cls, context):
  1184. prefs = context.preferences
  1185. return (prefs.active_section == 'KEYMAP')
  1186. def draw(self, context):
  1187. from rna_keymap_ui import draw_keymaps
  1188. layout = self.layout
  1189. # import time
  1190. # start = time.time()
  1191. # Keymap Settings
  1192. draw_keymaps(context, layout)
  1193. # print("runtime", time.time() - start)
  1194. class USERPREF_PT_addons(Panel):
  1195. bl_space_type = 'PREFERENCES'
  1196. bl_label = "Add-ons"
  1197. bl_region_type = 'WINDOW'
  1198. bl_options = {'HIDE_HEADER'}
  1199. _support_icon_mapping = {
  1200. 'OFFICIAL': 'FILE_BLEND',
  1201. 'COMMUNITY': 'COMMUNITY',
  1202. 'TESTING': 'EXPERIMENTAL',
  1203. }
  1204. @classmethod
  1205. def poll(cls, context):
  1206. prefs = context.preferences
  1207. return (prefs.active_section == 'ADDONS')
  1208. @staticmethod
  1209. def is_user_addon(mod, user_addon_paths):
  1210. import os
  1211. if not user_addon_paths:
  1212. for path in (
  1213. bpy.utils.script_path_user(),
  1214. bpy.utils.script_path_pref(),
  1215. ):
  1216. if path is not None:
  1217. user_addon_paths.append(os.path.join(path, "addons"))
  1218. for path in user_addon_paths:
  1219. if bpy.path.is_subdir(mod.__file__, path):
  1220. return True
  1221. return False
  1222. @staticmethod
  1223. def draw_error(layout, message):
  1224. lines = message.split("\n")
  1225. box = layout.box()
  1226. sub = box.row()
  1227. sub.label(text=lines[0])
  1228. sub.label(icon='ERROR')
  1229. for l in lines[1:]:
  1230. box.label(text=l)
  1231. def draw(self, context):
  1232. import os
  1233. import addon_utils
  1234. layout = self.layout
  1235. prefs = context.preferences
  1236. used_ext = {ext.module for ext in prefs.addons}
  1237. addon_user_dirs = tuple(
  1238. p for p in (
  1239. os.path.join(prefs.filepaths.script_directory, "addons"),
  1240. bpy.utils.user_resource('SCRIPTS', "addons"),
  1241. )
  1242. if p
  1243. )
  1244. # Development option for 2.8x, don't show users bundled addons
  1245. # unless they have been updated for 2.8x.
  1246. # Developers can turn them on with '--debug'
  1247. show_official_27x_addons = bpy.app.debug
  1248. # collect the categories that can be filtered on
  1249. addons = [
  1250. (mod, addon_utils.module_bl_info(mod))
  1251. for mod in addon_utils.modules(refresh=False)
  1252. ]
  1253. split = layout.split(factor=0.6)
  1254. row = split.row()
  1255. row.prop(context.window_manager, "addon_support", expand=True)
  1256. row = split.row(align=True)
  1257. row.operator("preferences.addon_install", icon='IMPORT', text="Install...")
  1258. row.operator("preferences.addon_refresh", icon='FILE_REFRESH', text="Refresh")
  1259. row = layout.row()
  1260. row.prop(context.window_manager, "addon_filter", text="")
  1261. row.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
  1262. col = layout.column()
  1263. # set in addon_utils.modules_refresh()
  1264. if addon_utils.error_duplicates:
  1265. box = col.box()
  1266. row = box.row()
  1267. row.label(text="Multiple add-ons with the same name found!")
  1268. row.label(icon='ERROR')
  1269. box.label(text="Delete one of each pair to resolve:")
  1270. for (addon_name, addon_file, addon_path) in addon_utils.error_duplicates:
  1271. box.separator()
  1272. sub_col = box.column(align=True)
  1273. sub_col.label(text=addon_name + ":")
  1274. sub_col.label(text=" " + addon_file)
  1275. sub_col.label(text=" " + addon_path)
  1276. if addon_utils.error_encoding:
  1277. self.draw_error(
  1278. col,
  1279. "One or more addons do not have UTF-8 encoding\n"
  1280. "(see console for details)",
  1281. )
  1282. filter = context.window_manager.addon_filter
  1283. search = context.window_manager.addon_search.lower()
  1284. support = context.window_manager.addon_support
  1285. # initialized on demand
  1286. user_addon_paths = []
  1287. for mod, info in addons:
  1288. module_name = mod.__name__
  1289. is_enabled = module_name in used_ext
  1290. if info["support"] not in support:
  1291. continue
  1292. # check if addon should be visible with current filters
  1293. if (
  1294. (filter == "All") or
  1295. (filter == info["category"]) or
  1296. (filter == "Enabled" and is_enabled) or
  1297. (filter == "Disabled" and not is_enabled) or
  1298. (filter == "User" and (mod.__file__.startswith(addon_user_dirs)))
  1299. ):
  1300. if search and search not in info["name"].lower():
  1301. if info["author"]:
  1302. if search not in info["author"].lower():
  1303. continue
  1304. else:
  1305. continue
  1306. # Skip 2.7x add-ons included with Blender, unless in debug mode.
  1307. is_addon_27x = info.get("blender", (0,)) < (2, 80)
  1308. if (
  1309. is_addon_27x and
  1310. (not show_official_27x_addons) and
  1311. (not mod.__file__.startswith(addon_user_dirs))
  1312. ):
  1313. continue
  1314. # Addon UI Code
  1315. col_box = col.column()
  1316. box = col_box.box()
  1317. colsub = box.column()
  1318. row = colsub.row(align=True)
  1319. row.operator(
  1320. "preferences.addon_expand",
  1321. icon='DISCLOSURE_TRI_DOWN' if info["show_expanded"] else 'DISCLOSURE_TRI_RIGHT',
  1322. emboss=False,
  1323. ).module = module_name
  1324. row.operator(
  1325. "preferences.addon_disable" if is_enabled else "preferences.addon_enable",
  1326. icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
  1327. emboss=False,
  1328. ).module = module_name
  1329. sub = row.row()
  1330. sub.active = is_enabled
  1331. sub.label(text="%s: %s" % (info["category"], info["name"]))
  1332. # WARNING: 2.8x exception, may be removed
  1333. # use disabled state for old add-ons, chances are they are broken.
  1334. if is_addon_27x:
  1335. sub.label(text="upgrade to 2.8x required")
  1336. sub.label(icon='ERROR')
  1337. # Remove code above after 2.8x migration is complete.
  1338. elif info["warning"]:
  1339. sub.label(icon='ERROR')
  1340. # icon showing support level.
  1341. sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
  1342. # Expanded UI (only if additional info is available)
  1343. if info["show_expanded"]:
  1344. if info["description"]:
  1345. split = colsub.row().split(factor=0.15)
  1346. split.label(text="Description:")
  1347. split.label(text=info["description"])
  1348. if info["location"]:
  1349. split = colsub.row().split(factor=0.15)
  1350. split.label(text="Location:")
  1351. split.label(text=info["location"])
  1352. if mod:
  1353. split = colsub.row().split(factor=0.15)
  1354. split.label(text="File:")
  1355. split.label(text=mod.__file__, translate=False)
  1356. if info["author"]:
  1357. split = colsub.row().split(factor=0.15)
  1358. split.label(text="Author:")
  1359. split.label(text=info["author"], translate=False)
  1360. if info["version"]:
  1361. split = colsub.row().split(factor=0.15)
  1362. split.label(text="Version:")
  1363. split.label(text=".".join(str(x) for x in info["version"]), translate=False)
  1364. if info["warning"]:
  1365. split = colsub.row().split(factor=0.15)
  1366. split.label(text="Warning:")
  1367. split.label(text=" " + info["warning"], icon='ERROR')
  1368. user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
  1369. tot_row = bool(info["wiki_url"]) + bool(user_addon)
  1370. if tot_row:
  1371. split = colsub.row().split(factor=0.15)
  1372. split.label(text="Internet:")
  1373. sub = split.row()
  1374. if info["wiki_url"]:
  1375. sub.operator(
  1376. "wm.url_open", text="Documentation", icon='HELP',
  1377. ).url = info["wiki_url"]
  1378. # Only add "Report a Bug" button if tracker_url is set
  1379. # or the add-on is bundled (use official tracker then).
  1380. if info.get("tracker_url") or not user_addon:
  1381. sub.operator(
  1382. "wm.url_open", text="Report a Bug", icon='URL',
  1383. ).url = info.get(
  1384. "tracker_url",
  1385. "https://developer.blender.org/maniphest/task/edit/form/2",
  1386. )
  1387. if user_addon:
  1388. sub.operator(
  1389. "preferences.addon_remove", text="Remove", icon='CANCEL',
  1390. ).module = mod.__name__
  1391. # Show addon user preferences
  1392. if is_enabled:
  1393. addon_preferences = prefs.addons[module_name].preferences
  1394. if addon_preferences is not None:
  1395. draw = getattr(addon_preferences, "draw", None)
  1396. if draw is not None:
  1397. addon_preferences_class = type(addon_preferences)
  1398. box_prefs = col_box.box()
  1399. box_prefs.label(text="Preferences:")
  1400. addon_preferences_class.layout = box_prefs
  1401. try:
  1402. draw(context)
  1403. except:
  1404. import traceback
  1405. traceback.print_exc()
  1406. box_prefs.label(text="Error (see console)", icon='ERROR')
  1407. del addon_preferences_class.layout
  1408. # Append missing scripts
  1409. # First collect scripts that are used but have no script file.
  1410. module_names = {mod.__name__ for mod, info in addons}
  1411. missing_modules = {ext for ext in used_ext if ext not in module_names}
  1412. if missing_modules and filter in {"All", "Enabled"}:
  1413. col.column().separator()
  1414. col.column().label(text="Missing script files")
  1415. module_names = {mod.__name__ for mod, info in addons}
  1416. for module_name in sorted(missing_modules):
  1417. is_enabled = module_name in used_ext
  1418. # Addon UI Code
  1419. box = col.column().box()
  1420. colsub = box.column()
  1421. row = colsub.row(align=True)
  1422. row.label(text="", icon='ERROR')
  1423. if is_enabled:
  1424. row.operator(
  1425. "preferences.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False,
  1426. ).module = module_name
  1427. row.label(text=module_name, translate=False)
  1428. class StudioLightPanelMixin():
  1429. bl_space_type = 'PREFERENCES'
  1430. bl_region_type = 'WINDOW'
  1431. @classmethod
  1432. def poll(cls, context):
  1433. prefs = context.preferences
  1434. return (prefs.active_section == 'LIGHTS')
  1435. def _get_lights(self, prefs):
  1436. return [light for light in prefs.studio_lights if light.is_user_defined and light.type == self.sl_type]
  1437. def draw(self, context):
  1438. layout = self.layout
  1439. prefs = context.preferences
  1440. lights = self._get_lights(prefs)
  1441. self.draw_light_list(layout, lights)
  1442. def draw_light_list(self, layout, lights):
  1443. if lights:
  1444. flow = layout.grid_flow(row_major=False, columns=4, even_columns=True, even_rows=True, align=False)
  1445. for studio_light in lights:
  1446. self.draw_studio_light(flow, studio_light)
  1447. else:
  1448. layout.label(text="No custom {} configured".format(self.bl_label))
  1449. def draw_studio_light(self, layout, studio_light):
  1450. box = layout.box()
  1451. row = box.row()
  1452. row.template_icon(layout.icon(studio_light), scale=3.0)
  1453. col = row.column()
  1454. op = col.operator("preferences.studiolight_uninstall", text="", icon='REMOVE')
  1455. op.index = studio_light.index
  1456. if studio_light.type == 'STUDIO':
  1457. op = col.operator("preferences.studiolight_copy_settings", text="", icon='IMPORT')
  1458. op.index = studio_light.index
  1459. box.label(text=studio_light.name)
  1460. class USERPREF_PT_studiolight_matcaps(Panel, StudioLightPanelMixin):
  1461. bl_label = "MatCaps"
  1462. sl_type = 'MATCAP'
  1463. def draw_header_preset(self, _context):
  1464. layout = self.layout
  1465. layout.operator("preferences.studiolight_install", icon='IMPORT', text="Install...").type = 'MATCAP'
  1466. layout.separator()
  1467. class USERPREF_PT_studiolight_world(Panel, StudioLightPanelMixin):
  1468. bl_label = "LookDev HDRIs"
  1469. sl_type = 'WORLD'
  1470. def draw_header_preset(self, _context):
  1471. layout = self.layout
  1472. layout.operator("preferences.studiolight_install", icon='IMPORT', text="Install...").type = 'WORLD'
  1473. layout.separator()
  1474. class USERPREF_PT_studiolight_lights(Panel, StudioLightPanelMixin):
  1475. bl_label = "Studio Lights"
  1476. sl_type = 'STUDIO'
  1477. def draw_header_preset(self, _context):
  1478. layout = self.layout
  1479. op = layout.operator("preferences.studiolight_install", icon='IMPORT', text="Install...")
  1480. op.type = 'STUDIO'
  1481. op.filter_glob = ".sl"
  1482. layout.separator()
  1483. class USERPREF_PT_studiolight_light_editor(Panel):
  1484. bl_label = "Editor"
  1485. bl_parent_id = "USERPREF_PT_studiolight_lights"
  1486. bl_space_type = 'PREFERENCES'
  1487. bl_region_type = 'WINDOW'
  1488. bl_options = {'DEFAULT_CLOSED'}
  1489. def opengl_light_buttons(self, layout, light):
  1490. col = layout.column()
  1491. col.active = light.use
  1492. col.prop(light, "use", text="Use Light")
  1493. col.prop(light, "diffuse_color", text="Diffuse")
  1494. col.prop(light, "specular_color", text="Specular")
  1495. col.prop(light, "smooth")
  1496. col.prop(light, "direction")
  1497. def draw(self, context):
  1498. layout = self.layout
  1499. prefs = context.preferences
  1500. system = prefs.system
  1501. row = layout.row()
  1502. row.prop(system, "use_studio_light_edit", toggle=True)
  1503. row.operator("preferences.studiolight_new", text="Save as Studio light", icon='FILE_TICK')
  1504. layout.separator()
  1505. layout.use_property_split = True
  1506. column = layout.split()
  1507. column.active = system.use_studio_light_edit
  1508. light = system.solid_lights[0]
  1509. colsplit = column.split(factor=0.85)
  1510. self.opengl_light_buttons(colsplit, light)
  1511. light = system.solid_lights[1]
  1512. colsplit = column.split(factor=0.85)
  1513. self.opengl_light_buttons(colsplit, light)
  1514. light = system.solid_lights[2]
  1515. colsplit = column.split(factor=0.85)
  1516. self.opengl_light_buttons(colsplit, light)
  1517. light = system.solid_lights[3]
  1518. self.opengl_light_buttons(column, light)
  1519. layout.separator()
  1520. layout.prop(system, "light_ambient")
  1521. # Order of registration defines order in UI,
  1522. # so dynamically generated classes are 'injected' in the intended order.
  1523. classes = (
  1524. USERPREF_PT_theme_user_interface,
  1525. *ThemeGenericClassGenerator.generate_panel_classes_for_wcols(),
  1526. USERPREF_HT_header,
  1527. USERPREF_PT_navigation_bar,
  1528. USERPREF_PT_save_preferences,
  1529. USERPREF_MT_save_load,
  1530. USERPREF_PT_interface_display,
  1531. USERPREF_PT_interface_editors,
  1532. USERPREF_PT_interface_translation,
  1533. USERPREF_PT_interface_text,
  1534. USERPREF_PT_interface_menus,
  1535. USERPREF_PT_interface_menus_mouse_over,
  1536. USERPREF_PT_interface_menus_pie,
  1537. USERPREF_PT_viewport_display,
  1538. USERPREF_PT_viewport_quality,
  1539. USERPREF_PT_viewport_textures,
  1540. USERPREF_PT_viewport_selection,
  1541. USERPREF_PT_edit_objects,
  1542. USERPREF_PT_edit_objects_new,
  1543. USERPREF_PT_edit_objects_duplicate_data,
  1544. USERPREF_PT_edit_cursor,
  1545. USERPREF_PT_edit_annotations,
  1546. USERPREF_PT_edit_weight_paint,
  1547. USERPREF_PT_edit_gpencil,
  1548. USERPREF_PT_edit_misc,
  1549. USERPREF_PT_animation_timeline,
  1550. USERPREF_PT_animation_keyframes,
  1551. USERPREF_PT_animation_autokey,
  1552. USERPREF_PT_animation_fcurves,
  1553. USERPREF_PT_system_cycles_devices,
  1554. USERPREF_PT_system_memory,
  1555. USERPREF_PT_system_sound,
  1556. USERPREF_MT_interface_theme_presets,
  1557. USERPREF_PT_theme,
  1558. USERPREF_PT_theme_interface_state,
  1559. USERPREF_PT_theme_interface_styles,
  1560. USERPREF_PT_theme_interface_gizmos,
  1561. USERPREF_PT_theme_interface_icons,
  1562. USERPREF_PT_theme_text_style,
  1563. USERPREF_PT_theme_bone_color_sets,
  1564. USERPREF_PT_file_paths_data,
  1565. USERPREF_PT_file_paths_render,
  1566. USERPREF_PT_file_paths_applications,
  1567. USERPREF_PT_file_paths_development,
  1568. USERPREF_PT_saveload_blend,
  1569. USERPREF_PT_saveload_blend_autosave,
  1570. USERPREF_PT_saveload_autorun,
  1571. USERPREF_PT_saveload_file_browser,
  1572. USERPREF_MT_ndof_settings,
  1573. USERPREF_MT_keyconfigs,
  1574. USERPREF_PT_input_keyboard,
  1575. USERPREF_PT_input_mouse,
  1576. USERPREF_PT_input_tablet,
  1577. USERPREF_PT_input_ndof,
  1578. USERPREF_PT_navigation_orbit,
  1579. USERPREF_PT_navigation_zoom,
  1580. USERPREF_PT_navigation_fly_walk,
  1581. USERPREF_PT_navigation_fly_walk_navigation,
  1582. USERPREF_PT_navigation_fly_walk_gravity,
  1583. USERPREF_PT_keymap,
  1584. USERPREF_PT_addons,
  1585. USERPREF_PT_studiolight_lights,
  1586. USERPREF_PT_studiolight_light_editor,
  1587. USERPREF_PT_studiolight_matcaps,
  1588. USERPREF_PT_studiolight_world,
  1589. # Add dynamically generated editor theme panels last,
  1590. # so they show up last in the theme section.
  1591. *ThemeGenericClassGenerator.generate_panel_classes_from_theme_areas(),
  1592. )
  1593. if __name__ == "__main__": # only for live edit.
  1594. from bpy.utils import register_class
  1595. for cls in classes:
  1596. register_class(cls)