diff options
author | Matt Ebb <matt@mke3.net> | 2010-04-14 10:27:50 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-04-14 10:27:50 +0400 |
commit | 486796ce31cdbec68ec765b011cd09b141e20578 (patch) | |
tree | e92dbfc6a717c6701f3786ea4c72294d4611b945 /release/scripts/op/presets.py | |
parent | 85590301a53f97080208d40ee97d88c4789d72d4 (diff) |
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
Diffstat (limited to 'release/scripts/op/presets.py')
-rw-r--r-- | release/scripts/op/presets.py | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/release/scripts/op/presets.py b/release/scripts/op/presets.py index 1a8e57f7c32..3272bdfb8ad 100644 --- a/release/scripts/op/presets.py +++ b/release/scripts/op/presets.py @@ -46,7 +46,13 @@ class AddPresetBase(bpy.types.Operator): target_path = bpy.utils.preset_paths(self.preset_subdir)[0] # we need some way to tell the user and system preset path - file_preset = open(os.path.join(target_path, filename), 'w') + path = os.path.join(target_path, filename) + if getattr(self, "save_keyconfig", True): + bpy.ops.wm.keyconfig_export(path=path, kc_name=self.properties.name) + file_preset = open(path, 'a') + file_preset.write("wm.active_keyconfig = kc\n\n") + else: + file_preset = open(path, 'w') for rna_path in self.preset_values: value = eval(rna_path) @@ -68,6 +74,24 @@ class AddPresetBase(bpy.types.Operator): return {'RUNNING_MODAL'} +class ExecutePreset(bpy.types.Operator): + ''' Executes a preset ''' + bl_idname = "script.execute_preset" + bl_label = "Execute a Python Preset" + + path = bpy.props.StringProperty(name="Path", description="Path of the Python file to execute", maxlen=512, default="") + preset_name = bpy.props.StringProperty(name="Preset Name", description="Name of the Preset being executed", default="") + menu_idname = bpy.props.StringProperty(name="Menu ID Name", description="ID name of the menu this was called from", default="") + + def execute(self, context): + # change the menu title to the most recently chosen option + exec("bpy.types.%s.bl_label=\'%s\'" % (self.properties.menu_idname, self.properties.preset_name)) + + # execute the preset using script.python_file_run + bpy.ops.script.python_file_run(path=self.properties.path) + return {'FINISHED'} + + class AddPresetRender(AddPresetBase): '''Add a Render Preset''' bl_idname = "render.preset_add" @@ -157,12 +181,32 @@ class AddPresetSunSky(AddPresetBase): preset_subdir = "sunsky" +class AddPresetInteraction(AddPresetBase): + '''Add an Application Interaction Preset''' + bl_idname = "wm.interaction_preset_add" + bl_label = "Add Interaction Preset" + name = AddPresetBase.name + save_keyconfig = True + + preset_values = [ + "bpy.context.user_preferences.edit.drag_immediately", + "bpy.context.user_preferences.edit.insertkey_xyz_to_rgb", + "bpy.context.user_preferences.inputs.select_mouse", + "bpy.context.user_preferences.inputs.zoom_style", + "bpy.context.user_preferences.inputs.zoom_axis", + "bpy.context.user_preferences.inputs.view_rotation", + "bpy.context.user_preferences.inputs.invert_zoom_direction", + ] + + preset_subdir = "interaction" classes = [ + ExecutePreset, AddPresetRender, AddPresetSSS, AddPresetCloth, - AddPresetSunSky] + AddPresetSunSky, + AddPresetInteraction] def register(): |