Cleanup: use f-strings
[blender.git] / release / scripts / startup / bl_ui / space_userpref.py
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
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import (
22     Header,
23     Menu,
24     Panel,
25 )
26 from bpy.app.translations import pgettext_iface as iface_
27 from bpy.app.translations import contexts as i18n_contexts
28
29
30 def opengl_lamp_buttons(column, lamp):
31     split = column.row()
32
33     split.prop(lamp, "use", text="", icon='OUTLINER_OB_LAMP' if lamp.use else 'LAMP_DATA')
34
35     col = split.column()
36     col.active = lamp.use
37     row = col.row()
38     row.label(text="Diffuse:")
39     row.prop(lamp, "diffuse_color", text="")
40     row = col.row()
41     row.label(text="Specular:")
42     row.prop(lamp, "specular_color", text="")
43
44     col = split.column()
45     col.active = lamp.use
46     col.prop(lamp, "direction", text="")
47
48
49 class USERPREF_HT_header(Header):
50     bl_space_type = 'USER_PREFERENCES'
51
52     def draw(self, context):
53         layout = self.layout
54
55         layout.template_header()
56
57         userpref = context.user_preferences
58
59         layout.operator_context = 'EXEC_AREA'
60         layout.operator("wm.save_userpref")
61
62         layout.operator_context = 'INVOKE_DEFAULT'
63
64         if userpref.active_section == 'INPUT':
65             layout.operator("wm.keyconfig_import")
66             layout.operator("wm.keyconfig_export")
67         elif userpref.active_section == 'ADDONS':
68             layout.operator("wm.addon_install", icon='FILESEL')
69             layout.operator("wm.addon_refresh", icon='FILE_REFRESH')
70             layout.menu("USERPREF_MT_addons_online_resources")
71         elif userpref.active_section == 'THEMES':
72             layout.operator("ui.reset_default_theme")
73             layout.operator("wm.theme_install")
74
75
76 class USERPREF_PT_tabs(Panel):
77     bl_label = ""
78     bl_space_type = 'USER_PREFERENCES'
79     bl_region_type = 'WINDOW'
80     bl_options = {'HIDE_HEADER'}
81
82     def draw(self, context):
83         layout = self.layout
84
85         userpref = context.user_preferences
86
87         layout.row().prop(userpref, "active_section", expand=True)
88
89
90 class USERPREF_MT_interaction_presets(Menu):
91     bl_label = "Presets"
92     preset_subdir = "interaction"
93     preset_operator = "script.execute_preset"
94     draw = Menu.draw_preset
95
96
97 class USERPREF_MT_app_templates(Menu):
98     bl_label = "Application Templates"
99     preset_subdir = "app_templates"
100
101     def draw_ex(self, context, *, use_splash=False, use_default=False, use_install=False):
102         import os
103
104         layout = self.layout
105
106         # now draw the presets
107         layout.operator_context = 'EXEC_DEFAULT'
108
109         if use_default:
110             props = layout.operator("wm.read_homefile", text="Default")
111             props.use_splash = True
112             props.app_template = ""
113             layout.separator()
114
115         template_paths = bpy.utils.app_template_paths()
116
117         # expand template paths
118         app_templates = []
119         for path in template_paths:
120             for d in os.listdir(path):
121                 if d.startswith(("__", ".")):
122                     continue
123                 template = os.path.join(path, d)
124                 if os.path.isdir(template):
125                     # template_paths_expand.append(template)
126                     app_templates.append(d)
127
128         for d in sorted(app_templates):
129             props = layout.operator(
130                 "wm.read_homefile",
131                 text=bpy.path.display_name(d),
132             )
133             props.use_splash = True
134             props.app_template = d
135
136         if use_install:
137             layout.separator()
138             layout.operator_context = 'INVOKE_DEFAULT'
139             props = layout.operator("wm.app_template_install")
140
141     def draw(self, context):
142         self.draw_ex(context, use_splash=False, use_default=True, use_install=True)
143
144
145 class USERPREF_MT_templates_splash(Menu):
146     bl_label = "Startup Templates"
147     preset_subdir = "templates"
148
149     def draw(self, context):
150         USERPREF_MT_app_templates.draw_ex(self, context, use_splash=True, use_default=True)
151
152
153 class USERPREF_MT_appconfigs(Menu):
154     bl_label = "AppPresets"
155     preset_subdir = "keyconfig"
156     preset_operator = "wm.appconfig_activate"
157
158     def draw(self, context):
159         self.layout.operator("wm.appconfig_default", text="Blender (default)")
160
161         # now draw the presets
162         Menu.draw_preset(self, context)
163
164
165 class USERPREF_MT_splash(Menu):
166     bl_label = "Splash"
167
168     def draw(self, context):
169         layout = self.layout
170
171         split = layout.split()
172         row = split.row()
173
174         if any(bpy.utils.app_template_paths()):
175             row.label("Template:")
176             template = context.user_preferences.app_template
177             row.menu(
178                 "USERPREF_MT_templates_splash",
179                 text=bpy.path.display_name(template) if template else "Default",
180             )
181         else:
182             row.label("")
183
184         row = split.row()
185         row.label("Interaction:")
186
187         text = bpy.path.display_name(context.window_manager.keyconfigs.active.name)
188         if not text:
189             text = "Blender (default)"
190         row.menu("USERPREF_MT_appconfigs", text=text)
191
192
193 # only for addons
194 class USERPREF_MT_splash_footer(Menu):
195     bl_label = ""
196
197     def draw(self, context):
198         pass
199
200
201 class USERPREF_PT_interface(Panel):
202     bl_space_type = 'USER_PREFERENCES'
203     bl_label = "Interface"
204     bl_region_type = 'WINDOW'
205     bl_options = {'HIDE_HEADER'}
206
207     @classmethod
208     def poll(cls, context):
209         userpref = context.user_preferences
210         return (userpref.active_section == 'INTERFACE')
211
212     def draw(self, context):
213         layout = self.layout
214
215         userpref = context.user_preferences
216         view = userpref.view
217
218         row = layout.row()
219
220         col = row.column()
221         col.label(text="Display:")
222         col.prop(view, "ui_scale", text="Scale")
223         col.prop(view, "ui_line_width", text="Line Width")
224         col.prop(view, "show_tooltips")
225         col.prop(view, "show_tooltips_python")
226         col.prop(view, "show_developer_ui")
227         col.prop(view, "show_object_info", text="Object Info")
228         col.prop(view, "show_large_cursors")
229         col.prop(view, "show_view_name", text="View Name")
230         col.prop(view, "show_playback_fps", text="Playback FPS")
231         col.prop(view, "use_global_scene")
232         col.prop(view, "object_origin_size")
233
234         col.separator()
235         col.separator()
236         col.separator()
237
238         col.prop(view, "show_mini_axis", text="Display Mini Axis")
239         sub = col.column()
240         sub.active = view.show_mini_axis
241         sub.prop(view, "mini_axis_size", text="Size")
242         sub.prop(view, "mini_axis_brightness", text="Brightness")
243
244         col.separator()
245
246         col.label("Warnings")
247         col.prop(view, "use_quit_dialog")
248
249         row.separator()
250         row.separator()
251
252         col = row.column()
253         col.label(text="View Manipulation:")
254         col.prop(view, "use_mouse_depth_cursor")
255         col.prop(view, "use_cursor_lock_adjust")
256         col.prop(view, "use_mouse_depth_navigate")
257         col.prop(view, "use_zoom_to_mouse")
258         col.prop(view, "use_rotate_around_active")
259         col.prop(view, "use_global_pivot")
260         col.prop(view, "use_camera_lock_parent")
261
262         col.separator()
263
264         col.prop(view, "use_auto_perspective")
265         col.prop(view, "smooth_view")
266         col.prop(view, "rotation_angle")
267
268         col.separator()
269         col.separator()
270
271         col.label(text="2D Viewports:")
272         col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
273         col.prop(view, "timecode_style")
274         col.prop(view, "view_frame_type")
275         if view.view_frame_type == 'SECONDS':
276             col.prop(view, "view_frame_seconds")
277         elif view.view_frame_type == 'KEYFRAMES':
278             col.prop(view, "view_frame_keyframes")
279
280         row.separator()
281         row.separator()
282
283         col = row.column()
284         # Toolbox doesn't exist yet
285         # col.label(text="Toolbox:")
286         #col.prop(view, "show_column_layout")
287         #col.label(text="Open Toolbox Delay:")
288         #col.prop(view, "open_left_mouse_delay", text="Hold LMB")
289         #col.prop(view, "open_right_mouse_delay", text="Hold RMB")
290         col.prop(view, "show_manipulator")
291         sub = col.column()
292         sub.active = view.show_manipulator
293         sub.prop(view, "manipulator_size", text="Size")
294         sub.prop(view, "manipulator_handle_size", text="Handle Size")
295         sub.prop(view, "manipulator_hotspot", text="Hotspot")
296
297         col.separator()
298         col.separator()
299         col.separator()
300
301         col.label(text="Menus:")
302         col.prop(view, "use_mouse_over_open")
303         sub = col.column()
304         sub.active = view.use_mouse_over_open
305
306         sub.prop(view, "open_toplevel_delay", text="Top Level")
307         sub.prop(view, "open_sublevel_delay", text="Sub Level")
308
309         col.separator()
310         col.label(text="Pie Menus:")
311         sub = col.column(align=True)
312         sub.prop(view, "pie_animation_timeout")
313         sub.prop(view, "pie_initial_timeout")
314         sub.prop(view, "pie_menu_radius")
315         sub.prop(view, "pie_menu_threshold")
316         sub.prop(view, "pie_menu_confirm")
317         col.separator()
318
319         col.prop(view, "show_splash")
320         col.separator()
321
322         col.label(text="App Template:")
323         col.label(text="Options intended for use with app-templates only.")
324         col.prop(view, "show_layout_ui")
325         col.prop(view, "show_view3d_cursor")
326
327
328 class USERPREF_PT_edit(Panel):
329     bl_space_type = 'USER_PREFERENCES'
330     bl_label = "Edit"
331     bl_region_type = 'WINDOW'
332     bl_options = {'HIDE_HEADER'}
333
334     @classmethod
335     def poll(cls, context):
336         userpref = context.user_preferences
337         return (userpref.active_section == 'EDITING')
338
339     def draw(self, context):
340         layout = self.layout
341
342         userpref = context.user_preferences
343         edit = userpref.edit
344
345         row = layout.row()
346
347         col = row.column()
348         col.label(text="Link Materials To:")
349         col.prop(edit, "material_link", text="")
350
351         col.separator()
352         col.separator()
353         col.separator()
354
355         col.label(text="New Objects:")
356         col.prop(edit, "use_enter_edit_mode")
357         col.label(text="Align To:")
358         col.prop(edit, "object_align", text="")
359
360         col.separator()
361         col.separator()
362         col.separator()
363
364         col.label(text="Undo:")
365         col.prop(edit, "use_global_undo")
366         col.prop(edit, "undo_steps", text="Steps")
367         col.prop(edit, "undo_memory_limit", text="Memory Limit")
368
369         row.separator()
370         row.separator()
371
372         col = row.column()
373         col.label(text="Grease Pencil:")
374         col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
375         col.separator()
376         col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
377         col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
378         col.separator()
379         col.prop(edit, "grease_pencil_default_color", text="Default Color")
380         col.separator()
381         col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
382         col.separator()
383         col.separator()
384         col.separator()
385         col.separator()
386         col.label(text="Playback:")
387         col.prop(edit, "use_negative_frames")
388         col.separator()
389         col.separator()
390         col.separator()
391         col.label(text="Node Editor:")
392         col.prop(edit, "node_margin")
393         col.label(text="Animation Editors:")
394         col.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
395
396         row.separator()
397         row.separator()
398
399         col = row.column()
400         col.label(text="Keyframing:")
401         col.prop(edit, "use_visual_keying")
402         col.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed")
403
404         col.separator()
405
406         col.prop(edit, "use_auto_keying", text="Auto Keyframing:")
407         col.prop(edit, "use_auto_keying_warning")
408
409         sub = col.column()
410
411         # ~ sub.active = edit.use_keyframe_insert_auto # incorrect, time-line can enable
412         sub.prop(edit, "use_keyframe_insert_available", text="Only Insert Available")
413
414         col.separator()
415
416         col.label(text="New F-Curve Defaults:")
417         col.prop(edit, "keyframe_new_interpolation_type", text="Interpolation")
418         col.prop(edit, "keyframe_new_handle_type", text="Handles")
419         col.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
420
421         col.separator()
422         col.separator()
423         col.separator()
424
425         col.label(text="Transform:")
426         col.prop(edit, "use_drag_immediately")
427
428         row.separator()
429         row.separator()
430
431         col = row.column()
432         col.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
433
434         col.separator()
435         col.separator()
436         col.separator()
437
438         col.label(text="Duplicate Data:")
439         col.prop(edit, "use_duplicate_mesh", text="Mesh")
440         col.prop(edit, "use_duplicate_surface", text="Surface")
441         col.prop(edit, "use_duplicate_curve", text="Curve")
442         col.prop(edit, "use_duplicate_text", text="Text")
443         col.prop(edit, "use_duplicate_metaball", text="Metaball")
444         col.prop(edit, "use_duplicate_armature", text="Armature")
445         col.prop(edit, "use_duplicate_lamp", text="Lamp")
446         col.prop(edit, "use_duplicate_material", text="Material")
447         col.prop(edit, "use_duplicate_texture", text="Texture")
448         #col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
449         col.prop(edit, "use_duplicate_action", text="Action")
450         col.prop(edit, "use_duplicate_particle", text="Particle")
451
452
453 class USERPREF_PT_system(Panel):
454     bl_space_type = 'USER_PREFERENCES'
455     bl_label = "System"
456     bl_region_type = 'WINDOW'
457     bl_options = {'HIDE_HEADER'}
458
459     @classmethod
460     def poll(cls, context):
461         userpref = context.user_preferences
462         return (userpref.active_section == 'SYSTEM')
463
464     def draw(self, context):
465         import sys
466         layout = self.layout
467
468         userpref = context.user_preferences
469         system = userpref.system
470
471         split = layout.split()
472
473         # 1. Column
474         column = split.column()
475         colsplit = column.split(percentage=0.85)
476
477         col = colsplit.column()
478         col.label(text="General:")
479
480         col.prop(system, "frame_server_port")
481         col.prop(system, "scrollback", text="Console Scrollback")
482
483         col.separator()
484
485         col.label(text="Sound:")
486         col.row().prop(system, "audio_device", expand=False)
487         sub = col.column()
488         sub.active = system.audio_device not in {'NONE', 'Null'}
489         #sub.prop(system, "use_preview_images")
490         sub.prop(system, "audio_channels", text="Channels")
491         sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
492         sub.prop(system, "audio_sample_rate", text="Sample Rate")
493         sub.prop(system, "audio_sample_format", text="Sample Format")
494
495         col.separator()
496
497         col.label(text="Screencast:")
498         col.prop(system, "screencast_fps")
499         col.prop(system, "screencast_wait_time")
500
501         col.separator()
502
503         if bpy.app.build_options.cycles:
504             addon = userpref.addons.get("cycles")
505             if addon is not None:
506                 addon.preferences.draw_impl(col, context)
507             del addon
508
509         if hasattr(system, "opensubdiv_compute_type"):
510             col.label(text="OpenSubdiv compute:")
511             col.row().prop(system, "opensubdiv_compute_type", text="")
512
513         # 2. Column
514         column = split.column()
515         colsplit = column.split(percentage=0.85)
516
517         col = colsplit.column()
518         col.label(text="OpenGL:")
519         col.prop(system, "gl_clip_alpha", slider=True)
520         col.prop(system, "use_mipmaps")
521         col.prop(system, "use_gpu_mipmap")
522         col.prop(system, "use_16bit_textures")
523
524         col.separator()
525         col.label(text="Selection")
526         col.prop(system, "select_method", text="")
527         col.prop(system, "use_select_pick_depth")
528
529         col.separator()
530
531         col.label(text="Anisotropic Filtering")
532         col.prop(system, "anisotropic_filter", text="")
533
534         col.separator()
535
536         col.label(text="Window Draw Method:")
537         col.prop(system, "window_draw_method", text="")
538         col.prop(system, "multi_sample", text="")
539         if sys.platform == "linux" and system.multi_sample != 'NONE':
540             col.label(text="Might fail for Mesh editing selection!")
541             col.separator()
542         col.prop(system, "use_region_overlap")
543
544         col.separator()
545
546         col.label(text="Text Draw Options:")
547         col.prop(system, "use_text_antialiasing")
548
549         col.separator()
550
551         col.label(text="Textures:")
552         col.prop(system, "gl_texture_limit", text="Limit Size")
553         col.prop(system, "texture_time_out", text="Time Out")
554         col.prop(system, "texture_collection_rate", text="Collection Rate")
555
556         col.separator()
557
558         col.label(text="Images Draw Method:")
559         col.prop(system, "image_draw_method", text="")
560
561         col.separator()
562
563         col.label(text="Sequencer/Clip Editor:")
564         # currently disabled in the code
565         # col.prop(system, "prefetch_frames")
566         col.prop(system, "memory_cache_limit")
567
568         # 3. Column
569         column = split.column()
570
571         column.label(text="Solid OpenGL Lights:")
572
573         split = column.split(percentage=0.1)
574         split.label()
575         split.label(text="Colors:")
576         split.label(text="Direction:")
577
578         lamp = system.solid_lights[0]
579         opengl_lamp_buttons(column, lamp)
580
581         lamp = system.solid_lights[1]
582         opengl_lamp_buttons(column, lamp)
583
584         lamp = system.solid_lights[2]
585         opengl_lamp_buttons(column, lamp)
586
587         column.separator()
588
589         column.label(text="Color Picker Type:")
590         column.row().prop(system, "color_picker_type", text="")
591
592         column.separator()
593
594         column.prop(system, "use_weight_color_range", text="Custom Weight Paint Range")
595         sub = column.column()
596         sub.active = system.use_weight_color_range
597         sub.template_color_ramp(system, "weight_color_range", expand=True)
598
599         column.separator()
600         column.prop(system, "font_path_ui")
601         column.prop(system, "font_path_ui_mono")
602
603         if bpy.app.build_options.international:
604             column.prop(system, "use_international_fonts")
605             if system.use_international_fonts:
606                 column.prop(system, "language")
607                 row = column.row()
608                 row.label(text="Translate:", text_ctxt=i18n_contexts.id_windowmanager)
609                 row = column.row(align=True)
610                 row.prop(system, "use_translate_interface", text="Interface", toggle=True)
611                 row.prop(system, "use_translate_tooltips", text="Tooltips", toggle=True)
612                 row.prop(system, "use_translate_new_dataname", text="New Data", toggle=True)
613
614
615 class USERPREF_MT_interface_theme_presets(Menu):
616     bl_label = "Presets"
617     preset_subdir = "interface_theme"
618     preset_operator = "script.execute_preset"
619     preset_type = 'XML'
620     preset_xml_map = (
621         ("user_preferences.themes[0]", "Theme"),
622         ("user_preferences.ui_styles[0]", "ThemeStyle"),
623     )
624     draw = Menu.draw_preset
625
626
627 class USERPREF_PT_theme(Panel):
628     bl_space_type = 'USER_PREFERENCES'
629     bl_label = "Themes"
630     bl_region_type = 'WINDOW'
631     bl_options = {'HIDE_HEADER'}
632
633     # not essential, hard-coded UI delimiters for the theme layout
634     ui_delimiters = {
635         'VIEW_3D': {
636             "text_grease_pencil",
637             "text_keyframe",
638             "speaker",
639             "freestyle_face_mark",
640             "split_normal",
641             "bone_solid",
642             "paint_curve_pivot",
643         },
644         'GRAPH_EDITOR': {
645             "handle_vertex_select",
646         },
647         'IMAGE_EDITOR': {
648             "paint_curve_pivot",
649         },
650         'NODE_EDITOR': {
651             "layout_node",
652         },
653         'CLIP_EDITOR': {
654             "handle_vertex_select",
655         }
656     }
657
658     @staticmethod
659     def _theme_generic(split, themedata, theme_area):
660
661         col = split.column()
662
663         def theme_generic_recurse(data):
664             col.label(data.rna_type.name)
665             row = col.row()
666             subsplit = row.split(percentage=0.95)
667
668             padding1 = subsplit.split(percentage=0.15)
669             padding1.column()
670
671             subsplit = row.split(percentage=0.85)
672
673             padding2 = subsplit.split(percentage=0.15)
674             padding2.column()
675
676             colsub_pair = padding1.column(), padding2.column()
677
678             props_type = {}
679
680             for i, prop in enumerate(data.rna_type.properties):
681                 if prop.identifier == "rna_type":
682                     continue
683
684                 props_type.setdefault((prop.type, prop.subtype), []).append(prop)
685
686             th_delimiters = USERPREF_PT_theme.ui_delimiters.get(theme_area)
687             for props_type, props_ls in sorted(props_type.items()):
688                 if props_type[0] == 'POINTER':
689                     for i, prop in enumerate(props_ls):
690                         theme_generic_recurse(getattr(data, prop.identifier))
691                 else:
692                     if th_delimiters is None:
693                         # simple, no delimiters
694                         for i, prop in enumerate(props_ls):
695                             colsub_pair[i % 2].row().prop(data, prop.identifier)
696                     else:
697                         # add hard coded delimiters
698                         i = 0
699                         for prop in props_ls:
700                             colsub = colsub_pair[i]
701                             colsub.row().prop(data, prop.identifier)
702                             i = (i + 1) % 2
703                             if prop.identifier in th_delimiters:
704                                 if i:
705                                     colsub = colsub_pair[1]
706                                     colsub.row().label("")
707                                 colsub_pair[0].row().label("")
708                                 colsub_pair[1].row().label("")
709                                 i = 0
710
711         theme_generic_recurse(themedata)
712
713     @staticmethod
714     def _theme_widget_style(layout, widget_style):
715
716         row = layout.row()
717
718         subsplit = row.split(percentage=0.95)
719
720         padding = subsplit.split(percentage=0.15)
721         colsub = padding.column()
722         colsub = padding.column()
723         colsub.row().prop(widget_style, "outline")
724         colsub.row().prop(widget_style, "item", slider=True)
725         colsub.row().prop(widget_style, "inner", slider=True)
726         colsub.row().prop(widget_style, "inner_sel", slider=True)
727
728         subsplit = row.split(percentage=0.85)
729
730         padding = subsplit.split(percentage=0.15)
731         colsub = padding.column()
732         colsub = padding.column()
733         colsub.row().prop(widget_style, "text")
734         colsub.row().prop(widget_style, "text_sel")
735         colsub.prop(widget_style, "show_shaded")
736         subsub = colsub.column(align=True)
737         subsub.active = widget_style.show_shaded
738         subsub.prop(widget_style, "shadetop")
739         subsub.prop(widget_style, "shadedown")
740
741         layout.separator()
742
743     @staticmethod
744     def _ui_font_style(layout, font_style):
745
746         split = layout.split()
747
748         col = split.column()
749         col.label(text="Kerning Style:")
750         col.row().prop(font_style, "font_kerning_style", expand=True)
751         col.prop(font_style, "points")
752
753         col = split.column()
754         col.label(text="Shadow Offset:")
755         col.prop(font_style, "shadow_offset_x", text="X")
756         col.prop(font_style, "shadow_offset_y", text="Y")
757
758         col = split.column()
759         col.prop(font_style, "shadow")
760         col.prop(font_style, "shadow_alpha")
761         col.prop(font_style, "shadow_value")
762
763         layout.separator()
764
765     @classmethod
766     def poll(cls, context):
767         userpref = context.user_preferences
768         return (userpref.active_section == 'THEMES')
769
770     def draw(self, context):
771         layout = self.layout
772
773         theme = context.user_preferences.themes[0]
774
775         split_themes = layout.split(percentage=0.2)
776
777         sub = split_themes.column()
778
779         sub.label(text="Presets:")
780         subrow = sub.row(align=True)
781
782         subrow.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
783         subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMIN')
784         subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMOUT').remove_active = True
785         sub.separator()
786
787         sub.prop(theme, "theme_area", expand=True)
788
789         split = layout.split(percentage=0.4)
790
791         layout.separator()
792         layout.separator()
793
794         split = split_themes.split()
795
796         if theme.theme_area == 'USER_INTERFACE':
797             col = split.column()
798             ui = theme.user_interface
799
800             col.label(text="Regular:")
801             self._theme_widget_style(col, ui.wcol_regular)
802
803             col.label(text="Tool:")
804             self._theme_widget_style(col, ui.wcol_tool)
805
806             col.label(text="Radio Buttons:")
807             self._theme_widget_style(col, ui.wcol_radio)
808
809             col.label(text="Text:")
810             self._theme_widget_style(col, ui.wcol_text)
811
812             col.label(text="Option:")
813             self._theme_widget_style(col, ui.wcol_option)
814
815             col.label(text="Toggle:")
816             self._theme_widget_style(col, ui.wcol_toggle)
817
818             col.label(text="Number Field:")
819             self._theme_widget_style(col, ui.wcol_num)
820
821             col.label(text="Value Slider:")
822             self._theme_widget_style(col, ui.wcol_numslider)
823
824             col.label(text="Box:")
825             self._theme_widget_style(col, ui.wcol_box)
826
827             col.label(text="Menu:")
828             self._theme_widget_style(col, ui.wcol_menu)
829
830             col.label(text="Pie Menu:")
831             self._theme_widget_style(col, ui.wcol_pie_menu)
832
833             col.label(text="Pulldown:")
834             self._theme_widget_style(col, ui.wcol_pulldown)
835
836             col.label(text="Menu Back:")
837             self._theme_widget_style(col, ui.wcol_menu_back)
838
839             col.label(text="Tooltip:")
840             self._theme_widget_style(col, ui.wcol_tooltip)
841
842             col.label(text="Menu Item:")
843             self._theme_widget_style(col, ui.wcol_menu_item)
844
845             col.label(text="Scroll Bar:")
846             self._theme_widget_style(col, ui.wcol_scroll)
847
848             col.label(text="Progress Bar:")
849             self._theme_widget_style(col, ui.wcol_progress)
850
851             col.label(text="List Item:")
852             self._theme_widget_style(col, ui.wcol_list_item)
853
854             ui_state = theme.user_interface.wcol_state
855             col.label(text="State:")
856
857             row = col.row()
858
859             subsplit = row.split(percentage=0.95)
860
861             padding = subsplit.split(percentage=0.15)
862             colsub = padding.column()
863             colsub = padding.column()
864             colsub.row().prop(ui_state, "inner_anim")
865             colsub.row().prop(ui_state, "inner_anim_sel")
866             colsub.row().prop(ui_state, "inner_driven")
867             colsub.row().prop(ui_state, "inner_driven_sel")
868
869             subsplit = row.split(percentage=0.85)
870
871             padding = subsplit.split(percentage=0.15)
872             colsub = padding.column()
873             colsub = padding.column()
874             colsub.row().prop(ui_state, "inner_key")
875             colsub.row().prop(ui_state, "inner_key_sel")
876             colsub.row().prop(ui_state, "blend")
877
878             col.separator()
879             col.separator()
880
881             col.label("Styles:")
882
883             row = col.row()
884
885             subsplit = row.split(percentage=0.95)
886
887             padding = subsplit.split(percentage=0.15)
888             colsub = padding.column()
889             colsub = padding.column()
890             colsub.row().prop(ui, "menu_shadow_fac")
891
892             subsplit = row.split(percentage=0.85)
893
894             padding = subsplit.split(percentage=0.15)
895             colsub = padding.column()
896             colsub = padding.column()
897             colsub.row().prop(ui, "menu_shadow_width")
898
899             row = col.row()
900
901             subsplit = row.split(percentage=0.95)
902
903             padding = subsplit.split(percentage=0.15)
904             colsub = padding.column()
905             colsub = padding.column()
906             colsub.row().prop(ui, "icon_alpha")
907
908             subsplit = row.split(percentage=0.85)
909
910             padding = subsplit.split(percentage=0.15)
911             colsub = padding.column()
912             colsub = padding.column()
913             colsub.row().prop(ui, "widget_emboss")
914
915             col.separator()
916             col.separator()
917
918             col.label("Axis Colors:")
919
920             row = col.row()
921
922             subsplit = row.split(percentage=0.95)
923
924             padding = subsplit.split(percentage=0.15)
925             colsub = padding.column()
926             colsub = padding.column()
927             colsub.row().prop(ui, "axis_x")
928             colsub.row().prop(ui, "axis_y")
929             colsub.row().prop(ui, "axis_z")
930
931             subsplit = row.split(percentage=0.85)
932
933             padding = subsplit.split(percentage=0.15)
934             colsub = padding.column()
935             colsub = padding.column()
936
937             layout.separator()
938             layout.separator()
939         elif theme.theme_area == 'BONE_COLOR_SETS':
940             col = split.column()
941
942             for i, ui in enumerate(theme.bone_color_sets, 1):
943                 col.label(iface_(f"Color Set {i:d}"), translate=False)
944
945                 row = col.row()
946
947                 subsplit = row.split(percentage=0.95)
948
949                 padding = subsplit.split(percentage=0.15)
950                 colsub = padding.column()
951                 colsub = padding.column()
952                 colsub.row().prop(ui, "normal")
953                 colsub.row().prop(ui, "select")
954                 colsub.row().prop(ui, "active")
955
956                 subsplit = row.split(percentage=0.85)
957
958                 padding = subsplit.split(percentage=0.15)
959                 colsub = padding.column()
960                 colsub = padding.column()
961                 colsub.row().prop(ui, "show_colored_constraints")
962         elif theme.theme_area == 'STYLE':
963             col = split.column()
964
965             style = context.user_preferences.ui_styles[0]
966
967             col.label(text="Panel Title:")
968             self._ui_font_style(col, style.panel_title)
969
970             col.separator()
971
972             col.label(text="Widget:")
973             self._ui_font_style(col, style.widget)
974
975             col.separator()
976
977             col.label(text="Widget Label:")
978             self._ui_font_style(col, style.widget_label)
979         else:
980             self._theme_generic(split, getattr(theme, theme.theme_area.lower()), theme.theme_area)
981
982
983 class USERPREF_PT_file(Panel):
984     bl_space_type = 'USER_PREFERENCES'
985     bl_label = "Files"
986     bl_region_type = 'WINDOW'
987     bl_options = {'HIDE_HEADER'}
988
989     @classmethod
990     def poll(cls, context):
991         userpref = context.user_preferences
992         return (userpref.active_section == 'FILES')
993
994     def draw(self, context):
995         layout = self.layout
996
997         userpref = context.user_preferences
998         paths = userpref.filepaths
999         system = userpref.system
1000
1001         split = layout.split(percentage=0.7)
1002
1003         col = split.column()
1004         col.label(text="File Paths:")
1005
1006         colsplit = col.split(percentage=0.95)
1007         col1 = colsplit.split(percentage=0.3)
1008
1009         sub = col1.column()
1010         sub.label(text="Fonts:")
1011         sub.label(text="Textures:")
1012         sub.label(text="Render Output:")
1013         sub.label(text="Scripts:")
1014         sub.label(text="Sounds:")
1015         sub.label(text="Temp:")
1016         sub.label(text="Render Cache:")
1017         sub.label(text="I18n Branches:")
1018         sub.label(text="Image Editor:")
1019         sub.label(text="Animation Player:")
1020
1021         sub = col1.column()
1022         sub.prop(paths, "font_directory", text="")
1023         sub.prop(paths, "texture_directory", text="")
1024         sub.prop(paths, "render_output_directory", text="")
1025         sub.prop(paths, "script_directory", text="")
1026         sub.prop(paths, "sound_directory", text="")
1027         sub.prop(paths, "temporary_directory", text="")
1028         sub.prop(paths, "render_cache_directory", text="")
1029         sub.prop(paths, "i18n_branches_directory", text="")
1030         sub.prop(paths, "image_editor", text="")
1031         subsplit = sub.split(percentage=0.3)
1032         subsplit.prop(paths, "animation_player_preset", text="")
1033         subsplit.prop(paths, "animation_player", text="")
1034
1035         col.separator()
1036         col.separator()
1037
1038         colsplit = col.split(percentage=0.95)
1039         sub = colsplit.column()
1040
1041         row = sub.split(percentage=0.3)
1042         row.label(text="Auto Execution:")
1043         row.prop(system, "use_scripts_auto_execute")
1044
1045         if system.use_scripts_auto_execute:
1046             box = sub.box()
1047             row = box.row()
1048             row.label(text="Excluded Paths:")
1049             row.operator("wm.userpref_autoexec_path_add", text="", icon='ZOOMIN', emboss=False)
1050             for i, path_cmp in enumerate(userpref.autoexec_paths):
1051                 row = box.row()
1052                 row.prop(path_cmp, "path", text="")
1053                 row.prop(path_cmp, "use_glob", text="", icon='FILTER')
1054                 row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i
1055
1056         col = split.column()
1057         col.label(text="Save & Load:")
1058         col.prop(paths, "use_relative_paths")
1059         col.prop(paths, "use_file_compression")
1060         col.prop(paths, "use_load_ui")
1061         col.prop(paths, "use_filter_files")
1062         col.prop(paths, "show_hidden_files_datablocks")
1063         col.prop(paths, "hide_recent_locations")
1064         col.prop(paths, "hide_system_bookmarks")
1065         col.prop(paths, "show_thumbnails")
1066
1067         col.separator()
1068
1069         col.prop(paths, "save_version")
1070         col.prop(paths, "recent_files")
1071         col.prop(paths, "use_save_preview_images")
1072
1073         col.separator()
1074
1075         col.label(text="Auto Save:")
1076         col.prop(paths, "use_keep_session")
1077         col.prop(paths, "use_auto_save_temporary_files")
1078         sub = col.column()
1079         sub.active = paths.use_auto_save_temporary_files
1080         sub.prop(paths, "auto_save_time", text="Timer (mins)")
1081
1082         col.separator()
1083
1084         col.label(text="Text Editor:")
1085         col.prop(system, "use_tabs_as_spaces")
1086
1087         colsplit = col.split(percentage=0.95)
1088         col1 = colsplit.split(percentage=0.3)
1089
1090         sub = col1.column()
1091         sub.label(text="Author:")
1092         sub = col1.column()
1093         sub.prop(system, "author", text="")
1094
1095
1096 class USERPREF_MT_ndof_settings(Menu):
1097     # accessed from the window key-bindings in C (only)
1098     bl_label = "3D Mouse Settings"
1099
1100     def draw(self, context):
1101         layout = self.layout
1102
1103         input_prefs = context.user_preferences.inputs
1104
1105         is_view3d = context.space_data.type == 'VIEW_3D'
1106
1107         layout.prop(input_prefs, "ndof_sensitivity")
1108         layout.prop(input_prefs, "ndof_orbit_sensitivity")
1109         layout.prop(input_prefs, "ndof_deadzone")
1110
1111         if is_view3d:
1112             layout.separator()
1113             layout.prop(input_prefs, "ndof_show_guide")
1114
1115             layout.separator()
1116             layout.label(text="Orbit Style")
1117             layout.row().prop(input_prefs, "ndof_view_navigate_method", text="")
1118             layout.row().prop(input_prefs, "ndof_view_rotate_method", text="")
1119             layout.separator()
1120             layout.label(text="Orbit Options")
1121             layout.prop(input_prefs, "ndof_rotx_invert_axis")
1122             layout.prop(input_prefs, "ndof_roty_invert_axis")
1123             layout.prop(input_prefs, "ndof_rotz_invert_axis")
1124
1125         # view2d use pan/zoom
1126         layout.separator()
1127         layout.label(text="Pan Options")
1128         layout.prop(input_prefs, "ndof_panx_invert_axis")
1129         layout.prop(input_prefs, "ndof_pany_invert_axis")
1130         layout.prop(input_prefs, "ndof_panz_invert_axis")
1131         layout.prop(input_prefs, "ndof_pan_yz_swap_axis")
1132
1133         layout.label(text="Zoom Options")
1134         layout.prop(input_prefs, "ndof_zoom_invert")
1135
1136         if is_view3d:
1137             layout.separator()
1138             layout.label(text="Fly/Walk Options")
1139             layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
1140             layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
1141
1142
1143 class USERPREF_MT_keyconfigs(Menu):
1144     bl_label = "KeyPresets"
1145     preset_subdir = "keyconfig"
1146     preset_operator = "wm.keyconfig_activate"
1147
1148     def draw(self, context):
1149         props = self.layout.operator("wm.context_set_value", text="Blender (default)")
1150         props.data_path = "window_manager.keyconfigs.active"
1151         props.value = "context.window_manager.keyconfigs.default"
1152
1153         # now draw the presets
1154         Menu.draw_preset(self, context)
1155
1156
1157 class USERPREF_PT_input(Panel):
1158     bl_space_type = 'USER_PREFERENCES'
1159     bl_label = "Input"
1160     bl_region_type = 'WINDOW'
1161     bl_options = {'HIDE_HEADER'}
1162
1163     @classmethod
1164     def poll(cls, context):
1165         userpref = context.user_preferences
1166         return (userpref.active_section == 'INPUT')
1167
1168     @staticmethod
1169     def draw_input_prefs(inputs, layout):
1170         import sys
1171
1172         # General settings
1173         row = layout.row()
1174         col = row.column()
1175
1176         sub = col.column()
1177         sub.label(text="Presets:")
1178         subrow = sub.row(align=True)
1179
1180         subrow.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label)
1181         subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMIN')
1182         subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMOUT').remove_active = True
1183         sub.separator()
1184
1185         sub.label(text="Mouse:")
1186         sub1 = sub.column()
1187         sub1.active = (inputs.select_mouse == 'RIGHT')
1188         sub1.prop(inputs, "use_mouse_emulate_3_button")
1189         sub.prop(inputs, "use_mouse_continuous")
1190         sub.prop(inputs, "drag_threshold")
1191         sub.prop(inputs, "tweak_threshold")
1192
1193         sub.label(text="Select With:")
1194         sub.row().prop(inputs, "select_mouse", expand=True)
1195
1196         sub = col.column()
1197         sub.label(text="Double Click:")
1198         sub.prop(inputs, "mouse_double_click_time", text="Speed")
1199
1200         sub.separator()
1201
1202         sub.prop(inputs, "use_emulate_numpad")
1203
1204         sub.separator()
1205
1206         sub.label(text="Orbit Style:")
1207         sub.row().prop(inputs, "view_rotate_method", expand=True)
1208
1209         sub.separator()
1210
1211         sub.label(text="Zoom Style:")
1212         sub.row().prop(inputs, "view_zoom_method", text="")
1213         if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
1214             sub.row().prop(inputs, "view_zoom_axis", expand=True)
1215             sub.prop(inputs, "invert_mouse_zoom", text="Invert Mouse Zoom Direction")
1216
1217         #sub.prop(inputs, "use_mouse_mmb_paste")
1218
1219         # col.separator()
1220
1221         sub = col.column()
1222         sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
1223         #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
1224
1225         if sys.platform == "darwin":
1226             sub = col.column()
1227             sub.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
1228
1229         col.separator()
1230         sub = col.column()
1231         sub.label(text="View Navigation:")
1232         sub.row().prop(inputs, "navigation_mode", expand=True)
1233
1234         sub.label(text="Walk Navigation:")
1235
1236         walk = inputs.walk_navigation
1237
1238         sub.prop(walk, "use_mouse_reverse")
1239         sub.prop(walk, "mouse_speed")
1240         sub.prop(walk, "teleport_time")
1241
1242         sub = col.column(align=True)
1243         sub.prop(walk, "walk_speed")
1244         sub.prop(walk, "walk_speed_factor")
1245
1246         sub.separator()
1247         sub.prop(walk, "use_gravity")
1248         sub = col.column(align=True)
1249         sub.active = walk.use_gravity
1250         sub.prop(walk, "view_height")
1251         sub.prop(walk, "jump_height")
1252
1253         if inputs.use_ndof:
1254             col.separator()
1255             col.label(text="NDOF Device:")
1256             sub = col.column(align=True)
1257             sub.prop(inputs, "ndof_sensitivity", text="Pan Sensitivity")
1258             sub.prop(inputs, "ndof_orbit_sensitivity", text="Orbit Sensitivity")
1259             sub.prop(inputs, "ndof_deadzone", text="Deadzone")
1260
1261             sub.separator()
1262             col.label(text="Navigation Style:")
1263             sub = col.column(align=True)
1264             sub.row().prop(inputs, "ndof_view_navigate_method", expand=True)
1265
1266             sub.separator()
1267             col.label(text="Rotation Style:")
1268             sub = col.column(align=True)
1269             sub.row().prop(inputs, "ndof_view_rotate_method", expand=True)
1270
1271         row.separator()
1272
1273     def draw(self, context):
1274         from rna_keymap_ui import draw_keymaps
1275
1276         layout = self.layout
1277
1278         #import time
1279
1280         #start = time.time()
1281
1282         userpref = context.user_preferences
1283
1284         inputs = userpref.inputs
1285
1286         split = layout.split(percentage=0.25)
1287
1288         # Input settings
1289         self.draw_input_prefs(inputs, split)
1290
1291         # Keymap Settings
1292         draw_keymaps(context, split)
1293
1294         #print("runtime", time.time() - start)
1295
1296
1297 class USERPREF_MT_addons_online_resources(Menu):
1298     bl_label = "Online Resources"
1299
1300     # menu to open web-pages with addons development guides
1301     def draw(self, context):
1302         layout = self.layout
1303
1304         layout.operator(
1305             "wm.url_open", text="Add-ons Catalog", icon='URL',
1306         ).url = "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts"
1307
1308         layout.separator()
1309
1310         layout.operator(
1311             "wm.url_open", text="How to share your add-on", icon='URL',
1312         ).url = "http://wiki.blender.org/index.php/Dev:Py/Sharing"
1313         layout.operator(
1314             "wm.url_open", text="Add-on Guidelines", icon='URL',
1315         ).url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons"
1316         layout.operator(
1317             "wm.url_open", text="API Concepts", icon='URL',
1318         ).url = bpy.types.WM_OT_doc_view._prefix + "/info_quickstart.html"
1319         layout.operator(
1320             "wm.url_open", text="Add-on Tutorial", icon='URL',
1321         ).url = bpy.types.WM_OT_doc_view._prefix + "/info_tutorial_addon.html"
1322
1323
1324 class USERPREF_PT_addons(Panel):
1325     bl_space_type = 'USER_PREFERENCES'
1326     bl_label = "Add-ons"
1327     bl_region_type = 'WINDOW'
1328     bl_options = {'HIDE_HEADER'}
1329
1330     _support_icon_mapping = {
1331         'OFFICIAL': 'FILE_BLEND',
1332         'COMMUNITY': 'POSE_DATA',
1333         'TESTING': 'MOD_EXPLODE',
1334     }
1335
1336     @classmethod
1337     def poll(cls, context):
1338         userpref = context.user_preferences
1339         return (userpref.active_section == 'ADDONS')
1340
1341     @staticmethod
1342     def is_user_addon(mod, user_addon_paths):
1343         import os
1344
1345         if not user_addon_paths:
1346             for path in (
1347                     bpy.utils.script_path_user(),
1348                     bpy.utils.script_path_pref(),
1349             ):
1350                 if path is not None:
1351                     user_addon_paths.append(os.path.join(path, "addons"))
1352
1353         for path in user_addon_paths:
1354             if bpy.path.is_subdir(mod.__file__, path):
1355                 return True
1356         return False
1357
1358     @staticmethod
1359     def draw_error(layout, message):
1360         lines = message.split("\n")
1361         box = layout.box()
1362         sub = box.row()
1363         sub.label(lines[0])
1364         sub.label(icon='ERROR')
1365         for l in lines[1:]:
1366             box.label(l)
1367
1368     def draw(self, context):
1369         import os
1370         import addon_utils
1371
1372         layout = self.layout
1373
1374         userpref = context.user_preferences
1375         used_ext = {ext.module for ext in userpref.addons}
1376
1377         userpref_addons_folder = os.path.join(userpref.filepaths.script_directory, "addons")
1378         scripts_addons_folder = bpy.utils.user_resource('SCRIPTS', "addons")
1379
1380         # collect the categories that can be filtered on
1381         addons = [
1382             (mod, addon_utils.module_bl_info(mod))
1383             for mod in addon_utils.modules(refresh=False)
1384         ]
1385
1386         split = layout.split(percentage=0.2)
1387         col = split.column()
1388         col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
1389
1390         col.label(text="Supported Level")
1391         col.prop(context.window_manager, "addon_support", expand=True)
1392
1393         col.label(text="Categories")
1394         col.prop(context.window_manager, "addon_filter", expand=True)
1395
1396         col = split.column()
1397
1398         # set in addon_utils.modules_refresh()
1399         if addon_utils.error_duplicates:
1400             box = col.box()
1401             row = box.row()
1402             row.label("Multiple add-ons with the same name found!")
1403             row.label(icon='ERROR')
1404             box.label("Please delete one of each pair:")
1405             for (addon_name, addon_file, addon_path) in addon_utils.error_duplicates:
1406                 box.separator()
1407                 sub_col = box.column(align=True)
1408                 sub_col.label(addon_name + ":")
1409                 sub_col.label("    " + addon_file)
1410                 sub_col.label("    " + addon_path)
1411
1412         if addon_utils.error_encoding:
1413             self.draw_error(
1414                 col,
1415                 "One or more addons do not have UTF-8 encoding\n"
1416                 "(see console for details)",
1417             )
1418
1419         filter = context.window_manager.addon_filter
1420         search = context.window_manager.addon_search.lower()
1421         support = context.window_manager.addon_support
1422
1423         # initialized on demand
1424         user_addon_paths = []
1425
1426         for mod, info in addons:
1427             module_name = mod.__name__
1428
1429             is_enabled = module_name in used_ext
1430
1431             if info["support"] not in support:
1432                 continue
1433
1434             # check if addon should be visible with current filters
1435             if ((filter == "All") or
1436                         (filter == info["category"]) or
1437                         (filter == "Enabled" and is_enabled) or
1438                     (filter == "Disabled" and not is_enabled) or
1439                     (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
1440                     ):
1441                 if search and search not in info["name"].lower():
1442                     if info["author"]:
1443                         if search not in info["author"].lower():
1444                             continue
1445                     else:
1446                         continue
1447
1448                 # Addon UI Code
1449                 col_box = col.column()
1450                 box = col_box.box()
1451                 colsub = box.column()
1452                 row = colsub.row(align=True)
1453
1454                 row.operator(
1455                     "wm.addon_expand",
1456                     icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT',
1457                     emboss=False,
1458                 ).module = module_name
1459
1460                 row.operator(
1461                     "wm.addon_disable" if is_enabled else "wm.addon_enable",
1462                     icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
1463                     emboss=False,
1464                 ).module = module_name
1465
1466                 sub = row.row()
1467                 sub.active = is_enabled
1468                 sub.label(text="%s: %s" % (info["category"], info["name"]))
1469                 if info["warning"]:
1470                     sub.label(icon='ERROR')
1471
1472                 # icon showing support level.
1473                 sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
1474
1475                 # Expanded UI (only if additional info is available)
1476                 if info["show_expanded"]:
1477                     if info["description"]:
1478                         split = colsub.row().split(percentage=0.15)
1479                         split.label(text="Description:")
1480                         split.label(text=info["description"])
1481                     if info["location"]:
1482                         split = colsub.row().split(percentage=0.15)
1483                         split.label(text="Location:")
1484                         split.label(text=info["location"])
1485                     if mod:
1486                         split = colsub.row().split(percentage=0.15)
1487                         split.label(text="File:")
1488                         split.label(text=mod.__file__, translate=False)
1489                     if info["author"]:
1490                         split = colsub.row().split(percentage=0.15)
1491                         split.label(text="Author:")
1492                         split.label(text=info["author"], translate=False)
1493                     if info["version"]:
1494                         split = colsub.row().split(percentage=0.15)
1495                         split.label(text="Version:")
1496                         split.label(text=".".join(str(x) for x in info["version"]), translate=False)
1497                     if info["warning"]:
1498                         split = colsub.row().split(percentage=0.15)
1499                         split.label(text="Warning:")
1500                         split.label(text="  " + info["warning"], icon='ERROR')
1501
1502                     user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
1503                     tot_row = bool(info["wiki_url"]) + bool(user_addon)
1504
1505                     if tot_row:
1506                         split = colsub.row().split(percentage=0.15)
1507                         split.label(text="Internet:")
1508                         if info["wiki_url"]:
1509                             split.operator(
1510                                 "wm.url_open", text="Documentation", icon='HELP',
1511                             ).url = info["wiki_url"]
1512                         # Only add "Report a Bug" button if tracker_url is set
1513                         # or the add-on is bundled (use official tracker then).
1514                         if info.get("tracker_url") or not user_addon:
1515                             split.operator(
1516                                 "wm.url_open", text="Report a Bug", icon='URL',
1517                             ).url = info.get(
1518                                 "tracker_url",
1519                                 "https://developer.blender.org/maniphest/task/edit/form/2",
1520                             )
1521                         if user_addon:
1522                             split.operator(
1523                                 "wm.addon_remove", text="Remove", icon='CANCEL',
1524                             ).module = mod.__name__
1525
1526                         for i in range(4 - tot_row):
1527                             split.separator()
1528
1529                     # Show addon user preferences
1530                     if is_enabled:
1531                         addon_preferences = userpref.addons[module_name].preferences
1532                         if addon_preferences is not None:
1533                             draw = getattr(addon_preferences, "draw", None)
1534                             if draw is not None:
1535                                 addon_preferences_class = type(addon_preferences)
1536                                 box_prefs = col_box.box()
1537                                 box_prefs.label("Preferences:")
1538                                 addon_preferences_class.layout = box_prefs
1539                                 try:
1540                                     draw(context)
1541                                 except:
1542                                     import traceback
1543                                     traceback.print_exc()
1544                                     box_prefs.label(text="Error (see console)", icon='ERROR')
1545                                 del addon_preferences_class.layout
1546
1547         # Append missing scripts
1548         # First collect scripts that are used but have no script file.
1549         module_names = {mod.__name__ for mod, info in addons}
1550         missing_modules = {ext for ext in used_ext if ext not in module_names}
1551
1552         if missing_modules and filter in {"All", "Enabled"}:
1553             col.column().separator()
1554             col.column().label(text="Missing script files")
1555
1556             module_names = {mod.__name__ for mod, info in addons}
1557             for module_name in sorted(missing_modules):
1558                 is_enabled = module_name in used_ext
1559                 # Addon UI Code
1560                 box = col.column().box()
1561                 colsub = box.column()
1562                 row = colsub.row(align=True)
1563
1564                 row.label(text="", icon='ERROR')
1565
1566                 if is_enabled:
1567                     row.operator(
1568                         "wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False,
1569                     ).module = module_name
1570
1571                 row.label(text=module_name, translate=False)
1572
1573
1574 classes = (
1575     USERPREF_HT_header,
1576     USERPREF_PT_tabs,
1577     USERPREF_MT_interaction_presets,
1578     USERPREF_MT_templates_splash,
1579     USERPREF_MT_app_templates,
1580     USERPREF_MT_appconfigs,
1581     USERPREF_MT_splash,
1582     USERPREF_MT_splash_footer,
1583     USERPREF_PT_interface,
1584     USERPREF_PT_edit,
1585     USERPREF_PT_system,
1586     USERPREF_MT_interface_theme_presets,
1587     USERPREF_PT_theme,
1588     USERPREF_PT_file,
1589     USERPREF_MT_ndof_settings,
1590     USERPREF_MT_keyconfigs,
1591     USERPREF_PT_input,
1592     USERPREF_MT_addons_online_resources,
1593     USERPREF_PT_addons,
1594 )
1595
1596 if __name__ == "__main__":  # only for live edit.
1597     from bpy.utils import register_class
1598     for cls in classes:
1599         register_class(cls)