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