Fix wrong placement of allow negative frames preference.
[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
28
29 class USERPREF_HT_header(Header):
30     bl_space_type = 'PREFERENCES'
31
32     def draw(self, _context):
33         layout = self.layout
34         layout.operator_context = 'EXEC_AREA'
35
36         layout.template_header()
37
38
39 class USERPREF_PT_navigation_bar(Panel):
40     bl_label = "Preferences Navigation"
41     bl_space_type = 'PREFERENCES'
42     bl_region_type = 'NAVIGATION_BAR'
43     bl_options = {'HIDE_HEADER'}
44
45     def draw(self, context):
46         layout = self.layout
47
48         prefs = context.preferences
49
50         col = layout.column()
51
52         col.scale_x = 1.3
53         col.scale_y = 1.3
54         col.prop(prefs, "active_section", expand=True)
55
56
57 class USERPREF_PT_save_preferences(Panel):
58     bl_label = "Save Preferences"
59     bl_space_type = 'PREFERENCES'
60     bl_region_type = 'EXECUTE'
61     bl_options = {'HIDE_HEADER'}
62
63     def draw(self, _context):
64         layout = self.layout
65         layout.operator_context = 'EXEC_AREA'
66
67         layout.scale_x = 1.3
68         layout.scale_y = 1.3
69
70         layout.operator("wm.save_userpref")
71
72
73 class PreferencePanel(Panel):
74     """
75     Base class for panels to center align contents with some horizontal margin.
76     Deriving classes need to implement a ``draw_props(context, layout)`` function.
77     """
78
79     bl_space_type = 'PREFERENCES'
80     bl_region_type = 'WINDOW'
81
82     def draw(self, context):
83         layout = self.layout
84         width = context.region.width
85         ui_scale = context.preferences.system.ui_scale
86
87         layout.use_property_split = True
88         layout.use_property_decorate = False  # No animation.
89
90         row = layout.row()
91         if width > (350 * ui_scale):  # No horizontal margin if region is rather small.
92             row.label()  # Needed so col below is centered.
93
94         col = row.column()
95         col.ui_units_x = 50
96
97         # draw_props implemented by deriving classes.
98         self.draw_props(context, col)
99
100         if width > (350 * ui_scale):  # No horizontal margin if region is rather small.
101             row.label()  # Needed so col above is centered.
102
103
104 class USERPREF_PT_interface_display(PreferencePanel):
105     bl_label = "Display"
106
107     @classmethod
108     def poll(cls, context):
109         prefs = context.preferences
110         return (prefs.active_section == 'INTERFACE')
111
112     def draw_props(self, context, layout):
113         prefs = context.preferences
114         view = prefs.view
115
116         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
117
118         flow.prop(view, "ui_scale", text="Resolution Scale")
119         flow.prop(view, "ui_line_width", text="Line Width")
120
121         layout.separator()
122
123         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
124
125         flow.prop(view, "show_splash", text="Splash Screen")
126         flow.prop(view, "show_tooltips")
127         flow.prop(view, "show_tooltips_python")
128         flow.prop(view, "show_developer_ui")
129         flow.prop(view, "show_large_cursors")
130
131
132 class USERPREF_PT_interface_text(PreferencePanel):
133     bl_label = "Text Rendering"
134     bl_options = {'DEFAULT_CLOSED'}
135
136     @classmethod
137     def poll(cls, context):
138         prefs = context.preferences
139         return (prefs.active_section == 'INTERFACE')
140
141     def draw_props(self, context, layout):
142         prefs = context.preferences
143         view = prefs.view
144
145         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
146
147         flow.prop(view, "use_text_antialiasing", text="Anti-aliasing")
148         sub = flow.column()
149         sub.active = view.use_text_antialiasing
150         sub.prop(view, "text_hinting", text="Hinting")
151
152         flow.prop(view, "font_path_ui")
153         flow.prop(view, "font_path_ui_mono")
154
155
156 class USERPREF_PT_interface_translation(PreferencePanel):
157     bl_label = "Translation"
158
159     @classmethod
160     def poll(cls, context):
161         prefs = context.preferences
162         return (prefs.active_section == 'INTERFACE') and bpy.app.build_options.international
163
164     def draw_header(self, context):
165         prefs = context.preferences
166         view = prefs.view
167
168         self.layout.prop(view, "use_international_fonts", text="")
169
170     def draw_props(self, context, layout):
171         prefs = context.preferences
172         view = prefs.view
173
174         layout.active = view.use_international_fonts
175
176         layout.prop(view, "language")
177
178         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
179
180         flow.prop(view, "use_translate_tooltips", text="Tooltips")
181         flow.prop(view, "use_translate_interface", text="Interface")
182         flow.prop(view, "use_translate_new_dataname", text="New Data")
183
184
185 class USERPREF_PT_interface_editors(PreferencePanel):
186     bl_label = "Editors"
187
188     @classmethod
189     def poll(cls, context):
190         prefs = context.preferences
191         return (prefs.active_section == 'INTERFACE')
192
193     def draw_props(self, context, layout):
194         prefs = context.preferences
195         view = prefs.view
196         system = prefs.system
197
198         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
199
200         flow.row().prop(view, "header_align_default", expand=True)
201         flow.prop(system, "use_region_overlap")
202         flow.prop(view, "show_layout_ui", text="Corner Splitting")
203         flow.prop(view, "color_picker_type")
204
205
206 class USERPREF_PT_interface_menus(PreferencePanel):
207     bl_label = "Menus"
208     bl_options = {'DEFAULT_CLOSED'}
209
210     @classmethod
211     def poll(cls, context):
212         prefs = context.preferences
213         return (prefs.active_section == 'INTERFACE')
214
215     def draw_props(self, context, layout):
216         prefs = context.preferences
217         view = prefs.view
218         system = prefs.system
219
220         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
221
222         flow.prop(view, "use_quit_dialog")
223
224
225 class USERPREF_PT_interface_menus_mouse_over(PreferencePanel):
226     bl_label = "Open on Mouse Over"
227     bl_parent_id = "USERPREF_PT_interface_menus"
228     bl_options = {'DEFAULT_CLOSED'}
229
230     def draw_header(self, context):
231         prefs = context.preferences
232         view = prefs.view
233
234         self.layout.prop(view, "use_mouse_over_open", text="")
235
236     def draw_props(self, context, layout):
237         prefs = context.preferences
238         view = prefs.view
239
240         layout.active = view.use_mouse_over_open
241
242         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
243
244         flow.prop(view, "open_toplevel_delay", text="Top Level")
245         flow.prop(view, "open_sublevel_delay", text="Sub Level")
246
247
248 class USERPREF_PT_interface_menus_pie(PreferencePanel):
249     bl_label = "Pie Menus"
250     bl_parent_id = "USERPREF_PT_interface_menus"
251     bl_options = {'DEFAULT_CLOSED'}
252
253     def draw_props(self, context, layout):
254         prefs = context.preferences
255         view = prefs.view
256
257         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
258
259         flow.prop(view, "pie_animation_timeout")
260         flow.prop(view, "pie_tap_timeout")
261         flow.prop(view, "pie_initial_timeout")
262         flow.prop(view, "pie_menu_radius")
263         flow.prop(view, "pie_menu_threshold")
264         flow.prop(view, "pie_menu_confirm")
265
266
267 class USERPREF_PT_edit_objects(PreferencePanel):
268     bl_label = "Objects"
269
270     @classmethod
271     def poll(cls, context):
272         prefs = context.preferences
273         return (prefs.active_section == 'EDITING')
274
275     def draw_props(self, context, layout):
276         prefs = context.preferences
277         edit = prefs.edit
278
279         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
280
281         flow.prop(edit, "material_link", text="Link Materials to")
282         flow.prop(edit, "object_align", text="Align New Objects to")
283         flow.prop(edit, "use_enter_edit_mode", text="Enter Edit Mode for New Objects")
284
285
286 class USERPREF_PT_edit_cursor(PreferencePanel):
287     bl_label = "3D Cursor"
288
289     @classmethod
290     def poll(cls, context):
291         prefs = context.preferences
292         return (prefs.active_section == 'EDITING')
293
294     def draw_props(self, context, layout):
295         prefs = context.preferences
296         edit = prefs.edit
297
298         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
299
300         flow.prop(edit, "use_mouse_depth_cursor")
301         flow.prop(edit, "use_cursor_lock_adjust")
302
303
304 class USERPREF_PT_edit_duplicate_data(PreferencePanel):
305     bl_label = "Duplicate Data"
306     bl_options = {'DEFAULT_CLOSED'}
307     bl_parent_id = "USERPREF_PT_edit_objects"
308
309     @classmethod
310     def poll(cls, context):
311         prefs = context.preferences
312         return (prefs.active_section == 'EDITING')
313
314     def draw_props(self, context, layout):
315         prefs = context.preferences
316         edit = prefs.edit
317
318         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
319
320         col = flow.column()
321         col.prop(edit, "use_duplicate_action", text="Action")
322         col.prop(edit, "use_duplicate_armature", text="Armature")
323         col.prop(edit, "use_duplicate_curve", text="Curve")
324         # col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
325         col.prop(edit, "use_duplicate_light", text="Light")
326         col = flow.column()
327         col.prop(edit, "use_duplicate_material", text="Material")
328         col.prop(edit, "use_duplicate_mesh", text="Mesh")
329         col.prop(edit, "use_duplicate_metaball", text="Metaball")
330         col.prop(edit, "use_duplicate_particle", text="Particle")
331         col = flow.column()
332         col.prop(edit, "use_duplicate_surface", text="Surface")
333         col.prop(edit, "use_duplicate_text", text="Text")
334         col.prop(edit, "use_duplicate_texture", text="Texture")
335
336
337 class USERPREF_PT_edit_gpencil(PreferencePanel):
338     bl_label = "Grease Pencil"
339     bl_options = {'DEFAULT_CLOSED'}
340
341     @classmethod
342     def poll(cls, context):
343         prefs = context.preferences
344         return (prefs.active_section == 'EDITING')
345
346     def draw_props(self, context, layout):
347         prefs = context.preferences
348         edit = prefs.edit
349
350         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
351
352         flow.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
353         flow.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
354
355
356 class USERPREF_PT_edit_annotations(PreferencePanel):
357     bl_label = "Annotations"
358
359     @classmethod
360     def poll(cls, context):
361         prefs = context.preferences
362         return (prefs.active_section == 'EDITING')
363
364     def draw_props(self, context, layout):
365         prefs = context.preferences
366         edit = prefs.edit
367
368         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
369
370         flow.prop(edit, "grease_pencil_default_color", text="Default Color")
371         flow.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
372         flow.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
373
374 class USERPREF_PT_edit_weight_paint(PreferencePanel):
375     bl_label = "Weight Paint"
376
377     @classmethod
378     def poll(cls, context):
379         prefs = context.preferences
380         return (prefs.active_section == 'EDITING')
381
382     def draw_props(self, context, layout):
383         prefs = context.preferences
384         view = prefs.view
385
386         layout.prop(view, "use_weight_color_range", text="Use Custom Colors")
387
388         col = layout.column()
389         col.active = view.use_weight_color_range
390         col.template_color_ramp(view, "weight_color_range", expand=True)
391
392
393 class USERPREF_PT_edit_misc(PreferencePanel):
394     bl_label = "Miscellaneous"
395     bl_options = {'DEFAULT_CLOSED'}
396
397     @classmethod
398     def poll(cls, context):
399         prefs = context.preferences
400         return (prefs.active_section == 'EDITING')
401
402     def draw_props(self, context, layout):
403         prefs = context.preferences
404         edit = prefs.edit
405
406         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
407
408         flow.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
409         flow.prop(edit, "node_margin", text="Node Auto-offset Margin")
410
411
412 class USERPREF_PT_animation_timeline(PreferencePanel):
413     bl_label = "Timeline"
414
415     @classmethod
416     def poll(cls, context):
417         prefs = context.preferences
418         return (prefs.active_section == 'ANIMATION')
419
420     def draw_props(self, context, layout):
421         prefs = context.preferences
422         view = prefs.view
423         edit = prefs.edit
424
425         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
426         flow.prop(edit, "use_negative_frames")
427
428         layout.separator()
429
430         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
431
432         flow.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
433         flow.prop(view, "timecode_style")
434         flow.prop(view, "view_frame_type")
435         if view.view_frame_type == 'SECONDS':
436             flow.prop(view, "view_frame_seconds")
437         elif view.view_frame_type == 'KEYFRAMES':
438             flow.prop(view, "view_frame_keyframes")
439
440
441 class USERPREF_PT_animation_keyframes(PreferencePanel):
442     bl_label = "Keyframes"
443
444     @classmethod
445     def poll(cls, context):
446         prefs = context.preferences
447         return (prefs.active_section == 'ANIMATION')
448
449     def draw_props(self, context, layout):
450         prefs = context.preferences
451         edit = prefs.edit
452
453         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
454
455         flow.prop(edit, "use_visual_keying")
456         flow.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed")
457
458
459 class USERPREF_PT_animation_autokey(PreferencePanel):
460     bl_label = "Auto-Keyframing"
461     bl_parent_id = "USERPREF_PT_animation_keyframes"
462
463     def draw_props(self, context, layout):
464         prefs = context.preferences
465         edit = prefs.edit
466
467         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
468
469         flow.prop(edit, "use_auto_keying_warning", text="Show Warning")
470         flow.prop(edit, "use_keyframe_insert_available", text="Only Insert Available")
471         flow.prop(edit, "use_auto_keying", text="Enable in New Scenes")
472
473
474 class USERPREF_PT_animation_fcurves(PreferencePanel):
475     bl_label = "F-Curves"
476
477     @classmethod
478     def poll(cls, context):
479         prefs = context.preferences
480         return (prefs.active_section == 'ANIMATION')
481
482     def draw_props(self, context, layout):
483         prefs = context.preferences
484         edit = prefs.edit
485
486         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
487
488         flow.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
489         flow.prop(edit, "keyframe_new_interpolation_type", text="Default Interpolation")
490         flow.prop(edit, "keyframe_new_handle_type", text="Default Handles")
491         flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
492
493
494 class USERPREF_PT_system_sound(PreferencePanel):
495     bl_label = "Sound"
496
497     @classmethod
498     def poll(cls, context):
499         prefs = context.preferences
500         return (prefs.active_section == 'SYSTEM')
501
502     def draw_props(self, context, layout):
503         prefs = context.preferences
504         system = prefs.system
505
506         layout.prop(system, "audio_device", expand=False)
507
508         sub = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False)
509         sub.active = system.audio_device not in {'NONE', 'Null'}
510         sub.prop(system, "audio_channels", text="Channels")
511         sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
512         sub.prop(system, "audio_sample_rate", text="Sample Rate")
513         sub.prop(system, "audio_sample_format", text="Sample Format")
514
515
516 class USERPREF_PT_system_cycles_devices(PreferencePanel):
517     bl_label = "Cycles Render Devices"
518
519     @classmethod
520     def poll(cls, context):
521         prefs = context.preferences
522         return (prefs.active_section == 'SYSTEM')
523
524     def draw_props(self, context, layout):
525         prefs = context.preferences
526
527         col = layout.column()
528         col.use_property_split = False
529
530         if bpy.app.build_options.cycles:
531             addon = prefs.addons.get("cycles")
532             if addon is not None:
533                 addon.preferences.draw_impl(col, context)
534             del addon
535
536         # NOTE: Disabled for until GPU side of OpenSubdiv is brought back.
537         # system = prefs.system
538         # if hasattr(system, "opensubdiv_compute_type"):
539         #     col.label(text="OpenSubdiv compute:")
540         #     col.row().prop(system, "opensubdiv_compute_type", text="")
541
542
543 class USERPREF_PT_viewport_display(PreferencePanel):
544     bl_label = "Display"
545
546     @classmethod
547     def poll(cls, context):
548         prefs = context.preferences
549         return (prefs.active_section == 'VIEWPORT')
550
551     def draw_props(self, context, layout):
552         prefs = context.preferences
553         view = prefs.view
554
555         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
556
557         flow.prop(view, "show_object_info", text="Object Info")
558         flow.prop(view, "show_view_name", text="View Name")
559         flow.prop(view, "show_playback_fps", text="Playback FPS")
560
561         layout.separator()
562
563         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
564
565         col = flow.column()
566         col.prop(view, "gizmo_size", text="Gizmo Size")
567         col.prop(view, "object_origin_size")
568         col.separator()
569
570         flow.separator()
571
572         col = flow.column()
573         col.prop(view, "mini_axis_type", text="3D Viewport Axis")
574
575         if view.mini_axis_type == 'MINIMAL':
576             sub = col.column()
577             sub.active = view.mini_axis_type == 'MINIMAL'
578             sub.prop(view, "mini_axis_size", text="Size")
579             sub.prop(view, "mini_axis_brightness", text="Brightness")
580
581
582 class USERPREF_PT_viewport_quality(PreferencePanel):
583     bl_label = "Quality"
584
585     @classmethod
586     def poll(cls, context):
587         prefs = context.preferences
588         return (prefs.active_section == 'VIEWPORT')
589
590     def draw_props(self, context, layout):
591         import sys
592         prefs = context.preferences
593         system = prefs.system
594
595         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
596
597         flow.prop(system, "gpu_viewport_quality")
598         flow.prop(system, "multi_sample", text="Multisampling")
599         flow.prop(system, "gpencil_multi_sample", text="Grease Pencil Multisampling")
600
601         if sys.platform == "linux" and system.multi_sample != 'NONE':
602             layout.label(text="Might fail for Mesh editing selection!")
603
604
605 class USERPREF_PT_viewport_textures(PreferencePanel):
606     bl_label = "Textures"
607
608     @classmethod
609     def poll(cls, context):
610         prefs = context.preferences
611         return (prefs.active_section == 'VIEWPORT')
612
613     def draw_props(self, context, layout):
614         prefs = context.preferences
615         system = prefs.system
616
617         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
618
619         flow.prop(system, "gl_texture_limit", text="Limit Size")
620         flow.prop(system, "anisotropic_filter")
621         flow.prop(system, "gl_clip_alpha", slider=True)
622         flow.prop(system, "image_draw_method", text="Image Display Method")
623
624
625 class USERPREF_PT_viewport_selection(PreferencePanel):
626     bl_label = "Selection"
627     bl_options = {'DEFAULT_CLOSED'}
628
629     @classmethod
630     def poll(cls, context):
631         prefs = context.preferences
632         return (prefs.active_section == 'VIEWPORT')
633
634     def draw_props(self, context, layout):
635         prefs = context.preferences
636         system = prefs.system
637
638         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
639
640         flow.prop(system, "use_select_pick_depth")
641
642
643 class USERPREF_PT_system_memory(PreferencePanel):
644     bl_label = "Memory/Limits"
645
646     @classmethod
647     def poll(cls, context):
648         prefs = context.preferences
649         return (prefs.active_section == 'SYSTEM')
650
651     def draw_props(self, context, layout):
652         prefs = context.preferences
653         system = prefs.system
654         edit = prefs.edit
655
656         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
657
658         flow.prop(edit, "undo_steps", text="Undo Steps")
659         flow.prop(edit, "undo_memory_limit", text="Undo Memory Limit")
660         flow.prop(edit, "use_global_undo")
661
662         layout.separator()
663
664         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
665
666         flow.prop(system, "memory_cache_limit", text="Sequencer Cache Limit")
667         flow.prop(system, "scrollback", text="Console Scrollback Lines")
668
669         layout.separator()
670
671         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
672
673         flow.prop(system, "texture_time_out", text="Texture Time Out")
674         flow.prop(system, "texture_collection_rate", text="Garbage Collection Rate")
675
676
677 class USERPREF_MT_interface_theme_presets(Menu):
678     bl_label = "Presets"
679     preset_subdir = "interface_theme"
680     preset_operator = "script.execute_preset"
681     preset_type = 'XML'
682     preset_xml_map = (
683         ("preferences.themes[0]", "Theme"),
684         ("preferences.ui_styles[0]", "ThemeStyle"),
685     )
686     draw = Menu.draw_preset
687
688     def reset_cb(context):
689         bpy.ops.ui.reset_default_theme()
690
691
692 class USERPREF_PT_theme(Panel):
693     bl_space_type = 'PREFERENCES'
694     bl_label = "Themes"
695     bl_region_type = 'WINDOW'
696     bl_options = {'HIDE_HEADER'}
697
698     @classmethod
699     def poll(cls, context):
700         prefs = context.preferences
701         return (prefs.active_section == 'THEMES')
702
703     def draw(self, _context):
704         layout = self.layout
705
706         split = layout.split(factor=0.6)
707
708         row = split.row(align=True)
709         row.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
710         row.operator("wm.interface_theme_preset_add", text="", icon='ADD')
711         row.operator("wm.interface_theme_preset_add", text="", icon='REMOVE').remove_active = True
712
713         row = split.row(align=True)
714         row.operator("wm.theme_install", text="Install...", icon='IMPORT')
715         row.operator("ui.reset_default_theme", text="Reset", icon='LOOP_BACK')
716
717
718 class USERPREF_PT_theme_user_interface(PreferencePanel):
719     bl_space_type = 'PREFERENCES'
720     bl_region_type = 'WINDOW'
721     bl_label = "User Interface"
722     bl_options = {'DEFAULT_CLOSED'}
723
724     @classmethod
725     def poll(cls, context):
726         prefs = context.preferences
727         return (prefs.active_section == 'THEMES')
728
729     def draw_header(self, _context):
730         layout = self.layout
731
732         layout.label(icon='WORKSPACE')
733
734     def draw(self, context):
735         pass
736
737
738 # Base class for dynamically defined widget color panels.
739 class PreferenceThemeWidgetColorPanel(Panel):
740     bl_space_type = 'PREFERENCES'
741     bl_region_type = 'WINDOW'
742     bl_parent_id = "USERPREF_PT_theme_user_interface"
743
744     @staticmethod
745     def draw(self, context):
746         theme = context.preferences.themes[0]
747         ui = theme.user_interface
748         widget_style = getattr(ui, self.wcol)
749         layout = self.layout
750
751         layout.use_property_split = True
752
753         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
754
755         col = flow.column()
756         col.prop(widget_style, "outline")
757         col.prop(widget_style, "item", slider=True)
758         col.prop(widget_style, "inner", slider=True)
759         col.prop(widget_style, "inner_sel", slider=True)
760
761         col = flow.column()
762         col.prop(widget_style, "text")
763         col.prop(widget_style, "text_sel")
764         col.prop(widget_style, "roundness")
765
766         col = flow.column()
767         col.prop(widget_style, "show_shaded")
768
769         colsub = col.column()
770         colsub.active = widget_style.show_shaded
771         colsub.prop(widget_style, "shadetop")
772         colsub.prop(widget_style, "shadedown")
773
774     @classmethod
775     def poll(cls, context):
776         prefs = context.preferences
777         return (prefs.active_section == 'THEMES')
778
779
780 class USERPREF_PT_theme_interface_state(PreferencePanel):
781     bl_label = "State"
782     bl_options = {'DEFAULT_CLOSED'}
783     bl_parent_id = "USERPREF_PT_theme_user_interface"
784
785     def draw_props(self, context, layout):
786         theme = context.preferences.themes[0]
787         ui_state = theme.user_interface.wcol_state
788
789         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
790
791         col = flow.column(align=True)
792         col.prop(ui_state, "inner_anim")
793         col.prop(ui_state, "inner_anim_sel")
794
795         col = flow.column(align=True)
796         col.prop(ui_state, "inner_driven")
797         col.prop(ui_state, "inner_driven_sel")
798
799         col = flow.column(align=True)
800         col.prop(ui_state, "inner_key")
801         col.prop(ui_state, "inner_key_sel")
802
803         col = flow.column(align=True)
804         col.prop(ui_state, "inner_overridden")
805         col.prop(ui_state, "inner_overridden_sel")
806
807         col = flow.column(align=True)
808         col.prop(ui_state, "inner_changed")
809         col.prop(ui_state, "inner_changed_sel")
810
811         col = flow.column(align=True)
812         col.prop(ui_state, "blend")
813
814
815 class USERPREF_PT_theme_interface_styles(PreferencePanel):
816     bl_label = "Styles"
817     bl_options = {'DEFAULT_CLOSED'}
818     bl_parent_id = "USERPREF_PT_theme_user_interface"
819
820     def draw_props(self, context, layout):
821         theme = context.preferences.themes[0]
822         ui = theme.user_interface
823
824         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
825
826         flow.prop(ui, "menu_shadow_fac")
827         flow.prop(ui, "icon_alpha")
828         flow.prop(ui, "icon_saturation")
829         flow.prop(ui, "editor_outline")
830         flow.prop(ui, "menu_shadow_width")
831         flow.prop(ui, "widget_emboss")
832
833
834 class USERPREF_PT_theme_interface_gizmos(PreferencePanel):
835     bl_label = "Axis & Gizmo Colors"
836     bl_options = {'DEFAULT_CLOSED'}
837     bl_parent_id = "USERPREF_PT_theme_user_interface"
838
839     def draw_props(self, context, layout):
840         theme = context.preferences.themes[0]
841         ui = theme.user_interface
842
843         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=True, align=False)
844
845         col = flow.column(align=True)
846         col.prop(ui, "axis_x", text="Axis X")
847         col.prop(ui, "axis_y", text="Y")
848         col.prop(ui, "axis_z", text="Z")
849
850         col = flow.column()
851         col.prop(ui, "gizmo_primary")
852         col.prop(ui, "gizmo_secondary")
853
854         col = flow.column()
855         col.prop(ui, "gizmo_a")
856         col.prop(ui, "gizmo_b")
857
858
859 class USERPREF_PT_theme_interface_icons(PreferencePanel):
860     bl_label = "Icon Colors"
861     bl_options = {'DEFAULT_CLOSED'}
862     bl_parent_id = "USERPREF_PT_theme_user_interface"
863
864     def draw_props(self, context, layout):
865         theme = context.preferences.themes[0]
866         ui = theme.user_interface
867
868         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
869
870         flow.prop(ui, "icon_collection")
871         flow.prop(ui, "icon_object")
872         flow.prop(ui, "icon_object_data")
873         flow.prop(ui, "icon_modifier")
874         flow.prop(ui, "icon_shading")
875
876
877 class USERPREF_PT_theme_text_style(PreferencePanel):
878     bl_label = "Text Style"
879     bl_options = {'DEFAULT_CLOSED'}
880
881     @classmethod
882     def poll(cls, context):
883         prefs = context.preferences
884         return (prefs.active_section == 'THEMES')
885
886     @staticmethod
887     def _ui_font_style(layout, font_style):
888         layout.use_property_split = True
889         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
890
891         col = flow.column()
892         col.row().prop(font_style, "font_kerning_style", expand=True)
893         col.prop(font_style, "points")
894
895         col = flow.column(align=True)
896         col.prop(font_style, "shadow_offset_x", text="Shadow Offset X")
897         col.prop(font_style, "shadow_offset_y", text="Y")
898
899         col = flow.column()
900         col.prop(font_style, "shadow")
901         col.prop(font_style, "shadow_alpha")
902         col.prop(font_style, "shadow_value")
903
904     def draw_header(self, _context):
905         layout = self.layout
906
907         layout.label(icon='FONTPREVIEW')
908
909     def draw_props(self, context, layout):
910         style = context.preferences.ui_styles[0]
911
912         layout.label(text="Panel Title")
913         self._ui_font_style(layout, style.panel_title)
914
915         layout.separator()
916
917         layout.label(text="Widget")
918         self._ui_font_style(layout, style.widget)
919
920         layout.separator()
921
922         layout.label(text="Widget Label")
923         self._ui_font_style(layout, style.widget_label)
924
925
926 class USERPREF_PT_theme_bone_color_sets(PreferencePanel):
927     bl_label = "Bone Color Sets"
928     bl_options = {'DEFAULT_CLOSED'}
929
930     @classmethod
931     def poll(cls, context):
932         prefs = context.preferences
933         return (prefs.active_section == 'THEMES')
934
935     def draw_header(self, _context):
936         layout = self.layout
937
938         layout.label(icon='COLOR')
939
940     def draw_props(self, context, layout):
941         theme = context.preferences.themes[0]
942
943         layout.use_property_split = True
944
945         for i, ui in enumerate(theme.bone_color_sets, 1):
946             layout.label(text=iface_(f"Color Set {i:d}"), translate=False)
947
948             flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
949
950             flow.prop(ui, "normal")
951             flow.prop(ui, "select")
952             flow.prop(ui, "active")
953             flow.prop(ui, "show_colored_constraints")
954
955
956 # Base class for dynamically defined theme-space panels.
957 class PreferenceThemeSpacePanel(Panel):
958     bl_space_type = 'PREFERENCES'
959     bl_region_type = 'WINDOW'
960
961     # not essential, hard-coded UI delimiters for the theme layout
962     ui_delimiters = {
963         'VIEW_3D': {
964             "text_grease_pencil",
965             "text_keyframe",
966             "speaker",
967             "freestyle_face_mark",
968             "split_normal",
969             "bone_solid",
970             "paint_curve_pivot",
971         },
972         'GRAPH_EDITOR': {
973             "handle_vertex_select",
974         },
975         'IMAGE_EDITOR': {
976             "paint_curve_pivot",
977         },
978         'NODE_EDITOR': {
979             "layout_node",
980         },
981         'CLIP_EDITOR': {
982             "handle_vertex_select",
983         }
984     }
985
986     # TODO theme_area should be deprecated
987     @staticmethod
988     def _theme_generic(layout, themedata, theme_area):
989
990         layout.use_property_split = True
991
992         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
993
994         props_type = {}
995
996         for prop in themedata.rna_type.properties:
997             if prop.identifier == "rna_type":
998                 continue
999
1000             props_type.setdefault((prop.type, prop.subtype), []).append(prop)
1001
1002         th_delimiters = PreferenceThemeSpacePanel.ui_delimiters.get(theme_area)
1003         for props_type, props_ls in sorted(props_type.items()):
1004             if props_type[0] == 'POINTER':
1005                 continue
1006
1007             if th_delimiters is None:
1008                 # simple, no delimiters
1009                 for prop in props_ls:
1010                     flow.prop(themedata, prop.identifier)
1011             else:
1012
1013                 for prop in props_ls:
1014                     flow.prop(themedata, prop.identifier)
1015
1016     @staticmethod
1017     def draw_header(self, _context):
1018         if hasattr(self, "icon") and self.icon != 'NONE':
1019             layout = self.layout
1020             layout.label(icon=self.icon)
1021
1022     @staticmethod
1023     def draw(self, context):
1024         layout = self.layout
1025         theme = context.preferences.themes[0]
1026
1027         datapath_list = self.datapath.split(".")
1028         data = theme
1029         for datapath_item in datapath_list:
1030             data = getattr(data, datapath_item)
1031         PreferenceThemeSpacePanel._theme_generic(layout, data, self.theme_area)
1032
1033     @classmethod
1034     def poll(cls, context):
1035         prefs = context.preferences
1036         return (prefs.active_section == 'THEMES')
1037
1038
1039 class ThemeGenericClassGenerator():
1040     generated_classes = []
1041
1042     @staticmethod
1043     def generate_panel_classes_for_wcols():
1044         wcols = [
1045             ("Regular", "wcol_regular"),
1046             ("Tool", "wcol_tool"),
1047             ("Toolbar Item", "wcol_toolbar_item"),
1048             ("Radio Buttons", "wcol_radio"),
1049             ("Text", "wcol_text"),
1050             ("Option", "wcol_option"),
1051             ("Toggle", "wcol_toggle"),
1052             ("Number Field", "wcol_num"),
1053             ("Value Slider", "wcol_numslider"),
1054             ("Box", "wcol_box"),
1055             ("Menu", "wcol_menu"),
1056             ("Pie Menu", "wcol_pie_menu"),
1057             ("Pulldown", "wcol_pulldown"),
1058             ("Menu Back", "wcol_menu_back"),
1059             ("Tooltip", "wcol_tooltip"),
1060             ("Menu Item", "wcol_menu_item"),
1061             ("Scroll Bar", "wcol_scroll"),
1062             ("Progress Bar", "wcol_progress"),
1063             ("List Item", "wcol_list_item"),
1064             ("Tab", "wcol_tab"),
1065         ]
1066
1067         for (name, wcol) in wcols:
1068             panel_id = "USERPREF_PT_theme_interface_" + wcol
1069             paneltype = type(panel_id, (PreferenceThemeWidgetColorPanel,), {
1070                 "bl_label": name,
1071                 "bl_options": {'DEFAULT_CLOSED'},
1072                 "draw": PreferenceThemeWidgetColorPanel.draw,
1073                 "wcol": wcol,
1074             })
1075
1076             ThemeGenericClassGenerator.generated_classes.append(paneltype)
1077
1078     @staticmethod
1079     def generate_theme_area_child_panel_classes(parent_id, rna_type, theme_area, datapath):
1080         def generate_child_panel_classes_recurse(parent_id, rna_type, theme_area, datapath):
1081             props_type = {}
1082
1083             for prop in rna_type.properties:
1084                 if prop.identifier == "rna_type":
1085                     continue
1086
1087                 props_type.setdefault((prop.type, prop.subtype), []).append(prop)
1088
1089             for props_type, props_ls in sorted(props_type.items()):
1090                 if props_type[0] == 'POINTER':
1091                     for prop in props_ls:
1092                         new_datapath = datapath + "." + prop.identifier if datapath else prop.identifier
1093                         panel_id = parent_id + "_" + prop.identifier
1094                         paneltype = type(panel_id, (PreferenceThemeSpacePanel,), {
1095                             "bl_label": rna_type.properties[prop.identifier].name,
1096                             "bl_parent_id": parent_id,
1097                             "bl_options": {'DEFAULT_CLOSED'},
1098                             "draw": PreferenceThemeSpacePanel.draw,
1099                             "theme_area": theme_area.identifier,
1100                             "datapath": new_datapath,
1101                         })
1102
1103                         ThemeGenericClassGenerator.generated_classes.append(paneltype)
1104                         generate_child_panel_classes_recurse(panel_id, prop.fixed_type, theme_area, new_datapath)
1105
1106         generate_child_panel_classes_recurse(parent_id, rna_type, theme_area, datapath)
1107
1108     @staticmethod
1109     def generate_panel_classes_from_theme_areas():
1110         from bpy.types import Theme
1111
1112         for theme_area in Theme.bl_rna.properties['theme_area'].enum_items_static:
1113             if theme_area.identifier in {'USER_INTERFACE', 'STYLE', 'BONE_COLOR_SETS'}:
1114                 continue
1115
1116             panel_id = "USERPREF_PT_theme_" + theme_area.identifier.lower()
1117             # Generate panel-class from theme_area
1118             paneltype = type(panel_id, (PreferenceThemeSpacePanel,), {
1119                 "bl_label": theme_area.name,
1120                 "bl_options": {'DEFAULT_CLOSED'},
1121                 "draw_header": PreferenceThemeSpacePanel.draw_header,
1122                 "draw": PreferenceThemeSpacePanel.draw,
1123                 "theme_area": theme_area.identifier,
1124                 "icon": theme_area.icon,
1125                 "datapath": theme_area.identifier.lower(),
1126             })
1127
1128             ThemeGenericClassGenerator.generated_classes.append(paneltype)
1129             ThemeGenericClassGenerator.generate_theme_area_child_panel_classes(
1130                 panel_id, Theme.bl_rna.properties[theme_area.identifier.lower()].fixed_type,
1131                 theme_area, theme_area.identifier.lower())
1132
1133
1134 class FilePathsPanel(Panel):
1135     bl_space_type = 'PREFERENCES'
1136     bl_region_type = 'WINDOW'
1137
1138     @classmethod
1139     def poll(cls, context):
1140         prefs = context.preferences
1141         return (prefs.active_section == 'FILE_PATHS')
1142
1143     def draw(self, context):
1144         layout = self.layout
1145
1146         layout.use_property_split = True
1147         layout.use_property_decorate = False
1148
1149         self.draw_props(context, layout)
1150
1151
1152 class USERPREF_PT_file_paths_data(FilePathsPanel):
1153     bl_label = "Data"
1154
1155     def draw_props(self, context, layout):
1156         paths = context.preferences.filepaths
1157
1158         col = self.layout.column()
1159         col.prop(paths, "font_directory", text="Fonts")
1160         col.prop(paths, "texture_directory", text="Textures")
1161         col.prop(paths, "script_directory", text="Scripts")
1162         col.prop(paths, "sound_directory", text="Sounds")
1163         col.prop(paths, "temporary_directory", text="Temporary Files")
1164
1165
1166 class USERPREF_PT_file_paths_render(FilePathsPanel):
1167     bl_label = "Render"
1168
1169     def draw_props(self, context, layout):
1170         paths = context.preferences.filepaths
1171
1172         col = self.layout.column()
1173         col.prop(paths, "render_output_directory", text="Render Output")
1174         col.prop(paths, "render_cache_directory", text="Render Cache")
1175
1176
1177 class USERPREF_PT_file_paths_applications(FilePathsPanel):
1178     bl_label = "Applications"
1179
1180     def draw_props(self, context, layout):
1181         paths = context.preferences.filepaths
1182
1183         col = layout.column()
1184         col.prop(paths, "image_editor", text="Image Editor")
1185         col.prop(paths, "animation_player_preset", text="Animation Player")
1186         if paths.animation_player_preset == 'CUSTOM':
1187             col.prop(paths, "animation_player", text="Player")
1188
1189
1190 class USERPREF_PT_file_paths_development(FilePathsPanel):
1191     bl_label = "Development"
1192
1193     @classmethod
1194     def poll(cls, context):
1195         prefs = context.preferences
1196         return (prefs.active_section == 'FILE_PATHS') and prefs.view.show_developer_ui
1197
1198     def draw_props(self, context, layout):
1199         paths = context.preferences.filepaths
1200         layout.prop(paths, "i18n_branches_directory", text="I18n Branches")
1201
1202
1203 class USERPREF_PT_saveload_autorun(PreferencePanel):
1204     bl_label = "Auto Run Python Scripts"
1205
1206     @classmethod
1207     def poll(cls, context):
1208         prefs = context.preferences
1209         return (prefs.active_section == 'SAVE_LOAD')
1210
1211     def draw_header(self, context):
1212         prefs = context.preferences
1213         paths = prefs.filepaths
1214
1215         self.layout.prop(paths, "use_scripts_auto_execute", text="")
1216
1217     def draw(self, context):
1218         layout = self.layout
1219         prefs = context.preferences
1220         paths = prefs.filepaths
1221
1222         layout.use_property_split = True
1223         layout.use_property_decorate = False  # No animation.
1224
1225         layout.active = paths.use_scripts_auto_execute
1226
1227         box = layout.box()
1228         row = box.row()
1229         row.label(text="Excluded Paths:")
1230         row.operator("wm.userpref_autoexec_path_add", text="", icon='ADD', emboss=False)
1231         for i, path_cmp in enumerate(prefs.autoexec_paths):
1232             row = box.row()
1233             row.prop(path_cmp, "path", text="")
1234             row.prop(path_cmp, "use_glob", text="", icon='FILTER')
1235             row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i
1236
1237
1238 class USERPREF_PT_saveload_blend(PreferencePanel):
1239     bl_label = "Blend Files"
1240
1241     @classmethod
1242     def poll(cls, context):
1243         prefs = context.preferences
1244         return (prefs.active_section == 'SAVE_LOAD')
1245
1246     def draw_props(self, context, layout):
1247         prefs = context.preferences
1248         paths = prefs.filepaths
1249
1250         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1251
1252         flow.prop(paths, "use_relative_paths")
1253         flow.prop(paths, "use_file_compression")
1254         flow.prop(paths, "use_load_ui")
1255         flow.prop(paths, "use_save_preview_images")
1256         flow.prop(paths, "use_tabs_as_spaces")
1257
1258         layout.separator()
1259
1260         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1261
1262         flow.prop(paths, "save_version")
1263         flow.prop(paths, "recent_files")
1264
1265
1266 class USERPREF_PT_saveload_blend_autosave(PreferencePanel):
1267     bl_label = "Auto Save"
1268     bl_parent_id = "USERPREF_PT_saveload_blend"
1269
1270     def draw_props(self, context, layout):
1271         prefs = context.preferences
1272         paths = prefs.filepaths
1273
1274         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1275
1276         flow.prop(paths, "use_keep_session")
1277         flow.prop(paths, "use_auto_save_temporary_files")
1278         sub = flow.column()
1279         sub.active = paths.use_auto_save_temporary_files
1280         sub.prop(paths, "auto_save_time", text="Timer (mins)")
1281
1282
1283 class USERPREF_PT_saveload_file_browser(PreferencePanel):
1284     bl_label = "File Browser"
1285
1286     @classmethod
1287     def poll(cls, context):
1288         prefs = context.preferences
1289         return (prefs.active_section == 'SAVE_LOAD')
1290
1291     def draw_props(self, context, layout):
1292         prefs = context.preferences
1293         paths = prefs.filepaths
1294
1295         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1296
1297         flow.prop(paths, "use_filter_files")
1298         flow.prop(paths, "show_hidden_files_datablocks")
1299         flow.prop(paths, "hide_recent_locations")
1300         flow.prop(paths, "hide_system_bookmarks")
1301         flow.prop(paths, "show_thumbnails")
1302
1303
1304 class USERPREF_MT_ndof_settings(Menu):
1305     # accessed from the window key-bindings in C (only)
1306     bl_label = "3D Mouse Settings"
1307
1308     def draw(self, context):
1309         layout = self.layout
1310
1311         input_prefs = context.preferences.inputs
1312
1313         is_view3d = context.space_data.type == 'VIEW_3D'
1314
1315         layout.prop(input_prefs, "ndof_sensitivity")
1316         layout.prop(input_prefs, "ndof_orbit_sensitivity")
1317         layout.prop(input_prefs, "ndof_deadzone")
1318
1319         if is_view3d:
1320             layout.separator()
1321             layout.prop(input_prefs, "ndof_show_guide")
1322
1323             layout.separator()
1324             layout.label(text="Orbit Style")
1325             layout.row().prop(input_prefs, "ndof_view_navigate_method", text="")
1326             layout.row().prop(input_prefs, "ndof_view_rotate_method", text="")
1327             layout.separator()
1328             layout.label(text="Orbit Options")
1329             layout.prop(input_prefs, "ndof_rotx_invert_axis")
1330             layout.prop(input_prefs, "ndof_roty_invert_axis")
1331             layout.prop(input_prefs, "ndof_rotz_invert_axis")
1332
1333         # view2d use pan/zoom
1334         layout.separator()
1335         layout.label(text="Pan Options")
1336         layout.prop(input_prefs, "ndof_panx_invert_axis")
1337         layout.prop(input_prefs, "ndof_pany_invert_axis")
1338         layout.prop(input_prefs, "ndof_panz_invert_axis")
1339         layout.prop(input_prefs, "ndof_pan_yz_swap_axis")
1340
1341         layout.label(text="Zoom Options")
1342         layout.prop(input_prefs, "ndof_zoom_invert")
1343
1344         if is_view3d:
1345             layout.separator()
1346             layout.label(text="Fly/Walk Options")
1347             layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
1348             layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
1349
1350
1351 class USERPREF_PT_input_keyboard(PreferencePanel):
1352     bl_label = "Keyboard"
1353
1354     @classmethod
1355     def poll(cls, context):
1356         prefs = context.preferences
1357         return (prefs.active_section == 'INPUT')
1358
1359     def draw_props(self, context, layout):
1360         prefs = context.preferences
1361         inputs = prefs.inputs
1362
1363         layout.prop(inputs, "use_emulate_numpad")
1364         layout.prop(inputs, "use_numeric_input_advanced")
1365
1366
1367 class USERPREF_PT_input_mouse(PreferencePanel):
1368     bl_label = "Mouse"
1369
1370     @classmethod
1371     def poll(cls, context):
1372         prefs = context.preferences
1373         return (prefs.active_section == 'INPUT')
1374
1375     def draw_props(self, context, layout):
1376         prefs = context.preferences
1377         inputs = prefs.inputs
1378
1379         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1380
1381         flow.prop(inputs, "use_mouse_emulate_3_button")
1382         flow.prop(inputs, "use_mouse_continuous")
1383         flow.prop(inputs, "use_drag_immediately")
1384         flow.prop(inputs, "drag_threshold")
1385         flow.prop(inputs, "tweak_threshold")
1386         flow.prop(inputs, "mouse_double_click_time", text="Double Click Speed")
1387
1388
1389 class USERPREF_PT_navigation_orbit(PreferencePanel):
1390     bl_label = "Orbit & Pan"
1391
1392     @classmethod
1393     def poll(cls, context):
1394         prefs = context.preferences
1395         return (prefs.active_section == 'NAVIGATION')
1396
1397     def draw_props(self, context, layout):
1398         import sys
1399         prefs = context.preferences
1400         inputs = prefs.inputs
1401         view = prefs.view
1402
1403         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1404
1405         flow.row().prop(inputs, "view_rotate_method", expand=True)
1406         flow.prop(inputs, "use_rotate_around_active")
1407         flow.prop(inputs, "use_auto_perspective")
1408         flow.prop(inputs, "use_mouse_depth_navigate")
1409
1410         flow.separator()
1411
1412         flow.prop(view, "smooth_view")
1413         flow.prop(view, "rotation_angle")
1414
1415         if sys.platform == "darwin":
1416             flow.separator()
1417             flow.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
1418
1419
1420 class USERPREF_PT_navigation_zoom(PreferencePanel):
1421     bl_label = "Zoom"
1422
1423     @classmethod
1424     def poll(cls, context):
1425         prefs = context.preferences
1426         return (prefs.active_section == 'NAVIGATION')
1427
1428     def draw_props(self, context, layout):
1429         prefs = context.preferences
1430         inputs = prefs.inputs
1431
1432         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1433
1434         flow.row().prop(inputs, "view_zoom_method", text="Zoom Method", expand=True)
1435         if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
1436             flow.row().prop(inputs, "view_zoom_axis", expand=True)
1437             flow.prop(inputs, "invert_mouse_zoom", text="Invert Mouse Zoom Direction")
1438
1439         flow.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
1440         # sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
1441         flow.prop(inputs, "use_zoom_to_mouse")
1442
1443
1444 class USERPREF_PT_navigation_fly_walk(PreferencePanel):
1445     bl_label = "Fly & Walk"
1446
1447     @classmethod
1448     def poll(cls, context):
1449         prefs = context.preferences
1450         return (prefs.active_section == 'NAVIGATION')
1451
1452     def draw_props(self, context, layout):
1453         prefs = context.preferences
1454         inputs = prefs.inputs
1455
1456         layout.row().prop(inputs, "navigation_mode", expand=True)
1457
1458         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1459         flow.prop(inputs, "use_camera_lock_parent")
1460
1461
1462 class USERPREF_PT_navigation_fly_walk_navigation(PreferencePanel):
1463     bl_label = "Walk"
1464     bl_parent_id = "USERPREF_PT_navigation_fly_walk"
1465     bl_options = {'DEFAULT_CLOSED'}
1466
1467     @classmethod
1468     def poll(cls, context):
1469         prefs = context.preferences
1470         return prefs.inputs.navigation_mode == 'WALK'
1471
1472     def draw_props(self, context, layout):
1473         prefs = context.preferences
1474         inputs = prefs.inputs
1475         walk = inputs.walk_navigation
1476
1477         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1478
1479         flow.prop(walk, "use_mouse_reverse")
1480         flow.prop(walk, "mouse_speed")
1481         flow.prop(walk, "teleport_time")
1482
1483         sub = flow.column(align=True)
1484         sub.prop(walk, "walk_speed")
1485         sub.prop(walk, "walk_speed_factor")
1486
1487
1488 class USERPREF_PT_navigation_fly_walk_gravity(PreferencePanel):
1489     bl_label = "Gravity"
1490     bl_parent_id = "USERPREF_PT_navigation_fly_walk"
1491     bl_options = {'DEFAULT_CLOSED'}
1492
1493     @classmethod
1494     def poll(cls, context):
1495         prefs = context.preferences
1496         return prefs.inputs.navigation_mode == 'WALK'
1497
1498     def draw_header(self, context):
1499         prefs = context.preferences
1500         inputs = prefs.inputs
1501         walk = inputs.walk_navigation
1502
1503         self.layout.prop(walk, "use_gravity", text="")
1504
1505     def draw_props(self, context, layout):
1506         prefs = context.preferences
1507         inputs = prefs.inputs
1508         walk = inputs.walk_navigation
1509
1510         layout.active = walk.use_gravity
1511
1512         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1513
1514         flow.prop(walk, "view_height")
1515         flow.prop(walk, "jump_height")
1516
1517
1518 class USERPREF_PT_input_tablet(PreferencePanel):
1519     bl_label = "Tablet"
1520
1521     @classmethod
1522     def poll(cls, context):
1523         prefs = context.preferences
1524         inputs = prefs.inputs
1525         return prefs.active_section == 'INPUT'
1526
1527     def draw_props(self, context, layout):
1528         prefs = context.preferences
1529         inputs = prefs.inputs
1530
1531         import sys
1532         if sys.platform[:3] == "win":
1533             layout.prop(inputs, "tablet_api")
1534             layout.separator()
1535
1536         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1537
1538         flow.prop(inputs, "pressure_threshold_max")
1539         flow.prop(inputs, "pressure_softness")
1540
1541
1542 class USERPREF_PT_input_ndof(PreferencePanel):
1543     bl_label = "NDOF"
1544     bl_options = {'DEFAULT_CLOSED'}
1545
1546     @classmethod
1547     def poll(cls, context):
1548         prefs = context.preferences
1549         inputs = prefs.inputs
1550         return prefs.active_section == 'INPUT' and inputs.use_ndof
1551
1552     def draw_props(self, context, layout):
1553         prefs = context.preferences
1554         inputs = prefs.inputs
1555
1556         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
1557
1558         flow.prop(inputs, "ndof_sensitivity", text="Pan Sensitivity")
1559         flow.prop(inputs, "ndof_orbit_sensitivity", text="Orbit Sensitivity")
1560         flow.prop(inputs, "ndof_deadzone", text="Deadzone")
1561
1562         layout.separator()
1563
1564         flow.row().prop(inputs, "ndof_view_navigate_method", expand=True)
1565         flow.row().prop(inputs, "ndof_view_rotate_method", expand=True)
1566
1567
1568 class USERPREF_MT_keyconfigs(Menu):
1569     bl_label = "KeyPresets"
1570     preset_subdir = "keyconfig"
1571     preset_operator = "wm.keyconfig_activate"
1572
1573     def draw(self, context):
1574         Menu.draw_preset(self, context)
1575
1576
1577 class USERPREF_PT_keymap(Panel):
1578     bl_space_type = 'PREFERENCES'
1579     bl_label = "Keymap"
1580     bl_region_type = 'WINDOW'
1581     bl_options = {'HIDE_HEADER'}
1582
1583     @classmethod
1584     def poll(cls, context):
1585         prefs = context.preferences
1586         return (prefs.active_section == 'KEYMAP')
1587
1588     def draw(self, context):
1589         from rna_keymap_ui import draw_keymaps
1590
1591         layout = self.layout
1592
1593         # import time
1594
1595         # start = time.time()
1596
1597         # Keymap Settings
1598         draw_keymaps(context, layout)
1599
1600         # print("runtime", time.time() - start)
1601
1602
1603 class USERPREF_PT_addons(Panel):
1604     bl_space_type = 'PREFERENCES'
1605     bl_label = "Add-ons"
1606     bl_region_type = 'WINDOW'
1607     bl_options = {'HIDE_HEADER'}
1608
1609     _support_icon_mapping = {
1610         'OFFICIAL': 'FILE_BLEND',
1611         'COMMUNITY': 'COMMUNITY',
1612         'TESTING': 'EXPERIMENTAL',
1613     }
1614
1615     @classmethod
1616     def poll(cls, context):
1617         prefs = context.preferences
1618         return (prefs.active_section == 'ADDONS')
1619
1620     @staticmethod
1621     def is_user_addon(mod, user_addon_paths):
1622         import os
1623
1624         if not user_addon_paths:
1625             for path in (
1626                     bpy.utils.script_path_user(),
1627                     bpy.utils.script_path_pref(),
1628             ):
1629                 if path is not None:
1630                     user_addon_paths.append(os.path.join(path, "addons"))
1631
1632         for path in user_addon_paths:
1633             if bpy.path.is_subdir(mod.__file__, path):
1634                 return True
1635         return False
1636
1637     @staticmethod
1638     def draw_error(layout, message):
1639         lines = message.split("\n")
1640         box = layout.box()
1641         sub = box.row()
1642         sub.label(text=lines[0])
1643         sub.label(icon='ERROR')
1644         for l in lines[1:]:
1645             box.label(text=l)
1646
1647     def draw(self, context):
1648         import os
1649         import addon_utils
1650
1651         layout = self.layout
1652
1653         prefs = context.preferences
1654         used_ext = {ext.module for ext in prefs.addons}
1655
1656         addon_user_dirs = tuple(
1657             p for p in (
1658                 os.path.join(prefs.filepaths.script_directory, "addons"),
1659                 bpy.utils.user_resource('SCRIPTS', "addons"),
1660             )
1661             if p
1662         )
1663
1664         # Development option for 2.8x, don't show users bundled addons
1665         # unless they have been updated for 2.8x.
1666         # Developers can turn them on with '--debug'
1667         show_official_27x_addons = bpy.app.debug
1668
1669         # collect the categories that can be filtered on
1670         addons = [
1671             (mod, addon_utils.module_bl_info(mod))
1672             for mod in addon_utils.modules(refresh=False)
1673         ]
1674
1675         split = layout.split(factor=0.6)
1676
1677         row = split.row()
1678         row.prop(context.window_manager, "addon_support", expand=True)
1679
1680         row = split.row(align=True)
1681         row.operator("wm.addon_install", icon='IMPORT', text="Install...")
1682         row.operator("wm.addon_refresh", icon='FILE_REFRESH', text="Refresh")
1683
1684         row = layout.row()
1685         row.prop(context.window_manager, "addon_filter", text="")
1686         row.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
1687
1688         col = layout.column()
1689
1690         # set in addon_utils.modules_refresh()
1691         if addon_utils.error_duplicates:
1692             box = col.box()
1693             row = box.row()
1694             row.label(text="Multiple add-ons with the same name found!")
1695             row.label(icon='ERROR')
1696             box.label(text="Delete one of each pair to resolve:")
1697             for (addon_name, addon_file, addon_path) in addon_utils.error_duplicates:
1698                 box.separator()
1699                 sub_col = box.column(align=True)
1700                 sub_col.label(text=addon_name + ":")
1701                 sub_col.label(text="    " + addon_file)
1702                 sub_col.label(text="    " + addon_path)
1703
1704         if addon_utils.error_encoding:
1705             self.draw_error(
1706                 col,
1707                 "One or more addons do not have UTF-8 encoding\n"
1708                 "(see console for details)",
1709             )
1710
1711         filter = context.window_manager.addon_filter
1712         search = context.window_manager.addon_search.lower()
1713         support = context.window_manager.addon_support
1714
1715         # initialized on demand
1716         user_addon_paths = []
1717
1718         for mod, info in addons:
1719             module_name = mod.__name__
1720
1721             is_enabled = module_name in used_ext
1722
1723             if info["support"] not in support:
1724                 continue
1725
1726             # check if addon should be visible with current filters
1727             if (
1728                     (filter == "All") or
1729                     (filter == info["category"]) or
1730                     (filter == "Enabled" and is_enabled) or
1731                     (filter == "Disabled" and not is_enabled) or
1732                     (filter == "User" and (mod.__file__.startswith(addon_user_dirs)))
1733             ):
1734                 if search and search not in info["name"].lower():
1735                     if info["author"]:
1736                         if search not in info["author"].lower():
1737                             continue
1738                     else:
1739                         continue
1740
1741                 # Skip 2.7x add-ons included with Blender, unless in debug mode.
1742                 is_addon_27x = info.get("blender", (0,)) < (2, 80)
1743                 if (
1744                         is_addon_27x and
1745                         (not show_official_27x_addons) and
1746                         (not mod.__file__.startswith(addon_user_dirs))
1747                 ):
1748                     continue
1749
1750                 # Addon UI Code
1751                 col_box = col.column()
1752                 box = col_box.box()
1753                 colsub = box.column()
1754                 row = colsub.row(align=True)
1755
1756                 row.operator(
1757                     "wm.addon_expand",
1758                     icon='DISCLOSURE_TRI_DOWN' if info["show_expanded"] else 'DISCLOSURE_TRI_RIGHT',
1759                     emboss=False,
1760                 ).module = module_name
1761
1762                 row.operator(
1763                     "wm.addon_disable" if is_enabled else "wm.addon_enable",
1764                     icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
1765                     emboss=False,
1766                 ).module = module_name
1767
1768                 sub = row.row()
1769                 sub.active = is_enabled
1770                 sub.label(text="%s: %s" % (info["category"], info["name"]))
1771
1772                 # WARNING: 2.8x exception, may be removed
1773                 # use disabled state for old add-ons, chances are they are broken.
1774                 if is_addon_27x:
1775                     sub.label(text="upgrade to 2.8x required")
1776                     sub.label(icon='ERROR')
1777                 # Remove code above after 2.8x migration is complete.
1778                 elif info["warning"]:
1779                     sub.label(icon='ERROR')
1780
1781                 # icon showing support level.
1782                 sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
1783
1784                 # Expanded UI (only if additional info is available)
1785                 if info["show_expanded"]:
1786                     if info["description"]:
1787                         split = colsub.row().split(factor=0.15)
1788                         split.label(text="Description:")
1789                         split.label(text=info["description"])
1790                     if info["location"]:
1791                         split = colsub.row().split(factor=0.15)
1792                         split.label(text="Location:")
1793                         split.label(text=info["location"])
1794                     if mod:
1795                         split = colsub.row().split(factor=0.15)
1796                         split.label(text="File:")
1797                         split.label(text=mod.__file__, translate=False)
1798                     if info["author"]:
1799                         split = colsub.row().split(factor=0.15)
1800                         split.label(text="Author:")
1801                         split.label(text=info["author"], translate=False)
1802                     if info["version"]:
1803                         split = colsub.row().split(factor=0.15)
1804                         split.label(text="Version:")
1805                         split.label(text=".".join(str(x) for x in info["version"]), translate=False)
1806                     if info["warning"]:
1807                         split = colsub.row().split(factor=0.15)
1808                         split.label(text="Warning:")
1809                         split.label(text="  " + info["warning"], icon='ERROR')
1810
1811                     user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
1812                     tot_row = bool(info["wiki_url"]) + bool(user_addon)
1813
1814                     if tot_row:
1815                         split = colsub.row().split(factor=0.15)
1816                         split.label(text="Internet:")
1817                         sub = split.row()
1818                         if info["wiki_url"]:
1819                             sub.operator(
1820                                 "wm.url_open", text="Documentation", icon='HELP',
1821                             ).url = info["wiki_url"]
1822                         # Only add "Report a Bug" button if tracker_url is set
1823                         # or the add-on is bundled (use official tracker then).
1824                         if info.get("tracker_url") or not user_addon:
1825                             sub.operator(
1826                                 "wm.url_open", text="Report a Bug", icon='URL',
1827                             ).url = info.get(
1828                                 "tracker_url",
1829                                 "https://developer.blender.org/maniphest/task/edit/form/2",
1830                             )
1831                         if user_addon:
1832                             sub.operator(
1833                                 "wm.addon_remove", text="Remove", icon='CANCEL',
1834                             ).module = mod.__name__
1835
1836                     # Show addon user preferences
1837                     if is_enabled:
1838                         addon_preferences = prefs.addons[module_name].preferences
1839                         if addon_preferences is not None:
1840                             draw = getattr(addon_preferences, "draw", None)
1841                             if draw is not None:
1842                                 addon_preferences_class = type(addon_preferences)
1843                                 box_prefs = col_box.box()
1844                                 box_prefs.label(text="Preferences:")
1845                                 addon_preferences_class.layout = box_prefs
1846                                 try:
1847                                     draw(context)
1848                                 except:
1849                                     import traceback
1850                                     traceback.print_exc()
1851                                     box_prefs.label(text="Error (see console)", icon='ERROR')
1852                                 del addon_preferences_class.layout
1853
1854         # Append missing scripts
1855         # First collect scripts that are used but have no script file.
1856         module_names = {mod.__name__ for mod, info in addons}
1857         missing_modules = {ext for ext in used_ext if ext not in module_names}
1858
1859         if missing_modules and filter in {"All", "Enabled"}:
1860             col.column().separator()
1861             col.column().label(text="Missing script files")
1862
1863             module_names = {mod.__name__ for mod, info in addons}
1864             for module_name in sorted(missing_modules):
1865                 is_enabled = module_name in used_ext
1866                 # Addon UI Code
1867                 box = col.column().box()
1868                 colsub = box.column()
1869                 row = colsub.row(align=True)
1870
1871                 row.label(text="", icon='ERROR')
1872
1873                 if is_enabled:
1874                     row.operator(
1875                         "wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False,
1876                     ).module = module_name
1877
1878                 row.label(text=module_name, translate=False)
1879
1880
1881 class StudioLightPanelMixin():
1882     bl_space_type = 'PREFERENCES'
1883     bl_region_type = 'WINDOW'
1884
1885     @classmethod
1886     def poll(cls, context):
1887         prefs = context.preferences
1888         return (prefs.active_section == 'LIGHTS')
1889
1890     def _get_lights(self, prefs):
1891         return [light for light in prefs.studio_lights if light.is_user_defined and light.type == self.sl_type]
1892
1893     def draw(self, context):
1894         layout = self.layout
1895         prefs = context.preferences
1896         lights = self._get_lights(prefs)
1897
1898         self.draw_light_list(layout, lights)
1899
1900     def draw_light_list(self, layout, lights):
1901         if lights:
1902             flow = layout.grid_flow(row_major=False, columns=4, even_columns=True, even_rows=True, align=False)
1903             for studio_light in lights:
1904                 self.draw_studio_light(flow, studio_light)
1905         else:
1906             layout.label(text="No custom {} configured".format(self.bl_label))
1907
1908     def draw_studio_light(self, layout, studio_light):
1909         box = layout.box()
1910         row = box.row()
1911
1912         row.template_icon(layout.icon(studio_light), scale=3.0)
1913         col = row.column()
1914         op = col.operator("wm.studiolight_uninstall", text="", icon='REMOVE')
1915         op.index = studio_light.index
1916
1917         if studio_light.type == 'STUDIO':
1918             op = col.operator("wm.studiolight_copy_settings", text="", icon='IMPORT')
1919             op.index = studio_light.index
1920
1921         box.label(text=studio_light.name)
1922
1923
1924 class USERPREF_PT_studiolight_matcaps(Panel, StudioLightPanelMixin):
1925     bl_label = "MatCaps"
1926     sl_type = 'MATCAP'
1927
1928     def draw_header_preset(self, context):
1929         layout = self.layout
1930         layout.operator("wm.studiolight_install", icon='IMPORT', text="Install...").type = 'MATCAP'
1931         layout.separator()
1932
1933
1934 class USERPREF_PT_studiolight_world(Panel, StudioLightPanelMixin):
1935     bl_label = "LookDev HDRIs"
1936     sl_type = 'WORLD'
1937
1938     def draw_header_preset(self, context):
1939         layout = self.layout
1940         layout.operator("wm.studiolight_install", icon='IMPORT', text="Install...").type = 'WORLD'
1941         layout.separator()
1942
1943
1944 class USERPREF_PT_studiolight_lights(Panel, StudioLightPanelMixin):
1945     bl_label = "Studio Lights"
1946     sl_type = 'STUDIO'
1947
1948     def draw_header_preset(self, context):
1949         layout = self.layout
1950         op = layout.operator("wm.studiolight_install", icon='IMPORT', text="Install...")
1951         op.type = 'STUDIO'
1952         op.filter_glob = ".sl"
1953         layout.separator()
1954
1955
1956 class USERPREF_PT_studiolight_light_editor(Panel):
1957     bl_label = "Editor"
1958     bl_parent_id = "USERPREF_PT_studiolight_lights"
1959     bl_space_type = 'PREFERENCES'
1960     bl_region_type = 'WINDOW'
1961     bl_options = {'DEFAULT_CLOSED'}
1962
1963     def opengl_light_buttons(self, layout, light):
1964
1965         col = layout.column()
1966         col.active = light.use
1967
1968         col.prop(light, "use", text="Use Light")
1969         col.prop(light, "diffuse_color", text="Diffuse")
1970         col.prop(light, "specular_color", text="Specular")
1971         col.prop(light, "smooth")
1972         col.prop(light, "direction")
1973
1974     def draw(self, context):
1975         layout = self.layout
1976
1977         prefs = context.preferences
1978         system = prefs.system
1979
1980         row = layout.row()
1981         row.prop(system, "edit_studio_light", toggle=True)
1982         row.operator("wm.studiolight_new", text="Save as Studio light", icon='FILE_TICK')
1983
1984         layout.separator()
1985
1986         layout.use_property_split = True
1987         column = layout.split()
1988         column.active = system.edit_studio_light
1989
1990         light = system.solid_lights[0]
1991         colsplit = column.split(factor=0.85)
1992         self.opengl_light_buttons(colsplit, light)
1993
1994         light = system.solid_lights[1]
1995         colsplit = column.split(factor=0.85)
1996         self.opengl_light_buttons(colsplit, light)
1997
1998         light = system.solid_lights[2]
1999         colsplit = column.split(factor=0.85)
2000         self.opengl_light_buttons(colsplit, light)
2001
2002         light = system.solid_lights[3]
2003         self.opengl_light_buttons(column, light)
2004
2005         layout.separator()
2006
2007         layout.prop(system, "light_ambient")
2008
2009
2010 ThemeGenericClassGenerator.generate_panel_classes_for_wcols()
2011
2012 # Order of registration defines order in UI, so dynamically generated classes are 'injected' in the intended order.
2013 classes = (USERPREF_PT_theme_user_interface,) + tuple(ThemeGenericClassGenerator.generated_classes)
2014
2015 classes += (
2016     USERPREF_HT_header,
2017     USERPREF_PT_navigation_bar,
2018     USERPREF_PT_save_preferences,
2019
2020     USERPREF_PT_interface_display,
2021     USERPREF_PT_interface_editors,
2022     USERPREF_PT_interface_translation,
2023     USERPREF_PT_interface_text,
2024     USERPREF_PT_interface_menus,
2025     USERPREF_PT_interface_menus_mouse_over,
2026     USERPREF_PT_interface_menus_pie,
2027
2028     USERPREF_PT_viewport_display,
2029     USERPREF_PT_viewport_quality,
2030     USERPREF_PT_viewport_textures,
2031     USERPREF_PT_viewport_selection,
2032
2033     USERPREF_PT_edit_objects,
2034     USERPREF_PT_edit_cursor,
2035     USERPREF_PT_edit_duplicate_data,
2036     USERPREF_PT_edit_annotations,
2037     USERPREF_PT_edit_weight_paint,
2038     USERPREF_PT_edit_gpencil,
2039     USERPREF_PT_edit_misc,
2040
2041     USERPREF_PT_animation_timeline,
2042     USERPREF_PT_animation_keyframes,
2043     USERPREF_PT_animation_autokey,
2044     USERPREF_PT_animation_fcurves,
2045
2046     USERPREF_PT_system_cycles_devices,
2047     USERPREF_PT_system_memory,
2048     USERPREF_PT_system_sound,
2049
2050     USERPREF_MT_interface_theme_presets,
2051     USERPREF_PT_theme,
2052     USERPREF_PT_theme_interface_state,
2053     USERPREF_PT_theme_interface_styles,
2054     USERPREF_PT_theme_interface_gizmos,
2055     USERPREF_PT_theme_interface_icons,
2056     USERPREF_PT_theme_text_style,
2057     USERPREF_PT_theme_bone_color_sets,
2058
2059     USERPREF_PT_file_paths_data,
2060     USERPREF_PT_file_paths_render,
2061     USERPREF_PT_file_paths_applications,
2062     USERPREF_PT_file_paths_development,
2063
2064     USERPREF_PT_saveload_blend,
2065     USERPREF_PT_saveload_blend_autosave,
2066     USERPREF_PT_saveload_autorun,
2067     USERPREF_PT_saveload_file_browser,
2068
2069     USERPREF_MT_ndof_settings,
2070     USERPREF_MT_keyconfigs,
2071
2072     USERPREF_PT_input_keyboard,
2073     USERPREF_PT_input_mouse,
2074     USERPREF_PT_input_tablet,
2075     USERPREF_PT_input_ndof,
2076     USERPREF_PT_navigation_orbit,
2077     USERPREF_PT_navigation_zoom,
2078     USERPREF_PT_navigation_fly_walk,
2079     USERPREF_PT_navigation_fly_walk_navigation,
2080     USERPREF_PT_navigation_fly_walk_gravity,
2081
2082     USERPREF_PT_keymap,
2083     USERPREF_PT_addons,
2084
2085     USERPREF_PT_studiolight_lights,
2086     USERPREF_PT_studiolight_light_editor,
2087     USERPREF_PT_studiolight_matcaps,
2088     USERPREF_PT_studiolight_world,
2089 )
2090
2091 # Add dynamically generated editor theme panels last, so they show up last in the theme section.
2092 ThemeGenericClassGenerator.generated_classes.clear()
2093 ThemeGenericClassGenerator.generate_panel_classes_from_theme_areas()
2094 classes += tuple(ThemeGenericClassGenerator.generated_classes)
2095
2096 if __name__ == "__main__":  # only for live edit.
2097     from bpy.utils import register_class
2098     for cls in classes:
2099         register_class(cls)