User Prefs: app-template option to hide the cursor
[blender-staging.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
317         col.prop(view, "show_splash")
318         col.separator()
319
320         col.label(text="App Template:")
321         col.label(text="Options intended for use with app-templates only.")
322         col.prop(view, "show_layout_ui")
323         col.prop(view, "show_view3d_cursor")
324
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
868             subsplit = row.split(percentage=0.85)
869
870             padding = subsplit.split(percentage=0.15)
871             colsub = padding.column()
872             colsub = padding.column()
873             colsub.row().prop(ui_state, "inner_key")
874             colsub.row().prop(ui_state, "inner_key_sel")
875             colsub.row().prop(ui_state, "blend")
876
877             col.separator()
878             col.separator()
879
880             col.label("Styles:")
881
882             row = col.row()
883
884             subsplit = row.split(percentage=0.95)
885
886             padding = subsplit.split(percentage=0.15)
887             colsub = padding.column()
888             colsub = padding.column()
889             colsub.row().prop(ui, "menu_shadow_fac")
890
891             subsplit = row.split(percentage=0.85)
892
893             padding = subsplit.split(percentage=0.15)
894             colsub = padding.column()
895             colsub = padding.column()
896             colsub.row().prop(ui, "menu_shadow_width")
897
898             row = col.row()
899
900             subsplit = row.split(percentage=0.95)
901
902             padding = subsplit.split(percentage=0.15)
903             colsub = padding.column()
904             colsub = padding.column()
905             colsub.row().prop(ui, "icon_alpha")
906
907             subsplit = row.split(percentage=0.85)
908
909             padding = subsplit.split(percentage=0.15)
910             colsub = padding.column()
911             colsub = padding.column()
912             colsub.row().prop(ui, "widget_emboss")
913
914             col.separator()
915             col.separator()
916
917             col.label("Axis Colors:")
918
919             row = col.row()
920
921             subsplit = row.split(percentage=0.95)
922
923             padding = subsplit.split(percentage=0.15)
924             colsub = padding.column()
925             colsub = padding.column()
926             colsub.row().prop(ui, "axis_x")
927             colsub.row().prop(ui, "axis_y")
928             colsub.row().prop(ui, "axis_z")
929
930             subsplit = row.split(percentage=0.85)
931
932             padding = subsplit.split(percentage=0.15)
933             colsub = padding.column()
934             colsub = padding.column()
935
936             layout.separator()
937             layout.separator()
938         elif theme.theme_area == 'BONE_COLOR_SETS':
939             col = split.column()
940
941             for i, ui in enumerate(theme.bone_color_sets):
942                 col.label(text=iface_("Color Set %d:") % (i + 1), translate=False)  # i starts from 0
943
944                 row = col.row()
945
946                 subsplit = row.split(percentage=0.95)
947
948                 padding = subsplit.split(percentage=0.15)
949                 colsub = padding.column()
950                 colsub = padding.column()
951                 colsub.row().prop(ui, "normal")
952                 colsub.row().prop(ui, "select")
953                 colsub.row().prop(ui, "active")
954
955                 subsplit = row.split(percentage=0.85)
956
957                 padding = subsplit.split(percentage=0.15)
958                 colsub = padding.column()
959                 colsub = padding.column()
960                 colsub.row().prop(ui, "show_colored_constraints")
961         elif theme.theme_area == 'STYLE':
962             col = split.column()
963
964             style = context.user_preferences.ui_styles[0]
965
966             col.label(text="Panel Title:")
967             self._ui_font_style(col, style.panel_title)
968
969             col.separator()
970
971             col.label(text="Widget:")
972             self._ui_font_style(col, style.widget)
973
974             col.separator()
975
976             col.label(text="Widget Label:")
977             self._ui_font_style(col, style.widget_label)
978         else:
979             self._theme_generic(split, getattr(theme, theme.theme_area.lower()), theme.theme_area)
980
981
982 class USERPREF_PT_file(Panel):
983     bl_space_type = 'USER_PREFERENCES'
984     bl_label = "Files"
985     bl_region_type = 'WINDOW'
986     bl_options = {'HIDE_HEADER'}
987
988     @classmethod
989     def poll(cls, context):
990         userpref = context.user_preferences
991         return (userpref.active_section == 'FILES')
992
993     def draw(self, context):
994         layout = self.layout
995
996         userpref = context.user_preferences
997         paths = userpref.filepaths
998         system = userpref.system
999
1000         split = layout.split(percentage=0.7)
1001
1002         col = split.column()
1003         col.label(text="File Paths:")
1004
1005         colsplit = col.split(percentage=0.95)
1006         col1 = colsplit.split(percentage=0.3)
1007
1008         sub = col1.column()
1009         sub.label(text="Fonts:")
1010         sub.label(text="Textures:")
1011         sub.label(text="Render Output:")
1012         sub.label(text="Scripts:")
1013         sub.label(text="Sounds:")
1014         sub.label(text="Temp:")
1015         sub.label(text="Render Cache:")
1016         sub.label(text="I18n Branches:")
1017         sub.label(text="Image Editor:")
1018         sub.label(text="Animation Player:")
1019
1020         sub = col1.column()
1021         sub.prop(paths, "font_directory", text="")
1022         sub.prop(paths, "texture_directory", text="")
1023         sub.prop(paths, "render_output_directory", text="")
1024         sub.prop(paths, "script_directory", text="")
1025         sub.prop(paths, "sound_directory", text="")
1026         sub.prop(paths, "temporary_directory", text="")
1027         sub.prop(paths, "render_cache_directory", text="")
1028         sub.prop(paths, "i18n_branches_directory", text="")
1029         sub.prop(paths, "image_editor", text="")
1030         subsplit = sub.split(percentage=0.3)
1031         subsplit.prop(paths, "animation_player_preset", text="")
1032         subsplit.prop(paths, "animation_player", text="")
1033
1034         col.separator()
1035         col.separator()
1036
1037         colsplit = col.split(percentage=0.95)
1038         sub = colsplit.column()
1039
1040         row = sub.split(percentage=0.3)
1041         row.label(text="Auto Execution:")
1042         row.prop(system, "use_scripts_auto_execute")
1043
1044         if system.use_scripts_auto_execute:
1045             box = sub.box()
1046             row = box.row()
1047             row.label(text="Excluded Paths:")
1048             row.operator("wm.userpref_autoexec_path_add", text="", icon='ZOOMIN', emboss=False)
1049             for i, path_cmp in enumerate(userpref.autoexec_paths):
1050                 row = box.row()
1051                 row.prop(path_cmp, "path", text="")
1052                 row.prop(path_cmp, "use_glob", text="", icon='FILTER')
1053                 row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i
1054
1055         col = split.column()
1056         col.label(text="Save & Load:")
1057         col.prop(paths, "use_relative_paths")
1058         col.prop(paths, "use_file_compression")
1059         col.prop(paths, "use_load_ui")
1060         col.prop(paths, "use_filter_files")
1061         col.prop(paths, "show_hidden_files_datablocks")
1062         col.prop(paths, "hide_recent_locations")
1063         col.prop(paths, "hide_system_bookmarks")
1064         col.prop(paths, "show_thumbnails")
1065
1066         col.separator()
1067
1068         col.prop(paths, "save_version")
1069         col.prop(paths, "recent_files")
1070         col.prop(paths, "use_save_preview_images")
1071
1072         col.separator()
1073
1074         col.label(text="Auto Save:")
1075         col.prop(paths, "use_keep_session")
1076         col.prop(paths, "use_auto_save_temporary_files")
1077         sub = col.column()
1078         sub.active = paths.use_auto_save_temporary_files
1079         sub.prop(paths, "auto_save_time", text="Timer (mins)")
1080
1081         col.separator()
1082
1083         col.label(text="Text Editor:")
1084         col.prop(system, "use_tabs_as_spaces")
1085
1086         colsplit = col.split(percentage=0.95)
1087         col1 = colsplit.split(percentage=0.3)
1088
1089         sub = col1.column()
1090         sub.label(text="Author:")
1091         sub = col1.column()
1092         sub.prop(system, "author", text="")
1093
1094
1095 class USERPREF_MT_ndof_settings(Menu):
1096     # accessed from the window key-bindings in C (only)
1097     bl_label = "3D Mouse Settings"
1098
1099     def draw(self, context):
1100         layout = self.layout
1101
1102         input_prefs = context.user_preferences.inputs
1103
1104         is_view3d = context.space_data.type == 'VIEW_3D'
1105
1106         layout.prop(input_prefs, "ndof_sensitivity")
1107         layout.prop(input_prefs, "ndof_orbit_sensitivity")
1108         layout.prop(input_prefs, "ndof_deadzone")
1109
1110         if is_view3d:
1111             layout.separator()
1112             layout.prop(input_prefs, "ndof_show_guide")
1113
1114             layout.separator()
1115             layout.label(text="Orbit Style")
1116             layout.row().prop(input_prefs, "ndof_view_navigate_method", text="")
1117             layout.row().prop(input_prefs, "ndof_view_rotate_method", text="")
1118             layout.separator()
1119             layout.label(text="Orbit Options")
1120             layout.prop(input_prefs, "ndof_rotx_invert_axis")
1121             layout.prop(input_prefs, "ndof_roty_invert_axis")
1122             layout.prop(input_prefs, "ndof_rotz_invert_axis")
1123
1124         # view2d use pan/zoom
1125         layout.separator()
1126         layout.label(text="Pan Options")
1127         layout.prop(input_prefs, "ndof_panx_invert_axis")
1128         layout.prop(input_prefs, "ndof_pany_invert_axis")
1129         layout.prop(input_prefs, "ndof_panz_invert_axis")
1130         layout.prop(input_prefs, "ndof_pan_yz_swap_axis")
1131
1132         layout.label(text="Zoom Options")
1133         layout.prop(input_prefs, "ndof_zoom_invert")
1134
1135         if is_view3d:
1136             layout.separator()
1137             layout.label(text="Fly/Walk Options")
1138             layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
1139             layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
1140
1141
1142 class USERPREF_MT_keyconfigs(Menu):
1143     bl_label = "KeyPresets"
1144     preset_subdir = "keyconfig"
1145     preset_operator = "wm.keyconfig_activate"
1146
1147     def draw(self, context):
1148         props = self.layout.operator("wm.context_set_value", text="Blender (default)")
1149         props.data_path = "window_manager.keyconfigs.active"
1150         props.value = "context.window_manager.keyconfigs.default"
1151
1152         # now draw the presets
1153         Menu.draw_preset(self, context)
1154
1155
1156 class USERPREF_PT_input(Panel):
1157     bl_space_type = 'USER_PREFERENCES'
1158     bl_label = "Input"
1159     bl_region_type = 'WINDOW'
1160     bl_options = {'HIDE_HEADER'}
1161
1162     @classmethod
1163     def poll(cls, context):
1164         userpref = context.user_preferences
1165         return (userpref.active_section == 'INPUT')
1166
1167     @staticmethod
1168     def draw_input_prefs(inputs, layout):
1169         import sys
1170
1171         # General settings
1172         row = layout.row()
1173         col = row.column()
1174
1175         sub = col.column()
1176         sub.label(text="Presets:")
1177         subrow = sub.row(align=True)
1178
1179         subrow.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label)
1180         subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMIN')
1181         subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMOUT').remove_active = True
1182         sub.separator()
1183
1184         sub.label(text="Mouse:")
1185         sub1 = sub.column()
1186         sub1.active = (inputs.select_mouse == 'RIGHT')
1187         sub1.prop(inputs, "use_mouse_emulate_3_button")
1188         sub.prop(inputs, "use_mouse_continuous")
1189         sub.prop(inputs, "drag_threshold")
1190         sub.prop(inputs, "tweak_threshold")
1191
1192         sub.label(text="Select With:")
1193         sub.row().prop(inputs, "select_mouse", expand=True)
1194
1195         sub = col.column()
1196         sub.label(text="Double Click:")
1197         sub.prop(inputs, "mouse_double_click_time", text="Speed")
1198
1199         sub.separator()
1200
1201         sub.prop(inputs, "use_emulate_numpad")
1202
1203         sub.separator()
1204
1205         sub.label(text="Orbit Style:")
1206         sub.row().prop(inputs, "view_rotate_method", expand=True)
1207
1208         sub.separator()
1209
1210         sub.label(text="Zoom Style:")
1211         sub.row().prop(inputs, "view_zoom_method", text="")
1212         if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
1213             sub.row().prop(inputs, "view_zoom_axis", expand=True)
1214             sub.prop(inputs, "invert_mouse_zoom", text="Invert Mouse Zoom Direction")
1215
1216         #sub.prop(inputs, "use_mouse_mmb_paste")
1217
1218         #col.separator()
1219
1220         sub = col.column()
1221         sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
1222         #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
1223
1224         if sys.platform == "darwin":
1225             sub = col.column()
1226             sub.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
1227
1228         col.separator()
1229         sub = col.column()
1230         sub.label(text="View Navigation:")
1231         sub.row().prop(inputs, "navigation_mode", expand=True)
1232
1233         sub.label(text="Walk Navigation:")
1234
1235         walk = inputs.walk_navigation
1236
1237         sub.prop(walk, "use_mouse_reverse")
1238         sub.prop(walk, "mouse_speed")
1239         sub.prop(walk, "teleport_time")
1240
1241         sub = col.column(align=True)
1242         sub.prop(walk, "walk_speed")
1243         sub.prop(walk, "walk_speed_factor")
1244
1245         sub.separator()
1246         sub.prop(walk, "use_gravity")
1247         sub = col.column(align=True)
1248         sub.active = walk.use_gravity
1249         sub.prop(walk, "view_height")
1250         sub.prop(walk, "jump_height")
1251
1252         if inputs.use_ndof:
1253             col.separator()
1254             col.label(text="NDOF Device:")
1255             sub = col.column(align=True)
1256             sub.prop(inputs, "ndof_sensitivity", text="Pan Sensitivity")
1257             sub.prop(inputs, "ndof_orbit_sensitivity", text="Orbit Sensitivity")
1258             sub.prop(inputs, "ndof_deadzone", text="Deadzone")
1259
1260             sub.separator()
1261             col.label(text="Navigation Style:")
1262             sub = col.column(align=True)
1263             sub.row().prop(inputs, "ndof_view_navigate_method", expand=True)
1264
1265             sub.separator()
1266             col.label(text="Rotation Style:")
1267             sub = col.column(align=True)
1268             sub.row().prop(inputs, "ndof_view_rotate_method", expand=True)
1269
1270         row.separator()
1271
1272     def draw(self, context):
1273         from rna_keymap_ui import draw_keymaps
1274
1275         layout = self.layout
1276
1277         #import time
1278
1279         #start = time.time()
1280
1281         userpref = context.user_preferences
1282
1283         inputs = userpref.inputs
1284
1285         split = layout.split(percentage=0.25)
1286
1287         # Input settings
1288         self.draw_input_prefs(inputs, split)
1289
1290         # Keymap Settings
1291         draw_keymaps(context, split)
1292
1293         #print("runtime", time.time() - start)
1294
1295
1296 class USERPREF_MT_addons_online_resources(Menu):
1297     bl_label = "Online Resources"
1298
1299     # menu to open web-pages with addons development guides
1300     def draw(self, context):
1301         layout = self.layout
1302
1303         layout.operator(
1304                 "wm.url_open", text="Add-ons Catalog", icon='URL',
1305                 ).url = "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts"
1306
1307         layout.separator()
1308
1309         layout.operator(
1310                 "wm.url_open", text="How to share your add-on", icon='URL',
1311                 ).url = "http://wiki.blender.org/index.php/Dev:Py/Sharing"
1312         layout.operator(
1313                 "wm.url_open", text="Add-on Guidelines", icon='URL',
1314                 ).url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons"
1315         layout.operator(
1316                 "wm.url_open", text="API Concepts", icon='URL',
1317                 ).url = bpy.types.WM_OT_doc_view._prefix + "/info_quickstart.html"
1318         layout.operator("wm.url_open", text="Add-on Tutorial", icon='URL',
1319                 ).url = bpy.types.WM_OT_doc_view._prefix + "/info_tutorial_addon.html"
1320
1321
1322 class USERPREF_PT_addons(Panel):
1323     bl_space_type = 'USER_PREFERENCES'
1324     bl_label = "Add-ons"
1325     bl_region_type = 'WINDOW'
1326     bl_options = {'HIDE_HEADER'}
1327
1328     _support_icon_mapping = {
1329         'OFFICIAL': 'FILE_BLEND',
1330         'COMMUNITY': 'POSE_DATA',
1331         'TESTING': 'MOD_EXPLODE',
1332         }
1333
1334     @classmethod
1335     def poll(cls, context):
1336         userpref = context.user_preferences
1337         return (userpref.active_section == 'ADDONS')
1338
1339     @staticmethod
1340     def is_user_addon(mod, user_addon_paths):
1341         import os
1342
1343         if not user_addon_paths:
1344             for path in (bpy.utils.script_path_user(),
1345                          bpy.utils.script_path_pref()):
1346                 if path is not None:
1347                     user_addon_paths.append(os.path.join(path, "addons"))
1348
1349         for path in user_addon_paths:
1350             if bpy.path.is_subdir(mod.__file__, path):
1351                 return True
1352         return False
1353
1354     @staticmethod
1355     def draw_error(layout, message):
1356         lines = message.split("\n")
1357         box = layout.box()
1358         sub = box.row()
1359         sub.label(lines[0])
1360         sub.label(icon='ERROR')
1361         for l in lines[1:]:
1362             box.label(l)
1363
1364     def draw(self, context):
1365         import os
1366         import addon_utils
1367
1368         layout = self.layout
1369
1370         userpref = context.user_preferences
1371         used_ext = {ext.module for ext in userpref.addons}
1372
1373         userpref_addons_folder = os.path.join(userpref.filepaths.script_directory, "addons")
1374         scripts_addons_folder = bpy.utils.user_resource('SCRIPTS', "addons")
1375
1376         # collect the categories that can be filtered on
1377         addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(refresh=False)]
1378
1379         split = layout.split(percentage=0.2)
1380         col = split.column()
1381         col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
1382
1383         col.label(text="Supported Level")
1384         col.prop(context.window_manager, "addon_support", expand=True)
1385
1386         col.label(text="Categories")
1387         col.prop(context.window_manager, "addon_filter", expand=True)
1388
1389         col = split.column()
1390
1391         # set in addon_utils.modules_refresh()
1392         if addon_utils.error_duplicates:
1393             box = col.box()
1394             row = box.row()
1395             row.label("Multiple add-ons with the same name found!")
1396             row.label(icon='ERROR')
1397             box.label("Please delete one of each pair:")
1398             for (addon_name, addon_file, addon_path) in addon_utils.error_duplicates:
1399                 box.separator()
1400                 sub_col = box.column(align=True)
1401                 sub_col.label(addon_name + ":")
1402                 sub_col.label("    " + addon_file)
1403                 sub_col.label("    " + addon_path)
1404
1405
1406         if addon_utils.error_encoding:
1407             self.draw_error(col,
1408                             "One or more addons do not have UTF-8 encoding\n"
1409                             "(see console for details)",
1410                             )
1411
1412         filter = context.window_manager.addon_filter
1413         search = context.window_manager.addon_search.lower()
1414         support = context.window_manager.addon_support
1415
1416         # initialized on demand
1417         user_addon_paths = []
1418
1419         for mod, info in addons:
1420             module_name = mod.__name__
1421
1422             is_enabled = module_name in used_ext
1423
1424             if info["support"] not in support:
1425                 continue
1426
1427             # check if addon should be visible with current filters
1428             if ((filter == "All") or
1429                 (filter == info["category"]) or
1430                 (filter == "Enabled" and is_enabled) or
1431                 (filter == "Disabled" and not is_enabled) or
1432                 (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
1433                 ):
1434
1435                 if search and search not in info["name"].lower():
1436                     if info["author"]:
1437                         if search not in info["author"].lower():
1438                             continue
1439                     else:
1440                         continue
1441
1442                 # Addon UI Code
1443                 col_box = col.column()
1444                 box = col_box.box()
1445                 colsub = box.column()
1446                 row = colsub.row(align=True)
1447
1448                 row.operator(
1449                         "wm.addon_expand",
1450                         icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT',
1451                         emboss=False,
1452                         ).module = module_name
1453
1454                 row.operator(
1455                         "wm.addon_disable" if is_enabled else "wm.addon_enable",
1456                         icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
1457                         emboss=False,
1458                         ).module = module_name
1459
1460                 sub = row.row()
1461                 sub.active = is_enabled
1462                 sub.label(text="%s: %s" % (info["category"], info["name"]))
1463                 if info["warning"]:
1464                     sub.label(icon='ERROR')
1465
1466                 # icon showing support level.
1467                 sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
1468
1469                 # Expanded UI (only if additional info is available)
1470                 if info["show_expanded"]:
1471                     if info["description"]:
1472                         split = colsub.row().split(percentage=0.15)
1473                         split.label(text="Description:")
1474                         split.label(text=info["description"])
1475                     if info["location"]:
1476                         split = colsub.row().split(percentage=0.15)
1477                         split.label(text="Location:")
1478                         split.label(text=info["location"])
1479                     if mod:
1480                         split = colsub.row().split(percentage=0.15)
1481                         split.label(text="File:")
1482                         split.label(text=mod.__file__, translate=False)
1483                     if info["author"]:
1484                         split = colsub.row().split(percentage=0.15)
1485                         split.label(text="Author:")
1486                         split.label(text=info["author"], translate=False)
1487                     if info["version"]:
1488                         split = colsub.row().split(percentage=0.15)
1489                         split.label(text="Version:")
1490                         split.label(text=".".join(str(x) for x in info["version"]), translate=False)
1491                     if info["warning"]:
1492                         split = colsub.row().split(percentage=0.15)
1493                         split.label(text="Warning:")
1494                         split.label(text="  " + info["warning"], icon='ERROR')
1495
1496                     user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
1497                     tot_row = bool(info["wiki_url"]) + bool(user_addon)
1498
1499                     if tot_row:
1500                         split = colsub.row().split(percentage=0.15)
1501                         split.label(text="Internet:")
1502                         if info["wiki_url"]:
1503                             split.operator("wm.url_open", text="Documentation", icon='HELP').url = info["wiki_url"]
1504                         split.operator("wm.url_open", text="Report a Bug", icon='URL').url = info.get(
1505                                 "tracker_url",
1506                                 "https://developer.blender.org/maniphest/task/edit/form/2")
1507                         if user_addon:
1508                             split.operator("wm.addon_remove", text="Remove", icon='CANCEL').module = mod.__name__
1509
1510                         for i in range(4 - tot_row):
1511                             split.separator()
1512
1513                     # Show addon user preferences
1514                     if is_enabled:
1515                         addon_preferences = userpref.addons[module_name].preferences
1516                         if addon_preferences is not None:
1517                             draw = getattr(addon_preferences, "draw", None)
1518                             if draw is not None:
1519                                 addon_preferences_class = type(addon_preferences)
1520                                 box_prefs = col_box.box()
1521                                 box_prefs.label("Preferences:")
1522                                 addon_preferences_class.layout = box_prefs
1523                                 try:
1524                                     draw(context)
1525                                 except:
1526                                     import traceback
1527                                     traceback.print_exc()
1528                                     box_prefs.label(text="Error (see console)", icon='ERROR')
1529                                 del addon_preferences_class.layout
1530
1531         # Append missing scripts
1532         # First collect scripts that are used but have no script file.
1533         module_names = {mod.__name__ for mod, info in addons}
1534         missing_modules = {ext for ext in used_ext if ext not in module_names}
1535
1536         if missing_modules and filter in {"All", "Enabled"}:
1537             col.column().separator()
1538             col.column().label(text="Missing script files")
1539
1540             module_names = {mod.__name__ for mod, info in addons}
1541             for module_name in sorted(missing_modules):
1542                 is_enabled = module_name in used_ext
1543                 # Addon UI Code
1544                 box = col.column().box()
1545                 colsub = box.column()
1546                 row = colsub.row(align=True)
1547
1548                 row.label(text="", icon='ERROR')
1549
1550                 if is_enabled:
1551                     row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name
1552
1553                 row.label(text=module_name, translate=False)
1554
1555
1556 classes = (
1557     USERPREF_HT_header,
1558     USERPREF_PT_tabs,
1559     USERPREF_MT_interaction_presets,
1560     USERPREF_MT_templates_splash,
1561     USERPREF_MT_app_templates,
1562     USERPREF_MT_appconfigs,
1563     USERPREF_MT_splash,
1564     USERPREF_MT_splash_footer,
1565     USERPREF_PT_interface,
1566     USERPREF_PT_edit,
1567     USERPREF_PT_system,
1568     USERPREF_MT_interface_theme_presets,
1569     USERPREF_PT_theme,
1570     USERPREF_PT_file,
1571     USERPREF_MT_ndof_settings,
1572     USERPREF_MT_keyconfigs,
1573     USERPREF_PT_input,
1574     USERPREF_MT_addons_online_resources,
1575     USERPREF_PT_addons,
1576 )
1577
1578 if __name__ == "__main__":  # only for live edit.
1579     from bpy.utils import register_class
1580     for cls in classes:
1581         register_class(cls)