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