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