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_MT_interaction_presets(Menu):
78 preset_subdir = "interaction"
79 preset_operator = "script.execute_preset"
80 draw = Menu.draw_preset
83 class USERPREF_MT_appconfigs(Menu):
84 bl_label = "AppPresets"
85 preset_subdir = "keyconfig"
86 preset_operator = "wm.appconfig_activate"
88 def draw(self, context):
89 self.layout.operator("wm.appconfig_default", text="Blender (default)")
91 # now draw the presets
92 Menu.draw_preset(self, context)
95 class USERPREF_PT_interface(Panel):
96 bl_space_type = 'USER_PREFERENCES'
97 bl_label = "Interface"
98 bl_region_type = 'WINDOW'
99 bl_options = {'HIDE_HEADER'}
102 def poll(cls, context):
103 userpref = context.user_preferences
104 return (userpref.active_section == 'INTERFACE')
106 def draw(self, context):
109 userpref = context.user_preferences
112 split = layout.split()
116 col.label(text="Display:")
117 col.prop(view, "ui_scale", text="Scale")
118 col.prop(view, "ui_line_width", text="Line Width")
119 col.prop(view, "show_tooltips")
120 col.prop(view, "show_object_info", text="Object Info")
121 col.prop(view, "show_large_cursors")
122 col.prop(view, "show_view_name", text="View Name")
123 col.prop(view, "show_playback_fps", text="Playback FPS")
124 col.prop(view, "object_origin_size")
128 # col.prop(view, "show_gizmo_navigate")
130 sub = col.column(align=True)
132 sub.label(text="3D Viewport Axis:")
133 sub.row().prop(view, "mini_axis_type", text="")
135 sub = col.column(align=True)
136 sub.active = view.mini_axis_type == 'MINIMAL'
137 sub.prop(view, "mini_axis_size", text="Size")
138 sub.prop(view, "mini_axis_brightness", text="Brightness")
142 # Toolbox doesn't exist yet
143 # col.label(text="Toolbox:")
144 #col.prop(view, "show_column_layout")
145 #col.label(text="Open Toolbox Delay:")
146 #col.prop(view, "open_left_mouse_delay", text="Hold LMB")
147 #col.prop(view, "open_right_mouse_delay", text="Hold RMB")
148 col.prop(view, "show_gizmo", text="Gizmos")
150 sub.active = view.show_gizmo
151 sub.prop(view, "gizmo_size", text="Size")
155 col.label(text="Development:")
156 col.prop(view, "show_tooltips_python")
157 col.prop(view, "show_developer_ui")
163 col.label(text="View Gizmos:")
164 col.prop(view, "use_mouse_depth_cursor")
165 col.prop(view, "use_cursor_lock_adjust")
166 col.prop(view, "use_mouse_depth_navigate")
167 col.prop(view, "use_zoom_to_mouse")
168 col.prop(view, "use_rotate_around_active")
169 col.prop(view, "use_camera_lock_parent")
173 col.prop(view, "use_auto_perspective")
174 col.prop(view, "smooth_view")
175 col.prop(view, "rotation_angle")
180 col.label(text="2D Viewports:")
181 col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
182 col.prop(view, "timecode_style")
183 col.prop(view, "view_frame_type")
184 if view.view_frame_type == 'SECONDS':
185 col.prop(view, "view_frame_seconds")
186 elif view.view_frame_type == 'KEYFRAMES':
187 col.prop(view, "view_frame_keyframes")
193 col.label(text="Menus:")
194 col.prop(view, "use_mouse_over_open")
196 sub.active = view.use_mouse_over_open
198 sub.prop(view, "open_toplevel_delay", text="Top Level")
199 sub.prop(view, "open_sublevel_delay", text="Sub Level")
202 col.label(text="Pie Menus:")
203 sub = col.column(align=True)
204 sub.prop(view, "pie_animation_timeout")
205 sub.prop(view, "pie_initial_timeout")
206 sub.prop(view, "pie_menu_radius")
207 sub.prop(view, "pie_menu_threshold")
208 sub.prop(view, "pie_menu_confirm")
211 col.prop(view, "show_splash")
213 col.label(text="Warnings:")
214 col.prop(view, "use_quit_dialog")
218 col.label(text="App Template:")
219 col.label(text="Options intended for use with app-templates only.")
220 col.prop(view, "show_layout_ui")
221 col.prop(view, "show_view3d_cursor")
224 class USERPREF_PT_edit(Panel):
225 bl_space_type = 'USER_PREFERENCES'
227 bl_region_type = 'WINDOW'
228 bl_options = {'HIDE_HEADER'}
231 def poll(cls, context):
232 userpref = context.user_preferences
233 return (userpref.active_section == 'EDITING')
235 def draw(self, context):
238 userpref = context.user_preferences
241 split = layout.split()
245 col.label(text="Link Materials To:")
246 col.prop(edit, "material_link", text="")
252 col.label(text="New Objects:")
253 col.prop(edit, "use_enter_edit_mode")
254 col.label(text="Align To:")
255 col.prop(edit, "object_align", text="")
261 col.label(text="Undo:")
262 col.prop(edit, "use_global_undo")
263 col.prop(edit, "undo_steps", text="Steps")
264 col.prop(edit, "undo_memory_limit", text="Memory Limit")
270 col.label(text="Grease Pencil/Annotations:")
272 col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
273 col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
276 col.label(text="Annotations:")
278 sub.prop(edit, "grease_pencil_default_color", text="Default Color")
279 col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
281 col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
287 col.label(text="Playback:")
288 col.prop(edit, "use_negative_frames")
290 col.label(text="Node Editor:")
291 col.prop(edit, "node_margin")
292 col.label(text="Animation Editors:")
293 col.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
299 col.label(text="Keyframing:")
300 col.prop(edit, "use_visual_keying")
301 col.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed")
305 col.prop(edit, "use_auto_keying", text="Auto Keyframing:")
306 col.prop(edit, "use_auto_keying_warning")
310 # ~ sub.active = edit.use_keyframe_insert_auto # incorrect, time-line can enable
311 sub.prop(edit, "use_keyframe_insert_available", text="Only Insert Available")
315 col.label(text="New F-Curve Defaults:")
316 col.prop(edit, "keyframe_new_interpolation_type", text="Interpolation")
317 col.prop(edit, "keyframe_new_handle_type", text="Handles")
318 col.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
324 col.label(text="Transform:")
325 col.prop(edit, "use_drag_immediately")
326 col.prop(edit, "use_numeric_input_advanced")
332 col.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
338 col.label(text="Duplicate Data:")
339 col.prop(edit, "use_duplicate_mesh", text="Mesh")
340 col.prop(edit, "use_duplicate_surface", text="Surface")
341 col.prop(edit, "use_duplicate_curve", text="Curve")
342 col.prop(edit, "use_duplicate_text", text="Text")
343 col.prop(edit, "use_duplicate_metaball", text="Metaball")
344 col.prop(edit, "use_duplicate_armature", text="Armature")
345 col.prop(edit, "use_duplicate_light", text="Light")
346 col.prop(edit, "use_duplicate_material", text="Material")
347 col.prop(edit, "use_duplicate_texture", text="Texture")
348 #col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
349 col.prop(edit, "use_duplicate_action", text="Action")
350 col.prop(edit, "use_duplicate_particle", text="Particle")
353 class USERPREF_PT_system(Panel):
354 bl_space_type = 'USER_PREFERENCES'
356 bl_region_type = 'WINDOW'
357 bl_options = {'HIDE_HEADER'}
360 def poll(cls, context):
361 userpref = context.user_preferences
362 return (userpref.active_section == 'SYSTEM')
364 def draw(self, context):
368 userpref = context.user_preferences
369 system = userpref.system
371 split = layout.split()
374 column = split.column()
375 colsplit = column.split(factor=0.85)
377 col = colsplit.column()
378 col.label(text="General:")
380 col.prop(system, "scrollback", text="Console Scrollback")
384 col.label(text="Sound:")
385 col.row().prop(system, "audio_device", expand=False)
387 sub.active = system.audio_device not in {'NONE', 'Null'}
388 #sub.prop(system, "use_preview_images")
389 sub.prop(system, "audio_channels", text="Channels")
390 sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
391 sub.prop(system, "audio_sample_rate", text="Sample Rate")
392 sub.prop(system, "audio_sample_format", text="Sample Format")
396 if bpy.app.build_options.cycles:
397 addon = userpref.addons.get("cycles")
398 if addon is not None:
399 addon.preferences.draw_impl(col, context)
402 if hasattr(system, "opensubdiv_compute_type"):
403 col.label(text="OpenSubdiv compute:")
404 col.row().prop(system, "opensubdiv_compute_type", text="")
407 column = split.column()
408 colsplit = column.split(factor=0.85)
410 col = colsplit.column()
411 col.label(text="OpenGL:")
412 col.prop(system, "gl_clip_alpha", slider=True)
413 col.prop(system, "use_gpu_mipmap")
414 col.prop(system, "use_16bit_textures")
417 col.label(text="Selection:")
418 col.prop(system, "select_method", text="")
419 col.prop(system, "use_select_pick_depth")
423 col.label(text="Anisotropic Filtering:")
424 col.prop(system, "anisotropic_filter", text="")
428 col.prop(system, "multi_sample", text="")
429 if sys.platform == "linux" and system.multi_sample != 'NONE':
430 col.label(text="Might fail for Mesh editing selection!")
432 col.prop(system, "use_region_overlap")
435 col.prop(system, "gpu_viewport_quality")
438 col.label(text="Grease Pencil Options:")
439 col.prop(system, "gpencil_multi_sample", text="")
442 col.label(text="Text Draw Options:")
443 col.prop(system, "use_text_antialiasing", text="Anti-aliasing")
445 sub.active = system.use_text_antialiasing
446 sub.prop(system, "text_hinting", text="Hinting")
449 column = split.column()
451 column.label(text="Textures:")
452 column.prop(system, "gl_texture_limit", text="Limit Size")
453 column.prop(system, "texture_time_out", text="Time Out")
454 column.prop(system, "texture_collection_rate", text="Collection Rate")
458 column.label(text="Images Draw Method:")
459 column.prop(system, "image_draw_method", text="")
463 column.label(text="Sequencer/Clip Editor:")
464 # currently disabled in the code
465 # column.prop(system, "prefetch_frames")
466 column.prop(system, "memory_cache_limit")
470 column.label(text="Color Picker Type:")
471 column.row().prop(system, "color_picker_type", text="")
475 column.prop(system, "use_weight_color_range", text="Custom Weight Paint Range")
476 sub = column.column()
477 sub.active = system.use_weight_color_range
478 sub.template_color_ramp(system, "weight_color_range", expand=True)
481 column.prop(system, "font_path_ui")
482 column.prop(system, "font_path_ui_mono")
484 if bpy.app.build_options.international:
485 column.prop(system, "use_international_fonts")
486 if system.use_international_fonts:
487 column.prop(system, "language")
489 row.label(text="Translate:", text_ctxt=i18n_contexts.id_windowmanager)
490 row = column.row(align=True)
491 row.prop(system, "use_translate_interface", text="Interface", toggle=True)
492 row.prop(system, "use_translate_tooltips", text="Tooltips", toggle=True)
493 row.prop(system, "use_translate_new_dataname", text="New Data", toggle=True)
496 class USERPREF_MT_interface_theme_presets(Menu):
498 preset_subdir = "interface_theme"
499 preset_operator = "script.execute_preset"
502 ("user_preferences.themes[0]", "Theme"),
503 ("user_preferences.ui_styles[0]", "ThemeStyle"),
505 draw = Menu.draw_preset
507 def reset_cb(context):
508 bpy.ops.ui.reset_default_theme()
511 class USERPREF_PT_theme(Panel):
512 bl_space_type = 'USER_PREFERENCES'
514 bl_region_type = 'WINDOW'
515 bl_options = {'HIDE_HEADER'}
517 # not essential, hard-coded UI delimiters for the theme layout
520 "text_grease_pencil",
523 "freestyle_face_mark",
529 "handle_vertex_select",
538 "handle_vertex_select",
543 def _theme_generic(split, themedata, theme_area):
547 def theme_generic_recurse(data):
548 col.label(text=data.rna_type.name)
550 subsplit = row.split(factor=0.95)
552 padding1 = subsplit.split(factor=0.15)
555 subsplit = row.split(factor=0.85)
557 padding2 = subsplit.split(factor=0.15)
560 colsub_pair = padding1.column(), padding2.column()
564 for i, prop in enumerate(data.rna_type.properties):
565 if prop.identifier == "rna_type":
568 props_type.setdefault((prop.type, prop.subtype), []).append(prop)
570 th_delimiters = USERPREF_PT_theme.ui_delimiters.get(theme_area)
571 for props_type, props_ls in sorted(props_type.items()):
572 if props_type[0] == 'POINTER':
573 for i, prop in enumerate(props_ls):
574 theme_generic_recurse(getattr(data, prop.identifier))
576 if th_delimiters is None:
577 # simple, no delimiters
578 for i, prop in enumerate(props_ls):
579 colsub_pair[i % 2].row().prop(data, prop.identifier)
581 # add hard coded delimiters
583 for prop in props_ls:
584 colsub = colsub_pair[i]
585 colsub.row().prop(data, prop.identifier)
587 if prop.identifier in th_delimiters:
589 colsub = colsub_pair[1]
590 colsub.row().label(text="")
591 colsub_pair[0].row().label(text="")
592 colsub_pair[1].row().label(text="")
595 theme_generic_recurse(themedata)
598 def _theme_widget_style(layout, widget_style):
602 subsplit = row.split(factor=0.95)
604 padding = subsplit.split(factor=0.15)
605 colsub = padding.column()
606 colsub = padding.column()
607 colsub.row().prop(widget_style, "outline")
608 colsub.row().prop(widget_style, "item", slider=True)
609 colsub.row().prop(widget_style, "inner", slider=True)
610 colsub.row().prop(widget_style, "inner_sel", slider=True)
611 colsub.row().prop(widget_style, "roundness")
613 subsplit = row.split(factor=0.85)
615 padding = subsplit.split(factor=0.15)
616 colsub = padding.column()
617 colsub = padding.column()
618 colsub.row().prop(widget_style, "text")
619 colsub.row().prop(widget_style, "text_sel")
620 colsub.prop(widget_style, "show_shaded")
621 subsub = colsub.column(align=True)
622 subsub.active = widget_style.show_shaded
623 subsub.prop(widget_style, "shadetop")
624 subsub.prop(widget_style, "shadedown")
629 def _ui_font_style(layout, font_style):
631 split = layout.split()
634 col.label(text="Kerning Style:")
635 col.row().prop(font_style, "font_kerning_style", expand=True)
636 col.prop(font_style, "points")
639 col.label(text="Shadow Offset:")
640 col.prop(font_style, "shadow_offset_x", text="X")
641 col.prop(font_style, "shadow_offset_y", text="Y")
644 col.prop(font_style, "shadow")
645 col.prop(font_style, "shadow_alpha")
646 col.prop(font_style, "shadow_value")
651 def poll(cls, context):
652 userpref = context.user_preferences
653 return (userpref.active_section == 'THEMES')
655 def draw(self, context):
658 theme = context.user_preferences.themes[0]
660 split_themes = layout.split(factor=0.2)
662 sub = split_themes.column()
664 sub.label(text="Presets:")
665 subrow = sub.row(align=True)
667 subrow.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
668 subrow.operator("wm.interface_theme_preset_add", text="", icon='ADD')
669 subrow.operator("wm.interface_theme_preset_add", text="", icon='REMOVE').remove_active = True
672 sub.prop(theme, "theme_area", expand=True)
674 split = layout.split(factor=0.4)
679 split = split_themes.split()
681 if theme.theme_area == 'USER_INTERFACE':
683 ui = theme.user_interface
685 col.label(text="Regular:")
686 self._theme_widget_style(col, ui.wcol_regular)
688 col.label(text="Tool:")
689 self._theme_widget_style(col, ui.wcol_tool)
691 col.label(text="Toolbar Item:")
692 self._theme_widget_style(col, ui.wcol_toolbar_item)
694 col.label(text="Radio Buttons:")
695 self._theme_widget_style(col, ui.wcol_radio)
697 col.label(text="Text:")
698 self._theme_widget_style(col, ui.wcol_text)
700 col.label(text="Option:")
701 self._theme_widget_style(col, ui.wcol_option)
703 col.label(text="Toggle:")
704 self._theme_widget_style(col, ui.wcol_toggle)
706 col.label(text="Number Field:")
707 self._theme_widget_style(col, ui.wcol_num)
709 col.label(text="Value Slider:")
710 self._theme_widget_style(col, ui.wcol_numslider)
712 col.label(text="Box:")
713 self._theme_widget_style(col, ui.wcol_box)
715 col.label(text="Menu:")
716 self._theme_widget_style(col, ui.wcol_menu)
718 col.label(text="Pie Menu:")
719 self._theme_widget_style(col, ui.wcol_pie_menu)
721 col.label(text="Pulldown:")
722 self._theme_widget_style(col, ui.wcol_pulldown)
724 col.label(text="Menu Back:")
725 self._theme_widget_style(col, ui.wcol_menu_back)
727 col.label(text="Tooltip:")
728 self._theme_widget_style(col, ui.wcol_tooltip)
730 col.label(text="Menu Item:")
731 self._theme_widget_style(col, ui.wcol_menu_item)
733 col.label(text="Scroll Bar:")
734 self._theme_widget_style(col, ui.wcol_scroll)
736 col.label(text="Progress Bar:")
737 self._theme_widget_style(col, ui.wcol_progress)
739 col.label(text="List Item:")
740 self._theme_widget_style(col, ui.wcol_list_item)
742 col.label(text="Tab:")
743 self._theme_widget_style(col, ui.wcol_tab)
745 ui_state = theme.user_interface.wcol_state
746 col.label(text="State:")
750 subsplit = row.split(factor=0.95)
752 padding = subsplit.split(factor=0.15)
753 colsub = padding.column()
754 colsub = padding.column()
755 colsub.row().prop(ui_state, "inner_anim")
756 colsub.row().prop(ui_state, "inner_anim_sel")
757 colsub.row().prop(ui_state, "inner_driven")
758 colsub.row().prop(ui_state, "inner_driven_sel")
759 colsub.row().prop(ui_state, "blend")
761 subsplit = row.split(factor=0.85)
763 padding = subsplit.split(factor=0.15)
764 colsub = padding.column()
765 colsub = padding.column()
766 colsub.row().prop(ui_state, "inner_key")
767 colsub.row().prop(ui_state, "inner_key_sel")
768 colsub.row().prop(ui_state, "inner_overridden")
769 colsub.row().prop(ui_state, "inner_overridden_sel")
774 col.label(text="Styles:")
778 subsplit = row.split(factor=0.95)
780 padding = subsplit.split(factor=0.15)
781 colsub = padding.column()
782 colsub = padding.column()
783 colsub.row().prop(ui, "menu_shadow_fac")
784 colsub.row().prop(ui, "icon_alpha")
785 colsub.row().prop(ui, "icon_saturation")
786 colsub.row().prop(ui, "editor_outline")
788 subsplit = row.split(factor=0.85)
790 padding = subsplit.split(factor=0.15)
791 colsub = padding.column()
792 colsub = padding.column()
793 colsub.row().prop(ui, "menu_shadow_width")
794 colsub.row().prop(ui, "widget_emboss")
799 col.label(text="Axis & Gizmo Colors:")
803 subsplit = row.split(factor=0.95)
805 padding = subsplit.split(factor=0.15)
806 colsub = padding.column()
807 colsub = padding.column()
808 colsub.row().prop(ui, "axis_x")
809 colsub.row().prop(ui, "axis_y")
810 colsub.row().prop(ui, "axis_z")
812 subsplit = row.split(factor=0.85)
814 padding = subsplit.split(factor=0.15)
815 colsub = padding.column()
816 colsub = padding.column()
817 colsub.row().prop(ui, "gizmo_primary")
818 colsub.row().prop(ui, "gizmo_secondary")
819 colsub.row().prop(ui, "gizmo_a")
820 colsub.row().prop(ui, "gizmo_b")
825 col.label(text="Icon Colors:")
829 subsplit = row.split(factor=0.95)
831 padding = subsplit.split(factor=0.15)
832 colsub = padding.column()
833 colsub = padding.column()
834 colsub.row().prop(ui, "icon_collection")
835 colsub.row().prop(ui, "icon_object")
836 colsub.row().prop(ui, "icon_object_data")
838 subsplit = row.split(factor=0.85)
840 padding = subsplit.split(factor=0.15)
841 colsub = padding.column()
842 colsub = padding.column()
843 colsub.row().prop(ui, "icon_modifier")
844 colsub.row().prop(ui, "icon_shading")
848 elif theme.theme_area == 'BONE_COLOR_SETS':
851 for i, ui in enumerate(theme.bone_color_sets, 1):
852 col.label(text=iface_(f"Color Set {i:d}"), translate=False)
856 subsplit = row.split(factor=0.95)
858 padding = subsplit.split(factor=0.15)
859 colsub = padding.column()
860 colsub = padding.column()
861 colsub.row().prop(ui, "normal")
862 colsub.row().prop(ui, "select")
863 colsub.row().prop(ui, "active")
865 subsplit = row.split(factor=0.85)
867 padding = subsplit.split(factor=0.15)
868 colsub = padding.column()
869 colsub = padding.column()
870 colsub.row().prop(ui, "show_colored_constraints")
871 elif theme.theme_area == 'STYLE':
874 style = context.user_preferences.ui_styles[0]
876 col.label(text="Panel Title:")
877 self._ui_font_style(col, style.panel_title)
881 col.label(text="Widget:")
882 self._ui_font_style(col, style.widget)
886 col.label(text="Widget Label:")
887 self._ui_font_style(col, style.widget_label)
889 self._theme_generic(split, getattr(theme, theme.theme_area.lower()), theme.theme_area)
892 class USERPREF_PT_file(Panel):
893 bl_space_type = 'USER_PREFERENCES'
895 bl_region_type = 'WINDOW'
896 bl_options = {'HIDE_HEADER'}
899 def poll(cls, context):
900 userpref = context.user_preferences
901 return (userpref.active_section == 'FILES')
903 def draw(self, context):
906 userpref = context.user_preferences
907 paths = userpref.filepaths
908 system = userpref.system
910 split = layout.split(factor=0.7)
913 col.label(text="File Paths:")
915 colsplit = col.split(factor=0.95)
916 col1 = colsplit.split(factor=0.3)
919 sub.label(text="Fonts:")
920 sub.label(text="Textures:")
921 sub.label(text="Render Output:")
922 sub.label(text="Scripts:")
923 sub.label(text="Sounds:")
924 sub.label(text="Temp:")
925 sub.label(text="Render Cache:")
926 sub.label(text="I18n Branches:")
927 sub.label(text="Image Editor:")
928 sub.label(text="Animation Player:")
931 sub.prop(paths, "font_directory", text="")
932 sub.prop(paths, "texture_directory", text="")
933 sub.prop(paths, "render_output_directory", text="")
934 sub.prop(paths, "script_directory", text="")
935 sub.prop(paths, "sound_directory", text="")
936 sub.prop(paths, "temporary_directory", text="")
937 sub.prop(paths, "render_cache_directory", text="")
938 sub.prop(paths, "i18n_branches_directory", text="")
939 sub.prop(paths, "image_editor", text="")
940 subsplit = sub.split(factor=0.3)
941 subsplit.prop(paths, "animation_player_preset", text="")
942 subsplit.prop(paths, "animation_player", text="")
947 colsplit = col.split(factor=0.95)
948 sub = colsplit.column()
950 row = sub.split(factor=0.3)
951 row.label(text="Auto Execution:")
952 row.prop(system, "use_scripts_auto_execute")
954 if system.use_scripts_auto_execute:
957 row.label(text="Excluded Paths:")
958 row.operator("wm.userpref_autoexec_path_add", text="", icon='ADD', emboss=False)
959 for i, path_cmp in enumerate(userpref.autoexec_paths):
961 row.prop(path_cmp, "path", text="")
962 row.prop(path_cmp, "use_glob", text="", icon='FILTER')
963 row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i
966 col.label(text="Save & Load:")
967 col.prop(paths, "use_relative_paths")
968 col.prop(paths, "use_file_compression")
969 col.prop(paths, "use_load_ui")
970 col.prop(paths, "use_filter_files")
971 col.prop(paths, "show_hidden_files_datablocks")
972 col.prop(paths, "hide_recent_locations")
973 col.prop(paths, "hide_system_bookmarks")
974 col.prop(paths, "show_thumbnails")
978 col.prop(paths, "save_version")
979 col.prop(paths, "recent_files")
980 col.prop(paths, "use_save_preview_images")
984 col.label(text="Auto Save:")
985 col.prop(paths, "use_keep_session")
986 col.prop(paths, "use_auto_save_temporary_files")
988 sub.active = paths.use_auto_save_temporary_files
989 sub.prop(paths, "auto_save_time", text="Timer (mins)")
993 col.label(text="Text Editor:")
994 col.prop(system, "use_tabs_as_spaces")
996 colsplit = col.split(factor=0.95)
997 col1 = colsplit.split(factor=0.3)
1000 sub.label(text="Author:")
1002 sub.prop(system, "author", text="")
1005 class USERPREF_MT_ndof_settings(Menu):
1006 # accessed from the window key-bindings in C (only)
1007 bl_label = "3D Mouse Settings"
1009 def draw(self, context):
1010 layout = self.layout
1012 input_prefs = context.user_preferences.inputs
1014 is_view3d = context.space_data.type == 'VIEW_3D'
1016 layout.prop(input_prefs, "ndof_sensitivity")
1017 layout.prop(input_prefs, "ndof_orbit_sensitivity")
1018 layout.prop(input_prefs, "ndof_deadzone")
1022 layout.prop(input_prefs, "ndof_show_guide")
1025 layout.label(text="Orbit Style")
1026 layout.row().prop(input_prefs, "ndof_view_navigate_method", text="")
1027 layout.row().prop(input_prefs, "ndof_view_rotate_method", text="")
1029 layout.label(text="Orbit Options")
1030 layout.prop(input_prefs, "ndof_rotx_invert_axis")
1031 layout.prop(input_prefs, "ndof_roty_invert_axis")
1032 layout.prop(input_prefs, "ndof_rotz_invert_axis")
1034 # view2d use pan/zoom
1036 layout.label(text="Pan Options")
1037 layout.prop(input_prefs, "ndof_panx_invert_axis")
1038 layout.prop(input_prefs, "ndof_pany_invert_axis")
1039 layout.prop(input_prefs, "ndof_panz_invert_axis")
1040 layout.prop(input_prefs, "ndof_pan_yz_swap_axis")
1042 layout.label(text="Zoom Options")
1043 layout.prop(input_prefs, "ndof_zoom_invert")
1047 layout.label(text="Fly/Walk Options")
1048 layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
1049 layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
1052 class USERPREF_MT_keyconfigs(Menu):
1053 bl_label = "KeyPresets"
1054 preset_subdir = "keyconfig"
1055 preset_operator = "wm.keyconfig_activate"
1057 def draw(self, context):
1058 Menu.draw_preset(self, context)
1061 class USERPREF_PT_input(Panel):
1062 bl_space_type = 'USER_PREFERENCES'
1064 bl_region_type = 'WINDOW'
1065 bl_options = {'HIDE_HEADER'}
1068 def poll(cls, context):
1069 userpref = context.user_preferences
1070 return (userpref.active_section == 'INPUT')
1073 def draw_input_prefs_keyconfig(context, layout):
1074 kc = context.window_manager.keyconfigs.active
1075 kc_prefs = kc.preferences
1076 if kc_prefs is not None:
1078 box.label(text=kc.name.replace("_", " ").title() + " Keymap")
1079 # Defined by user preset, may contain mistakes out of our control.
1084 traceback.print_exc()
1087 def draw_input_prefs(inputs, layout):
1091 sub = layout.column()
1092 sub.label(text="Presets:")
1093 subrow = sub.row(align=True)
1095 subrow.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label)
1096 subrow.operator("wm.interaction_preset_add", text="", icon='ADD')
1097 subrow.operator("wm.interaction_preset_add", text="", icon='REMOVE').remove_active = True
1100 sub.label(text="Mouse:")
1101 sub.prop(inputs, "use_mouse_emulate_3_button")
1102 sub.prop(inputs, "use_mouse_continuous")
1103 sub.prop(inputs, "drag_threshold")
1104 sub.prop(inputs, "tweak_threshold")
1106 sub = layout.column()
1107 sub.label(text="Double Click:")
1108 sub.prop(inputs, "mouse_double_click_time", text="Speed")
1112 sub.prop(inputs, "use_emulate_numpad")
1116 sub.label(text="Orbit Style:")
1117 sub.row().prop(inputs, "view_rotate_method", expand=True)
1121 sub.label(text="Zoom Style:")
1122 sub.row().prop(inputs, "view_zoom_method", text="")
1123 if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
1124 sub.row().prop(inputs, "view_zoom_axis", expand=True)
1125 sub.prop(inputs, "invert_mouse_zoom", text="Invert Mouse Zoom Direction")
1127 #sub.prop(inputs, "use_mouse_mmb_paste")
1129 # layout.separator()
1131 sub = layout.column()
1132 sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
1133 #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
1135 if sys.platform == "darwin":
1136 sub = layout.column()
1137 sub.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
1140 sub = layout.column()
1141 sub.label(text="View Navigation:")
1142 sub.row().prop(inputs, "navigation_mode", expand=True)
1144 sub.label(text="Walk Navigation:")
1146 walk = inputs.walk_navigation
1148 sub.prop(walk, "use_mouse_reverse")
1149 sub.prop(walk, "mouse_speed")
1150 sub.prop(walk, "teleport_time")
1152 sub = layout.column(align=True)
1153 sub.prop(walk, "walk_speed")
1154 sub.prop(walk, "walk_speed_factor")
1157 sub.prop(walk, "use_gravity")
1158 sub = layout.column(align=True)
1159 sub.active = walk.use_gravity
1160 sub.prop(walk, "view_height")
1161 sub.prop(walk, "jump_height")
1165 layout.label(text="NDOF Device:")
1166 sub = layout.column(align=True)
1167 sub.prop(inputs, "ndof_sensitivity", text="Pan Sensitivity")
1168 sub.prop(inputs, "ndof_orbit_sensitivity", text="Orbit Sensitivity")
1169 sub.prop(inputs, "ndof_deadzone", text="Deadzone")
1172 layout.label(text="Navigation Style:")
1173 sub = layout.column(align=True)
1174 sub.row().prop(inputs, "ndof_view_navigate_method", expand=True)
1177 layout.label(text="Rotation Style:")
1178 sub = layout.column(align=True)
1179 sub.row().prop(inputs, "ndof_view_rotate_method", expand=True)
1181 def draw(self, context):
1182 from rna_keymap_ui import draw_keymaps
1184 layout = self.layout
1188 #start = time.time()
1190 userpref = context.user_preferences
1192 inputs = userpref.inputs
1194 split = layout.split(factor=0.25)
1200 self.draw_input_prefs(inputs, col)
1202 # When the keyconfig defines it's own preferences.
1203 self.draw_input_prefs_keyconfig(context, col)
1208 draw_keymaps(context, split)
1210 #print("runtime", time.time() - start)
1213 class USERPREF_MT_addons_online_resources(Menu):
1214 bl_label = "Online Resources"
1216 # menu to open web-pages with addons development guides
1217 def draw(self, context):
1218 layout = self.layout
1221 "wm.url_open", text="Add-ons Catalog", icon='URL',
1222 ).url = "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts"
1227 "wm.url_open", text="How to share your add-on", icon='URL',
1228 ).url = "http://wiki.blender.org/index.php/Dev:Py/Sharing"
1230 "wm.url_open", text="Add-on Guidelines", icon='URL',
1231 ).url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons"
1233 "wm.url_open", text="API Concepts", icon='URL',
1234 ).url = bpy.types.WM_OT_doc_view._prefix + "/info_quickstart.html"
1236 "wm.url_open", text="Add-on Tutorial", icon='URL',
1237 ).url = bpy.types.WM_OT_doc_view._prefix + "/info_tutorial_addon.html"
1240 class USERPREF_PT_addons(Panel):
1241 bl_space_type = 'USER_PREFERENCES'
1242 bl_label = "Add-ons"
1243 bl_region_type = 'WINDOW'
1244 bl_options = {'HIDE_HEADER'}
1246 _support_icon_mapping = {
1247 'OFFICIAL': 'FILE_BLEND',
1248 'COMMUNITY': 'POSE_DATA',
1249 'TESTING': 'MOD_EXPLODE',
1253 def poll(cls, context):
1254 userpref = context.user_preferences
1255 return (userpref.active_section == 'ADDONS')
1258 def is_user_addon(mod, user_addon_paths):
1261 if not user_addon_paths:
1263 bpy.utils.script_path_user(),
1264 bpy.utils.script_path_pref(),
1266 if path is not None:
1267 user_addon_paths.append(os.path.join(path, "addons"))
1269 for path in user_addon_paths:
1270 if bpy.path.is_subdir(mod.__file__, path):
1275 def draw_error(layout, message):
1276 lines = message.split("\n")
1279 sub.label(text=lines[0])
1280 sub.label(icon='ERROR')
1284 def draw(self, context):
1288 layout = self.layout
1290 userpref = context.user_preferences
1291 used_ext = {ext.module for ext in userpref.addons}
1293 addon_user_dirs = tuple(
1295 os.path.join(userpref.filepaths.script_directory, "addons"),
1296 bpy.utils.user_resource('SCRIPTS', "addons"),
1301 # Development option for 2.8x, don't show users bundled addons
1302 # unless they have been updated for 2.8x.
1303 # Developers can turn them on with '--debug'
1304 show_official_27x_addons = bpy.app.debug
1306 # collect the categories that can be filtered on
1308 (mod, addon_utils.module_bl_info(mod))
1309 for mod in addon_utils.modules(refresh=False)
1312 split = layout.split(factor=0.2)
1313 col = split.column()
1314 col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
1316 col.label(text="Supported Level")
1317 col.prop(context.window_manager, "addon_support", expand=True)
1319 col.label(text="Categories")
1320 col.prop(context.window_manager, "addon_filter", expand=True)
1322 col = split.column()
1324 # set in addon_utils.modules_refresh()
1325 if addon_utils.error_duplicates:
1328 row.label(text="Multiple add-ons with the same name found!")
1329 row.label(icon='ERROR')
1330 box.label(text="Delete one of each pair to resolve:")
1331 for (addon_name, addon_file, addon_path) in addon_utils.error_duplicates:
1333 sub_col = box.column(align=True)
1334 sub_col.label(text=addon_name + ":")
1335 sub_col.label(text=" " + addon_file)
1336 sub_col.label(text=" " + addon_path)
1338 if addon_utils.error_encoding:
1341 "One or more addons do not have UTF-8 encoding\n"
1342 "(see console for details)",
1345 filter = context.window_manager.addon_filter
1346 search = context.window_manager.addon_search.lower()
1347 support = context.window_manager.addon_support
1349 # initialized on demand
1350 user_addon_paths = []
1352 for mod, info in addons:
1353 module_name = mod.__name__
1355 is_enabled = module_name in used_ext
1357 if info["support"] not in support:
1360 # check if addon should be visible with current filters
1362 (filter == "All") or
1363 (filter == info["category"]) or
1364 (filter == "Enabled" and is_enabled) or
1365 (filter == "Disabled" and not is_enabled) or
1366 (filter == "User" and (mod.__file__.startswith(addon_user_dirs)))
1368 if search and search not in info["name"].lower():
1370 if search not in info["author"].lower():
1375 # Skip 2.7x add-ons included with Blender, unless in debug mode.
1376 is_addon_27x = info.get("blender", (0,)) < (2, 80)
1379 (not show_official_27x_addons) and
1380 (not mod.__file__.startswith(addon_user_dirs))
1385 col_box = col.column()
1387 colsub = box.column()
1388 row = colsub.row(align=True)
1392 icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT',
1394 ).module = module_name
1397 "wm.addon_disable" if is_enabled else "wm.addon_enable",
1398 icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
1400 ).module = module_name
1403 sub.active = is_enabled
1404 sub.label(text="%s: %s" % (info["category"], info["name"]))
1406 # WARNING: 2.8x exception, may be removed
1407 # use disabled state for old add-ons, chances are they are broken.
1409 sub.label(text="upgrade to 2.8x required")
1410 sub.label(icon='ERROR')
1411 # Remove code above after 2.8x migration is complete.
1412 elif info["warning"]:
1413 sub.label(icon='ERROR')
1415 # icon showing support level.
1416 sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
1418 # Expanded UI (only if additional info is available)
1419 if info["show_expanded"]:
1420 if info["description"]:
1421 split = colsub.row().split(factor=0.15)
1422 split.label(text="Description:")
1423 split.label(text=info["description"])
1424 if info["location"]:
1425 split = colsub.row().split(factor=0.15)
1426 split.label(text="Location:")
1427 split.label(text=info["location"])
1429 split = colsub.row().split(factor=0.15)
1430 split.label(text="File:")
1431 split.label(text=mod.__file__, translate=False)
1433 split = colsub.row().split(factor=0.15)
1434 split.label(text="Author:")
1435 split.label(text=info["author"], translate=False)
1437 split = colsub.row().split(factor=0.15)
1438 split.label(text="Version:")
1439 split.label(text=".".join(str(x) for x in info["version"]), translate=False)
1441 split = colsub.row().split(factor=0.15)
1442 split.label(text="Warning:")
1443 split.label(text=" " + info["warning"], icon='ERROR')
1445 user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
1446 tot_row = bool(info["wiki_url"]) + bool(user_addon)
1449 split = colsub.row().split(factor=0.15)
1450 split.label(text="Internet:")
1451 if info["wiki_url"]:
1453 "wm.url_open", text="Documentation", icon='HELP',
1454 ).url = info["wiki_url"]
1455 # Only add "Report a Bug" button if tracker_url is set
1456 # or the add-on is bundled (use official tracker then).
1457 if info.get("tracker_url") or not user_addon:
1459 "wm.url_open", text="Report a Bug", icon='URL',
1462 "https://developer.blender.org/maniphest/task/edit/form/2",
1466 "wm.addon_remove", text="Remove", icon='CANCEL',
1467 ).module = mod.__name__
1469 for _ in range(4 - tot_row):
1472 # Show addon user preferences
1474 addon_preferences = userpref.addons[module_name].preferences
1475 if addon_preferences is not None:
1476 draw = getattr(addon_preferences, "draw", None)
1477 if draw is not None:
1478 addon_preferences_class = type(addon_preferences)
1479 box_prefs = col_box.box()
1480 box_prefs.label(text="Preferences:")
1481 addon_preferences_class.layout = box_prefs
1486 traceback.print_exc()
1487 box_prefs.label(text="Error (see console)", icon='ERROR')
1488 del addon_preferences_class.layout
1490 # Append missing scripts
1491 # First collect scripts that are used but have no script file.
1492 module_names = {mod.__name__ for mod, info in addons}
1493 missing_modules = {ext for ext in used_ext if ext not in module_names}
1495 if missing_modules and filter in {"All", "Enabled"}:
1496 col.column().separator()
1497 col.column().label(text="Missing script files")
1499 module_names = {mod.__name__ for mod, info in addons}
1500 for module_name in sorted(missing_modules):
1501 is_enabled = module_name in used_ext
1503 box = col.column().box()
1504 colsub = box.column()
1505 row = colsub.row(align=True)
1507 row.label(text="", icon='ERROR')
1511 "wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False,
1512 ).module = module_name
1514 row.label(text=module_name, translate=False)
1517 class StudioLightPanelMixin():
1518 bl_space_type = 'USER_PREFERENCES'
1519 bl_region_type = 'WINDOW'
1522 def poll(cls, context):
1523 userpref = context.user_preferences
1524 return (userpref.active_section == 'LIGHTS')
1526 def _get_lights(self, userpref):
1527 return [light for light in userpref.studio_lights if light.is_user_defined and light.orientation == self.sl_orientation]
1529 def draw(self, context):
1530 layout = self.layout
1531 userpref = context.user_preferences
1532 lights = self._get_lights(userpref)
1534 flow = layout.column_flow(columns=4)
1535 for studio_light in lights:
1536 self.draw_studio_light(flow, studio_light)
1538 layout.label(text="No custom {} configured".format(self.bl_label))
1540 def draw_studio_light(self, layout, studio_light):
1544 row.template_icon(layout.icon(studio_light), scale=6.0)
1545 op = row.operator('wm.studiolight_uninstall', text="", icon='REMOVE')
1546 op.index = studio_light.index
1548 box.label(text=studio_light.name)
1551 class USERPREF_PT_studiolight_matcaps(Panel, StudioLightPanelMixin):
1552 bl_label = "MatCaps"
1553 sl_orientation = 'MATCAP'
1556 class USERPREF_PT_studiolight_world(Panel, StudioLightPanelMixin):
1557 bl_label = "World HDRI"
1558 sl_orientation = 'WORLD'
1561 class USERPREF_PT_studiolight_camera(Panel, StudioLightPanelMixin):
1562 bl_label = "Camera HDRI"
1563 sl_orientation = 'CAMERA'
1566 class USERPREF_PT_studiolight_specular(Panel, StudioLightPanelMixin):
1567 bl_label = "Specular Lights"
1568 sl_orientation = 'CAMERA'
1571 def poll(cls, context):
1572 userpref = context.user_preferences
1573 return (userpref.active_section == 'LIGHTS')
1575 def opengl_light_buttons(self, column, light):
1576 split = column.split()
1578 col = split.column()
1579 col.prop(light, "use", text="Use", icon='OUTLINER_OB_LIGHT' if light.use else 'LIGHT_DATA')
1582 sub.active = light.use
1583 sub.prop(light, "specular_color")
1585 col = split.column()
1586 col.active = light.use
1587 col.prop(light, "direction", text="")
1589 def draw(self, context):
1590 layout = self.layout
1591 column = layout.split()
1593 userpref = context.user_preferences
1594 system = userpref.system
1596 light = system.solid_lights[0]
1597 colsplit = column.split(factor=0.85)
1598 self.opengl_light_buttons(colsplit, light)
1600 light = system.solid_lights[1]
1601 colsplit = column.split(factor=0.85)
1602 self.opengl_light_buttons(colsplit, light)
1604 light = system.solid_lights[2]
1605 self.opengl_light_buttons(column, light)
1611 USERPREF_MT_interaction_presets,
1612 USERPREF_MT_appconfigs,
1613 USERPREF_PT_interface,
1616 USERPREF_MT_interface_theme_presets,
1619 USERPREF_MT_ndof_settings,
1620 USERPREF_MT_keyconfigs,
1622 USERPREF_MT_addons_online_resources,
1624 USERPREF_PT_studiolight_matcaps,
1625 USERPREF_PT_studiolight_world,
1626 USERPREF_PT_studiolight_camera,
1627 USERPREF_PT_studiolight_specular,
1630 if __name__ == "__main__": # only for live edit.
1631 from bpy.utils import register_class