1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import (
26 from bpy.app.translations import pgettext_iface as iface_
27 from bpy.app.translations import contexts as i18n_contexts
30 class USERPREF_HT_header(Header):
31 bl_space_type = 'USER_PREFERENCES'
33 def draw(self, context):
36 # No need to show type selector.
37 # layout.template_header()
39 userpref = context.user_preferences
41 if userpref.active_section == 'INPUT':
42 layout.operator("wm.keyconfig_import", icon='IMPORT')
43 layout.operator("wm.keyconfig_export", icon='EXPORT')
44 elif userpref.active_section == 'ADDONS':
45 layout.operator("wm.addon_install", icon='FILEBROWSER')
46 layout.operator("wm.addon_refresh", icon='FILE_REFRESH')
47 layout.menu("USERPREF_MT_addons_online_resources")
48 elif userpref.active_section == 'LIGHTS':
49 layout.operator('wm.studiolight_install', text="Add MatCap").orientation = 'MATCAP'
50 layout.operator('wm.studiolight_install', text="Add World HDRI").orientation = 'WORLD'
51 layout.operator('wm.studiolight_install', text="Add Camera HDRI").orientation = 'CAMERA'
52 elif userpref.active_section == 'THEMES':
53 layout.operator("wm.theme_install", icon='FILEBROWSER')
54 layout.operator("ui.reset_default_theme", icon='LOOP_BACK')
56 layout.separator_spacer()
58 layout.operator_context = 'EXEC_AREA'
59 layout.operator("wm.save_userpref")
62 class USERPREF_PT_tabs(Panel):
64 bl_space_type = 'USER_PREFERENCES'
65 bl_region_type = 'WINDOW'
66 bl_options = {'HIDE_HEADER'}
68 def draw(self, context):
71 userpref = context.user_preferences
73 layout.row().prop(userpref, "active_section", expand=True)
76 class USERPREF_PT_interface(Panel):
77 bl_space_type = 'USER_PREFERENCES'
78 bl_label = "Interface"
79 bl_region_type = 'WINDOW'
80 bl_options = {'HIDE_HEADER'}
83 def poll(cls, context):
84 userpref = context.user_preferences
85 return (userpref.active_section == 'INTERFACE')
87 def draw(self, context):
90 userpref = context.user_preferences
93 split = layout.split()
97 col.label(text="Display:")
98 col.prop(view, "ui_scale", text="Scale")
99 col.prop(view, "ui_line_width", text="Line Width")
100 col.prop(view, "show_tooltips")
101 col.prop(view, "show_object_info", text="Object Info")
102 col.prop(view, "show_large_cursors")
103 col.prop(view, "show_view_name", text="View Name")
104 col.prop(view, "show_playback_fps", text="Playback FPS")
105 col.prop(view, "object_origin_size")
109 # col.prop(view, "show_gizmo_navigate")
111 sub = col.column(align=True)
113 sub.label(text="3D Viewport Axis:")
114 sub.row().prop(view, "mini_axis_type", text="")
116 sub = col.column(align=True)
117 sub.active = view.mini_axis_type == 'MINIMAL'
118 sub.prop(view, "mini_axis_size", text="Size")
119 sub.prop(view, "mini_axis_brightness", text="Brightness")
123 # Toolbox doesn't exist yet
124 # col.label(text="Toolbox:")
125 #col.prop(view, "show_column_layout")
126 #col.label(text="Open Toolbox Delay:")
127 #col.prop(view, "open_left_mouse_delay", text="Hold LMB")
128 #col.prop(view, "open_right_mouse_delay", text="Hold RMB")
129 col.prop(view, "show_gizmo", text="Gizmos")
131 sub.active = view.show_gizmo
132 sub.prop(view, "gizmo_size", text="Size")
136 col.label(text="Development:")
137 col.prop(view, "show_tooltips_python")
138 col.prop(view, "show_developer_ui")
144 col.label(text="View Gizmos:")
145 col.prop(view, "use_mouse_depth_cursor")
146 col.prop(view, "use_cursor_lock_adjust")
147 col.prop(view, "use_mouse_depth_navigate")
148 col.prop(view, "use_zoom_to_mouse")
149 col.prop(view, "use_rotate_around_active")
150 col.prop(view, "use_camera_lock_parent")
154 col.prop(view, "use_auto_perspective")
155 col.prop(view, "smooth_view")
156 col.prop(view, "rotation_angle")
161 col.label(text="2D Viewports:")
162 col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
163 col.prop(view, "timecode_style")
164 col.prop(view, "view_frame_type")
165 if view.view_frame_type == 'SECONDS':
166 col.prop(view, "view_frame_seconds")
167 elif view.view_frame_type == 'KEYFRAMES':
168 col.prop(view, "view_frame_keyframes")
174 col.label(text="Menus:")
175 col.prop(view, "use_mouse_over_open")
177 sub.active = view.use_mouse_over_open
179 sub.prop(view, "open_toplevel_delay", text="Top Level")
180 sub.prop(view, "open_sublevel_delay", text="Sub Level")
183 col.label(text="Pie Menus:")
184 sub = col.column(align=True)
185 sub.prop(view, "pie_animation_timeout")
186 sub.prop(view, "pie_initial_timeout")
187 sub.prop(view, "pie_menu_radius")
188 sub.prop(view, "pie_menu_threshold")
189 sub.prop(view, "pie_menu_confirm")
192 col.prop(view, "show_splash")
194 col.label(text="Warnings:")
195 col.prop(view, "use_quit_dialog")
199 col.label(text="App Template:")
200 col.label(text="Options intended for use with app-templates only.")
201 col.prop(view, "show_layout_ui")
202 col.prop(view, "show_view3d_cursor")
205 class USERPREF_PT_edit(Panel):
206 bl_space_type = 'USER_PREFERENCES'
208 bl_region_type = 'WINDOW'
209 bl_options = {'HIDE_HEADER'}
212 def poll(cls, context):
213 userpref = context.user_preferences
214 return (userpref.active_section == 'EDITING')
216 def draw(self, context):
219 userpref = context.user_preferences
222 split = layout.split()
226 col.label(text="Link Materials To:")
227 col.prop(edit, "material_link", text="")
233 col.label(text="New Objects:")
234 col.prop(edit, "use_enter_edit_mode")
235 col.label(text="Align To:")
236 col.prop(edit, "object_align", text="")
242 col.label(text="Undo:")
243 col.prop(edit, "use_global_undo")
244 col.prop(edit, "undo_steps", text="Steps")
245 col.prop(edit, "undo_memory_limit", text="Memory Limit")
251 col.label(text="Grease Pencil/Annotations:")
253 col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
254 col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
257 col.label(text="Annotations:")
259 sub.prop(edit, "grease_pencil_default_color", text="Default Color")
260 col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
262 col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
268 col.label(text="Playback:")
269 col.prop(edit, "use_negative_frames")
271 col.label(text="Node Editor:")
272 col.prop(edit, "node_margin")
273 col.label(text="Animation Editors:")
274 col.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
280 col.label(text="Keyframing:")
281 col.prop(edit, "use_visual_keying")
282 col.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed")
286 col.prop(edit, "use_auto_keying", text="Auto Keyframing:")
287 col.prop(edit, "use_auto_keying_warning")
291 # ~ sub.active = edit.use_keyframe_insert_auto # incorrect, time-line can enable
292 sub.prop(edit, "use_keyframe_insert_available", text="Only Insert Available")
296 col.label(text="New F-Curve Defaults:")
297 col.prop(edit, "keyframe_new_interpolation_type", text="Interpolation")
298 col.prop(edit, "keyframe_new_handle_type", text="Handles")
299 col.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
305 col.label(text="Transform:")
306 col.prop(edit, "use_drag_immediately")
307 col.prop(edit, "use_numeric_input_advanced")
313 col.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
319 col.label(text="Duplicate Data:")
320 col.prop(edit, "use_duplicate_mesh", text="Mesh")
321 col.prop(edit, "use_duplicate_surface", text="Surface")
322 col.prop(edit, "use_duplicate_curve", text="Curve")
323 col.prop(edit, "use_duplicate_text", text="Text")
324 col.prop(edit, "use_duplicate_metaball", text="Metaball")
325 col.prop(edit, "use_duplicate_armature", text="Armature")
326 col.prop(edit, "use_duplicate_light", text="Light")
327 col.prop(edit, "use_duplicate_material", text="Material")
328 col.prop(edit, "use_duplicate_texture", text="Texture")
329 #col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
330 col.prop(edit, "use_duplicate_action", text="Action")
331 col.prop(edit, "use_duplicate_particle", text="Particle")
334 class USERPREF_PT_system(Panel):
335 bl_space_type = 'USER_PREFERENCES'
337 bl_region_type = 'WINDOW'
338 bl_options = {'HIDE_HEADER'}
341 def poll(cls, context):
342 userpref = context.user_preferences
343 return (userpref.active_section == 'SYSTEM')
345 def draw(self, context):
349 userpref = context.user_preferences
350 system = userpref.system
352 split = layout.split()
355 column = split.column()
356 colsplit = column.split(factor=0.85)
358 col = colsplit.column()
359 col.label(text="General:")
361 col.prop(system, "scrollback", text="Console Scrollback")
365 col.label(text="Sound:")
366 col.row().prop(system, "audio_device", expand=False)
368 sub.active = system.audio_device not in {'NONE', 'Null'}
369 #sub.prop(system, "use_preview_images")
370 sub.prop(system, "audio_channels", text="Channels")
371 sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
372 sub.prop(system, "audio_sample_rate", text="Sample Rate")
373 sub.prop(system, "audio_sample_format", text="Sample Format")
377 if bpy.app.build_options.cycles:
378 addon = userpref.addons.get("cycles")
379 if addon is not None:
380 addon.preferences.draw_impl(col, context)
383 if hasattr(system, "opensubdiv_compute_type"):
384 col.label(text="OpenSubdiv compute:")
385 col.row().prop(system, "opensubdiv_compute_type", text="")
388 column = split.column()
389 colsplit = column.split(factor=0.85)
391 col = colsplit.column()
392 col.label(text="OpenGL:")
393 col.prop(system, "gl_clip_alpha", slider=True)
394 col.prop(system, "use_gpu_mipmap")
395 col.prop(system, "use_16bit_textures")
398 col.label(text="Selection:")
399 col.prop(system, "select_method", text="")
400 col.prop(system, "use_select_pick_depth")
404 col.label(text="Anisotropic Filtering:")
405 col.prop(system, "anisotropic_filter", text="")
409 col.prop(system, "multi_sample", text="")
410 if sys.platform == "linux" and system.multi_sample != 'NONE':
411 col.label(text="Might fail for Mesh editing selection!")
413 col.prop(system, "use_region_overlap")
416 col.prop(system, "gpu_viewport_quality")
419 col.label(text="Grease Pencil Options:")
420 col.prop(system, "gpencil_multi_sample", text="")
423 col.label(text="Text Draw Options:")
424 col.prop(system, "use_text_antialiasing", text="Anti-aliasing")
426 sub.active = system.use_text_antialiasing
427 sub.prop(system, "text_hinting", text="Hinting")
430 column = split.column()
432 column.label(text="Textures:")
433 column.prop(system, "gl_texture_limit", text="Limit Size")
434 column.prop(system, "texture_time_out", text="Time Out")
435 column.prop(system, "texture_collection_rate", text="Collection Rate")
439 column.label(text="Images Draw Method:")
440 column.prop(system, "image_draw_method", text="")
444 column.label(text="Sequencer/Clip Editor:")
445 # currently disabled in the code
446 # column.prop(system, "prefetch_frames")
447 column.prop(system, "memory_cache_limit")
451 column.label(text="Color Picker Type:")
452 column.row().prop(system, "color_picker_type", text="")
456 column.prop(system, "use_weight_color_range", text="Custom Weight Paint Range")
457 sub = column.column()
458 sub.active = system.use_weight_color_range
459 sub.template_color_ramp(system, "weight_color_range", expand=True)
462 column.prop(system, "font_path_ui")
463 column.prop(system, "font_path_ui_mono")
465 if bpy.app.build_options.international:
466 column.prop(system, "use_international_fonts")
467 if system.use_international_fonts:
468 column.prop(system, "language")
470 row.label(text="Translate:", text_ctxt=i18n_contexts.id_windowmanager)
471 row = column.row(align=True)
472 row.prop(system, "use_translate_interface", text="Interface", toggle=True)
473 row.prop(system, "use_translate_tooltips", text="Tooltips", toggle=True)
474 row.prop(system, "use_translate_new_dataname", text="New Data", toggle=True)
477 class USERPREF_MT_interface_theme_presets(Menu):
479 preset_subdir = "interface_theme"
480 preset_operator = "script.execute_preset"
483 ("user_preferences.themes[0]", "Theme"),
484 ("user_preferences.ui_styles[0]", "ThemeStyle"),
486 draw = Menu.draw_preset
488 def reset_cb(context):
489 bpy.ops.ui.reset_default_theme()
492 class USERPREF_PT_theme(Panel):
493 bl_space_type = 'USER_PREFERENCES'
495 bl_region_type = 'WINDOW'
496 bl_options = {'HIDE_HEADER'}
498 # not essential, hard-coded UI delimiters for the theme layout
501 "text_grease_pencil",
504 "freestyle_face_mark",
510 "handle_vertex_select",
519 "handle_vertex_select",
524 def _theme_generic(split, themedata, theme_area):
528 def theme_generic_recurse(data):
529 col.label(text=data.rna_type.name)
531 subsplit = row.split(factor=0.95)
533 padding1 = subsplit.split(factor=0.15)
536 subsplit = row.split(factor=0.85)
538 padding2 = subsplit.split(factor=0.15)
541 colsub_pair = padding1.column(), padding2.column()
545 for i, prop in enumerate(data.rna_type.properties):
546 if prop.identifier == "rna_type":
549 props_type.setdefault((prop.type, prop.subtype), []).append(prop)
551 th_delimiters = USERPREF_PT_theme.ui_delimiters.get(theme_area)
552 for props_type, props_ls in sorted(props_type.items()):
553 if props_type[0] == 'POINTER':
554 for i, prop in enumerate(props_ls):
555 theme_generic_recurse(getattr(data, prop.identifier))
557 if th_delimiters is None:
558 # simple, no delimiters
559 for i, prop in enumerate(props_ls):
560 colsub_pair[i % 2].row().prop(data, prop.identifier)
562 # add hard coded delimiters
564 for prop in props_ls:
565 colsub = colsub_pair[i]
566 colsub.row().prop(data, prop.identifier)
568 if prop.identifier in th_delimiters:
570 colsub = colsub_pair[1]
571 colsub.row().label(text="")
572 colsub_pair[0].row().label(text="")
573 colsub_pair[1].row().label(text="")
576 theme_generic_recurse(themedata)
579 def _theme_widget_style(layout, widget_style):
583 subsplit = row.split(factor=0.95)
585 padding = subsplit.split(factor=0.15)
586 colsub = padding.column()
587 colsub = padding.column()
588 colsub.row().prop(widget_style, "outline")
589 colsub.row().prop(widget_style, "item", slider=True)
590 colsub.row().prop(widget_style, "inner", slider=True)
591 colsub.row().prop(widget_style, "inner_sel", slider=True)
592 colsub.row().prop(widget_style, "roundness")
594 subsplit = row.split(factor=0.85)
596 padding = subsplit.split(factor=0.15)
597 colsub = padding.column()
598 colsub = padding.column()
599 colsub.row().prop(widget_style, "text")
600 colsub.row().prop(widget_style, "text_sel")
601 colsub.prop(widget_style, "show_shaded")
602 subsub = colsub.column(align=True)
603 subsub.active = widget_style.show_shaded
604 subsub.prop(widget_style, "shadetop")
605 subsub.prop(widget_style, "shadedown")
610 def _ui_font_style(layout, font_style):
612 split = layout.split()
615 col.label(text="Kerning Style:")
616 col.row().prop(font_style, "font_kerning_style", expand=True)
617 col.prop(font_style, "points")
620 col.label(text="Shadow Offset:")
621 col.prop(font_style, "shadow_offset_x", text="X")
622 col.prop(font_style, "shadow_offset_y", text="Y")
625 col.prop(font_style, "shadow")
626 col.prop(font_style, "shadow_alpha")
627 col.prop(font_style, "shadow_value")
632 def poll(cls, context):
633 userpref = context.user_preferences
634 return (userpref.active_section == 'THEMES')
636 def draw(self, context):
639 theme = context.user_preferences.themes[0]
641 split_themes = layout.split(factor=0.2)
643 sub = split_themes.column()
645 sub.label(text="Presets:")
646 subrow = sub.row(align=True)
648 subrow.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
649 subrow.operator("wm.interface_theme_preset_add", text="", icon='ADD')
650 subrow.operator("wm.interface_theme_preset_add", text="", icon='REMOVE').remove_active = True
653 sub.prop(theme, "theme_area", expand=True)
655 split = layout.split(factor=0.4)
660 split = split_themes.split()
662 if theme.theme_area == 'USER_INTERFACE':
664 ui = theme.user_interface
666 col.label(text="Regular:")
667 self._theme_widget_style(col, ui.wcol_regular)
669 col.label(text="Tool:")
670 self._theme_widget_style(col, ui.wcol_tool)
672 col.label(text="Toolbar Item:")
673 self._theme_widget_style(col, ui.wcol_toolbar_item)
675 col.label(text="Radio Buttons:")
676 self._theme_widget_style(col, ui.wcol_radio)
678 col.label(text="Text:")
679 self._theme_widget_style(col, ui.wcol_text)
681 col.label(text="Option:")
682 self._theme_widget_style(col, ui.wcol_option)
684 col.label(text="Toggle:")
685 self._theme_widget_style(col, ui.wcol_toggle)
687 col.label(text="Number Field:")
688 self._theme_widget_style(col, ui.wcol_num)
690 col.label(text="Value Slider:")
691 self._theme_widget_style(col, ui.wcol_numslider)
693 col.label(text="Box:")
694 self._theme_widget_style(col, ui.wcol_box)
696 col.label(text="Menu:")
697 self._theme_widget_style(col, ui.wcol_menu)
699 col.label(text="Pie Menu:")
700 self._theme_widget_style(col, ui.wcol_pie_menu)
702 col.label(text="Pulldown:")
703 self._theme_widget_style(col, ui.wcol_pulldown)
705 col.label(text="Menu Back:")
706 self._theme_widget_style(col, ui.wcol_menu_back)
708 col.label(text="Tooltip:")
709 self._theme_widget_style(col, ui.wcol_tooltip)
711 col.label(text="Menu Item:")
712 self._theme_widget_style(col, ui.wcol_menu_item)
714 col.label(text="Scroll Bar:")
715 self._theme_widget_style(col, ui.wcol_scroll)
717 col.label(text="Progress Bar:")
718 self._theme_widget_style(col, ui.wcol_progress)
720 col.label(text="List Item:")
721 self._theme_widget_style(col, ui.wcol_list_item)
723 col.label(text="Tab:")
724 self._theme_widget_style(col, ui.wcol_tab)
726 ui_state = theme.user_interface.wcol_state
727 col.label(text="State:")
731 subsplit = row.split(factor=0.95)
733 padding = subsplit.split(factor=0.15)
734 colsub = padding.column()
735 colsub = padding.column()
736 colsub.row().prop(ui_state, "inner_anim")
737 colsub.row().prop(ui_state, "inner_anim_sel")
738 colsub.row().prop(ui_state, "inner_driven")
739 colsub.row().prop(ui_state, "inner_driven_sel")
740 colsub.row().prop(ui_state, "blend")
742 subsplit = row.split(factor=0.85)
744 padding = subsplit.split(factor=0.15)
745 colsub = padding.column()
746 colsub = padding.column()
747 colsub.row().prop(ui_state, "inner_key")
748 colsub.row().prop(ui_state, "inner_key_sel")
749 colsub.row().prop(ui_state, "inner_overridden")
750 colsub.row().prop(ui_state, "inner_overridden_sel")
755 col.label(text="Styles:")
759 subsplit = row.split(factor=0.95)
761 padding = subsplit.split(factor=0.15)
762 colsub = padding.column()
763 colsub = padding.column()
764 colsub.row().prop(ui, "menu_shadow_fac")
765 colsub.row().prop(ui, "icon_alpha")
766 colsub.row().prop(ui, "icon_saturation")
767 colsub.row().prop(ui, "editor_outline")
769 subsplit = row.split(factor=0.85)
771 padding = subsplit.split(factor=0.15)
772 colsub = padding.column()
773 colsub = padding.column()
774 colsub.row().prop(ui, "menu_shadow_width")
775 colsub.row().prop(ui, "widget_emboss")
780 col.label(text="Axis & Gizmo Colors:")
784 subsplit = row.split(factor=0.95)
786 padding = subsplit.split(factor=0.15)
787 colsub = padding.column()
788 colsub = padding.column()
789 colsub.row().prop(ui, "axis_x")
790 colsub.row().prop(ui, "axis_y")
791 colsub.row().prop(ui, "axis_z")
793 subsplit = row.split(factor=0.85)
795 padding = subsplit.split(factor=0.15)
796 colsub = padding.column()
797 colsub = padding.column()
798 colsub.row().prop(ui, "gizmo_primary")
799 colsub.row().prop(ui, "gizmo_secondary")
800 colsub.row().prop(ui, "gizmo_a")
801 colsub.row().prop(ui, "gizmo_b")
806 col.label(text="Icon Colors:")
810 subsplit = row.split(factor=0.95)
812 padding = subsplit.split(factor=0.15)
813 colsub = padding.column()
814 colsub = padding.column()
815 colsub.row().prop(ui, "icon_collection")
816 colsub.row().prop(ui, "icon_object")
817 colsub.row().prop(ui, "icon_object_data")
819 subsplit = row.split(factor=0.85)
821 padding = subsplit.split(factor=0.15)
822 colsub = padding.column()
823 colsub = padding.column()
824 colsub.row().prop(ui, "icon_modifier")
825 colsub.row().prop(ui, "icon_shading")
829 elif theme.theme_area == 'BONE_COLOR_SETS':
832 for i, ui in enumerate(theme.bone_color_sets, 1):
833 col.label(text=iface_(f"Color Set {i:d}"), translate=False)
837 subsplit = row.split(factor=0.95)
839 padding = subsplit.split(factor=0.15)
840 colsub = padding.column()
841 colsub = padding.column()
842 colsub.row().prop(ui, "normal")
843 colsub.row().prop(ui, "select")
844 colsub.row().prop(ui, "active")
846 subsplit = row.split(factor=0.85)
848 padding = subsplit.split(factor=0.15)
849 colsub = padding.column()
850 colsub = padding.column()
851 colsub.row().prop(ui, "show_colored_constraints")
852 elif theme.theme_area == 'STYLE':
855 style = context.user_preferences.ui_styles[0]
857 col.label(text="Panel Title:")
858 self._ui_font_style(col, style.panel_title)
862 col.label(text="Widget:")
863 self._ui_font_style(col, style.widget)
867 col.label(text="Widget Label:")
868 self._ui_font_style(col, style.widget_label)
870 self._theme_generic(split, getattr(theme, theme.theme_area.lower()), theme.theme_area)
873 class USERPREF_PT_file(Panel):
874 bl_space_type = 'USER_PREFERENCES'
876 bl_region_type = 'WINDOW'
877 bl_options = {'HIDE_HEADER'}
880 def poll(cls, context):
881 userpref = context.user_preferences
882 return (userpref.active_section == 'FILES')
884 def draw(self, context):
887 userpref = context.user_preferences
888 paths = userpref.filepaths
889 system = userpref.system
891 split = layout.split(factor=0.7)
894 col.label(text="File Paths:")
896 colsplit = col.split(factor=0.95)
897 col1 = colsplit.split(factor=0.3)
900 sub.label(text="Fonts:")
901 sub.label(text="Textures:")
902 sub.label(text="Render Output:")
903 sub.label(text="Scripts:")
904 sub.label(text="Sounds:")
905 sub.label(text="Temp:")
906 sub.label(text="Render Cache:")
907 sub.label(text="I18n Branches:")
908 sub.label(text="Image Editor:")
909 sub.label(text="Animation Player:")
912 sub.prop(paths, "font_directory", text="")
913 sub.prop(paths, "texture_directory", text="")
914 sub.prop(paths, "render_output_directory", text="")
915 sub.prop(paths, "script_directory", text="")
916 sub.prop(paths, "sound_directory", text="")
917 sub.prop(paths, "temporary_directory", text="")
918 sub.prop(paths, "render_cache_directory", text="")
919 sub.prop(paths, "i18n_branches_directory", text="")
920 sub.prop(paths, "image_editor", text="")
921 subsplit = sub.split(factor=0.3)
922 subsplit.prop(paths, "animation_player_preset", text="")
923 subsplit.prop(paths, "animation_player", text="")
928 colsplit = col.split(factor=0.95)
929 sub = colsplit.column()
931 row = sub.split(factor=0.3)
932 row.label(text="Auto Execution:")
933 row.prop(system, "use_scripts_auto_execute")
935 if system.use_scripts_auto_execute:
938 row.label(text="Excluded Paths:")
939 row.operator("wm.userpref_autoexec_path_add", text="", icon='ADD', emboss=False)
940 for i, path_cmp in enumerate(userpref.autoexec_paths):
942 row.prop(path_cmp, "path", text="")
943 row.prop(path_cmp, "use_glob", text="", icon='FILTER')
944 row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i
947 col.label(text="Save & Load:")
948 col.prop(paths, "use_relative_paths")
949 col.prop(paths, "use_file_compression")
950 col.prop(paths, "use_load_ui")
951 col.prop(paths, "use_filter_files")
952 col.prop(paths, "show_hidden_files_datablocks")
953 col.prop(paths, "hide_recent_locations")
954 col.prop(paths, "hide_system_bookmarks")
955 col.prop(paths, "show_thumbnails")
959 col.prop(paths, "save_version")
960 col.prop(paths, "recent_files")
961 col.prop(paths, "use_save_preview_images")
965 col.label(text="Auto Save:")
966 col.prop(paths, "use_keep_session")
967 col.prop(paths, "use_auto_save_temporary_files")
969 sub.active = paths.use_auto_save_temporary_files
970 sub.prop(paths, "auto_save_time", text="Timer (mins)")
974 col.label(text="Text Editor:")
975 col.prop(system, "use_tabs_as_spaces")
977 colsplit = col.split(factor=0.95)
978 col1 = colsplit.split(factor=0.3)
981 sub.label(text="Author:")
983 sub.prop(system, "author", text="")
986 class USERPREF_MT_ndof_settings(Menu):
987 # accessed from the window key-bindings in C (only)
988 bl_label = "3D Mouse Settings"
990 def draw(self, context):
993 input_prefs = context.user_preferences.inputs
995 is_view3d = context.space_data.type == 'VIEW_3D'
997 layout.prop(input_prefs, "ndof_sensitivity")
998 layout.prop(input_prefs, "ndof_orbit_sensitivity")
999 layout.prop(input_prefs, "ndof_deadzone")
1003 layout.prop(input_prefs, "ndof_show_guide")
1006 layout.label(text="Orbit Style")
1007 layout.row().prop(input_prefs, "ndof_view_navigate_method", text="")
1008 layout.row().prop(input_prefs, "ndof_view_rotate_method", text="")
1010 layout.label(text="Orbit Options")
1011 layout.prop(input_prefs, "ndof_rotx_invert_axis")
1012 layout.prop(input_prefs, "ndof_roty_invert_axis")
1013 layout.prop(input_prefs, "ndof_rotz_invert_axis")
1015 # view2d use pan/zoom
1017 layout.label(text="Pan Options")
1018 layout.prop(input_prefs, "ndof_panx_invert_axis")
1019 layout.prop(input_prefs, "ndof_pany_invert_axis")
1020 layout.prop(input_prefs, "ndof_panz_invert_axis")
1021 layout.prop(input_prefs, "ndof_pan_yz_swap_axis")
1023 layout.label(text="Zoom Options")
1024 layout.prop(input_prefs, "ndof_zoom_invert")
1028 layout.label(text="Fly/Walk Options")
1029 layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
1030 layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
1033 class USERPREF_MT_keyconfigs(Menu):
1034 bl_label = "KeyPresets"
1035 preset_subdir = "keyconfig"
1036 preset_operator = "wm.keyconfig_activate"
1038 def draw(self, context):
1039 Menu.draw_preset(self, context)
1042 class USERPREF_PT_input(Panel):
1043 bl_space_type = 'USER_PREFERENCES'
1045 bl_region_type = 'WINDOW'
1046 bl_options = {'HIDE_HEADER'}
1049 def poll(cls, context):
1050 userpref = context.user_preferences
1051 return (userpref.active_section == 'INPUT')
1054 def draw_input_prefs_keyconfig(context, layout):
1055 kc = context.window_manager.keyconfigs.active
1056 kc_prefs = kc.preferences
1057 if kc_prefs is not None:
1059 box.label(text=kc.name.replace("_", " ").title() + " Keymap")
1060 # Defined by user preset, may contain mistakes out of our control.
1065 traceback.print_exc()
1068 def draw_input_prefs(inputs, layout):
1072 sub = layout.column()
1074 sub.label(text="Mouse:")
1075 sub.prop(inputs, "use_mouse_emulate_3_button")
1076 sub.prop(inputs, "use_mouse_continuous")
1077 sub.prop(inputs, "drag_threshold")
1078 sub.prop(inputs, "tweak_threshold")
1080 sub = layout.column()
1081 sub.label(text="Double Click:")
1082 sub.prop(inputs, "mouse_double_click_time", text="Speed")
1086 sub.prop(inputs, "use_emulate_numpad")
1090 sub.label(text="Orbit Style:")
1091 sub.row().prop(inputs, "view_rotate_method", expand=True)
1095 sub.label(text="Zoom Style:")
1096 sub.row().prop(inputs, "view_zoom_method", text="")
1097 if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
1098 sub.row().prop(inputs, "view_zoom_axis", expand=True)
1099 sub.prop(inputs, "invert_mouse_zoom", text="Invert Mouse Zoom Direction")
1101 #sub.prop(inputs, "use_mouse_mmb_paste")
1103 # layout.separator()
1105 sub = layout.column()
1106 sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
1107 #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
1109 if sys.platform == "darwin":
1110 sub = layout.column()
1111 sub.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
1114 sub = layout.column()
1115 sub.label(text="View Navigation:")
1116 sub.row().prop(inputs, "navigation_mode", expand=True)
1118 sub.label(text="Walk Navigation:")
1120 walk = inputs.walk_navigation
1122 sub.prop(walk, "use_mouse_reverse")
1123 sub.prop(walk, "mouse_speed")
1124 sub.prop(walk, "teleport_time")
1126 sub = layout.column(align=True)
1127 sub.prop(walk, "walk_speed")
1128 sub.prop(walk, "walk_speed_factor")
1131 sub.prop(walk, "use_gravity")
1132 sub = layout.column(align=True)
1133 sub.active = walk.use_gravity
1134 sub.prop(walk, "view_height")
1135 sub.prop(walk, "jump_height")
1139 layout.label(text="NDOF Device:")
1140 sub = layout.column(align=True)
1141 sub.prop(inputs, "ndof_sensitivity", text="Pan Sensitivity")
1142 sub.prop(inputs, "ndof_orbit_sensitivity", text="Orbit Sensitivity")
1143 sub.prop(inputs, "ndof_deadzone", text="Deadzone")
1146 layout.label(text="Navigation Style:")
1147 sub = layout.column(align=True)
1148 sub.row().prop(inputs, "ndof_view_navigate_method", expand=True)
1151 layout.label(text="Rotation Style:")
1152 sub = layout.column(align=True)
1153 sub.row().prop(inputs, "ndof_view_rotate_method", expand=True)
1155 def draw(self, context):
1156 from rna_keymap_ui import draw_keymaps
1158 layout = self.layout
1162 #start = time.time()
1164 userpref = context.user_preferences
1166 inputs = userpref.inputs
1168 split = layout.split(factor=0.25)
1174 self.draw_input_prefs(inputs, col)
1176 # When the keyconfig defines it's own preferences.
1177 self.draw_input_prefs_keyconfig(context, col)
1182 draw_keymaps(context, split)
1184 #print("runtime", time.time() - start)
1187 class USERPREF_MT_addons_online_resources(Menu):
1188 bl_label = "Online Resources"
1190 # menu to open web-pages with addons development guides
1191 def draw(self, context):
1192 layout = self.layout
1195 "wm.url_open", text="Add-ons Catalog", icon='URL',
1196 ).url = "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts"
1201 "wm.url_open", text="How to share your add-on", icon='URL',
1202 ).url = "http://wiki.blender.org/index.php/Dev:Py/Sharing"
1204 "wm.url_open", text="Add-on Guidelines", icon='URL',
1205 ).url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons"
1207 "wm.url_open", text="API Concepts", icon='URL',
1208 ).url = bpy.types.WM_OT_doc_view._prefix + "/info_quickstart.html"
1210 "wm.url_open", text="Add-on Tutorial", icon='URL',
1211 ).url = bpy.types.WM_OT_doc_view._prefix + "/info_tutorial_addon.html"
1214 class USERPREF_PT_addons(Panel):
1215 bl_space_type = 'USER_PREFERENCES'
1216 bl_label = "Add-ons"
1217 bl_region_type = 'WINDOW'
1218 bl_options = {'HIDE_HEADER'}
1220 _support_icon_mapping = {
1221 'OFFICIAL': 'FILE_BLEND',
1222 'COMMUNITY': 'POSE_DATA',
1223 'TESTING': 'MOD_EXPLODE',
1227 def poll(cls, context):
1228 userpref = context.user_preferences
1229 return (userpref.active_section == 'ADDONS')
1232 def is_user_addon(mod, user_addon_paths):
1235 if not user_addon_paths:
1237 bpy.utils.script_path_user(),
1238 bpy.utils.script_path_pref(),
1240 if path is not None:
1241 user_addon_paths.append(os.path.join(path, "addons"))
1243 for path in user_addon_paths:
1244 if bpy.path.is_subdir(mod.__file__, path):
1249 def draw_error(layout, message):
1250 lines = message.split("\n")
1253 sub.label(text=lines[0])
1254 sub.label(icon='ERROR')
1258 def draw(self, context):
1262 layout = self.layout
1264 userpref = context.user_preferences
1265 used_ext = {ext.module for ext in userpref.addons}
1267 addon_user_dirs = tuple(
1269 os.path.join(userpref.filepaths.script_directory, "addons"),
1270 bpy.utils.user_resource('SCRIPTS', "addons"),
1275 # Development option for 2.8x, don't show users bundled addons
1276 # unless they have been updated for 2.8x.
1277 # Developers can turn them on with '--debug'
1278 show_official_27x_addons = bpy.app.debug
1280 # collect the categories that can be filtered on
1282 (mod, addon_utils.module_bl_info(mod))
1283 for mod in addon_utils.modules(refresh=False)
1286 split = layout.split(factor=0.2)
1287 col = split.column()
1288 col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
1290 col.label(text="Supported Level")
1291 col.prop(context.window_manager, "addon_support", expand=True)
1293 col.label(text="Categories")
1294 col.prop(context.window_manager, "addon_filter", expand=True)
1296 col = split.column()
1298 # set in addon_utils.modules_refresh()
1299 if addon_utils.error_duplicates:
1302 row.label(text="Multiple add-ons with the same name found!")
1303 row.label(icon='ERROR')
1304 box.label(text="Delete one of each pair to resolve:")
1305 for (addon_name, addon_file, addon_path) in addon_utils.error_duplicates:
1307 sub_col = box.column(align=True)
1308 sub_col.label(text=addon_name + ":")
1309 sub_col.label(text=" " + addon_file)
1310 sub_col.label(text=" " + addon_path)
1312 if addon_utils.error_encoding:
1315 "One or more addons do not have UTF-8 encoding\n"
1316 "(see console for details)",
1319 filter = context.window_manager.addon_filter
1320 search = context.window_manager.addon_search.lower()
1321 support = context.window_manager.addon_support
1323 # initialized on demand
1324 user_addon_paths = []
1326 for mod, info in addons:
1327 module_name = mod.__name__
1329 is_enabled = module_name in used_ext
1331 if info["support"] not in support:
1334 # check if addon should be visible with current filters
1336 (filter == "All") or
1337 (filter == info["category"]) or
1338 (filter == "Enabled" and is_enabled) or
1339 (filter == "Disabled" and not is_enabled) or
1340 (filter == "User" and (mod.__file__.startswith(addon_user_dirs)))
1342 if search and search not in info["name"].lower():
1344 if search not in info["author"].lower():
1349 # Skip 2.7x add-ons included with Blender, unless in debug mode.
1350 is_addon_27x = info.get("blender", (0,)) < (2, 80)
1353 (not show_official_27x_addons) and
1354 (not mod.__file__.startswith(addon_user_dirs))
1359 col_box = col.column()
1361 colsub = box.column()
1362 row = colsub.row(align=True)
1366 icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT',
1368 ).module = module_name
1371 "wm.addon_disable" if is_enabled else "wm.addon_enable",
1372 icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
1374 ).module = module_name
1377 sub.active = is_enabled
1378 sub.label(text="%s: %s" % (info["category"], info["name"]))
1380 # WARNING: 2.8x exception, may be removed
1381 # use disabled state for old add-ons, chances are they are broken.
1383 sub.label(text="upgrade to 2.8x required")
1384 sub.label(icon='ERROR')
1385 # Remove code above after 2.8x migration is complete.
1386 elif info["warning"]:
1387 sub.label(icon='ERROR')
1389 # icon showing support level.
1390 sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
1392 # Expanded UI (only if additional info is available)
1393 if info["show_expanded"]:
1394 if info["description"]:
1395 split = colsub.row().split(factor=0.15)
1396 split.label(text="Description:")
1397 split.label(text=info["description"])
1398 if info["location"]:
1399 split = colsub.row().split(factor=0.15)
1400 split.label(text="Location:")
1401 split.label(text=info["location"])
1403 split = colsub.row().split(factor=0.15)
1404 split.label(text="File:")
1405 split.label(text=mod.__file__, translate=False)
1407 split = colsub.row().split(factor=0.15)
1408 split.label(text="Author:")
1409 split.label(text=info["author"], translate=False)
1411 split = colsub.row().split(factor=0.15)
1412 split.label(text="Version:")
1413 split.label(text=".".join(str(x) for x in info["version"]), translate=False)
1415 split = colsub.row().split(factor=0.15)
1416 split.label(text="Warning:")
1417 split.label(text=" " + info["warning"], icon='ERROR')
1419 user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
1420 tot_row = bool(info["wiki_url"]) + bool(user_addon)
1423 split = colsub.row().split(factor=0.15)
1424 split.label(text="Internet:")
1425 if info["wiki_url"]:
1427 "wm.url_open", text="Documentation", icon='HELP',
1428 ).url = info["wiki_url"]
1429 # Only add "Report a Bug" button if tracker_url is set
1430 # or the add-on is bundled (use official tracker then).
1431 if info.get("tracker_url") or not user_addon:
1433 "wm.url_open", text="Report a Bug", icon='URL',
1436 "https://developer.blender.org/maniphest/task/edit/form/2",
1440 "wm.addon_remove", text="Remove", icon='CANCEL',
1441 ).module = mod.__name__
1443 for _ in range(4 - tot_row):
1446 # Show addon user preferences
1448 addon_preferences = userpref.addons[module_name].preferences
1449 if addon_preferences is not None:
1450 draw = getattr(addon_preferences, "draw", None)
1451 if draw is not None:
1452 addon_preferences_class = type(addon_preferences)
1453 box_prefs = col_box.box()
1454 box_prefs.label(text="Preferences:")
1455 addon_preferences_class.layout = box_prefs
1460 traceback.print_exc()
1461 box_prefs.label(text="Error (see console)", icon='ERROR')
1462 del addon_preferences_class.layout
1464 # Append missing scripts
1465 # First collect scripts that are used but have no script file.
1466 module_names = {mod.__name__ for mod, info in addons}
1467 missing_modules = {ext for ext in used_ext if ext not in module_names}
1469 if missing_modules and filter in {"All", "Enabled"}:
1470 col.column().separator()
1471 col.column().label(text="Missing script files")
1473 module_names = {mod.__name__ for mod, info in addons}
1474 for module_name in sorted(missing_modules):
1475 is_enabled = module_name in used_ext
1477 box = col.column().box()
1478 colsub = box.column()
1479 row = colsub.row(align=True)
1481 row.label(text="", icon='ERROR')
1485 "wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False,
1486 ).module = module_name
1488 row.label(text=module_name, translate=False)
1491 class StudioLightPanelMixin():
1492 bl_space_type = 'USER_PREFERENCES'
1493 bl_region_type = 'WINDOW'
1496 def poll(cls, context):
1497 userpref = context.user_preferences
1498 return (userpref.active_section == 'LIGHTS')
1500 def _get_lights(self, userpref):
1501 return [light for light in userpref.studio_lights if light.is_user_defined and light.orientation == self.sl_orientation]
1503 def draw(self, context):
1504 layout = self.layout
1505 userpref = context.user_preferences
1506 lights = self._get_lights(userpref)
1508 flow = layout.column_flow(columns=4)
1509 for studio_light in lights:
1510 self.draw_studio_light(flow, studio_light)
1512 layout.label(text="No custom {} configured".format(self.bl_label))
1514 def draw_studio_light(self, layout, studio_light):
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
1522 box.label(text=studio_light.name)
1525 class USERPREF_PT_studiolight_matcaps(Panel, StudioLightPanelMixin):
1526 bl_label = "MatCaps"
1527 sl_orientation = 'MATCAP'
1530 class USERPREF_PT_studiolight_world(Panel, StudioLightPanelMixin):
1531 bl_label = "World HDRI"
1532 sl_orientation = 'WORLD'
1535 class USERPREF_PT_studiolight_camera(Panel, StudioLightPanelMixin):
1536 bl_label = "Camera HDRI"
1537 sl_orientation = 'CAMERA'
1540 class USERPREF_PT_studiolight_specular(Panel, StudioLightPanelMixin):
1541 bl_label = "Specular Lights"
1542 sl_orientation = 'CAMERA'
1545 def poll(cls, context):
1546 userpref = context.user_preferences
1547 return (userpref.active_section == 'LIGHTS')
1549 def opengl_light_buttons(self, column, light):
1550 split = column.split()
1552 col = split.column()
1553 col.prop(light, "use", text="Use", icon='OUTLINER_OB_LIGHT' if light.use else 'LIGHT_DATA')
1556 sub.active = light.use
1557 sub.prop(light, "specular_color")
1559 col = split.column()
1560 col.active = light.use
1561 col.prop(light, "direction", text="")
1563 def draw(self, context):
1564 layout = self.layout
1565 column = layout.split()
1567 userpref = context.user_preferences
1568 system = userpref.system
1570 light = system.solid_lights[0]
1571 colsplit = column.split(factor=0.85)
1572 self.opengl_light_buttons(colsplit, light)
1574 light = system.solid_lights[1]
1575 colsplit = column.split(factor=0.85)
1576 self.opengl_light_buttons(colsplit, light)
1578 light = system.solid_lights[2]
1579 self.opengl_light_buttons(column, light)
1585 USERPREF_PT_interface,
1588 USERPREF_MT_interface_theme_presets,
1591 USERPREF_MT_ndof_settings,
1592 USERPREF_MT_keyconfigs,
1594 USERPREF_MT_addons_online_resources,
1596 USERPREF_PT_studiolight_matcaps,
1597 USERPREF_PT_studiolight_world,
1598 USERPREF_PT_studiolight_camera,
1599 USERPREF_PT_studiolight_specular,
1602 if __name__ == "__main__": # only for live edit.
1603 from bpy.utils import register_class