Movie Clip Node: skip putting frame to cache when rendering animation
[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             layout.operator("wm.theme_install")
100
101
102 class USERPREF_PT_tabs(Panel):
103     bl_label = ""
104     bl_space_type = 'USER_PREFERENCES'
105     bl_region_type = 'WINDOW'
106     bl_options = {'HIDE_HEADER'}
107
108     def draw(self, context):
109         layout = self.layout
110
111         userpref = context.user_preferences
112
113         layout.prop(userpref, "active_section", expand=True)
114
115
116 class USERPREF_MT_interaction_presets(Menu):
117     bl_label = "Presets"
118     preset_subdir = "interaction"
119     preset_operator = "script.execute_preset"
120     draw = Menu.draw_preset
121
122
123 class USERPREF_MT_appconfigs(Menu):
124     bl_label = "AppPresets"
125     preset_subdir = "keyconfig"
126     preset_operator = "wm.appconfig_activate"
127
128     def draw(self, context):
129         self.layout.operator("wm.appconfig_default", text="Blender (default)")
130
131         # now draw the presets
132         Menu.draw_preset(self, context)
133
134
135 class USERPREF_MT_splash(Menu):
136     bl_label = "Splash"
137
138     def draw(self, context):
139         layout = self.layout
140         split = layout.split()
141         row = split.row()
142         row.label("")
143         row = split.row()
144         row.label("Interaction:")
145         # XXX, no redraws
146         # text = bpy.path.display_name(context.window_manager.keyconfigs.active.name)
147         # if not text:
148         #     text = "Blender (default)"
149         row.menu("USERPREF_MT_appconfigs", text="Preset")
150
151
152 class USERPREF_PT_interface(Panel):
153     bl_space_type = 'USER_PREFERENCES'
154     bl_label = "Interface"
155     bl_region_type = 'WINDOW'
156     bl_options = {'HIDE_HEADER'}
157
158     @classmethod
159     def poll(cls, context):
160         userpref = context.user_preferences
161         return (userpref.active_section == 'INTERFACE')
162
163     def draw(self, context):
164         layout = self.layout
165
166         userpref = context.user_preferences
167         view = userpref.view
168
169         row = layout.row()
170
171         col = row.column()
172         col.label(text="Display:")
173         col.prop(view, "show_tooltips")
174         col.prop(view, "show_tooltips_python")
175         col.prop(view, "show_object_info", text="Object Info")
176         col.prop(view, "show_large_cursors")
177         col.prop(view, "show_view_name", text="View Name")
178         col.prop(view, "show_playback_fps", text="Playback FPS")
179         col.prop(view, "use_global_scene")
180         col.prop(view, "object_origin_size")
181
182         col.separator()
183         col.separator()
184         col.separator()
185
186         col.prop(view, "show_mini_axis", text="Display Mini Axis")
187         sub = col.column()
188         sub.active = view.show_mini_axis
189         sub.prop(view, "mini_axis_size", text="Size")
190         sub.prop(view, "mini_axis_brightness", text="Brightness")
191
192         col.separator()
193         row.separator()
194         row.separator()
195
196         col = row.column()
197         col.label(text="View Manipulation:")
198         col.prop(view, "use_mouse_auto_depth")
199         col.prop(view, "use_zoom_to_mouse")
200         col.prop(view, "use_rotate_around_active")
201         col.prop(view, "use_global_pivot")
202         col.prop(view, "use_camera_lock_parent")
203
204         col.separator()
205
206         col.prop(view, "use_auto_perspective")
207         col.prop(view, "smooth_view")
208         col.prop(view, "rotation_angle")
209
210         col.separator()
211         col.separator()
212
213         col.label(text="2D Viewports:")
214         col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
215         col.prop(view, "timecode_style")
216
217         row.separator()
218         row.separator()
219
220         col = row.column()
221         #Toolbox doesn't exist yet
222         #col.label(text="Toolbox:")
223         #col.prop(view, "show_column_layout")
224         #col.label(text="Open Toolbox Delay:")
225         #col.prop(view, "open_left_mouse_delay", text="Hold LMB")
226         #col.prop(view, "open_right_mouse_delay", text="Hold RMB")
227         col.prop(view, "show_manipulator")
228         sub = col.column()
229         sub.active = view.show_manipulator
230         sub.prop(view, "manipulator_size", text="Size")
231         sub.prop(view, "manipulator_handle_size", text="Handle Size")
232         sub.prop(view, "manipulator_hotspot", text="Hotspot")
233
234         col.separator()
235         col.separator()
236         col.separator()
237
238         col.label(text="Menus:")
239         col.prop(view, "use_mouse_over_open")
240         col.label(text="Menu Open Delay:")
241         col.prop(view, "open_toplevel_delay", text="Top Level")
242         col.prop(view, "open_sublevel_delay", text="Sub Level")
243
244         col.separator()
245
246         col.prop(view, "show_splash")
247
248         if os.name == "nt":
249             col.prop(view, "quit_dialog")
250
251
252 class USERPREF_PT_edit(Panel):
253     bl_space_type = 'USER_PREFERENCES'
254     bl_label = "Edit"
255     bl_region_type = 'WINDOW'
256     bl_options = {'HIDE_HEADER'}
257
258     @classmethod
259     def poll(cls, context):
260         userpref = context.user_preferences
261         return (userpref.active_section == 'EDITING')
262
263     def draw(self, context):
264         layout = self.layout
265
266         userpref = context.user_preferences
267         edit = userpref.edit
268
269         row = layout.row()
270
271         col = row.column()
272         col.label(text="Link Materials To:")
273         col.prop(edit, "material_link", text="")
274
275         col.separator()
276         col.separator()
277         col.separator()
278
279         col.label(text="New Objects:")
280         col.prop(edit, "use_enter_edit_mode")
281         col.label(text="Align To:")
282         col.prop(edit, "object_align", text="")
283
284         col.separator()
285         col.separator()
286         col.separator()
287
288         col.label(text="Undo:")
289         col.prop(edit, "use_global_undo")
290         col.prop(edit, "undo_steps", text="Steps")
291         col.prop(edit, "undo_memory_limit", text="Memory Limit")
292
293         row.separator()
294         row.separator()
295
296         col = row.column()
297         col.label(text="Grease Pencil:")
298         col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
299         col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
300         #~ col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke")
301         col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
302         col.prop(edit, "use_grease_pencil_smooth_stroke", text="Smooth Stroke")
303         col.separator()
304         col.separator()
305         col.separator()
306         col.label(text="Playback:")
307         col.prop(edit, "use_negative_frames")
308         col.separator()
309         col.separator()
310         col.separator()
311         col.label(text="Animation Editors:")
312         col.prop(edit, "fcurve_unselected_alpha", text="F-Curve Visibility")
313
314         row.separator()
315         row.separator()
316
317         col = row.column()
318         col.label(text="Keyframing:")
319         col.prop(edit, "use_visual_keying")
320         col.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed")
321
322         col.separator()
323
324         col.prop(edit, "use_auto_keying", text="Auto Keyframing:")
325
326         sub = col.column()
327
328         #~ sub.active = edit.use_keyframe_insert_auto # incorrect, time-line can enable
329         sub.prop(edit, "use_keyframe_insert_available", text="Only Insert Available")
330
331         col.separator()
332
333         col.label(text="New F-Curve Defaults:")
334         col.prop(edit, "keyframe_new_interpolation_type", text="Interpolation")
335         col.prop(edit, "keyframe_new_handle_type", text="Handles")
336         col.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB")
337
338         col.separator()
339         col.separator()
340         col.separator()
341
342         col.label(text="Transform:")
343         col.prop(edit, "use_drag_immediately")
344
345         row.separator()
346         row.separator()
347
348         col = row.column()
349         col.prop(edit, "sculpt_paint_overlay_color", text="Sculpt Overlay Color")
350
351         col.separator()
352         col.separator()
353         col.separator()
354
355         col.label(text="Duplicate Data:")
356         col.prop(edit, "use_duplicate_mesh", text="Mesh")
357         col.prop(edit, "use_duplicate_surface", text="Surface")
358         col.prop(edit, "use_duplicate_curve", text="Curve")
359         col.prop(edit, "use_duplicate_text", text="Text")
360         col.prop(edit, "use_duplicate_metaball", text="Metaball")
361         col.prop(edit, "use_duplicate_armature", text="Armature")
362         col.prop(edit, "use_duplicate_lamp", text="Lamp")
363         col.prop(edit, "use_duplicate_material", text="Material")
364         col.prop(edit, "use_duplicate_texture", text="Texture")
365         #col.prop(edit, "use_duplicate_fcurve", text="F-Curve")
366         col.prop(edit, "use_duplicate_action", text="Action")
367         col.prop(edit, "use_duplicate_particle", text="Particle")
368
369
370 class USERPREF_PT_system(Panel):
371     bl_space_type = 'USER_PREFERENCES'
372     bl_label = "System"
373     bl_region_type = 'WINDOW'
374     bl_options = {'HIDE_HEADER'}
375
376     @classmethod
377     def poll(cls, context):
378         userpref = context.user_preferences
379         return (userpref.active_section == 'SYSTEM')
380
381     def draw(self, context):
382         layout = self.layout
383
384         userpref = context.user_preferences
385         system = userpref.system
386
387         split = layout.split()
388
389         # 1. Column
390         column = split.column()
391         colsplit = column.split(percentage=0.85)
392
393         col = colsplit.column()
394         col.label(text="General:")
395         col.prop(system, "dpi")
396         col.prop(system, "frame_server_port")
397         col.prop(system, "scrollback", text="Console Scrollback")
398
399         col.separator()
400         col.separator()
401
402         col.label(text="Sound:")
403         col.row().prop(system, "audio_device", expand=True)
404         sub = col.column()
405         sub.active = system.audio_device != 'NONE'
406         #sub.prop(system, "use_preview_images")
407         sub.prop(system, "audio_channels", text="Channels")
408         sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
409         sub.prop(system, "audio_sample_rate", text="Sample Rate")
410         sub.prop(system, "audio_sample_format", text="Sample Format")
411
412         col.separator()
413         col.separator()
414
415         col.label(text="Screencast:")
416         col.prop(system, "screencast_fps")
417         col.prop(system, "screencast_wait_time")
418
419         col.separator()
420         col.separator()
421
422         if hasattr(system, "compute_device"):
423             col.label(text="Compute Device:")
424             col.row().prop(system, "compute_device_type", expand=True)
425             sub = col.row()
426             sub.active = system.compute_device_type != 'CPU'
427             sub.prop(system, "compute_device", text="")
428
429         # 2. Column
430         column = split.column()
431         colsplit = column.split(percentage=0.85)
432
433         col = colsplit.column()
434         col.label(text="OpenGL:")
435         col.prop(system, "gl_clip_alpha", slider=True)
436         col.prop(system, "use_mipmaps")
437         col.prop(system, "use_gpu_mipmap")
438         col.prop(system, "use_16bit_textures")
439         col.label(text="Anisotropic Filtering")
440         col.prop(system, "anisotropic_filter", text="")
441         col.prop(system, "use_vertex_buffer_objects")
442         # Anti-aliasing is disabled as it breaks border/lasso select
443         #~ col.prop(system, "use_antialiasing")
444         col.label(text="Window Draw Method:")
445         col.prop(system, "window_draw_method", text="")
446         col.label(text="Text Draw Options:")
447         col.prop(system, "use_text_antialiasing")
448         col.label(text="Textures:")
449         col.prop(system, "gl_texture_limit", text="Limit Size")
450         col.prop(system, "texture_time_out", text="Time Out")
451         col.prop(system, "texture_collection_rate", text="Collection Rate")
452
453         col.separator()
454         col.separator()
455         col.separator()
456
457         col.label(text="Sequencer / Clip Editor:")
458         col.prop(system, "prefetch_frames")
459         col.prop(system, "memory_cache_limit")
460
461         # 3. Column
462         column = split.column()
463
464         column.label(text="Solid OpenGL lights:")
465
466         split = column.split(percentage=0.1)
467         split.label()
468         split.label(text="Colors:")
469         split.label(text="Direction:")
470
471         lamp = system.solid_lights[0]
472         opengl_lamp_buttons(column, lamp)
473
474         lamp = system.solid_lights[1]
475         opengl_lamp_buttons(column, lamp)
476
477         lamp = system.solid_lights[2]
478         opengl_lamp_buttons(column, lamp)
479
480         column.separator()
481
482         column.label(text="Color Picker Type:")
483         column.row().prop(system, "color_picker_type", text="")
484
485         column.separator()
486
487         column.prop(system, "use_weight_color_range", text="Custom Weight Paint Range")
488         sub = column.column()
489         sub.active = system.use_weight_color_range
490         sub.template_color_ramp(system, "weight_color_range", expand=True)
491
492         column.separator()
493
494         column.prop(system, "use_international_fonts")
495         if system.use_international_fonts:
496             column.prop(system, "language")
497             row = column.row()
498             row.label(text="Translate:")
499             row.prop(system, "use_translate_interface", text="Interface")
500             row.prop(system, "use_translate_tooltips", text="Tooltips")
501
502
503 class USERPREF_MT_interface_theme_presets(Menu):
504     bl_label = "Presets"
505     preset_subdir = "interface_theme"
506     preset_operator = "script.execute_preset"
507     preset_type = 'XML'
508     preset_xml_map = (("user_preferences.themes[0]", "Theme"), )
509     draw = Menu.draw_preset
510
511
512 class USERPREF_PT_theme(Panel):
513     bl_space_type = 'USER_PREFERENCES'
514     bl_label = "Themes"
515     bl_region_type = 'WINDOW'
516     bl_options = {'HIDE_HEADER'}
517
518     @staticmethod
519     def _theme_generic(split, themedata):
520
521         col = split.column()
522
523         def theme_generic_recurse(data):
524             col.label(data.rna_type.name)
525             row = col.row()
526             subsplit = row.split(percentage=0.95)
527
528             padding1 = subsplit.split(percentage=0.15)
529             padding1.column()
530
531             subsplit = row.split(percentage=0.85)
532
533             padding2 = subsplit.split(percentage=0.15)
534             padding2.column()
535
536             colsub_pair = padding1.column(), padding2.column()
537
538             props_type = {}
539
540             for i, prop in enumerate(data.rna_type.properties):
541                 if prop.identifier == "rna_type":
542                     continue
543
544                 props_type.setdefault((prop.type, prop.subtype), []).append(prop)
545
546             for props_type, props_ls in sorted(props_type.items()):
547                 if props_type[0] == 'POINTER':
548                     for i, prop in enumerate(props_ls):
549                         theme_generic_recurse(getattr(data, prop.identifier))
550                 else:
551                     for i, prop in enumerate(props_ls):
552                         colsub_pair[i % 2].row().prop(data, prop.identifier)
553
554         theme_generic_recurse(themedata)
555
556     @classmethod
557     def poll(cls, context):
558         userpref = context.user_preferences
559         return (userpref.active_section == 'THEMES')
560
561     def draw(self, context):
562         layout = self.layout
563
564         theme = context.user_preferences.themes[0]
565
566         split_themes = layout.split(percentage=0.2)
567
568         sub = split_themes.column()
569
570         sub.label(text="Presets:")
571         subrow = sub.row(align=True)
572
573         subrow.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
574         subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMIN')
575         subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMOUT').remove_active = True
576         sub.separator()
577
578         sub.prop(theme, "theme_area", expand=True)
579
580         split = layout.split(percentage=0.4)
581
582         layout.separator()
583         layout.separator()
584
585         split = split_themes.split()
586
587         if theme.theme_area == 'USER_INTERFACE':
588             col = split.column()
589
590             ui = theme.user_interface.wcol_regular
591             col.label(text="Regular:")
592             ui_items_general(col, ui)
593
594             ui = theme.user_interface.wcol_tool
595             col.label(text="Tool:")
596             ui_items_general(col, ui)
597
598             ui = theme.user_interface.wcol_radio
599             col.label(text="Radio Buttons:")
600             ui_items_general(col, ui)
601
602             ui = theme.user_interface.wcol_text
603             col.label(text="Text:")
604             ui_items_general(col, ui)
605
606             ui = theme.user_interface.wcol_option
607             col.label(text="Option:")
608             ui_items_general(col, ui)
609
610             ui = theme.user_interface.wcol_toggle
611             col.label(text="Toggle:")
612             ui_items_general(col, ui)
613
614             ui = theme.user_interface.wcol_num
615             col.label(text="Number Field:")
616             ui_items_general(col, ui)
617
618             ui = theme.user_interface.wcol_numslider
619             col.label(text="Value Slider:")
620             ui_items_general(col, ui)
621
622             ui = theme.user_interface.wcol_box
623             col.label(text="Box:")
624             ui_items_general(col, ui)
625
626             ui = theme.user_interface.wcol_menu
627             col.label(text="Menu:")
628             ui_items_general(col, ui)
629
630             ui = theme.user_interface.wcol_pulldown
631             col.label(text="Pulldown:")
632             ui_items_general(col, ui)
633
634             ui = theme.user_interface.wcol_menu_back
635             col.label(text="Menu Back:")
636             ui_items_general(col, ui)
637
638             ui = theme.user_interface.wcol_tooltip
639             col.label(text="Tooltip:")
640             ui_items_general(col, ui)
641
642             ui = theme.user_interface.wcol_menu_item
643             col.label(text="Menu Item:")
644             ui_items_general(col, ui)
645
646             ui = theme.user_interface.wcol_scroll
647             col.label(text="Scroll Bar:")
648             ui_items_general(col, ui)
649
650             ui = theme.user_interface.wcol_progress
651             col.label(text="Progress Bar:")
652             ui_items_general(col, ui)
653
654             ui = theme.user_interface.wcol_list_item
655             col.label(text="List Item:")
656             ui_items_general(col, ui)
657
658             ui = theme.user_interface.wcol_state
659             col.label(text="State:")
660
661             row = col.row()
662
663             subsplit = row.split(percentage=0.95)
664
665             padding = subsplit.split(percentage=0.15)
666             colsub = padding.column()
667             colsub = padding.column()
668             colsub.row().prop(ui, "inner_anim")
669             colsub.row().prop(ui, "inner_anim_sel")
670             colsub.row().prop(ui, "inner_driven")
671             colsub.row().prop(ui, "inner_driven_sel")
672
673             subsplit = row.split(percentage=0.85)
674
675             padding = subsplit.split(percentage=0.15)
676             colsub = padding.column()
677             colsub = padding.column()
678             colsub.row().prop(ui, "inner_key")
679             colsub.row().prop(ui, "inner_key_sel")
680             colsub.row().prop(ui, "blend")
681
682             col.separator()
683             col.separator()
684
685             ui = theme.user_interface
686             col.label("Icons:")
687
688             row = col.row()
689
690             subsplit = row.split(percentage=0.95)
691
692             padding = subsplit.split(percentage=0.15)
693             colsub = padding.column()
694             colsub = padding.column()
695             colsub.row().prop(ui, "icon_file")
696
697             subsplit = row.split(percentage=0.85)
698
699             padding = subsplit.split(percentage=0.15)
700             colsub = padding.column()
701             colsub = padding.column()
702             colsub.row().prop(ui, "icon_alpha")
703
704             col.separator()
705             col.separator()
706
707             ui = theme.user_interface.panel
708             col.label("Panels:")
709
710             row = col.row()
711
712             subsplit = row.split(percentage=0.95)
713
714             padding = subsplit.split(percentage=0.15)
715             colsub = padding.column()
716             colsub = padding.column()
717             rowsub = colsub.row()
718             rowsub.prop(ui, "show_header")
719             rowsub.label()
720
721             subsplit = row.split(percentage=0.85)
722
723             padding = subsplit.split(percentage=0.15)
724             colsub = padding.column()
725             colsub = padding.column()
726             colsub.row().prop(ui, "header")
727
728             layout.separator()
729             layout.separator()
730         elif theme.theme_area == 'BONE_COLOR_SETS':
731             col = split.column()
732
733             for i, ui in enumerate(theme.bone_color_sets):
734                 col.label(text="Color Set" + " %d:" % (i + 1))  # i starts from 0
735
736                 row = col.row()
737
738                 subsplit = row.split(percentage=0.95)
739
740                 padding = subsplit.split(percentage=0.15)
741                 colsub = padding.column()
742                 colsub = padding.column()
743                 colsub.row().prop(ui, "normal")
744                 colsub.row().prop(ui, "select")
745                 colsub.row().prop(ui, "active")
746
747                 subsplit = row.split(percentage=0.85)
748
749                 padding = subsplit.split(percentage=0.15)
750                 colsub = padding.column()
751                 colsub = padding.column()
752                 colsub.row().prop(ui, "show_colored_constraints")
753         else:
754             self._theme_generic(split, getattr(theme, theme.theme_area.lower()))
755
756
757 class USERPREF_PT_file(Panel):
758     bl_space_type = 'USER_PREFERENCES'
759     bl_label = "Files"
760     bl_region_type = 'WINDOW'
761     bl_options = {'HIDE_HEADER'}
762
763     @classmethod
764     def poll(cls, context):
765         userpref = context.user_preferences
766         return (userpref.active_section == 'FILES')
767
768     def draw(self, context):
769         layout = self.layout
770
771         userpref = context.user_preferences
772         paths = userpref.filepaths
773         system = userpref.system
774
775         split = layout.split(percentage=0.7)
776
777         col = split.column()
778         col.label(text="File Paths:")
779
780         colsplit = col.split(percentage=0.95)
781         col1 = colsplit.split(percentage=0.3)
782
783         sub = col1.column()
784         sub.label(text="Fonts:")
785         sub.label(text="Textures:")
786         sub.label(text="Render Output:")
787         sub.label(text="Scripts:")
788         sub.label(text="Sounds:")
789         sub.label(text="Temp:")
790         sub.label(text="I18n Branches:")
791         sub.label(text="Image Editor:")
792         sub.label(text="Animation Player:")
793
794         sub = col1.column()
795         sub.prop(paths, "font_directory", text="")
796         sub.prop(paths, "texture_directory", text="")
797         sub.prop(paths, "render_output_directory", text="")
798         sub.prop(paths, "script_directory", text="")
799         sub.prop(paths, "sound_directory", text="")
800         sub.prop(paths, "temporary_directory", text="")
801         sub.prop(paths, "i18n_branches_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__)