UI: Add back ability to select a custom interface font
[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 Header, Menu, Panel
22 from bpy.app.translations import pgettext_iface as iface_
23 from bpy.app.translations import contexts as i18n_contexts
24
25
26 def opengl_lamp_buttons(column, lamp):
27     split = column.split(percentage=0.1)
28
29     split.prop(lamp, "use", text="", icon='OUTLINER_OB_LAMP' if lamp.use else 'LAMP_DATA')
30
31     col = split.column()
32     col.active = lamp.use
33     row = col.row()
34     row.label(text="Diffuse:")
35     row.prop(lamp, "diffuse_color", text="")
36     row = col.row()
37     row.label(text="Specular:")
38     row.prop(lamp, "specular_color", text="")
39
40     col = split.column()
41     col.active = lamp.use
42     col.prop(lamp, "direction", text="")
43
44
45 class USERPREF_HT_header(Header):
46     bl_space_type = 'USER_PREFERENCES'
47
48     def draw(self, context):
49         layout = self.layout
50
51         layout.template_header()
52
53         userpref = context.user_preferences
54
55         layout.operator_context = 'EXEC_AREA'
56         layout.operator("wm.save_userpref")
57
58         layout.operator_context = 'INVOKE_DEFAULT'
59
60         if userpref.active_section == 'INPUT':
61             layout.operator("wm.keyconfig_import")
62             layout.operator("wm.keyconfig_export")
63         elif userpref.active_section == 'ADDONS':
64             layout.operator("wm.addon_install", icon='FILESEL')
65             layout.operator("wm.addon_refresh", icon='FILE_REFRESH')
66             layout.menu("USERPREF_MT_addons_dev_guides")
67         elif userpref.active_section == 'THEMES':
68             layout.operator("ui.reset_default_theme")
69             layout.operator("wm.theme_install")
70
71
72 class USERPREF_PT_tabs(Panel):
73     bl_label = ""
74     bl_space_type = 'USER_PREFERENCES'
75     bl_region_type = 'WINDOW'
76     bl_options = {'HIDE_HEADER'}
77
78     def draw(self, context):
79         layout = self.layout
80
81         userpref = context.user_preferences
82
83         layout.prop(userpref, "active_section", expand=True)
84
85
86 class USERPREF_MT_interaction_presets(Menu):
87     bl_label = "Presets"
88     preset_subdir = "interaction"
89     preset_operator = "script.execute_preset"
90     draw = Menu.draw_preset
91
92
93 class USERPREF_MT_appconfigs(Menu):
94     bl_label = "AppPresets"
95     preset_subdir = "keyconfig"
96     preset_operator = "wm.appconfig_activate"
97
98     def draw(self, context):
99         self.layout.operator("wm.appconfig_default", text="Blender (default)")
100
101         # now draw the presets
102         Menu.draw_preset(self, context)
103
104
105 class USERPREF_MT_splash(Menu):
106     bl_label = "Splash"
107
108     def draw(self, context):
109         layout = self.layout
110
111         split = layout.split()
112         row = split.row()
113         row.label("")
114         row = split.row()
115         row.label("Interaction:")
116         # XXX, no redraws
117         # text = bpy.path.display_name(context.window_manager.keyconfigs.active.name)
118         # if not text:
119         #     text = "Blender (default)"
120         row.menu("USERPREF_MT_appconfigs", text="Preset")
121
122
123 class USERPREF_PT_interface(Panel):
124     bl_space_type = 'USER_PREFERENCES'
125     bl_label = "Interface"
126     bl_region_type = 'WINDOW'
127     bl_options = {'HIDE_HEADER'}
128
129     @classmethod
130     def poll(cls, context):
131         userpref = context.user_preferences
132         return (userpref.active_section == 'INTERFACE')
133
134     def draw(self, context):
135         import sys
136         layout = self.layout
137
138         userpref = context.user_preferences
139         view = userpref.view
140
141         row = layout.row()
142
143         col = row.column()
144         col.label(text="Display:")
145         col.prop(view, "show_tooltips")
146         col.prop(view, "show_tooltips_python")
147         col.prop(view, "show_object_info", text="Object Info")
148         col.prop(view, "show_large_cursors")
149         col.prop(view, "show_view_name", text="View Name")
150         col.prop(view, "show_playback_fps", text="Playback FPS")
151         col.prop(view, "use_global_scene")
152         col.prop(view, "object_origin_size")
153
154         col.separator()
155         col.separator()
156         col.separator()
157
158         col.prop(view, "show_mini_axis", text="Display Mini Axis")
159         sub = col.column()
160         sub.active = view.show_mini_axis
161         sub.prop(view, "mini_axis_size", text="Size")
162         sub.prop(view, "mini_axis_brightness", text="Brightness")
163
164         col.separator()
165         row.separator()
166         row.separator()
167
168         col = row.column()
169         col.label(text="View Manipulation:")
170         col.prop(view, "use_mouse_depth_cursor")
171         col.prop(view, "use_mouse_depth_navigate")
172         col.prop(view, "use_zoom_to_mouse")
173         col.prop(view, "use_rotate_around_active")
174         col.prop(view, "use_global_pivot")
175         col.prop(view, "use_camera_lock_parent")
176
177         col.separator()
178
179         col.prop(view, "use_auto_perspective")
180         col.prop(view, "smooth_view")
181         col.prop(view, "rotation_angle")
182
183         col.separator()
184         col.separator()
185
186         col.label(text="2D Viewports:")
187         col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
188         col.prop(view, "timecode_style")
189
190         row.separator()
191         row.separator()
192
193         col = row.column()
194         #Toolbox doesn't exist yet
195         #col.label(text="Toolbox:")
196         #col.prop(view, "show_column_layout")
197         #col.label(text="Open Toolbox Delay:")
198         #col.prop(view, "open_left_mouse_delay", text="Hold LMB")
199         #col.prop(view, "open_right_mouse_delay", text="Hold RMB")
200         col.prop(view, "show_manipulator")
201         sub = col.column()
202         sub.active = view.show_manipulator
203         sub.prop(view, "manipulator_size", text="Size")
204         sub.prop(view, "manipulator_handle_size", text="Handle Size")
205         sub.prop(view, "manipulator_hotspot", text="Hotspot")
206
207         col.separator()
208         col.separator()
209         col.separator()
210
211         col.label(text="Menus:")
212         col.prop(view, "use_mouse_over_open")
213         sub = col.column()
214         sub.active = view.use_mouse_over_open
215
216         sub.prop(view, "open_toplevel_delay", text="Top Level")
217         sub.prop(view, "open_sublevel_delay", text="Sub Level")
218
219         col.separator()
220         col.separator()
221         col.separator()
222
223         col.prop(view, "show_splash")
224
225         if sys.platform[:3] == "win":
226             col.prop(view, "use_quit_dialog")
227
228
229 class USERPREF_PT_edit(Panel):
230     bl_space_type = 'USER_PREFERENCES'
231     bl_label = "Edit"
232     bl_region_type = 'WINDOW'
233     bl_options = {'HIDE_HEADER'}
234
235     @classmethod
236     def poll(cls, context):
237         userpref = context.user_preferences
238         return (userpref.active_section == 'EDITING')
239
240     def draw(self, context):
241         layout = self.layout
242
243         userpref = context.user_preferences
244         edit = userpref.edit
245
246         row = layout.row()
247
248         col = row.column()
249         col.label(text="Link Materials To:")
250         col.prop(edit, "material_link", text="")
251
252         col.separator()
253         col.separator()
254         col.separator()
255
256         col.label(text="New Objects:")
257         col.prop(edit, "use_enter_edit_mode")
258         col.label(text="Align To:")
259         col.prop(edit, "object_align", text="")
260
261         col.separator()
262         col.separator()
263         col.separator()
264
265         col.label(text="Undo:")
266         col.prop(edit, "use_global_undo")
267         col.prop(edit, "undo_steps", text="Steps")
268         col.prop(edit, "undo_memory_limit", text="Memory Limit")
269
270         row.separator()
271         row.separator()
272
273         col = row.column()
274         col.label(text="Grease Pencil:")
275         col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
276         col.separator()
277         col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
278         col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
279         col.separator()
280         col.prop(edit, "use_grease_pencil_smooth_stroke", text="Smooth Stroke")
281         col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
282         col.separator()
283         col.prop(edit, "grease_pencil_default_color", text="Default Color")
284         col.separator()
285         col.separator()
286         col.separator()
287         col.label(text="Playback:")
288         col.prop(edit, "use_negative_frames")
289         col.separator()
290         col.separator()
291         col.separator()
292         col.label(text="Animation Editors:")
293         col.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
294
295         row.separator()
296         row.separator()
297
298         col = row.column()
299         col.label(text="Keyframing:")
300         col.prop(edit, "use_visual_keying")
301         col.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed")
302
303         col.separator()
304
305         col.prop(edit, "use_auto_keying", text="Auto Keyframing:")
306         col.prop(edit, "use_auto_keying_warning")
307
308         sub = col.column()
309
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")
312
313         col.separator()
314
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")
319
320         col.separator()
321         col.separator()
322         col.separator()
323
324         col.label(text="Transform:")
325         col.prop(edit, "use_drag_immediately")
326
327         row.separator()
328         row.separator()
329
330         col = row.column()
331         col.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
332
333         col.separator()
334         col.separator()
335         col.separator()
336
337         col.label(text="Duplicate Data:")
338         col.prop(edit, "use_duplicate_mesh", text="Mesh")
339         col.prop(edit, "use_duplicate_surface", text="Surface")
340         col.prop(edit, "use_duplicate_curve", text="Curve")
341         col.prop(edit, "use_duplicate_text", text="Text")
342         col.prop(edit, "use_duplicate_metaball", text="Metaball")
343         col.prop(edit, "use_duplicate_armature", text="Armature")
344         col.prop(edit, "use_duplicate_lamp", text="Lamp")
345         col.prop(edit, "use_duplicate_material", text="Material")
346         col.prop(edit, "use_duplicate_texture", text="Texture")
347         #col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
348         col.prop(edit, "use_duplicate_action", text="Action")
349         col.prop(edit, "use_duplicate_particle", text="Particle")
350
351
352 class USERPREF_PT_system(Panel):
353     bl_space_type = 'USER_PREFERENCES'
354     bl_label = "System"
355     bl_region_type = 'WINDOW'
356     bl_options = {'HIDE_HEADER'}
357
358     @classmethod
359     def poll(cls, context):
360         userpref = context.user_preferences
361         return (userpref.active_section == 'SYSTEM')
362
363     def draw(self, context):
364         import sys
365         layout = self.layout
366
367         userpref = context.user_preferences
368         system = userpref.system
369
370         split = layout.split()
371
372         # 1. Column
373         column = split.column()
374         colsplit = column.split(percentage=0.85)
375
376         col = colsplit.column()
377         col.label(text="General:")
378         col.prop(system, "dpi")
379         col.prop(system, "frame_server_port")
380         col.prop(system, "scrollback", text="Console Scrollback")
381
382         col.separator()
383
384         col.label(text="Sound:")
385         col.row().prop(system, "audio_device", expand=True)
386         sub = col.column()
387         sub.active = system.audio_device != 'NONE'
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")
393
394         col.separator()
395
396         col.label(text="Screencast:")
397         col.prop(system, "screencast_fps")
398         col.prop(system, "screencast_wait_time")
399
400         col.separator()
401
402         if hasattr(system, "compute_device_type"):
403             col.label(text="Compute Device:")
404             col.row().prop(system, "compute_device_type", expand=True)
405             sub = col.row()
406             sub.active = system.compute_device_type != 'CPU'
407             sub.prop(system, "compute_device", text="")
408
409         # 2. Column
410         column = split.column()
411         colsplit = column.split(percentage=0.85)
412
413         col = colsplit.column()
414         col.label(text="OpenGL:")
415         col.prop(system, "gl_clip_alpha", slider=True)
416         col.prop(system, "use_mipmaps")
417         col.prop(system, "use_gpu_mipmap")
418         col.prop(system, "use_16bit_textures")
419
420         col.separator()
421
422         col.label(text="Anisotropic Filtering")
423         col.prop(system, "anisotropic_filter", text="")
424         col.prop(system, "use_vertex_buffer_objects")
425
426         col.separator()
427
428         col.label(text="Window Draw Method:")
429         col.prop(system, "window_draw_method", text="")
430         col.prop(system, "multi_sample", text="")
431         if sys.platform == "linux" and system.multi_sample != 'NONE':
432             col.label(text="Might fail for Mesh editing selection!")
433             col.separator()
434         col.prop(system, "use_region_overlap")
435
436         col.separator()
437
438         col.label(text="Text Draw Options:")
439         col.prop(system, "use_text_antialiasing")
440
441         col.separator()
442
443         col.label(text="Textures:")
444         col.prop(system, "gl_texture_limit", text="Limit Size")
445         col.prop(system, "texture_time_out", text="Time Out")
446         col.prop(system, "texture_collection_rate", text="Collection Rate")
447
448         col.separator()
449
450         col.label(text="Images Draw Method:")
451         col.prop(system, "image_draw_method", text="")
452
453         col.separator()
454
455         col.label(text="Sequencer / Clip Editor:")
456         col.prop(system, "prefetch_frames")
457         col.prop(system, "memory_cache_limit")
458
459         # 3. Column
460         column = split.column()
461
462         column.label(text="Solid OpenGL lights:")
463
464         split = column.split(percentage=0.1)
465         split.label()
466         split.label(text="Colors:")
467         split.label(text="Direction:")
468
469         lamp = system.solid_lights[0]
470         opengl_lamp_buttons(column, lamp)
471
472         lamp = system.solid_lights[1]
473         opengl_lamp_buttons(column, lamp)
474
475         lamp = system.solid_lights[2]
476         opengl_lamp_buttons(column, lamp)
477
478         column.separator()
479
480         column.label(text="Color Picker Type:")
481         column.row().prop(system, "color_picker_type", text="")
482
483         column.separator()
484
485         column.prop(system, "use_weight_color_range", text="Custom Weight Paint Range")
486         sub = column.column()
487         sub.active = system.use_weight_color_range
488         sub.template_color_ramp(system, "weight_color_range", expand=True)
489
490         column.separator()
491         column.prop(system, "font_path_ui")
492
493         if bpy.app.build_options.international:
494             column.prop(system, "use_international_fonts")
495             if system.use_international_fonts:
496                 column.prop(system, "language")
497                 row = column.row()
498                 row.label(text="Translate:", text_ctxt=i18n_contexts.id_windowmanager)
499                 row = column.row(align=True)
500                 row.prop(system, "use_translate_interface", text="Interface", toggle=True)
501                 row.prop(system, "use_translate_tooltips", text="Tooltips", toggle=True)
502                 row.prop(system, "use_translate_new_dataname", text="New Data", toggle=True)
503
504
505 class USERPREF_MT_interface_theme_presets(Menu):
506     bl_label = "Presets"
507     preset_subdir = "interface_theme"
508     preset_operator = "script.execute_preset"
509     preset_type = 'XML'
510     preset_xml_map = (
511         ("user_preferences.themes[0]", "Theme"),
512         ("user_preferences.ui_styles[0]", "ThemeStyle"),
513         )
514     draw = Menu.draw_preset
515
516
517 class USERPREF_PT_theme(Panel):
518     bl_space_type = 'USER_PREFERENCES'
519     bl_label = "Themes"
520     bl_region_type = 'WINDOW'
521     bl_options = {'HIDE_HEADER'}
522
523     @staticmethod
524     def _theme_generic(split, themedata):
525
526         col = split.column()
527
528         def theme_generic_recurse(data):
529             col.label(data.rna_type.name)
530             row = col.row()
531             subsplit = row.split(percentage=0.95)
532
533             padding1 = subsplit.split(percentage=0.15)
534             padding1.column()
535
536             subsplit = row.split(percentage=0.85)
537
538             padding2 = subsplit.split(percentage=0.15)
539             padding2.column()
540
541             colsub_pair = padding1.column(), padding2.column()
542
543             props_type = {}
544
545             for i, prop in enumerate(data.rna_type.properties):
546                 if prop.identifier == "rna_type":
547                     continue
548
549                 props_type.setdefault((prop.type, prop.subtype), []).append(prop)
550
551             for props_type, props_ls in sorted(props_type.items()):
552                 if props_type[0] == 'POINTER':
553                     for i, prop in enumerate(props_ls):
554                         theme_generic_recurse(getattr(data, prop.identifier))
555                 else:
556                     for i, prop in enumerate(props_ls):
557                         colsub_pair[i % 2].row().prop(data, prop.identifier)
558
559         theme_generic_recurse(themedata)
560
561     @staticmethod
562     def _theme_widget_style(layout, widget_style):
563
564         row = layout.row()
565
566         subsplit = row.split(percentage=0.95)
567
568         padding = subsplit.split(percentage=0.15)
569         colsub = padding.column()
570         colsub = padding.column()
571         colsub.row().prop(widget_style, "outline")
572         colsub.row().prop(widget_style, "item", slider=True)
573         colsub.row().prop(widget_style, "inner", slider=True)
574         colsub.row().prop(widget_style, "inner_sel", slider=True)
575
576         subsplit = row.split(percentage=0.85)
577
578         padding = subsplit.split(percentage=0.15)
579         colsub = padding.column()
580         colsub = padding.column()
581         colsub.row().prop(widget_style, "text")
582         colsub.row().prop(widget_style, "text_sel")
583         colsub.prop(widget_style, "show_shaded")
584         subsub = colsub.column(align=True)
585         subsub.active = widget_style.show_shaded
586         subsub.prop(widget_style, "shadetop")
587         subsub.prop(widget_style, "shadedown")
588
589         layout.separator()
590
591     @staticmethod
592     def _ui_font_style(layout, font_style):
593
594         split = layout.split()
595
596         col = split.column()
597         col.label(text="Kerning Style:")
598         col.row().prop(font_style, "font_kerning_style", expand=True)
599         col.prop(font_style, "points")
600
601         col = split.column()
602         col.label(text="Shadow Offset:")
603         col.prop(font_style, "shadow_offset_x", text="X")
604         col.prop(font_style, "shadow_offset_y", text="Y")
605
606         col = split.column()
607         col.prop(font_style, "shadow")
608         col.prop(font_style, "shadow_alpha")
609         col.prop(font_style, "shadow_value")
610
611         layout.separator()
612
613     @classmethod
614     def poll(cls, context):
615         userpref = context.user_preferences
616         return (userpref.active_section == 'THEMES')
617
618     def draw(self, context):
619         layout = self.layout
620
621         theme = context.user_preferences.themes[0]
622
623         split_themes = layout.split(percentage=0.2)
624
625         sub = split_themes.column()
626
627         sub.label(text="Presets:")
628         subrow = sub.row(align=True)
629
630         subrow.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
631         subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMIN')
632         subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMOUT').remove_active = True
633         sub.separator()
634
635         sub.prop(theme, "theme_area", expand=True)
636
637         split = layout.split(percentage=0.4)
638
639         layout.separator()
640         layout.separator()
641
642         split = split_themes.split()
643
644         if theme.theme_area == 'USER_INTERFACE':
645             col = split.column()
646             ui = theme.user_interface
647
648             col.label(text="Regular:")
649             self._theme_widget_style(col, ui.wcol_regular)
650
651             col.label(text="Tool:")
652             self._theme_widget_style(col, ui.wcol_tool)
653
654             col.label(text="Radio Buttons:")
655             self._theme_widget_style(col, ui.wcol_radio)
656
657             col.label(text="Text:")
658             self._theme_widget_style(col, ui.wcol_text)
659
660             col.label(text="Option:")
661             self._theme_widget_style(col, ui.wcol_option)
662
663             col.label(text="Toggle:")
664             self._theme_widget_style(col, ui.wcol_toggle)
665
666             col.label(text="Number Field:")
667             self._theme_widget_style(col, ui.wcol_num)
668
669             col.label(text="Value Slider:")
670             self._theme_widget_style(col, ui.wcol_numslider)
671
672             col.label(text="Box:")
673             self._theme_widget_style(col, ui.wcol_box)
674
675             col.label(text="Menu:")
676             self._theme_widget_style(col, ui.wcol_menu)
677
678             col.label(text="Pulldown:")
679             self._theme_widget_style(col, ui.wcol_pulldown)
680
681             col.label(text="Menu Back:")
682             self._theme_widget_style(col, ui.wcol_menu_back)
683
684             col.label(text="Tooltip:")
685             self._theme_widget_style(col, ui.wcol_tooltip)
686
687             col.label(text="Menu Item:")
688             self._theme_widget_style(col, ui.wcol_menu_item)
689
690             col.label(text="Scroll Bar:")
691             self._theme_widget_style(col, ui.wcol_scroll)
692
693             col.label(text="Progress Bar:")
694             self._theme_widget_style(col, ui.wcol_progress)
695
696             col.label(text="List Item:")
697             self._theme_widget_style(col, ui.wcol_list_item)
698
699             ui_state = theme.user_interface.wcol_state
700             col.label(text="State:")
701
702             row = col.row()
703
704             subsplit = row.split(percentage=0.95)
705
706             padding = subsplit.split(percentage=0.15)
707             colsub = padding.column()
708             colsub = padding.column()
709             colsub.row().prop(ui_state, "inner_anim")
710             colsub.row().prop(ui_state, "inner_anim_sel")
711             colsub.row().prop(ui_state, "inner_driven")
712             colsub.row().prop(ui_state, "inner_driven_sel")
713
714             subsplit = row.split(percentage=0.85)
715
716             padding = subsplit.split(percentage=0.15)
717             colsub = padding.column()
718             colsub = padding.column()
719             colsub.row().prop(ui_state, "inner_key")
720             colsub.row().prop(ui_state, "inner_key_sel")
721             colsub.row().prop(ui_state, "blend")
722
723             col.separator()
724             col.separator()
725
726             col.label("Menu Shadow:")
727
728             row = col.row()
729
730             subsplit = row.split(percentage=0.95)
731
732             padding = subsplit.split(percentage=0.15)
733             colsub = padding.column()
734             colsub = padding.column()
735             colsub.row().prop(ui, "menu_shadow_fac")
736
737             subsplit = row.split(percentage=0.85)
738
739             padding = subsplit.split(percentage=0.15)
740             colsub = padding.column()
741             colsub = padding.column()
742             colsub.row().prop(ui, "menu_shadow_width")
743
744             col.separator()
745             col.separator()
746
747             col.label("Icons:")
748
749             row = col.row()
750
751             subsplit = row.split(percentage=0.95)
752
753             padding = subsplit.split(percentage=0.15)
754             colsub = padding.column()
755             colsub = padding.column()
756             # Not working yet.
757             #~ colsub.active = False
758             #~ colsub.row().prop(ui, "icon_file")
759
760             subsplit = row.split(percentage=0.85)
761
762             padding = subsplit.split(percentage=0.15)
763             colsub = padding.column()
764             colsub = padding.column()
765             colsub.row().prop(ui, "icon_alpha")
766
767             col.separator()
768             col.separator()
769
770             col.label("Axis Colors:")
771
772             row = col.row()
773
774             subsplit = row.split(percentage=0.95)
775
776             padding = subsplit.split(percentage=0.15)
777             colsub = padding.column()
778             colsub = padding.column()
779             colsub.row().prop(ui, "axis_x")
780             colsub.row().prop(ui, "axis_y")
781             colsub.row().prop(ui, "axis_z")
782
783             subsplit = row.split(percentage=0.85)
784
785             padding = subsplit.split(percentage=0.15)
786             colsub = padding.column()
787             colsub = padding.column()
788
789             layout.separator()
790             layout.separator()
791         elif theme.theme_area == 'BONE_COLOR_SETS':
792             col = split.column()
793
794             for i, ui in enumerate(theme.bone_color_sets):
795                 col.label(text=iface_("Color Set %d:") % (i + 1), translate=False)  # i starts from 0
796
797                 row = col.row()
798
799                 subsplit = row.split(percentage=0.95)
800
801                 padding = subsplit.split(percentage=0.15)
802                 colsub = padding.column()
803                 colsub = padding.column()
804                 colsub.row().prop(ui, "normal")
805                 colsub.row().prop(ui, "select")
806                 colsub.row().prop(ui, "active")
807
808                 subsplit = row.split(percentage=0.85)
809
810                 padding = subsplit.split(percentage=0.15)
811                 colsub = padding.column()
812                 colsub = padding.column()
813                 colsub.row().prop(ui, "show_colored_constraints")
814         elif theme.theme_area == 'STYLE':
815             col = split.column()
816
817             style = context.user_preferences.ui_styles[0]
818
819             col.label(text="Panel Title:")
820             self._ui_font_style(col, style.panel_title)
821
822             col.separator()
823
824             col.label(text="Widget:")
825             self._ui_font_style(col, style.widget)
826
827             col.separator()
828
829             col.label(text="Widget Label:")
830             self._ui_font_style(col, style.widget_label)
831         else:
832             self._theme_generic(split, getattr(theme, theme.theme_area.lower()))
833
834
835 class USERPREF_PT_file(Panel):
836     bl_space_type = 'USER_PREFERENCES'
837     bl_label = "Files"
838     bl_region_type = 'WINDOW'
839     bl_options = {'HIDE_HEADER'}
840
841     @classmethod
842     def poll(cls, context):
843         userpref = context.user_preferences
844         return (userpref.active_section == 'FILES')
845
846     def draw(self, context):
847         layout = self.layout
848
849         userpref = context.user_preferences
850         paths = userpref.filepaths
851         system = userpref.system
852
853         split = layout.split(percentage=0.7)
854
855         col = split.column()
856         col.label(text="File Paths:")
857
858         colsplit = col.split(percentage=0.95)
859         col1 = colsplit.split(percentage=0.3)
860
861         sub = col1.column()
862         sub.label(text="Fonts:")
863         sub.label(text="Textures:")
864         sub.label(text="Render Output:")
865         sub.label(text="Scripts:")
866         sub.label(text="Sounds:")
867         sub.label(text="Temp:")
868         sub.label(text="I18n Branches:")
869         sub.label(text="Image Editor:")
870         sub.label(text="Animation Player:")
871
872         sub = col1.column()
873         sub.prop(paths, "font_directory", text="")
874         sub.prop(paths, "texture_directory", text="")
875         sub.prop(paths, "render_output_directory", text="")
876         sub.prop(paths, "script_directory", text="")
877         sub.prop(paths, "sound_directory", text="")
878         sub.prop(paths, "temporary_directory", text="")
879         sub.prop(paths, "i18n_branches_directory", text="")
880         sub.prop(paths, "image_editor", text="")
881         subsplit = sub.split(percentage=0.3)
882         subsplit.prop(paths, "animation_player_preset", text="")
883         subsplit.prop(paths, "animation_player", text="")
884
885         col.separator()
886         col.separator()
887
888         colsplit = col.split(percentage=0.95)
889         sub = colsplit.column()
890
891         row = sub.split(percentage=0.3)
892         row.label(text="Auto Execution:")
893         row.prop(system, "use_scripts_auto_execute")
894
895         if system.use_scripts_auto_execute:
896             box = sub.box()
897             row = box.row()
898             row.label(text="Excluded Paths:")
899             row.operator("wm.userpref_autoexec_path_add", text="", icon='ZOOMIN', emboss=False)
900             for i, path_cmp in enumerate(userpref.autoexec_paths):
901                 row = box.row()
902                 row.prop(path_cmp, "path", text="")
903                 row.prop(path_cmp, "use_glob", text="", icon='FILTER')
904                 row.operator("wm.userpref_autoexec_path_remove", text="", icon='X', emboss=False).index = i
905
906         col = split.column()
907         col.label(text="Save & Load:")
908         col.prop(paths, "use_relative_paths")
909         col.prop(paths, "use_file_compression")
910         col.prop(paths, "use_load_ui")
911         col.prop(paths, "use_filter_files")
912         col.prop(paths, "show_hidden_files_datablocks")
913         col.prop(paths, "hide_recent_locations")
914         col.prop(paths, "hide_system_bookmarks")
915         col.prop(paths, "show_thumbnails")
916
917         col.separator()
918
919         col.prop(paths, "save_version")
920         col.prop(paths, "recent_files")
921         col.prop(paths, "use_save_preview_images")
922
923         col.separator()
924
925         col.label(text="Auto Save:")
926         col.prop(paths, "use_keep_session")
927         col.prop(paths, "use_auto_save_temporary_files")
928         sub = col.column()
929         sub.active = paths.use_auto_save_temporary_files
930         sub.prop(paths, "auto_save_time", text="Timer (mins)")
931
932         col.separator()
933
934         col.label(text="Text Editor:")
935         col.prop(system, "use_tabs_as_spaces")
936
937         colsplit = col.split(percentage=0.95)
938         col1 = colsplit.split(percentage=0.3)
939
940         sub = col1.column()
941         sub.label(text="Author:")
942         sub = col1.column()
943         sub.prop(system, "author", text="")
944
945
946 class USERPREF_MT_ndof_settings(Menu):
947     # accessed from the window key-bindings in C (only)
948     bl_label = "3D Mouse Settings"
949
950     def draw(self, context):
951         layout = self.layout
952
953         input_prefs = context.user_preferences.inputs
954
955         is_view3d = context.space_data.type == 'VIEW_3D'
956
957         layout.prop(input_prefs, "ndof_sensitivity")
958         layout.prop(input_prefs, "ndof_orbit_sensitivity")
959
960         if is_view3d:
961             layout.separator()
962             layout.prop(input_prefs, "ndof_show_guide")
963
964             layout.separator()
965             layout.label(text="Orbit style")
966             layout.row().prop(input_prefs, "ndof_view_navigate_method", text="")
967             layout.row().prop(input_prefs, "ndof_view_rotate_method", text="")
968             layout.separator()
969             layout.label(text="Orbit options")
970             layout.prop(input_prefs, "ndof_rotx_invert_axis")
971             layout.prop(input_prefs, "ndof_roty_invert_axis")
972             layout.prop(input_prefs, "ndof_rotz_invert_axis")
973
974         # view2d use pan/zoom
975         layout.separator()
976         layout.label(text="Pan options")
977         layout.prop(input_prefs, "ndof_panx_invert_axis")
978         layout.prop(input_prefs, "ndof_pany_invert_axis")
979         layout.prop(input_prefs, "ndof_panz_invert_axis")
980         layout.prop(input_prefs, "ndof_pan_yz_swap_axis")
981
982         layout.label(text="Zoom options")
983         layout.prop(input_prefs, "ndof_zoom_invert")
984
985         if is_view3d:
986             layout.separator()
987             layout.label(text="Fly/Walk options")
988             layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
989             layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
990
991
992 class USERPREF_MT_keyconfigs(Menu):
993     bl_label = "KeyPresets"
994     preset_subdir = "keyconfig"
995     preset_operator = "wm.keyconfig_activate"
996
997     def draw(self, context):
998         props = self.layout.operator("wm.context_set_value", text="Blender (default)")
999         props.data_path = "window_manager.keyconfigs.active"
1000         props.value = "context.window_manager.keyconfigs.default"
1001
1002         # now draw the presets
1003         Menu.draw_preset(self, context)
1004
1005
1006 class USERPREF_PT_input(Panel):
1007     bl_space_type = 'USER_PREFERENCES'
1008     bl_label = "Input"
1009     bl_region_type = 'WINDOW'
1010     bl_options = {'HIDE_HEADER'}
1011
1012     @classmethod
1013     def poll(cls, context):
1014         userpref = context.user_preferences
1015         return (userpref.active_section == 'INPUT')
1016
1017     def draw_input_prefs(self, inputs, layout):
1018         import sys
1019
1020         # General settings
1021         row = layout.row()
1022         col = row.column()
1023
1024         sub = col.column()
1025         sub.label(text="Presets:")
1026         subrow = sub.row(align=True)
1027
1028         subrow.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label)
1029         subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMIN')
1030         subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMOUT').remove_active = True
1031         sub.separator()
1032
1033         sub.label(text="Mouse:")
1034         sub1 = sub.column()
1035         sub1.active = (inputs.select_mouse == 'RIGHT')
1036         sub1.prop(inputs, "use_mouse_emulate_3_button")
1037         sub.prop(inputs, "use_mouse_continuous")
1038         sub.prop(inputs, "drag_threshold")
1039         sub.prop(inputs, "tweak_threshold")
1040
1041         sub.label(text="Select With:")
1042         sub.row().prop(inputs, "select_mouse", expand=True)
1043
1044         sub = col.column()
1045         sub.label(text="Double Click:")
1046         sub.prop(inputs, "mouse_double_click_time", text="Speed")
1047
1048         sub.separator()
1049
1050         sub.prop(inputs, "use_emulate_numpad")
1051
1052         sub.separator()
1053
1054         sub.label(text="Orbit Style:")
1055         sub.row().prop(inputs, "view_rotate_method", expand=True)
1056
1057         sub.separator()
1058
1059         sub.label(text="Zoom Style:")
1060         sub.row().prop(inputs, "view_zoom_method", text="")
1061         if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
1062             sub.row().prop(inputs, "view_zoom_axis", expand=True)
1063             sub.prop(inputs, "invert_mouse_zoom", text="Invert Mouse Zoom Direction")
1064
1065         #sub.prop(inputs, "use_mouse_mmb_paste")
1066
1067         #col.separator()
1068
1069         sub = col.column()
1070         sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
1071         #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
1072
1073         if sys.platform == "darwin":
1074             sub = col.column()
1075             sub.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction")
1076
1077         col.separator()
1078         sub = col.column()
1079         sub.label(text="View Navigation:")
1080         sub.row().prop(inputs, "navigation_mode", expand=True)
1081         if inputs.navigation_mode == 'WALK':
1082             walk = inputs.walk_navigation
1083
1084             sub.prop(walk, "use_mouse_reverse")
1085             sub.prop(walk, "mouse_speed")
1086             sub.prop(walk, "teleport_time")
1087
1088             sub = col.column(align=True)
1089             sub.prop(walk, "walk_speed")
1090             sub.prop(walk, "walk_speed_factor")
1091
1092             sub.separator()
1093             sub.prop(walk, "use_gravity")
1094             sub = col.column(align=True)
1095             sub.active = walk.use_gravity
1096             sub.prop(walk, "view_height")
1097             sub.prop(walk, "jump_height")
1098
1099         col.separator()
1100         sub = col.column()
1101         sub.label(text="NDOF Device:")
1102         sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity")
1103         sub.prop(inputs, "ndof_orbit_sensitivity", text="NDOF Orbit Sensitivity")
1104         sub.row().prop(inputs, "ndof_view_navigate_method", expand=True)
1105         sub.row().prop(inputs, "ndof_view_rotate_method", expand=True)
1106
1107         row.separator()
1108
1109     def draw(self, context):
1110         from rna_keymap_ui import draw_keymaps
1111
1112         layout = self.layout
1113
1114         #import time
1115
1116         #start = time.time()
1117
1118         userpref = context.user_preferences
1119
1120         inputs = userpref.inputs
1121
1122         split = layout.split(percentage=0.25)
1123
1124         # Input settings
1125         self.draw_input_prefs(inputs, split)
1126
1127         # Keymap Settings
1128         draw_keymaps(context, split)
1129
1130         #print("runtime", time.time() - start)
1131
1132
1133 class USERPREF_MT_addons_dev_guides(Menu):
1134     bl_label = "Development Guides"
1135
1136     # menu to open web-pages with addons development guides
1137     def draw(self, context):
1138         layout = self.layout
1139
1140         layout.operator("wm.url_open", text="API Concepts", icon='URL').url = "http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro"
1141         layout.operator("wm.url_open", text="Addon Guidelines", icon='URL').url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons"
1142         layout.operator("wm.url_open", text="How to share your addon", icon='URL').url = "http://wiki.blender.org/index.php/Dev:Py/Sharing"
1143
1144
1145 class USERPREF_PT_addons(Panel):
1146     bl_space_type = 'USER_PREFERENCES'
1147     bl_label = "Addons"
1148     bl_region_type = 'WINDOW'
1149     bl_options = {'HIDE_HEADER'}
1150
1151     _support_icon_mapping = {
1152         'OFFICIAL': 'FILE_BLEND',
1153         'COMMUNITY': 'POSE_DATA',
1154         'TESTING': 'MOD_EXPLODE',
1155         }
1156
1157     @classmethod
1158     def poll(cls, context):
1159         userpref = context.user_preferences
1160         return (userpref.active_section == 'ADDONS')
1161
1162     @staticmethod
1163     def is_user_addon(mod, user_addon_paths):
1164         import os
1165
1166         if not user_addon_paths:
1167             for path in (bpy.utils.script_path_user(),
1168                          bpy.utils.script_path_pref()):
1169                 if path is not None:
1170                     user_addon_paths.append(os.path.join(path, "addons"))
1171
1172         for path in user_addon_paths:
1173             if bpy.path.is_subdir(mod.__file__, path):
1174                 return True
1175         return False
1176
1177     @staticmethod
1178     def draw_error(layout, message):
1179         lines = message.split("\n")
1180         box = layout.box()
1181         sub = box.row()
1182         sub.label(lines[0])
1183         sub.label(icon='ERROR')
1184         for l in lines[1:]:
1185             box.label(l)
1186
1187     def draw(self, context):
1188         import os
1189         import addon_utils
1190
1191         layout = self.layout
1192
1193         userpref = context.user_preferences
1194         used_ext = {ext.module for ext in userpref.addons}
1195
1196         userpref_addons_folder = os.path.join(userpref.filepaths.script_directory, "addons")
1197         scripts_addons_folder = bpy.utils.user_resource('SCRIPTS', "addons")
1198
1199         # collect the categories that can be filtered on
1200         addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(refresh=False)]
1201
1202         split = layout.split(percentage=0.2)
1203         col = split.column()
1204         col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
1205
1206         col.label(text="Supported Level")
1207         col.prop(context.window_manager, "addon_support", expand=True)
1208
1209         col.label(text="Categories")
1210         col.prop(context.window_manager, "addon_filter", expand=True)
1211
1212         col = split.column()
1213
1214         # set in addon_utils.modules_refresh()
1215         if addon_utils.error_duplicates:
1216             self.draw_error(col,
1217                             "Multiple addons using the same name found!\n"
1218                             "likely a problem with the script search path.\n"
1219                             "(see console for details)",
1220                             )
1221
1222         if addon_utils.error_encoding:
1223             self.draw_error(col,
1224                             "One or more addons do not have UTF-8 encoding\n"
1225                             "(see console for details)",
1226                             )
1227
1228         filter = context.window_manager.addon_filter
1229         search = context.window_manager.addon_search.lower()
1230         support = context.window_manager.addon_support
1231
1232         # initialized on demand
1233         user_addon_paths = []
1234
1235         for mod, info in addons:
1236             module_name = mod.__name__
1237
1238             is_enabled = module_name in used_ext
1239
1240             if info["support"] not in support:
1241                 continue
1242
1243             # check if addon should be visible with current filters
1244             if ((filter == "All") or
1245                 (filter == info["category"]) or
1246                 (filter == "Enabled" and is_enabled) or
1247                 (filter == "Disabled" and not is_enabled) or
1248                 (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
1249                 ):
1250
1251                 if search and search not in info["name"].lower():
1252                     if info["author"]:
1253                         if search not in info["author"].lower():
1254                             continue
1255                     else:
1256                         continue
1257
1258                 # Addon UI Code
1259                 col_box = col.column()
1260                 box = col_box.box()
1261                 colsub = box.column()
1262                 row = colsub.row()
1263
1264                 row.operator("wm.addon_expand", icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT', emboss=False).module = module_name
1265
1266                 sub = row.row()
1267                 sub.active = is_enabled
1268                 sub.label(text='%s: %s' % (info["category"], info["name"]))
1269                 if info["warning"]:
1270                     sub.label(icon='ERROR')
1271
1272                 # icon showing support level.
1273                 sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
1274
1275                 if is_enabled:
1276                     row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name
1277                 else:
1278                     row.operator("wm.addon_enable", icon='CHECKBOX_DEHLT', text="", emboss=False).module = module_name
1279
1280                 # Expanded UI (only if additional info is available)
1281                 if info["show_expanded"]:
1282                     if info["description"]:
1283                         split = colsub.row().split(percentage=0.15)
1284                         split.label(text="Description:")
1285                         split.label(text=info["description"])
1286                     if info["location"]:
1287                         split = colsub.row().split(percentage=0.15)
1288                         split.label(text="Location:")
1289                         split.label(text=info["location"])
1290                     if mod:
1291                         split = colsub.row().split(percentage=0.15)
1292                         split.label(text="File:")
1293                         split.label(text=mod.__file__, translate=False)
1294                     if info["author"]:
1295                         split = colsub.row().split(percentage=0.15)
1296                         split.label(text="Author:")
1297                         split.label(text=info["author"], translate=False)
1298                     if info["version"]:
1299                         split = colsub.row().split(percentage=0.15)
1300                         split.label(text="Version:")
1301                         split.label(text='.'.join(str(x) for x in info["version"]), translate=False)
1302                     if info["warning"]:
1303                         split = colsub.row().split(percentage=0.15)
1304                         split.label(text="Warning:")
1305                         split.label(text='  ' + info["warning"], icon='ERROR')
1306
1307                     user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
1308                     tot_row = bool(info["wiki_url"]) + bool(user_addon)
1309
1310                     if tot_row:
1311                         split = colsub.row().split(percentage=0.15)
1312                         split.label(text="Internet:")
1313                         if info["wiki_url"]:
1314                             split.operator("wm.url_open", text="Documentation", icon='HELP').url = info["wiki_url"]
1315                         split.operator("wm.url_open", text="Report a Bug", icon='URL').url = info.get(
1316                                 "tracker_url",
1317                                 "http://developer.blender.org/maniphest/task/create/?project=3&type=Bug")
1318                         if user_addon:
1319                             split.operator("wm.addon_remove", text="Remove", icon='CANCEL').module = mod.__name__
1320
1321                         for i in range(4 - tot_row):
1322                             split.separator()
1323
1324                     # Show addon user preferences
1325                     if is_enabled:
1326                         addon_preferences = userpref.addons[module_name].preferences
1327                         if addon_preferences is not None:
1328                             draw = getattr(addon_preferences, "draw", None)
1329                             if draw is not None:
1330                                 addon_preferences_class = type(addon_preferences)
1331                                 box_prefs = col_box.box()
1332                                 box_prefs.label("Preferences:")
1333                                 addon_preferences_class.layout = box_prefs
1334                                 try:
1335                                     draw(context)
1336                                 except:
1337                                     import traceback
1338                                     traceback.print_exc()
1339                                     box_prefs.label(text="Error (see console)", icon='ERROR')
1340                                 del addon_preferences_class.layout
1341
1342         # Append missing scripts
1343         # First collect scripts that are used but have no script file.
1344         module_names = {mod.__name__ for mod, info in addons}
1345         missing_modules = {ext for ext in used_ext if ext not in module_names}
1346
1347         if missing_modules and filter in {"All", "Enabled"}:
1348             col.column().separator()
1349             col.column().label(text="Missing script files")
1350
1351             module_names = {mod.__name__ for mod, info in addons}
1352             for module_name in sorted(missing_modules):
1353                 is_enabled = module_name in used_ext
1354                 # Addon UI Code
1355                 box = col.column().box()
1356                 colsub = box.column()
1357                 row = colsub.row()
1358
1359                 row.label(text=module_name, translate=False, icon='ERROR')
1360
1361                 if is_enabled:
1362                     row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name
1363
1364 if __name__ == "__main__":  # only for live edit.
1365     bpy.utils.register_module(__name__)