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