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