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