[Bf-blender-cvs] [3ef59c4fd33] temp-keymap-industry-compat: Temp branch for industry compat keymap
Campbell Barton
noreply at git.blender.org
Wed Apr 10 10:17:52 CEST 2019
Commit: 3ef59c4fd33d6d666b5ed45697140ef957482c8c
Author: Campbell Barton
Date: Wed Apr 10 10:16:29 2019 +0200
Branches: temp-keymap-industry-compat
https://developer.blender.org/rB3ef59c4fd33d6d666b5ed45697140ef957482c8c
Temp branch for industry compat keymap
===================================================================
A release/scripts/presets/keyconfig/industry_compatible.py
A release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
===================================================================
diff --git a/release/scripts/presets/keyconfig/industry_compatible.py b/release/scripts/presets/keyconfig/industry_compatible.py
new file mode 100644
index 00000000000..5ccaedd6031
--- /dev/null
+++ b/release/scripts/presets/keyconfig/industry_compatible.py
@@ -0,0 +1,182 @@
+import os
+import bpy
+
+# ------------------------------------------------------------------------------
+# Operators needed by this keymap to function
+
+# Selection Modes
+
+class IC_KEYMAP_OT_mesh_select_mode(bpy.types.Operator):
+ bl_idname = "ic_keymap.mesh_select_mode"
+ bl_label = "Switch to Vertex, Edge or Face Mode from any mode"
+ bl_options = {'UNDO'}
+
+ mode: bpy.props.EnumProperty(
+ name="Mode",
+ items=(
+ ('VERTEX', "Vertex", "Switcth to Vertex Mode From any Mode"),
+ ('EDGE', "Edge", "Switcth to Edge Mode From any Mode"),
+ ('FACE', "Face", "Switcth to Face Mode From any Mode"),
+ ),
+ )
+
+ @classmethod
+ def poll(cls, context):
+ return (context.active_object is not None) and (context.object.type == 'MESH')
+
+ def execute(self, context):
+
+ if self.mode == "VERTEX":
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.mesh.select_mode(type='VERT')
+ elif self.mode == "EDGE":
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.mesh.select_mode(type='EDGE')
+ elif self.mode == "FACE":
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.mesh.select_mode(type='FACE')
+
+ return{'FINISHED'}
+
+# JKL controls for playback
+
+class IC_KEYMAP_OT_jkl_controls(bpy.types.Operator):
+ bl_idname = "ic_keymap.jkl_controls"
+ bl_label = "jkl Controls"
+ bl_description = "jkl Controls"
+
+ mode: bpy.props.EnumProperty(
+ name="JKL Mode",
+ items=(
+ ('J', "J", "Play Backwards"),
+ ('K', "K", "Pause"),
+ ('L', "L", "Play Forwards"),
+ ('KJ', "L", "Step Frame Back"),
+ ('KL', "L", "Step Frame Forward"),
+ ),
+ )
+
+ def execute(self, context):
+ scr = bpy.context.screen
+ scops = bpy.ops.screen
+
+ if self.mode == "J":
+ if scr.is_animation_playing == True:
+ scops.animation_play()
+ scops.animation_play(reverse=True)
+ else:
+ scops.animation_play(reverse=True)
+ elif self.mode == "L":
+ if scr.is_animation_playing == True:
+ scops.animation_play()
+ scops.animation_play()
+ else:
+ scops.animation_play()
+ elif self.mode == "K":
+ if scr.is_animation_playing == True:
+ scops.animation_play()
+ elif self.mode == "KJ":
+ if scr.is_animation_playing == True:
+ scops.animation_play()
+ bpy.context.scene.frame_set(bpy.context.scene.frame_current - 1)
+ elif self.mode == "KL":
+ if scr.is_animation_playing == True:
+ scops.animation_play()
+ bpy.context.scene.frame_set(bpy.context.scene.frame_current + 1)
+ else:
+ if scr.is_animation_playing == True:
+ scops.animation_play()
+
+ return {'FINISHED'}
+
+
+# Keyframe
+
+class IC_KEYMAP_OT_insert_key(bpy.types.Operator):
+ bl_idname = "ic_keymap.insert_key"
+ bl_label = "Insert Location Keyframe"
+ bl_options = {'UNDO'}
+
+ mode: bpy.props.EnumProperty(
+ name="Keyframe Mode",
+ items=(
+ ('LOCATION', "Location", "Set location keyframe"),
+ ('ROTATION', "Rotation", "Set rotation keyframe"),
+ ('SCALING', "Scaling", "Set scaling keyframe"),
+ ('LOCROTSCALE', "LocRotScale", "Set location, rotation and scaling keyframes"),
+ ),
+ )
+
+ def execute(self, context):
+ if self.mode == "LOCATION":
+ bpy.ops.anim.keyframe_insert_menu(type='Location')
+ elif self.mode == "ROTATION":
+ bpy.ops.anim.keyframe_insert_menu(type='Rotation')
+ elif self.mode == "SCALING":
+ bpy.ops.anim.keyframe_insert_menu(type='Scaling')
+ elif self.mode == "LOCROTSCALE":
+ bpy.ops.anim.keyframe_insert_menu(type='LocRotScale')
+ return{'FINISHED'}
+
+
+classes = (
+ IC_KEYMAP_OT_mesh_select_mode,
+ IC_KEYMAP_OT_insert_key,
+ IC_KEYMAP_OT_jkl_controls,
+)
+
+
+
+# ------------------------------------------------------------------------------
+# Keymap
+
+dirname, filename = os.path.split(__file__)
+idname = os.path.splitext(filename)[0]
+
+def update_fn(_self, _context):
+ load()
+
+
+def keyconfig_data_oskey_from_ctrl(keyconfig_data_src):
+ # TODO, make into more generic event transforming function.
+ keyconfig_data_dst = []
+ for km_name, km_parms, km_items_data_src in keyconfig_data_src:
+ km_items_data_dst = km_items_data_src.copy()
+ items_dst = []
+ km_items_data_dst["items"] = items_dst
+ for item_src in km_items_data_src["items"]:
+ item_op, item_event, item_prop = item_src
+ if "ctrl" in item_event:
+ item_event = item_event.copy()
+ item_event["oskey"] = item_event["ctrl"]
+ del item_event["ctrl"]
+ items_dst.append((item_op, item_event, item_prop))
+ items_dst.append(item_src)
+ keyconfig_data_dst.append((km_name, km_parms, km_items_data_dst))
+ return keyconfig_data_dst
+
+
+industry_compatible = bpy.utils.execfile(os.path.join(dirname, "keymap_data", "industry_compatible_data.py"))
+
+
+def load():
+ from sys import platform
+ from bl_keymap_utils.io import keyconfig_init_from_data
+
+ prefs = bpy.context.preferences
+
+ kc = bpy.context.window_manager.keyconfigs.new(idname)
+ params = industry_compatible.Params(use_mouse_emulate_3_button=prefs.inputs.use_mouse_emulate_3_button)
+ keyconfig_data = industry_compatible.generate_keymaps(params)
+
+ if platform == 'darwin':
+ keyconfig_data = keyconfig_data_oskey_from_ctrl(keyconfig_data)
+
+ keyconfig_init_from_data(kc, keyconfig_data)
+
+if __name__ == "__main__":
+ # XXX, no way to unregister
+ for cls in classes:
+ bpy.utils.register_class(cls)
+
+ load()
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
new file mode 100644
index 00000000000..72d8633ea5d
--- /dev/null
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -0,0 +1,3633 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+
+# ------------------------------------------------------------------------------
+# Configurable Parameters
+
+class Params:
+ __slots__ = (
+ "select_mouse",
+ "select_mouse_value",
+ "select_tweak",
+ "action_mouse",
+ "action_tweak",
+ "tool_mouse",
+ "tool_tweak",
+ "use_mouse_emulate_3_button",
+
+ )
+
+ def __init__(
+ self,
+ *,
+ use_mouse_emulate_3_button=False,
+ ):
+ self.tool_mouse = 'LEFTMOUSE'
+ self.tool_tweak = 'EVT_TWEAK_L'
+ self.action_tweak = 'EVT_TWEAK_R'
+ self.use_mouse_emulate_3_button = use_mouse_emulate_3_button
+
+
+# ------------------------------------------------------------------------------
+# Constants
+
+
+# Physical layout.
+NUMBERS_1 = ('ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE', 'ZERO')
+# Numeric order.
+NUMBERS_0 = ('ZERO', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE')
+
+
+# ------------------------------------------------------------------------------
+# Keymap Item Wrappers
+
+def op_menu(menu, kmi_args):
+ return ("wm.call_menu", kmi_args, {"properties": [("name", menu)]})
+
+
+def op_menu_pie(menu, kmi_args):
+ return ("wm.call_menu_pie", kmi_args, {"properties": [("name", menu)]})
+
+
+def op_panel(menu, kmi_args, kmi_data=()):
+ return ("wm.call_panel", kmi_args, {"properties": [("name", menu), *kmi_data]})
+
+
+def op_tool(tool, kmi_args):
+ return ("wm.tool_set_by_id", kmi_args, {"properties": [("name", tool)]})
+
+
+def op_tool_cycle(tool, kmi_args):
+ return ("wm.tool_set_by_id", kmi_args, {"properties": [("name", tool), ("cycle", True)]})
+
+
+# ------------------------------------------------------------------------------
+# Keymap Templates
+
+
+def _template_items_object_subdivision_set():
+ return [
+ ("object.subdivision_set",
+ {"type": NUMBERS_0[i], "value": 'PRESS', "ctrl": True},
+ {"properties": [("level", i), ("relative", False)]})
+ for i in range(6)
+ ]
+
+
+def _template_items_gizmo_tweak_value():
+ return [
+ ("gizmogroup.gizmo_tweak", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None),
+ ]
+
+
+def _template_items_animation():
+ return [
+ ("screen.frame_offset", {"type": 'LEFT_ARROW', "value": 'PRESS'},
+ {"properties": [("delta", -1)]}),
+ ("screen.frame_offset", {"type": 'RIGHT_ARROW', "value": 'PRESS'},
+ {"properties": [("delta", 1)]}),
+ ("screen.frame_jump", {"type": 'RIGHT_ARROW', "value": 'PRESS', "ctrl": True},
+ {"properties": [("end", True)]}),
+ ("screen.frame_jump", {"type": 'LEFT_ARROW', "value": 'PRESS', "c
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list