[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25409] trunk/blender: First version of updated key map editor UI (in User Preferences)

Matt Ebb matt at mke3.net
Wed Dec 16 11:13:27 CET 2009


Revision: 25409
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25409
Author:   broken
Date:     2009-12-16 11:13:26 +0100 (Wed, 16 Dec 2009)

Log Message:
-----------
First version of updated key map editor UI (in User Preferences)

Now the key maps are displayed in a hierarchical list which you can 
browse through. As well as in the main list, modal key maps are also 
available in context, for example, if you unfold out a Transform key 
map item, you'll be able to fold out and access its modal key map underneath.

More work to do, including search, better operator browsing, etc.
Still need to revise the ordering/hierarchy and clean up naming to be 
consistent too, it's a bit of an 'evolved' mess right now.

Thanks to theeth for some initial work here too.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface_layout.c
    trunk/blender/source/blender/makesdna/DNA_windowmanager_types.h
    trunk/blender/source/blender/makesrna/intern/rna_ui_api.c
    trunk/blender/source/blender/makesrna/intern/rna_wm.c

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2009-12-15 23:35:26 UTC (rev 25408)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2009-12-16 10:13:26 UTC (rev 25409)
@@ -19,7 +19,84 @@
 # <pep8 compliant>
 import bpy
 
