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