[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3230] contrib/py/scripts/addons/ presets/keyconfig/blender_2012_experimental.py: The beginnings of a new keymap for Blender.

Nathan Vegdahl cessen at cessen.com
Fri Apr 6 12:07:14 CEST 2012


Revision: 3230
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3230
Author:   cessen
Date:     2012-04-06 10:07:14 +0000 (Fri, 06 Apr 2012)
Log Message:
-----------
The beginnings of a new keymap for Blender.
It shows up in the presets menu as "Blender 2012 Experimental". Working
title. ;-)

Most of the changes so far have to do with mode switching.  I'm playing
around with making the spacebar sort of the central "context manager" key,
responsible for mode switching.  The tab key has subsequently been assigned
the operator search menu functionality, which the spacebar previously had.

Also a few miscellaneous things:
- Pressing g/r/s and then an axis now uses the selected space, instead of
having to hit the axis key twice.
- The +/- keys (top row, not numpad) now increase/decrease the subsurf
level when in mesh edit mode.  The prior ctrl-# hotkeys for that no longer
work in edit mode.
- Most hotkeys involving the top-row function keys are now disabled.  I'm
trying to see if we can manage without the function keys, since they are used
as system hotkeys on OSX.
- In the python code of the keymap you can enable Maya-style manipulator
hotkeys (Q, W, E, and R).  Currently disabled, but you can turn it on
easily via a variable at the top of the file.
- Probably some miscellaneous things I'm forgetting.

Modified Paths:
--------------
    contrib/py/scripts/addons/presets/keyconfig/blender_2012_experimental.py

