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