+KM_HIERARCHY = [
+                    ('Window', 'EMPTY', 'WINDOW', []), # file save, window change, exit
+                    ('Screen Editing', 'EMPTY', 'WINDOW', []),    # resizing, action corners
+                    ('Screen', 'EMPTY', 'WINDOW', []),    # full screen, undo, screenshot
 
+                    ('View2D', 'EMPTY', 'WINDOW', []),    # view 2d navigation (per region)
+                    ('Frames', 'EMPTY', 'WINDOW', []),    # frame navigation (per region)
+                    ('Header', 'EMPTY', 'WINDOW', []),    # header stuff (per region)
+                    ('Markers', 'EMPTY', 'WINDOW', []),    # markers (per region)
+                    ('Animation', 'EMPTY', 'WINDOW', []),    # frame change on click, preview range (per region)
+                    ('Grease Pencil', 'EMPTY', 'WINDOW', []), # grease pencil stuff (per region)
+                    
+                    ('View2D Buttons List', 'EMPTY', 'WINDOW', []), # view 2d with buttons navigation
+                    ('Animation_Channels', 'EMPTY', 'WINDOW', []),
+                    
+                    ('Buttons Generic', 'PROPERTIES', 'WINDOW', []), # align context menu
+                    ('TimeLine', 'TIMELINE', 'WINDOW', []),
+                    ('Outliner', 'OUTLINER', 'WINDOW', []),
+                    
+                    ('View3D', 'VIEW_3D', 'WINDOW', [ # view 3d navigation and generic stuff (select, transform)
+                        ('Pose', 'EMPTY', 'WINDOW', []),
+                        ('Object Mode', 'EMPTY', 'WINDOW', []),
+                        ('Vertex Paint', 'EMPTY', 'WINDOW', []),
+                        ('Weight Paint', 'EMPTY', 'WINDOW', []),
+                        ('Face Mask', 'EMPTY', 'WINDOW', []),
+                        ('Sculpt', 'EMPTY', 'WINDOW', []),
+                        ('EditMesh', 'EMPTY', 'WINDOW', []),
+                        ('Curve', 'EMPTY', 'WINDOW', []),
+                        ('Armature', 'EMPTY', 'WINDOW', []),
+                        ('Metaball', 'EMPTY', 'WINDOW', []),
+                        ('Lattice', 'EMPTY', 'WINDOW', []),
+                        ('Armature_Sketch', 'EMPTY', 'WINDOW', []),
+                        ('Particle', 'EMPTY', 'WINDOW', []),
+                        ('Font', 'EMPTY', 'WINDOW', []),
+                        ('Object Non-modal', 'EMPTY', 'WINDOW', []), # mode change
+                        ('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
+                        ('View3D Generic', 'VIEW_3D', 'WINDOW', [])    # toolbar and properties
+                        ]),
+                    ('GraphEdit Keys', 'GRAPH_EDITOR', 'WINDOW', [
+                        ('GraphEdit Generic', 'GRAPH_EDITOR', 'WINDOW', [])
+                        ]),
+                    
+                    ('Image', 'IMAGE_EDITOR', 'WINDOW', [
+                        ('UVEdit', 'EMPTY', 'WINDOW', []), # image (reverse order, UVEdit before Image
+                        ('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
+                        ('Image Generic', 'IMAGE_EDITOR', 'WINDOW', [])
+                        ]),
+                    
+                    ('Node Generic', 'NODE_EDITOR', 'WINDOW', [
+                        ('Node', 'NODE_EDITOR', 'WINDOW', [])
+                        ]),
+                    ('File', 'FILE_BROWSER', 'WINDOW', [
+                        ('FileMain', 'FILE_BROWSER', 'WINDOW', []),
+                        ('FileButtons', 'FILE_BROWSER', 'WINDOW', [])
+                        ]),
+                    ('Action_Keys', 'DOPESHEET_EDITOR', 'WINDOW', []),
+                    ('NLA Generic', 'NLA_EDITOR', 'WINDOW', [
+                        ('NLA Channels', 'NLA_EDITOR', 'WINDOW', []),
+                        ('NLA Data', 'NLA_EDITOR', 'WINDOW', [])
+                        ]),
+                    ('Script', 'SCRIPTS_WINDOW', 'WINDOW', []),
+                    ('Text', 'TEXT_EDITOR', 'WINDOW', []),
+                    ('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', []),
+                    ('Logic Generic', 'LOGIC_EDITOR', 'WINDOW', []),
+                    ('Console', 'CONSOLE', 'WINDOW', []),
+                    
+                    
+                    ('View3D Gesture Circle', 'EMPTY', 'WINDOW', []),
+                    ('Gesture Border', 'EMPTY', 'WINDOW', []),
+                    ('Standard Modal Map', 'EMPTY', 'WINDOW', []),
+                    ('Transform Modal Map', 'EMPTY', 'WINDOW', []),
+                    ('View3D Fly Modal', 'EMPTY', 'WINDOW', []),
+                    ('View3D Rotate Modal', 'EMPTY', 'WINDOW', []),
+                    ('View3D Move Modal', 'EMPTY', 'WINDOW', []),
+                    ('View3D Zoom Modal', 'EMPTY', 'WINDOW', []),
+                ]
+
+
 class USERPREF_HT_header(bpy.types.Header):
     bl_space_type = 'USER_PREFERENCES'
 
@@ -1176,29 +1253,172 @@
     def poll(self, context):
         userpref = context.user_preferences
         return (userpref.active_section == 'INPUT')
+    
+    def draw_entry(self, kc, entry, col, level = 0):
+        idname, spaceid, regionid, children = entry
+        
+        km = kc.find_keymap(idname, space_type = spaceid, region_type = regionid)
+        
+        if km:
+            km = km.active()
+            self.draw_km(kc, km, children, col, level)
 
-    def draw(self, context):
-        layout = self.layout
+    def indented_layout(self, layout, level):
+        indentpx = 16
+        if level == 0:
+            level = 0.0001   # Tweak so that a percentage of 0 won't split by half
+        indent = level*indentpx / bpy.context.region.width
+        
+        split=layout.split(percentage=indent)
+        col = split.column()
+        col = split.column()
+        return col
+    
+    def draw_km(self, kc, km, children, layout, level):
+        layout.set_context_pointer("keymap", km)
+        
+        col = self.indented_layout(layout, level)
+        
+        row = col.row()
+        row.prop(km, "children_expanded", text="", no_bg=True)
+        row.label(text=km.name)
+        
+        row.label()
+        row.label()
+        
+        if km.user_defined:
+            row.operator("WM_OT_keymap_restore", text="Restore")
+        else:
+            row.operator("WM_OT_keymap_edit", text="Edit")
+        
+        if km.children_expanded:
+            if children:
+                # Put the Parent key map's entries in a 'global' sub-category
+                # equal in hierarchy to the other children categories
+                subcol = self.indented_layout(col, level + 1)
+                subrow = subcol.row()
+                subrow.prop(km, "items_expanded", text="", no_bg=True)                  
+                subrow.label(text="%s (Global)" % km.name)
+            else:
+                km.items_expanded = True
+            
+            # Key Map items
+            if km.items_expanded:
+                for kmi in km.items:
+                    self.draw_kmi(kc, km, kmi, col, level + 1)
+                
+                # "Add New" at end of keymap item list
+                col = self.indented_layout(col, level+1)
+                subcol = col.split(percentage=0.2).column()
+                subcol.active = km.user_defined
+                subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
+            
+            col.separator()
+            
+            # Child key maps
+            if children:
+                subcol = col.column()
+                row = subcol.row()
+                
+                for entry in children:
+                    self.draw_entry(kc, entry, col, level + 1)
+        
+        
+    def draw_kmi(self, kc, km, kmi, layout, level):
+        layout.set_context_pointer("keyitem", kmi)
+    
+        col = self.indented_layout(layout, level)
 
-        userpref = context.user_preferences
-        wm = context.manager
-        #input = userpref.input
-        #input = userpref
-        inputs = userpref.inputs
+        col.enabled = km.user_defined
+        
+        if km.user_defined:
+            col = col.column(align=True)
+            box = col.box()
+        else:
+            box = col.column()
+        
+        split = box.split(percentage=0.4)
+        
+        # header bar
+        row = split.row()
+        row.prop(kmi, "expanded", text="", no_bg=True)
+        row.prop(kmi, "active", text="", no_bg=True)
+        
+        if km.modal:
+            row.prop(kmi, "propvalue", text="")
+        else:
+            row.label(text=kmi.name)
+        
+        row = split.row()
+        row.prop(kmi, "map_type", text="")
+        if kmi.map_type == 'KEYBOARD':
+            row.prop(kmi, "type", text="", full_event=True)
+        elif kmi.map_type == 'MOUSE':
+            row.prop(kmi, "type", text="", full_event=True)
+        elif kmi.map_type == 'TWEAK':
+            subrow = row.row()
+            subrow.prop(kmi, "type", text="")
+            subrow.prop(kmi, "value", text="")
+        elif kmi.map_type == 'TIMER':
+            row.prop(kmi, "type", text="")
+        else:
+            row.label()
+    
+        row.operator("wm.keyitem_remove", text="", icon='X')
+        
+        # Expanded, additional event settings
+        if kmi.expanded:
+            box = col.box()
+            
+            if kmi.map_type not in ('TEXTINPUT', 'TIMER'):
+                split = box.split(percentage=0.4)
+                sub = split.row()
+                
+                if km.modal:
+                    sub.prop(kmi, "propvalue", text="")
+                else:
+                    sub.prop(kmi, "idname", text="")
+                
+                sub = split.column()
+                subrow = sub.row(align=True)
 
-        split = layout.split(percentage=0.25)
+                if kmi.map_type == 'KEYBOARD':
+                    subrow.prop(kmi, "type", text="", event=True)
+                    subrow.prop(kmi, "value", text="")
+                elif kmi.map_type == 'MOUSE':
+                    subrow.prop(kmi, "type", text="")

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list