Modified: contrib/py/scripts/addons/presets/keyconfig/blender_2012_experimental.py
===================================================================
--- contrib/py/scripts/addons/presets/keyconfig/blender_2012_experimental.py	2012-04-06 10:03:33 UTC (rev 3229)
+++ contrib/py/scripts/addons/presets/keyconfig/blender_2012_experimental.py	2012-04-06 10:07:14 UTC (rev 3230)
@@ -0,0 +1,816 @@
+""" An experimental new keymap for Blender.
+    Work in progress!
+"""
+import bpy
+
+###############################################################
+# Some configuration variables to toggle various ideas on/off #
+###############################################################
+DEVELOPER_HOTKEYS = False  # Weird hotkeys that only developers use
+
+WINDOW_TYPE_SWITCHING = False  # Shift-f# hotkeys for switching window types
+
+SUBSURF_RELATIVE = True  # Make subsurf hotkeys work by relative
+                         # shifting instead of absolute setting
+                         
+MAYA_STYLE_MANIPULATORS = False  # Maya-style "QWER" hotkeys for manipulators
+
+
+
+
+###############################
+# Custom operators/menus/etc. #
+###############################
+
+class ShiftSubsurfLevel(bpy.types.Operator):
+    ''' Shifts the subsurf level of the selected objects up or
+        down by the given amount.  Has maximum limit, to avoid
+        going crazy and running out of RAM.
+    '''
+    bl_idname = "object.shift_subsurf_level"
+    bl_label = "Shift Subsurf Level"
+    
+    delta = bpy.props.IntProperty(name="Delta", description="Amount to increase/decrease the subsurf level.", default=1)
+    min = bpy.props.IntProperty(name="Minimum", description="The lowest subsurf level to shift to.", default=0)
+    max = bpy.props.IntProperty(name="Maximum", description="The highest subsurf level to shift to.", default=4)
+    
+    @classmethod
+    def poll(cls, context):
+        return context.active_object is not None
+
+    def execute(self, context):
+        for obj in context.selected_objects:
+            # Find the last subsurf modifier in the stack
+            m = None
+            for mod in obj.modifiers:
+                if mod.type == "SUBSURF":
+                    m = mod
+            
+            # Add a subsurf modifier if necessary
+            if not m and self.delta > 0:
+                m = obj.modifiers.new(name="Subsurf", type="SUBSURF")
+                m.levels = 0
+            
+            # Adjust it's subsurf level
+            if m:
+                if self.delta > 0:
+                    if (m.levels + self.delta) <= self.max:
+                        m.levels += self.delta
+                elif self.delta < 0:
+                    if (m.levels + self.delta) >= self.min:
+                        m.levels += self.delta
+        return {'FINISHED'}
+bpy.utils.register_class(ShiftSubsurfLevel)
+
+
+class SetManipulator(bpy.types.Operator):
+    '''Set's the manipulator mode.'''
+    bl_idname = "view3d.manipulator_set"
+    bl_label = "Set Manipulator"
+    mode = bpy.props.EnumProperty(items=[("NONE", "None", ""),
+                                         ("TRANSLATE", "Translate", ""),
+                                         ("ROTATE", "Rotate", ""),
+                                         ("SCALE", "Scale", "")],
+                                         default="NONE")
+    def execute(self, context):
+        if self.mode == "NONE":
+            context.space_data.show_manipulator = False
+        elif self.mode == "TRANSLATE":
+            context.space_data.show_manipulator = True
+            context.space_data.use_manipulator_translate = True
+            context.space_data.use_manipulator_rotate = False
+            context.space_data.use_manipulator_scale = False
+        elif self.mode == "ROTATE":
+            context.space_data.show_manipulator = True
+            context.space_data.use_manipulator_translate = False
+            context.space_data.use_manipulator_rotate = True
+            context.space_data.use_manipulator_scale = False
+        elif self.mode == "SCALE":
+            context.space_data.show_manipulator = True
+            context.space_data.use_manipulator_translate = False
+            context.space_data.use_manipulator_rotate = False
+            context.space_data.use_manipulator_scale = True
+            
+        return {'FINISHED'}
+bpy.utils.register_class(SetManipulator)
+
+
+class ModeSwitchMenu(bpy.types.Menu):
+    """ A menu for switching between object modes.
+    """
+    bl_idname = "OBJECT_MT_mode_switch_menu"
+    bl_label = "Switch Mode"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.operator_enum("object.mode_set", "mode")
+bpy.utils.register_class(ModeSwitchMenu)
+# Work around
+bpy.ops.object.mode_set(mode="OBJECT", toggle=False)
+
+
+
+
+
+
+######################################################################
+######################################################################
+############### KEYMAP BEGINS ########################################
+######################################################################
+######################################################################
+wm = bpy.context.window_manager
+kc = wm.keyconfigs.new('Blender 2012 (experimental!)')
+
+
+##############
+# Map Window #
+##############
+km = kc.keymaps.new('Window', space_type='EMPTY', region_type='WINDOW', modal=False)
+
+#------
+# Quit
+#------
+kmi = km.keymap_items.new('wm.quit_blender', 'Q', 'PRESS', ctrl=True)
+
+#----------------------
+# Operator search menu
+#----------------------
+kmi = km.keymap_items.new('wm.search_menu', 'TAB', 'PRESS')
+
+#-----------------
+# File management
+#-----------------
+# Open
+kmi = km.keymap_items.new('wm.read_homefile', 'N', 'PRESS', ctrl=True)
+kmi = km.keymap_items.new('wm.save_homefile', 'U', 'PRESS', ctrl=True)
+kmi = km.keymap_items.new('wm.open_mainfile', 'O', 'PRESS', ctrl=True)
+kmi = km.keymap_items.new('wm.link_append', 'O', 'PRESS', ctrl=True, alt=True)
+
+# Save
+kmi = km.keymap_items.new('wm.save_mainfile', 'S', 'PRESS', ctrl=True)
+kmi = km.keymap_items.new('wm.save_as_mainfile', 'S', 'PRESS', shift=True, ctrl=True)
+
+#------------------
+# Window switching
+#------------------
+if WINDOW_TYPE_SWITCHING:
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F2', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'LOGIC_EDITOR'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F3', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'NODE_EDITOR'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F4', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'CONSOLE'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F5', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'VIEW_3D'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F6', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'GRAPH_EDITOR'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F7', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'PROPERTIES'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F8', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'SEQUENCE_EDITOR'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F9', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'OUTLINER'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F10', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'IMAGE_EDITOR'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F11', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'TEXT_EDITOR'
+    kmi = km.keymap_items.new('wm.context_set_enum', 'F12', 'PRESS', shift=True)
+    kmi.properties.data_path = 'area.type'
+    kmi.properties.value = 'DOPESHEET_EDITOR'
+
+#-------------
+# NDof Device
+#-------------
+kmi = km.keymap_items.new('wm.call_menu', 'NDOF_BUTTON_MENU', 'PRESS')
+kmi.properties.name = 'USERPREF_MT_ndof_settings'
+kmi = km.keymap_items.new('wm.ndof_sensitivity_change', 'NDOF_BUTTON_PLUS', 'PRESS')
+kmi.properties.decrease = False
+kmi.properties.fast = False
+kmi = km.keymap_items.new('wm.ndof_sensitivity_change', 'NDOF_BUTTON_MINUS', 'PRESS')
+kmi.properties.decrease = True
+kmi.properties.fast = False
+kmi = km.keymap_items.new('wm.ndof_sensitivity_change', 'NDOF_BUTTON_PLUS', 'PRESS', shift=True)
+kmi.properties.decrease = False
+kmi.properties.fast = True
+kmi = km.keymap_items.new('wm.ndof_sensitivity_change', 'NDOF_BUTTON_MINUS', 'PRESS', shift=True)
+kmi.properties.decrease = True
+kmi.properties.fast = True
+
+#------
+# Misc
+#------
+kmi = km.keymap_items.new('wm.window_fullscreen_toggle', 'F11', 'PRESS', alt=True)
+
+#-----------------------
+# Development/debugging
+#-----------------------
+if DEVELOPER_HOTKEYS:
+    kmi = km.keymap_items.new('wm.redraw_timer', 'T', 'PRESS', ctrl=True, alt=True)
+    kmi = km.keymap_items.new('wm.debug_menu', 'D', 'PRESS', ctrl=True, alt=True)
+
+#-----
+# ???
+#-----
+kmi = km.keymap_items.new('info.reports_display_update', 'TIMER', 'ANY', any=True)
+
+
+
+
+##################
+# 3D View Global #
+##################
+km = kc.keymaps.new('3D View', space_type='VIEW_3D', region_type='WINDOW', modal=False)
+
+#-----------------
+# View navigation
+#-----------------
+# ???
+kmi = km.keymap_items.new('view3d.rotate', 'MOUSEROTATE', 'ANY')
+kmi = km.keymap_items.new('view3d.smoothview', 'TIMER1', 'ANY', any=True)
+
+# Perspective/ortho
+kmi = km.keymap_items.new('view3d.view_persportho', 'NUMPAD_5', 'PRESS')
+
+# Camera view
+kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_0', 'PRESS')
+kmi.properties.type = 'CAMERA'
+
+# Basics with mouse
+kmi = km.keymap_items.new('view3d.rotate', 'MIDDLEMOUSE', 'PRESS')
+kmi = km.keymap_items.new('view3d.move', 'MIDDLEMOUSE', 'PRESS', shift=True)
+kmi = km.keymap_items.new('view3d.zoom', 'MIDDLEMOUSE', 'PRESS', ctrl=True)
+kmi = km.keymap_items.new('view3d.dolly', 'MIDDLEMOUSE', 'PRESS', shift=True, ctrl=True)
+
+# Basics with mouse wheel
+kmi = km.keymap_items.new('view3d.zoom', 'WHEELINMOUSE', 'PRESS')
+kmi.properties.delta = 1

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list