[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58068] trunk/blender/release/scripts/ startup/bl_ui: re-arrange space_userpref_keymap, no need to use a subclass here, just import the module and call draw_keymaps().
Campbell Barton
ideasman42 at gmail.com
Mon Jul 8 09:25:34 CEST 2013
Revision: 58068
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58068
Author: campbellbarton
Date: 2013-07-08 07:25:33 +0000 (Mon, 08 Jul 2013)
Log Message:
-----------
re-arrange space_userpref_keymap, no need to use a subclass here, just import the module and call draw_keymaps().
- making this change now because some addons developers are interested in showing keymap UI in their addons prefs and using the class involved making a fake class instance which isnt needed.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/__init__.py
trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py
Modified: trunk/blender/release/scripts/startup/bl_ui/__init__.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/__init__.py 2013-07-08 05:27:50 UTC (rev 58067)
+++ trunk/blender/release/scripts/startup/bl_ui/__init__.py 2013-07-08 07:25:33 UTC (rev 58068)
@@ -72,7 +72,6 @@
"space_sequencer",
"space_text",
"space_time",
- "space_userpref_keymap",
"space_userpref",
"space_view3d",
"space_view3d_toolbar",
Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py 2013-07-08 05:27:50 UTC (rev 58067)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py 2013-07-08 07:25:33 UTC (rev 58068)
@@ -917,9 +917,6 @@
col.prop(system, "author", text="")
-from bl_ui.space_userpref_keymap import InputKeyMapPanel
-
-
class USERPREF_MT_ndof_settings(Menu):
# accessed from the window key-bindings in C (only)
bl_label = "3D Mouse Settings"
@@ -960,9 +957,25 @@
layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
-class USERPREF_PT_input(Panel, InputKeyMapPanel):
+class USERPREF_MT_keyconfigs(Menu):
+ bl_label = "KeyPresets"
+ preset_subdir = "keyconfig"
+ preset_operator = "wm.keyconfig_activate"
+
+ def draw(self, context):
+ props = self.layout.operator("wm.context_set_value", text="Blender (default)")
+ props.data_path = "window_manager.keyconfigs.active"
+ props.value = "context.window_manager.keyconfigs.default"
+
+ # now draw the presets
+ Menu.draw_preset(self, context)
+
+
+class USERPREF_PT_input(Panel):
bl_space_type = 'USER_PREFERENCES'
bl_label = "Input"
+ bl_region_type = 'WINDOW'
+ bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
@@ -1039,6 +1052,8 @@
row.separator()
def draw(self, context):
+ from bl_ui.space_userpref_keymap import draw_keymaps
+
layout = self.layout
#import time
@@ -1055,7 +1070,7 @@
self.draw_input_prefs(inputs, split)
# Keymap Settings
- self.draw_keymaps(context, split)
+ draw_keymaps(context, split)
#print("runtime", time.time() - start)
Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py 2013-07-08 05:27:50 UTC (rev 58067)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py 2013-07-08 07:25:33 UTC (rev 58068)
@@ -17,375 +17,368 @@
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
+
+__all__ = (
+ "draw_entry",
+ "draw_km",
+ "draw_kmi",
+ "draw_filtered",
+ "draw_hierarchy",
+ "draw_keymaps",
+ )
+
+
import bpy
-from bpy.types import Menu
from bpy.app.translations import pgettext_iface as iface_
from bpy.app.translations import contexts as i18n_contexts
-class USERPREF_MT_keyconfigs(Menu):
- bl_label = "KeyPresets"
- preset_subdir = "keyconfig"
- preset_operator = "wm.keyconfig_activate"
+def _indented_layout(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
- def draw(self, context):
- props = self.layout.operator("wm.context_set_value", text="Blender (default)")
- props.data_path = "window_manager.keyconfigs.active"
- props.value = "context.window_manager.keyconfigs.default"
+ split = layout.split(percentage=indent)
+ col = split.column()
+ col = split.column()
+ return col
- # now draw the presets
- Menu.draw_preset(self, context)
+def draw_entry(display_keymaps, entry, col, level=0):
+ idname, spaceid, regionid, children = entry
-class InputKeyMapPanel:
- bl_space_type = 'USER_PREFERENCES'
- bl_label = "Input"
- bl_region_type = 'WINDOW'
- bl_options = {'HIDE_HEADER'}
+ for km, kc in display_keymaps:
+ if km.name == idname and km.space_type == spaceid and km.region_type == regionid:
+ draw_km(display_keymaps, kc, km, children, col, level)
- def draw_entry(self, display_keymaps, entry, col, level=0):
- idname, spaceid, regionid, children = entry
-
- for km, kc in display_keymaps:
- if km.name == idname and km.space_type == spaceid and km.region_type == regionid:
- self.draw_km(display_keymaps, kc, km, children, col, level)
-
- '''
+ '''
+ km = kc.keymaps.find(idname, space_type=spaceid, region_type=regionid)
+ if not km:
+ kc = defkc
km = kc.keymaps.find(idname, space_type=spaceid, region_type=regionid)
- if not km:
- kc = defkc
- km = kc.keymaps.find(idname, space_type=spaceid, region_type=regionid)
- if km:
- self.draw_km(kc, km, children, col, level)
- '''
+ if km:
+ draw_km(kc, km, children, col, level)
+ '''
- 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(display_keymaps, kc, km, children, layout, level):
+ km = km.active()
- def draw_km(self, display_keymaps, kc, km, children, layout, level):
- km = km.active()
+ layout.context_pointer_set("keymap", km)
- layout.context_pointer_set("keymap", km)
+ col = _indented_layout(layout, level)
- col = self.indented_layout(layout, level)
+ row = col.row()
+ row.prop(km, "show_expanded_children", text="", emboss=False)
+ row.label(text=km.name, text_ctxt=i18n_contexts.id_windowmanager)
- row = col.row()
- row.prop(km, "show_expanded_children", text="", emboss=False)
- row.label(text=km.name, text_ctxt=i18n_contexts.id_windowmanager)
+ row.label()
+ row.label()
+ if km.is_modal:
+ row.label(text="", icon='LINKED')
+ if km.is_user_modified:
+ row.operator("wm.keymap_restore", text="Restore")
+ else:
row.label()
- row.label()
- if km.is_modal:
- row.label(text="", icon='LINKED')
- if km.is_user_modified:
- row.operator("wm.keymap_restore", text="Restore")
+ if km.show_expanded_children:
+ if children:
+ # Put the Parent key map's entries in a 'global' sub-category
+ # equal in hierarchy to the other children categories
+ subcol = _indented_layout(col, level + 1)
+ subrow = subcol.row()
+ subrow.prop(km, "show_expanded_items", text="", emboss=False)
+ subrow.label(text=iface_("%s (Global)") % km.name, translate=False)
else:
- row.label()
+ km.show_expanded_items = True
- if km.show_expanded_children:
- 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, "show_expanded_items", text="", emboss=False)
- subrow.label(text=iface_("%s (Global)") % km.name, translate=False)
- else:
- km.show_expanded_items = True
+ # Key Map items
+ if km.show_expanded_items:
+ for kmi in km.keymap_items:
+ draw_kmi(display_keymaps, kc, km, kmi, col, level + 1)
- # Key Map items
- if km.show_expanded_items:
- for kmi in km.keymap_items:
- self.draw_kmi(display_keymaps, kc, km, kmi, col, level + 1)
+ # "Add New" at end of keymap item list
+ col = _indented_layout(col, level + 1)
+ subcol = col.split(percentage=0.2).column()
+ subcol.operator("wm.keyitem_add", text="Add New", text_ctxt=i18n_contexts.id_windowmanager,
+ icon='ZOOMIN')
- # "Add New" at end of keymap item list
- col = self.indented_layout(col, level + 1)
- subcol = col.split(percentage=0.2).column()
- subcol.operator("wm.keyitem_add", text="Add New", text_ctxt=i18n_contexts.id_windowmanager,
- icon='ZOOMIN')
+ col.separator()
- col.separator()
+ # Child key maps
+ if children:
+ subcol = col.column()
+ row = subcol.row()
- # Child key maps
- if children:
- subcol = col.column()
- row = subcol.row()
+ for entry in children:
+ draw_entry(display_keymaps, entry, col, level + 1)
- for entry in children:
- self.draw_entry(display_keymaps, entry, col, level + 1)
- def draw_kmi(self, display_keymaps, kc, km, kmi, layout, level):
- map_type = kmi.map_type
+def draw_kmi(display_keymaps, kc, km, kmi, layout, level):
+ map_type = kmi.map_type
- col = self.indented_layout(layout, level)
+ col = _indented_layout(layout, level)
- if kmi.show_expanded:
- col = col.column(align=True)
- box = col.box()
- else:
- box = col.column()
+ if kmi.show_expanded:
+ col = col.column(align=True)
+ box = col.box()
+ else:
+ box = col.column()
- split = box.split(percentage=0.05)
+ split = box.split(percentage=0.05)
- # header bar
- row = split.row()
- row.prop(kmi, "show_expanded", text="", emboss=False)
+ # header bar
+ row = split.row()
+ row.prop(kmi, "show_expanded", text="", emboss=False)
- row = split.row()
- row.prop(kmi, "active", text="", emboss=False)
+ row = split.row()
+ row.prop(kmi, "active", text="", emboss=False)
- if km.is_modal:
- row.prop(kmi, "propvalue", text="")
- else:
- row.label(text=kmi.name)
+ if km.is_modal:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list