Camera tracking: support of tripod motion solving
[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 import os
23 import addon_utils
24
25
26 def ui_items_general(col, context):
27     """ General UI Theme Settings (User Interface)
28     """
29
30     row = col.row()
31
32     subsplit = row.split(percentage=0.95)
33
34     padding = subsplit.split(percentage=0.15)
35     colsub = padding.column()
36     colsub = padding.column()
37     colsub.row().prop(context, "outline")
38     colsub.row().prop(context, "item", slider=True)
39     colsub.row().prop(context, "inner", slider=True)
40     colsub.row().prop(context, "inner_sel", slider=True)
41
42     subsplit = row.split(percentage=0.85)
43
44     padding = subsplit.split(percentage=0.15)
45     colsub = padding.column()
46     colsub = padding.column()
47     colsub.row().prop(context, "text")
48     colsub.row().prop(context, "text_sel")
49     colsub.prop(context, "show_shaded")
50     subsub = colsub.column(align=True)
51     subsub.active = context.show_shaded
52     subsub.prop(context, "shadetop")
53     subsub.prop(context, "shadedown")
54
55     col.separator()
56
57
58 def opengl_lamp_buttons(column, lamp):
59     split = column.split(percentage=0.1)
60
61     split.prop(lamp, "use", text="", icon='OUTLINER_OB_LAMP' if lamp.use else 'LAMP_DATA')
62
63     col = split.column()
64     col.active = lamp.use
65     row = col.row()
66     row.label(text="Diffuse:")
67     row.prop(lamp, "diffuse_color", text="")
68     row = col.row()
69     row.label(text="Specular:")
70     row.prop(lamp, "specular_color", text="")
71
72     col = split.column()
73     col.active = lamp.use
74     col.prop(lamp, "direction", text="")
75
76
77 class USERPREF_HT_header(Header):
78     bl_space_type = 'USER_PREFERENCES'
79
80     def draw(self, context):
81         layout = self.layout
82         layout.template_header(menus=False)
83
84         userpref = context.user_preferences
85
86         layout.operator_context = 'EXEC_AREA'
87         layout.operator("wm.save_homefile", text="Save As Default")
88
89         layout.operator_context = 'INVOKE_DEFAULT'
90
91         if userpref.active_section == 'INPUT':
92             layout.operator("wm.keyconfig_import")
93             layout.operator("wm.keyconfig_export")
94         elif userpref.active_section == 'ADDONS':
95             layout.operator("wm.addon_install")
96             layout.menu("USERPREF_MT_addons_dev_guides")
97         elif userpref.active_section == 'THEMES':
98             layout.operator("ui.reset_default_theme")
99
100
101 class USERPREF_PT_tabs(Panel):
102     bl_label = ""
103     bl_space_type = 'USER_PREFERENCES'
104     bl_region_type = 'WINDOW'
105     bl_options = {'HIDE_HEADER'}
106
107     def draw(self, context):
108         layout = self.layout
109
110         userpref = context.user_preferences
111
112         layout.prop(userpref, "active_section", expand=True)
113
114
115 class USERPREF_MT_interaction_presets(Menu):
116     bl_label = "Presets"
117     preset_subdir = "interaction"
118     preset_operator = "script.execute_preset"
119     draw = Menu.draw_preset
120
121
122 class USERPREF_MT_appconfigs(Menu):
123     bl_label = "AppPresets"
124     preset_subdir = "keyconfig"
125     preset_operator = "wm.appconfig_activate"
126
127     def draw(self, context):
128         self.layout.operator("wm.appconfig_default", text="Blender (default)")
129
130         # now draw the presets
131         Menu.draw_preset(self, context)
132
133
134 class USERPREF_MT_splash(Menu):
135     bl_label = "Splash"
136
137     def draw(self, context):
138         layout = self.layout
139         split = layout.split()
140         row = split.row()
141         row.label("")
142         row = split.row()
143         row.label("Interaction:")
144         # XXX, no redraws
145         # text = bpy.path.display_name(context.window_manager.keyconfigs.active.name)
146         # if not text:
147         #     text = "Blender (default)"
148         row.menu("USERPREF_MT_appconfigs", text="Preset")
149
150
151 class USERPREF_PT_interface(Panel):
152     bl_space_type = 'USER_PREFERENCES'
153     bl_label = "Interface"
154     bl_region_type = 'WINDOW'
155     bl_options = {'HIDE_HEADER'}
156
157     @classmethod
158     def poll(cls, context):
159         userpref = context.user_preferences
160         return (userpref.active_section == 'INTERFACE')
161
162     def draw(self, context):
163         layout = self.layout
164
165         userpref = context.user_preferences
166         view = userpref.view
167
168         row = layout.row()
169
170         col = row.column()
171         col.label(text="Display:")
172         col.prop(view, "show_tooltips")
173         col.prop(view, "show_tooltips_python")
174         col.prop(view, "show_object_info", text="Object Info")
175         col.prop(view, "show_large_cursors")
176         col.prop(view, "show_view_name", text="View Name")
177         col.prop(view, "show_playback_fps", text="Playback FPS")
178         col.prop(view, "use_global_scene")
179         col.prop(view, "object_origin_size")
180
181         col.separator()
182         col.separator()
183         col.separator()
184
185         col.prop(view, "show_mini_axis", text="Display Mini Axis")
186         sub = col.column()
187         sub.active = view.show_mini_axis
188         sub.prop(view, "mini_axis_size", text="Size")
189         sub.prop(view, "mini_axis_brightness", text="Brightness")
190
191         col.separator()
192         row.separator()
193         row.separator()
194
195         col = row.column()
196         col.label(text="View Manipulation:")
197         col.prop(view, "use_mouse_auto_depth")
198         col.prop(view, "use_zoom_to_mouse")
199         col.prop(view, "use_rotate_around_active")
200         col.prop(view, "use_global_pivot")
201         col.prop(view, "use_camera_lock_parent")
202
203         col.separator()
204
205         col.prop(view, "use_auto_perspective")
206         col.prop(view, "smooth_view")
207         col.prop(view, "rotation_angle")
208
209         col.separator()
210         col.separator()
211
212         col.label(text="2D Viewports:")
213         col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
214         col.prop(view, "timecode_style")
215
216         row.separator()
217         row.separator()
218
219         col = row.column()
220         #Toolbox doesn't exist yet
221         #col.label(text="Toolbox:")
222         #col.prop(view, "show_column_layout")
223         #col.label(text="Open Toolbox Delay:")
224         #col.prop(view, "open_left_mouse_delay", text="Hold LMB")
225         #col.prop(view, "open_right_mouse_delay", text="Hold RMB")
226         col.prop(view, "show_manipulator")
227         sub = col.column()
228         sub.active = view.show_manipulator
229         sub.prop(view, "manipulator_size", text="Size")
230         sub.prop(view, "manipulator_handle_size", text="Handle Size")
231         sub.prop(view, "manipulator_hotspot", text="Hotspot")
232
233         col.separator()
234         col.separator()
235         col.separator()
236
237         col.label(text="Menus:")
238         col.prop(view, "use_mouse_over_open")
239         col.label(text="Menu Open Delay:")
240         col.prop(view, "open_toplevel_delay", text="Top Level")
241         col.prop(view, "open_sublevel_delay", text="Sub Level")
242
243         col.separator()
244
245         col.prop(view, "show_splash")
246
247         if os.name == 'nt':
248             col.prop(view, "quit_dialog")
249
250
251 class USERPREF_PT_edit(Panel):
252     bl_space_type = 'USER_PREFERENCES'
253     bl_label = "Edit"
254     bl_region_type = 'WINDOW'
255     bl_options = {'HIDE_HEADER'}
256
257     @classmethod
258     def poll(cls, context):
259         userpref = context.user_preferences
260         return (userpref.active_section == 'EDITING')
261
262     def draw(self, context):
263         layout = self.layout
264
265         userpref = context.user_preferences
266         edit = userpref.edit
267
268         row = layout.row()
269
270         col = row.column()
271         col.label(text="Link Materials To:")
272         col.prop(edit, "material_link", text="")
273
274         col.separator()
275         col.separator()
276         col.separator()
277
278         col.label(text="New Objects:")
279         col.prop(edit, "use_enter_edit_mode")
280         col.label(text="Align To:")
281         col.prop(edit, "object_align", text="")
282
283         col.separator()
284         col.separator()
285         col.separator()
286
287         col.label(text="Undo:")
288         col.prop(edit, "use_global_undo")
289         col.prop(edit, "undo_steps", text="Steps")
290         col.prop(edit, "undo_memory_limit", text="Memory Limit")
291
292         row.separator()
293         row.separator()
294
295         col = row.column()
296         col.label(text="Grease Pencil:")
297         col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
298         col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
299         #~ col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
300         col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
301         col.prop(edit, "use_grease_pencil_smooth_stroke", text="Smooth Stroke")
302         col.separator()
303         col.separator()
304         col.separator()
305         col.label(text="Playback:")
306         col.prop(edit, "use_negative_frames")
307         col.separator()
308         col.separator()
309         col.separator()
310         col.label(text="Animation Editors:")
311         col.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
312
313         row.separator()
314         row.separator()
315
316         col = row.column()
317         col.label(text="Keyframing:")
318         col.prop(edit, "use_visual_keying")
319         col.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed")
320
321         col.separator()
322
323         col.prop(edit, "use_auto_keying", text="Auto Keyframing:")
324
325         sub = col.column()
326
327         #~ sub.active = edit.use_keyframe_insert_auto # incorrect, time-line can enable
328         sub.prop(edit, "use_keyframe_insert_available", text="Only Insert Available")
329
330         col.separator()
331
332         col.label(text="New F-Curve Defaults:")
333         col.prop(edit, "keyframe_new_interpolation_type", text="Interpolation")
334         col.prop(edit, "keyframe_new_handle_type", text="Handles")
335         col.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
336
337         col.separator()
338         col.separator()
339         col.separator()
340
341         col.label(text="Transform:")
342         col.prop(edit, "use_drag_immediately")
343
344         row.separator()
345         row.separator()
346
347         col = row.column()
348         col.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
349
350         col.separator()
351         col.separator()
352         col.separator()
353
354         col.label(text="Duplicate Data:")
355         col.prop(edit, "use_duplicate_mesh", text="Mesh")
356         col.prop(edit, "use_duplicate_surface", text="Surface")
357         col.prop(edit, "use_duplicate_curve", text="Curve")
358         col.prop(edit, "use_duplicate_text", text="Text")
359         col.prop(edit, "use_duplicate_metaball", text="Metaball")
360         col.prop(edit, "use_duplicate_armature", text="Armature")
361         col.prop(edit, "use_duplicate_lamp", text="Lamp")
362         col.prop(edit, "use_duplicate_material", text="Material")
363         col.prop(edit, "use_duplicate_texture", text="Texture")
364         #col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
365         col.prop(edit, "use_duplicate_action", text="Action")
366         col.prop(edit, "use_duplicate_particle", text="Particle")
367
368
369 class USERPREF_PT_system(Panel):
370     bl_space_type = 'USER_PREFERENCES'
371     bl_label = "System"
372     bl_region_type = 'WINDOW'
373     bl_options = {'HIDE_HEADER'}
374
375     @classmethod
376     def poll(cls, context):
377         userpref = context.user_preferences
378         return (userpref.active_section == 'SYSTEM')
379
380     def draw(self, context):
381         layout = self.layout
382
383         userpref = context.user_preferences
384         system = userpref.system
385
386         split = layout.split()
387
388         # 1. Column
389         column = split.column()
390         colsplit = column.split(percentage=0.85)
391
392         col = colsplit.column()
393         col.label(text="General:")
394         col.prop(system, "dpi")
395         col.prop(system, "frame_server_port")
396         col.prop(system, "scrollback", text="Console Scrollback")
397
398         col.separator()
399         col.separator()
400
401         col.label(text="Sound:")
402         col.row().prop(system, "audio_device", expand=True)
403         sub = col.column()
404         sub.active = system.audio_device != 'NONE'
405         #sub.prop(system, "use_preview_images")
406         sub.prop(system, "audio_channels", text="Channels")
407         sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
408         sub.prop(system, "audio_sample_rate", text="Sample Rate")
409         sub.prop(system, "audio_sample_format", text="Sample Format")
410
411         col.separator()
412         col.separator()
413
414         col.label(text="Screencast:")
415         col.prop(system, "screencast_fps")
416         col.prop(system, "screencast_wait_time")
417
418         col.separator()
419         col.separator()
420
421         if hasattr(system, 'compute_device'):
422             col.label(text="Compute Device:")
423             col.row().prop(system, "compute_device_type", expand=True)
424             sub = col.row()
425             sub.active = system.compute_device_type != 'CPU'
426             sub.prop(system, "compute_device", text="")
427
428         # 2. Column
429         column = split.column()
430         colsplit = column.split(percentage=0.85)
431
432         col = colsplit.column()
433         col.label(text="OpenGL:")
434         col.prop(system, "gl_clip_alpha", slider=True)
435         col.prop(system, "use_mipmaps")
436         col.prop(system, "use_16bit_textures")
437         col.label(text="Anisotropic Filtering")
438         col.prop(system, "anisotropic_filter", text="")
439         col.prop(system, "use_vertex_buffer_objects")
440         # Anti-aliasing is disabled as it breaks border/lasso select
441         #~ col.prop(system, "use_antialiasing")
442         col.label(text="Window Draw Method:")
443         col.prop(system, "window_draw_method", text="")
444         col.label(text="Text Draw Options:")
445         col.prop(system, "use_text_antialiasing")
446         col.label(text="Textures:")
447         col.prop(system, "gl_texture_limit", text="Limit Size")
448         col.prop(system, "texture_time_out", text="Time Out")
449         col.prop(system, "texture_collection_rate", text="Collection Rate")
450
451         col.separator()
452         col.separator()
453         col.separator()
454
455         col.label(text="Sequencer:")
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
492         column.prop(system, "use_international_fonts")
493         if system.use_international_fonts:
494             column.prop(system, "language")
495             row = column.row()
496             row.label(text="Translate:")
497             row.prop(system, "use_translate_interface", text="Interface")
498             row.prop(system, "use_translate_tooltips", text="Tooltips")
499
500
501 class USERPREF_MT_interface_theme_presets(Menu):
502     bl_label = "Presets"
503     preset_subdir = "interface_theme"
504     preset_operator = "script.execute_preset"
505     preset_type = 'XML'
506     preset_xml_map = (("user_preferences.themes[0]", "Theme"), )
507     draw = Menu.draw_preset
508
509
510 class USERPREF_PT_theme(Panel):
511     bl_space_type = 'USER_PREFERENCES'
512     bl_label = "Themes"
513     bl_region_type = 'WINDOW'
514     bl_options = {'HIDE_HEADER'}
515
516     @staticmethod
517     def _theme_generic(split, themedata):
518
519         col = split.column()
520
521         def theme_generic_recurse(data):
522             col.label(data.rna_type.name)
523             row = col.row()
524             subsplit = row.split(percentage=0.95)
525
526             padding1 = subsplit.split(percentage=0.15)
527             padding1.column()
528
529             subsplit = row.split(percentage=0.85)
530
531             padding2 = subsplit.split(percentage=0.15)
532             padding2.column()
533
534             colsub_pair = padding1.column(), padding2.column()
535
536             props_type = {}
537
538             for i, prop in enumerate(data.rna_type.properties):
539                 if prop.identifier == "rna_type":
540                     continue
541
542                 props_type.setdefault((prop.type, prop.subtype), []).append(prop)
543
544             for props_type, props_ls in sorted(props_type.items()):
545                 if props_type[0] == 'POINTER':
546                     for i, prop in enumerate(props_ls):
547                         theme_generic_recurse(getattr(data, prop.identifier))
548                 else:
549                     for i, prop in enumerate(props_ls):
550                         colsub_pair[i % 2].row().prop(data, prop.identifier)
551
552         theme_generic_recurse(themedata)
553
554     @classmethod
555     def poll(cls, context):
556         userpref = context.user_preferences
557         return (userpref.active_section == 'THEMES')
558
559     def draw(self, context):
560         layout = self.layout
561
562         theme = context.user_preferences.themes[0]
563
564         split_themes = layout.split(percentage=0.2)
565
566         sub = split_themes.column()
567
568         sub.label(text="Presets:")
569         subrow = sub.row(align=True)
570
571         subrow.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
572         subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMIN')
573         subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMOUT').remove_active = True
574         sub.separator()
575
576         sub.prop(theme, "theme_area", expand=True)
577
578         split = layout.split(percentage=0.4)
579
580         layout.separator()
581         layout.separator()
582
583         split = split_themes.split()
584
585         if theme.theme_area == 'USER_INTERFACE':
586             col = split.column()
587
588             ui = theme.user_interface.wcol_regular
589             col.label(text="Regular:")
590             ui_items_general(col, ui)
591
592             ui = theme.user_interface.wcol_tool
593             col.label(text="Tool:")
594             ui_items_general(col, ui)
595
596             ui = theme.user_interface.wcol_radio
597             col.label(text="Radio Buttons:")
598             ui_items_general(col, ui)
599
600             ui = theme.user_interface.wcol_text
601             col.label(text="Text:")
602             ui_items_general(col, ui)
603
604             ui = theme.user_interface.wcol_option
605             col.label(text="Option:")
606             ui_items_general(col, ui)
607
608             ui = theme.user_interface.wcol_toggle
609             col.label(text="Toggle:")
610             ui_items_general(col, ui)
611
612             ui = theme.user_interface.wcol_num
613             col.label(text="Number Field:")
614             ui_items_general(col, ui)
615
616             ui = theme.user_interface.wcol_numslider
617             col.label(text="Value Slider:")
618             ui_items_general(col, ui)
619
620             ui = theme.user_interface.wcol_box
621             col.label(text="Box:")
622             ui_items_general(col, ui)
623
624             ui = theme.user_interface.wcol_menu
625             col.label(text="Menu:")
626             ui_items_general(col, ui)
627
628             ui = theme.user_interface.wcol_pulldown
629             col.label(text="Pulldown:")
630             ui_items_general(col, ui)
631
632             ui = theme.user_interface.wcol_menu_back
633             col.label(text="Menu Back:")
634             ui_items_general(col, ui)
635
636             ui = theme.user_interface.wcol_tooltip
637             col.label(text="Tooltip:")
638             ui_items_general(col, ui)
639
640             ui = theme.user_interface.wcol_tooltip
641             col.label(text="Tooltip:")
642             ui_items_general(col, ui)
643
644             ui = theme.user_interface.wcol_menu_item
645             col.label(text="Menu Item:")
646             ui_items_general(col, ui)
647
648             ui = theme.user_interface.wcol_scroll
649             col.label(text="Scroll Bar:")
650             ui_items_general(col, ui)
651
652             ui = theme.user_interface.wcol_progress
653             col.label(text="Progress Bar:")
654             ui_items_general(col, ui)
655
656             ui = theme.user_interface.wcol_list_item
657             col.label(text="List Item:")
658             ui_items_general(col, ui)
659
660             ui = theme.user_interface.wcol_state
661             col.label(text="State:")
662
663             row = col.row()
664
665             subsplit = row.split(percentage=0.95)
666
667             padding = subsplit.split(percentage=0.15)
668             colsub = padding.column()
669             colsub = padding.column()
670             colsub.row().prop(ui, "inner_anim")
671             colsub.row().prop(ui, "inner_anim_sel")
672             colsub.row().prop(ui, "inner_driven")
673             colsub.row().prop(ui, "inner_driven_sel")
674
675             subsplit = row.split(percentage=0.85)
676
677             padding = subsplit.split(percentage=0.15)
678             colsub = padding.column()
679             colsub = padding.column()
680             colsub.row().prop(ui, "inner_key")
681             colsub.row().prop(ui, "inner_key_sel")
682             colsub.row().prop(ui, "blend")
683
684             col.separator()
685             col.separator()
686
687             ui = theme.user_interface
688             col.label("Icons:")
689
690             row = col.row()
691
692             subsplit = row.split(percentage=0.95)
693
694             padding = subsplit.split(percentage=0.15)
695             colsub = padding.column()
696             colsub = padding.column()
697             colsub.row().prop(ui, "icon_file")
698
699             subsplit = row.split(percentage=0.85)
700
701             padding = subsplit.split(percentage=0.15)
702             colsub = padding.column()
703             colsub = padding.column()
704             colsub.row().prop(ui, "icon_alpha")
705
706             col.separator()
707             col.separator()
708
709             ui = theme.user_interface.panel
710             col.label("Panels:")
711
712             row = col.row()
713
714             subsplit = row.split(percentage=0.95)
715
716             padding = subsplit.split(percentage=0.15)
717             colsub = padding.column()
718             colsub = padding.column()
719             rowsub = colsub.row()
720             rowsub.prop(ui, "show_header")
721             rowsub.label()
722
723             subsplit = row.split(percentage=0.85)
724
725             padding = subsplit.split(percentage=0.15)
726             colsub = padding.column()
727             colsub = padding.column()
728             colsub.row().prop(ui, "header")
729
730             layout.separator()
731             layout.separator()
732         elif theme.theme_area == 'BONE_COLOR_SETS':
733             col = split.column()
734
735             for i, ui in enumerate(theme.bone_color_sets):
736                 col.label(text="Color Set" + " %d:" % (i + 1))  # i starts from 0
737
738                 row = col.row()
739
740                 subsplit = row.split(percentage=0.95)
741
742                 padding = subsplit.split(percentage=0.15)
743                 colsub = padding.column()
744                 colsub = padding.column()
745                 colsub.row().prop(ui, "normal")
746                 colsub.row().prop(ui, "select")
747                 colsub.row().prop(ui, "active")
748
749                 subsplit = row.split(percentage=0.85)
750
751                 padding = subsplit.split(percentage=0.15)
752                 colsub = padding.column()
753                 colsub = padding.column()
754                 colsub.row().prop(ui, "show_colored_constraints")
755         else:
756             self._theme_generic(split, getattr(theme, theme.theme_area.lower()))
757
758
759 class USERPREF_PT_file(Panel):
760     bl_space_type = 'USER_PREFERENCES'
761     bl_label = "Files"
762     bl_region_type = 'WINDOW'
763     bl_options = {'HIDE_HEADER'}
764
765     @classmethod
766     def poll(cls, context):
767         userpref = context.user_preferences
768         return (userpref.active_section == 'FILES')
769
770     def draw(self, context):
771         layout = self.layout
772
773         userpref = context.user_preferences
774         paths = userpref.filepaths
775         system = userpref.system
776
777         split = layout.split(percentage=0.7)
778
779         col = split.column()
780         col.label(text="File Paths:")
781
782         colsplit = col.split(percentage=0.95)
783         col1 = colsplit.split(percentage=0.3)
784
785         sub = col1.column()
786         sub.label(text="Fonts:")
787         sub.label(text="Textures:")
788         sub.label(text="Render Output:")
789         sub.label(text="Scripts:")
790         sub.label(text="Sounds:")
791         sub.label(text="Temp:")
792         sub.label(text="Image Editor:")
793         sub.label(text="Animation Player:")
794
795         sub = col1.column()
796         sub.prop(paths, "font_directory", text="")
797         sub.prop(paths, "texture_directory", text="")
798         sub.prop(paths, "render_output_directory", text="")
799         sub.prop(paths, "script_directory", text="")
800         sub.prop(paths, "sound_directory", text="")
801         sub.prop(paths, "temporary_directory", text="")
802         sub.prop(paths, "image_editor", text="")
803         subsplit = sub.split(percentage=0.3)
804         subsplit.prop(paths, "animation_player_preset", text="")
805         subsplit.prop(paths, "animation_player", text="")
806
807         col.separator()
808         col.separator()
809
810         colsplit = col.split(percentage=0.95)
811         sub = colsplit.column()
812         sub.label(text="Author:")
813         sub.prop(system, "author", text="")
814
815         col = split.column()
816         col.label(text="Save & Load:")
817         col.prop(paths, "use_relative_paths")
818         col.prop(paths, "use_file_compression")
819         col.prop(paths, "use_load_ui")
820         col.prop(paths, "use_filter_files")
821         col.prop(paths, "show_hidden_files_datablocks")
822         col.prop(paths, "hide_recent_locations")
823         col.prop(paths, "show_thumbnails")
824
825         col.separator()
826         col.separator()
827
828         col.prop(paths, "save_version")
829         col.prop(paths, "recent_files")
830         col.prop(paths, "use_save_preview_images")
831         col.label(text="Auto Save:")
832         col.prop(paths, "use_auto_save_temporary_files")
833         sub = col.column()
834         sub.active = paths.use_auto_save_temporary_files
835         sub.prop(paths, "auto_save_time", text="Timer (mins)")
836
837         col.separator()
838
839         col.label(text="Scripts:")
840         col.prop(system, "use_scripts_auto_execute")
841         col.prop(system, "use_tabs_as_spaces")
842
843
844 from bl_ui.space_userpref_keymap import InputKeyMapPanel
845
846
847 class USERPREF_MT_ndof_settings(Menu):
848     # accessed from the window key-bindings in C (only)
849     bl_label = "3D Mouse Settings"
850
851     def draw(self, context):
852         layout = self.layout
853         input_prefs = context.user_preferences.inputs
854
855         layout.separator()
856         layout.prop(input_prefs, "ndof_sensitivity")
857
858         if context.space_data.type == 'VIEW_3D':
859             layout.separator()
860             layout.prop(input_prefs, "ndof_show_guide")
861
862             layout.separator()
863             layout.label(text="Orbit options")
864             if input_prefs.view_rotate_method == 'TRACKBALL':
865                 layout.prop(input_prefs, "ndof_roll_invert_axis")
866             layout.prop(input_prefs, "ndof_tilt_invert_axis")
867             layout.prop(input_prefs, "ndof_rotate_invert_axis")
868             layout.prop(input_prefs, "ndof_zoom_invert")
869
870             layout.separator()
871             layout.label(text="Pan options")
872             layout.prop(input_prefs, "ndof_panx_invert_axis")
873             layout.prop(input_prefs, "ndof_pany_invert_axis")
874             layout.prop(input_prefs, "ndof_panz_invert_axis")
875
876             layout.label(text="Zoom options")
877             layout.prop(input_prefs, "ndof_zoom_updown")
878
879             layout.separator()
880             layout.label(text="Fly options")
881             layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
882             layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
883
884
885 class USERPREF_PT_input(Panel, InputKeyMapPanel):
886     bl_space_type = 'USER_PREFERENCES'
887     bl_label = "Input"
888
889     @classmethod
890     def poll(cls, context):
891         userpref = context.user_preferences
892         return (userpref.active_section == 'INPUT')
893
894     def draw_input_prefs(self, inputs, layout):
895         # General settings
896         row = layout.row()
897         col = row.column()
898
899         sub = col.column()
900         sub.label(text="Presets:")
901         subrow = sub.row(align=True)
902
903         subrow.menu("USERPREF_MT_interaction_presets", text=bpy.types.USERPREF_MT_interaction_presets.bl_label)
904         subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMIN')
905         subrow.operator("wm.interaction_preset_add", text="", icon='ZOOMOUT').remove_active = True
906         sub.separator()
907
908         sub.label(text="Mouse:")
909         sub1 = sub.column()
910         sub1.active = (inputs.select_mouse == 'RIGHT')
911         sub1.prop(inputs, "use_mouse_emulate_3_button")
912         sub.prop(inputs, "use_mouse_continuous")
913         sub.prop(inputs, "drag_threshold")
914         sub.prop(inputs, "tweak_threshold")
915
916         sub.label(text="Select With:")
917         sub.row().prop(inputs, "select_mouse", expand=True)
918
919         sub = col.column()
920         sub.label(text="Double Click:")
921         sub.prop(inputs, "mouse_double_click_time", text="Speed")
922
923         sub.separator()
924
925         sub.prop(inputs, "use_emulate_numpad")
926
927         sub.separator()
928
929         sub.label(text="Orbit Style:")
930         sub.row().prop(inputs, "view_rotate_method", expand=True)
931
932         sub.label(text="Zoom Style:")
933         sub.row().prop(inputs, "view_zoom_method", text="")
934         if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
935             sub.row().prop(inputs, "view_zoom_axis", expand=True)
936             sub.prop(inputs, "invert_mouse_zoom")
937
938         #sub.prop(inputs, "use_mouse_mmb_paste")
939
940         #col.separator()
941
942         sub = col.column()
943         sub.label(text="Mouse Wheel:")
944         sub.prop(inputs, "invert_zoom_wheel", text="Invert Wheel Zoom Direction")
945         #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
946
947         col.separator()
948         sub = col.column()
949         sub.label(text="NDOF Device:")
950         sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity")
951
952         row.separator()
953
954     def draw(self, context):
955         layout = self.layout
956
957         #import time
958
959         #start = time.time()
960
961         userpref = context.user_preferences
962
963         inputs = userpref.inputs
964
965         split = layout.split(percentage=0.25)
966
967         # Input settings
968         self.draw_input_prefs(inputs, split)
969
970         # Keymap Settings
971         self.draw_keymaps(context, split)
972
973         #print("runtime", time.time() - start)
974
975
976 class USERPREF_MT_addons_dev_guides(Menu):
977     bl_label = "Development Guides"
978
979     # menu to open web-pages with addons development guides
980     def draw(self, context):
981         layout = self.layout
982         layout.operator("wm.url_open", text="API Concepts", icon='URL').url = "http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro"
983         layout.operator("wm.url_open", text="Addon Guidelines", icon='URL').url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons"
984         layout.operator("wm.url_open", text="How to share your addon", icon='URL').url = "http://wiki.blender.org/index.php/Dev:Py/Sharing"
985
986
987 class USERPREF_PT_addons(Panel):
988     bl_space_type = 'USER_PREFERENCES'
989     bl_label = "Addons"
990     bl_region_type = 'WINDOW'
991     bl_options = {'HIDE_HEADER'}
992
993     _support_icon_mapping = {
994         'OFFICIAL': 'FILE_BLEND',
995         'COMMUNITY': 'POSE_DATA',
996         'TESTING': 'MOD_EXPLODE',
997         }
998
999     @classmethod
1000     def poll(cls, context):
1001         userpref = context.user_preferences
1002         return (userpref.active_section == 'ADDONS')
1003
1004     @staticmethod
1005     def is_user_addon(mod, user_addon_paths):
1006         if not user_addon_paths:
1007             user_script_path = bpy.utils.user_script_path()
1008             if user_script_path is not None:
1009                 user_addon_paths.append(os.path.join(user_script_path, "addons"))
1010             user_addon_paths.append(os.path.join(bpy.utils.resource_path('USER'), "scripts", "addons"))
1011
1012         for path in user_addon_paths:
1013             if bpy.path.is_subdir(mod.__file__, path):
1014                 return True
1015         return False
1016
1017     @staticmethod
1018     def draw_error(layout, message):
1019         lines = message.split("\n")
1020         box = layout.box()
1021         rowsub = box.row()
1022         rowsub.label(lines[0])
1023         rowsub.label(icon='ERROR')
1024         for l in lines[1:]:
1025             box.label(l)
1026
1027     def draw(self, context):
1028         layout = self.layout
1029
1030         userpref = context.user_preferences
1031         used_ext = {ext.module for ext in userpref.addons}
1032
1033         # collect the categories that can be filtered on
1034         addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(addon_utils.addons_fake_modules)]
1035
1036         split = layout.split(percentage=0.2)
1037         col = split.column()
1038         col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
1039
1040         col.label(text="Supported Level")
1041         col.prop(context.window_manager, "addon_support", expand=True)
1042
1043         col.label(text="Categories")
1044         col.prop(context.window_manager, "addon_filter", expand=True)
1045
1046         col = split.column()
1047
1048         # set in addon_utils.modules(...)
1049         if addon_utils.error_duplicates:
1050             self.draw_error(col,
1051                             "Multiple addons using the same name found!\n"
1052                             "likely a problem with the script search path.\n"
1053                             "(see console for details)",
1054                             )
1055
1056         if addon_utils.error_encoding:
1057             self.draw_error(col,
1058                             "One or more addons do not have UTF-8 encoding\n"
1059                             "(see console for details)",
1060                             )
1061
1062         filter = context.window_manager.addon_filter
1063         search = context.window_manager.addon_search.lower()
1064         support = context.window_manager.addon_support
1065
1066         # initialized on demand
1067         user_addon_paths = []
1068
1069         for mod, info in addons:
1070             module_name = mod.__name__
1071
1072             is_enabled = module_name in used_ext
1073
1074             if info["support"] not in support:
1075                 continue
1076
1077             # check if addon should be visible with current filters
1078             if ((filter == "All") or
1079                 (filter == info["category"]) or
1080                 (filter == "Enabled" and is_enabled) or
1081                 (filter == "Disabled" and not is_enabled)):
1082
1083                 if search and search not in info["name"].lower():
1084                     if info["author"]:
1085                         if search not in info["author"].lower():
1086                             continue
1087                     else:
1088                         continue
1089
1090                 # Addon UI Code
1091                 box = col.column().box()
1092                 colsub = box.column()
1093                 row = colsub.row()
1094
1095                 row.operator("wm.addon_expand", icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT', emboss=False).module = module_name
1096
1097                 rowsub = row.row()
1098                 rowsub.active = is_enabled
1099                 rowsub.label(text='%s: %s' % (info['category'], info["name"]))
1100                 if info["warning"]:
1101                     rowsub.label(icon='ERROR')
1102
1103                 # icon showing support level.
1104                 rowsub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
1105
1106                 if is_enabled:
1107                     row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name
1108                 else:
1109                     row.operator("wm.addon_enable", icon='CHECKBOX_DEHLT', text="", emboss=False).module = module_name
1110
1111                 # Expanded UI (only if additional info is available)
1112                 if info["show_expanded"]:
1113                     if info["description"]:
1114                         split = colsub.row().split(percentage=0.15)
1115                         split.label(text="Description:")
1116                         split.label(text=info["description"])
1117                     if info["location"]:
1118                         split = colsub.row().split(percentage=0.15)
1119                         split.label(text="Location:")
1120                         split.label(text=info["location"])
1121                     if mod:
1122                         split = colsub.row().split(percentage=0.15)
1123                         split.label(text="File:")
1124                         split.label(text=mod.__file__)
1125                     if info["author"]:
1126                         split = colsub.row().split(percentage=0.15)
1127                         split.label(text="Author:")
1128                         split.label(text=info["author"])
1129                     if info["version"]:
1130                         split = colsub.row().split(percentage=0.15)
1131                         split.label(text="Version:")
1132                         split.label(text='.'.join(str(x) for x in info["version"]))
1133                     if info["warning"]:
1134                         split = colsub.row().split(percentage=0.15)
1135                         split.label(text="Warning:")
1136                         split.label(text='  ' + info["warning"], icon='ERROR')
1137
1138                     user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths)
1139                     tot_row = bool(info["wiki_url"]) + bool(info["tracker_url"]) + bool(user_addon)
1140
1141                     if tot_row:
1142                         split = colsub.row().split(percentage=0.15)
1143                         split.label(text="Internet:")
1144                         if info["wiki_url"]:
1145                             split.operator("wm.url_open", text="Link to the Wiki", icon='HELP').url = info["wiki_url"]
1146                         if info["tracker_url"]:
1147                             split.operator("wm.url_open", text="Report a Bug", icon='URL').url = info["tracker_url"]
1148                         if user_addon:
1149                             split.operator("wm.addon_remove", text="Remove", icon='CANCEL').module = mod.__name__
1150
1151                         for i in range(4 - tot_row):
1152                             split.separator()
1153
1154         # Append missing scripts
1155         # First collect scripts that are used but have no script file.
1156         module_names = {mod.__name__ for mod, info in addons}
1157         missing_modules = {ext for ext in used_ext if ext not in module_names}
1158
1159         if missing_modules and filter in {"All", "Enabled"}:
1160             col.column().separator()
1161             col.column().label(text="Missing script files")
1162
1163             module_names = {mod.__name__ for mod, info in addons}
1164             for module_name in sorted(missing_modules):
1165                 is_enabled = module_name in used_ext
1166                 # Addon UI Code
1167                 box = col.column().box()
1168                 colsub = box.column()
1169                 row = colsub.row()
1170
1171                 row.label(text=module_name, icon='ERROR')
1172
1173                 if is_enabled:
1174                     row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name
1175
1176 if __name__ == "__main__":  # only for live edit.
1177     bpy.utils.register_module(__name__)