2010-04-14 07:09:01 +00:00
|
|
|
# ##### 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 #####
|
|
|
|
|
|
|
|
# <pep8 compliant>
|
|
|
|
import bpy
|
2012-04-08 13:11:25 +00:00
|
|
|
from bpy.types import Menu
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class USERPREF_MT_keyconfigs(Menu):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "KeyPresets"
|
2010-09-14 16:45:24 +00:00
|
|
|
preset_subdir = "keyconfig"
|
|
|
|
preset_operator = "wm.keyconfig_activate"
|
2011-01-01 07:20:34 +00:00
|
|
|
|
2010-09-14 16:45:24 +00:00
|
|
|
def draw(self, context):
|
2011-09-21 15:18:38 +00:00
|
|
|
props = self.layout.operator("wm.context_set_value", text="Blender (default)")
|
2010-09-14 16:45:24 +00:00
|
|
|
props.data_path = "window_manager.keyconfigs.active"
|
|
|
|
props.value = "context.window_manager.keyconfigs.default"
|
|
|
|
|
|
|
|
# now draw the presets
|
2011-08-12 06:57:00 +00:00
|
|
|
Menu.draw_preset(self, context)
|
2010-09-14 16:45:24 +00:00
|
|
|
|
|
|
|
|
2011-05-19 09:52:11 +00:00
|
|
|
class InputKeyMapPanel:
|
2010-04-14 07:09:01 +00:00
|
|
|
bl_space_type = 'USER_PREFERENCES'
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Input"
|
2010-04-14 07:09:01 +00:00
|
|
|
bl_region_type = 'WINDOW'
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'HIDE_HEADER'}
|
2010-04-17 19:05:53 +00:00
|
|
|
|
2010-04-14 07:09:01 +00:00
|
|
|
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)
|
2010-04-17 19:05:53 +00:00
|
|
|
|
2010-04-14 07:09:01 +00:00
|
|
|
'''
|
2010-08-30 13:50:59 +00:00
|
|
|
km = kc.keymaps.find(idname, space_type=spaceid, region_type=regionid)
|
2010-04-14 07:09:01 +00:00
|
|
|
if not km:
|
|
|
|
kc = defkc
|
2010-08-30 13:50:59 +00:00
|
|
|
km = kc.keymaps.find(idname, space_type=spaceid, region_type=regionid)
|
2010-04-17 19:05:53 +00:00
|
|
|
|
2010-04-14 07:09:01 +00:00
|
|
|
if km:
|
|
|
|
self.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
|
2010-08-20 10:02:21 +00:00
|
|
|
indent = level * indentpx / bpy.context.region.width
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
split = layout.split(percentage=indent)
|
|
|
|
col = split.column()
|
|
|
|
col = split.column()
|
|
|
|
return col
|
|
|
|
|
|
|
|
def draw_km(self, display_keymaps, kc, km, children, layout, level):
|
|
|
|
km = km.active()
|
|
|
|
|
2010-09-03 07:25:37 +00:00
|
|
|
layout.context_pointer_set("keymap", km)
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
col = self.indented_layout(layout, level)
|
|
|
|
|
|
|
|
row = col.row()
|
2010-08-17 17:03:52 +00:00
|
|
|
row.prop(km, "show_expanded_children", text="", emboss=False)
|
2011-09-21 15:18:38 +00:00
|
|
|
row.label(text=km.name)
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
row.label()
|
|
|
|
row.label()
|
|
|
|
|
2010-08-18 07:14:10 +00:00
|
|
|
if km.is_modal:
|
2010-04-14 07:09:01 +00:00
|
|
|
row.label(text="", icon='LINKED')
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
if km.is_user_modified:
|
2011-09-21 15:18:38 +00:00
|
|
|
row.operator("wm.keymap_restore", text="Restore")
|
2010-04-14 07:09:01 +00:00
|
|
|
else:
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
row.label()
|
2010-04-14 07:09:01 +00:00
|
|
|
|
2010-08-17 17:03:52 +00:00
|
|
|
if km.show_expanded_children:
|
2010-04-14 07:09:01 +00:00
|
|
|
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()
|
2010-08-17 17:03:52 +00:00
|
|
|
subrow.prop(km, "show_expanded_items", text="", emboss=False)
|
2011-09-21 15:18:38 +00:00
|
|
|
subrow.label(text="%s " % km.name + "(Global)")
|
2010-04-14 07:09:01 +00:00
|
|
|
else:
|
2010-08-17 17:03:52 +00:00
|
|
|
km.show_expanded_items = True
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
# Key Map items
|
2010-08-17 17:03:52 +00:00
|
|
|
if km.show_expanded_items:
|
2011-03-25 02:12:44 +00:00
|
|
|
for kmi in km.keymap_items:
|
2010-04-14 07:09:01 +00:00
|
|
|
self.draw_kmi(display_keymaps, 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()
|
2011-09-21 15:18:38 +00:00
|
|
|
subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
col.separator()
|
|
|
|
|
|
|
|
# Child key maps
|
|
|
|
if children:
|
|
|
|
subcol = col.column()
|
|
|
|
row = subcol.row()
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
col = self.indented_layout(layout, level)
|
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
if kmi.show_expanded:
|
2010-04-14 07:09:01 +00:00
|
|
|
col = col.column(align=True)
|
|
|
|
box = col.box()
|
|
|
|
else:
|
|
|
|
box = col.column()
|
|
|
|
|
|
|
|
split = box.split(percentage=0.05)
|
|
|
|
|
|
|
|
# header bar
|
|
|
|
row = split.row()
|
2010-08-17 17:03:52 +00:00
|
|
|
row.prop(kmi, "show_expanded", text="", emboss=False)
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
row = split.row()
|
2010-06-26 20:00:45 +00:00
|
|
|
row.prop(kmi, "active", text="", emboss=False)
|
2010-04-14 07:09:01 +00:00
|
|
|
|
2010-08-18 07:14:10 +00:00
|
|
|
if km.is_modal:
|
2010-04-14 07:09:01 +00:00
|
|
|
row.prop(kmi, "propvalue", text="")
|
|
|
|
else:
|
2011-09-21 15:18:38 +00:00
|
|
|
row.label(text=kmi.name)
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
row = split.row()
|
|
|
|
row.prop(kmi, "map_type", text="")
|
|
|
|
if map_type == 'KEYBOARD':
|
|
|
|
row.prop(kmi, "type", text="", full_event=True)
|
|
|
|
elif map_type == 'MOUSE':
|
|
|
|
row.prop(kmi, "type", text="", full_event=True)
|
2011-08-02 07:08:22 +00:00
|
|
|
elif map_type == 'NDOF':
|
2011-07-21 21:43:42 +00:00
|
|
|
row.prop(kmi, "type", text="", full_event=True)
|
2010-04-14 07:09:01 +00:00
|
|
|
elif map_type == 'TWEAK':
|
|
|
|
subrow = row.row()
|
|
|
|
subrow.prop(kmi, "type", text="")
|
|
|
|
subrow.prop(kmi, "value", text="")
|
|
|
|
elif map_type == 'TIMER':
|
|
|
|
row.prop(kmi, "type", text="")
|
|
|
|
else:
|
|
|
|
row.label()
|
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
if (not kmi.is_user_defined) and kmi.is_user_modified:
|
2011-10-23 00:53:50 +00:00
|
|
|
row.operator("wm.keyitem_restore", text="", icon='BACK').item_id = kmi.id
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
else:
|
2011-10-23 00:53:50 +00:00
|
|
|
row.operator("wm.keyitem_remove", text="", icon='X').item_id = kmi.id
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
# Expanded, additional event settings
|
2010-08-17 17:03:52 +00:00
|
|
|
if kmi.show_expanded:
|
2010-04-14 07:09:01 +00:00
|
|
|
box = col.box()
|
|
|
|
|
2011-03-07 13:23:45 +00:00
|
|
|
if map_type not in {'TEXTINPUT', 'TIMER'}:
|
2010-04-14 07:09:01 +00:00
|
|
|
split = box.split(percentage=0.4)
|
|
|
|
sub = split.row()
|
|
|
|
|
2010-08-18 07:14:10 +00:00
|
|
|
if km.is_modal:
|
2010-04-14 07:09:01 +00:00
|
|
|
sub.prop(kmi, "propvalue", text="")
|
|
|
|
else:
|
2010-09-06 22:43:09 +00:00
|
|
|
# One day...
|
2012-02-08 04:37:37 +00:00
|
|
|
#~ sub.prop_search(kmi, "idname", bpy.context.window_manager, "operators_all", text="")
|
2010-04-14 07:09:01 +00:00
|
|
|
sub.prop(kmi, "idname", text="")
|
|
|
|
|
|
|
|
sub = split.column()
|
|
|
|
subrow = sub.row(align=True)
|
|
|
|
|
2011-08-02 07:08:22 +00:00
|
|
|
if map_type in {'KEYBOARD', 'NDOF'}:
|
2010-04-14 07:09:01 +00:00
|
|
|
subrow.prop(kmi, "type", text="", event=True)
|
|
|
|
subrow.prop(kmi, "value", text="")
|
|
|
|
elif map_type == 'MOUSE':
|
|
|
|
subrow.prop(kmi, "type", text="")
|
|
|
|
subrow.prop(kmi, "value", text="")
|
|
|
|
|
|
|
|
subrow = sub.row()
|
|
|
|
subrow.scale_x = 0.75
|
|
|
|
subrow.prop(kmi, "any")
|
|
|
|
subrow.prop(kmi, "shift")
|
|
|
|
subrow.prop(kmi, "ctrl")
|
|
|
|
subrow.prop(kmi, "alt")
|
|
|
|
subrow.prop(kmi, "oskey", text="Cmd")
|
|
|
|
subrow.prop(kmi, "key_modifier", text="", event=True)
|
|
|
|
|
|
|
|
# Operator properties
|
2011-10-04 13:24:48 +00:00
|
|
|
box.template_keymap_item_properties(kmi)
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
# Modal key maps attached to this operator
|
2010-08-18 07:14:10 +00:00
|
|
|
if not km.is_modal:
|
2010-08-30 13:50:59 +00:00
|
|
|
kmm = kc.keymaps.find_modal(kmi.idname)
|
2010-04-14 07:09:01 +00:00
|
|
|
if kmm:
|
|
|
|
self.draw_km(display_keymaps, kc, kmm, None, layout, level + 1)
|
2010-09-03 07:25:37 +00:00
|
|
|
layout.context_pointer_set("keymap", km)
|
2010-04-17 19:05:53 +00:00
|
|
|
|
2010-08-25 14:29:14 +00:00
|
|
|
def draw_filtered(self, display_keymaps, filter_text, layout):
|
2010-04-14 07:09:01 +00:00
|
|
|
for km, kc in display_keymaps:
|
|
|
|
km = km.active()
|
2010-09-03 07:25:37 +00:00
|
|
|
layout.context_pointer_set("keymap", km)
|
2010-04-14 07:09:01 +00:00
|
|
|
|
2011-03-25 02:12:44 +00:00
|
|
|
filtered_items = [kmi for kmi in km.keymap_items if filter_text in kmi.name.lower()]
|
2010-04-14 07:09:01 +00:00
|
|
|
|
2012-01-02 16:18:39 +00:00
|
|
|
if filtered_items:
|
2010-04-14 07:09:01 +00:00
|
|
|
col = layout.column()
|
|
|
|
|
|
|
|
row = col.row()
|
2011-11-08 01:32:34 +00:00
|
|
|
row.label(text=km.name, icon='DOT')
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
row.label()
|
|
|
|
row.label()
|
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
if km.is_user_modified:
|
2011-09-21 15:18:38 +00:00
|
|
|
row.operator("wm.keymap_restore", text="Restore")
|
2010-04-14 07:09:01 +00:00
|
|
|
else:
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
row.label()
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
for kmi in filtered_items:
|
|
|
|
self.draw_kmi(display_keymaps, kc, km, kmi, col, 1)
|
|
|
|
|
|
|
|
# "Add New" at end of keymap item list
|
|
|
|
col = self.indented_layout(layout, 1)
|
|
|
|
subcol = col.split(percentage=0.2).column()
|
2011-09-21 15:18:38 +00:00
|
|
|
subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
def draw_hierarchy(self, display_keymaps, layout):
|
2011-09-26 11:22:07 +00:00
|
|
|
from bpy_extras import keyconfig_utils
|
|
|
|
for entry in keyconfig_utils.KM_HIERARCHY:
|
2010-04-14 07:09:01 +00:00
|
|
|
self.draw_entry(display_keymaps, entry, layout)
|
|
|
|
|
|
|
|
def draw_keymaps(self, context, layout):
|
2011-09-26 11:22:07 +00:00
|
|
|
from bpy_extras import keyconfig_utils
|
|
|
|
|
2010-09-02 04:53:05 +00:00
|
|
|
wm = context.window_manager
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
kc = wm.keyconfigs.user
|
2010-04-17 19:05:53 +00:00
|
|
|
|
|
|
|
col = layout.column()
|
2010-04-14 07:09:01 +00:00
|
|
|
sub = col.column()
|
|
|
|
|
|
|
|
subsplit = sub.split()
|
|
|
|
subcol = subsplit.column()
|
2010-04-17 19:05:53 +00:00
|
|
|
|
2010-09-14 16:45:24 +00:00
|
|
|
row = subcol.row(align=True)
|
2011-01-01 07:20:34 +00:00
|
|
|
|
2011-10-17 06:58:07 +00:00
|
|
|
#~ row.prop_search(wm.keyconfigs, "active", wm, "keyconfigs", text="Key Config:")
|
2010-09-14 16:45:24 +00:00
|
|
|
text = bpy.path.display_name(context.window_manager.keyconfigs.active.name)
|
|
|
|
if not text:
|
2011-09-21 15:18:38 +00:00
|
|
|
text = "Blender (default)"
|
2010-10-06 20:29:00 +00:00
|
|
|
row.menu("USERPREF_MT_keyconfigs", text=text)
|
2011-11-08 01:32:34 +00:00
|
|
|
row.operator("wm.keyconfig_preset_add", text="", icon='ZOOMIN')
|
|
|
|
row.operator("wm.keyconfig_preset_add", text="", icon='ZOOMOUT').remove_active = True
|
2011-01-01 07:20:34 +00:00
|
|
|
|
2011-10-17 06:58:07 +00:00
|
|
|
#~ layout.context_pointer_set("keyconfig", wm.keyconfigs.active)
|
|
|
|
#~ row.operator("wm.keyconfig_remove", text="", icon='X')
|
2010-04-14 07:09:01 +00:00
|
|
|
|
2011-11-08 01:32:34 +00:00
|
|
|
row.prop(context.space_data, "filter_text", icon='VIEWZOOM')
|
2010-04-14 07:09:01 +00:00
|
|
|
|
|
|
|
col.separator()
|
|
|
|
|
2011-09-26 11:22:07 +00:00
|
|
|
display_keymaps = keyconfig_utils.keyconfig_merge(kc, kc)
|
2010-08-17 07:49:53 +00:00
|
|
|
if context.space_data.filter_text != "":
|
|
|
|
filter_text = context.space_data.filter_text.lower()
|
2010-08-25 14:29:14 +00:00
|
|
|
self.draw_filtered(display_keymaps, filter_text, col)
|
2010-04-14 07:09:01 +00:00
|
|
|
else:
|
|
|
|
self.draw_hierarchy(display_keymaps, col)
|
|
|
|
|
|
|
|
|
2011-04-04 10:13:04 +00:00
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
bpy.utils.register_module(__name__)
|