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