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