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