[Bf-blender-cvs] [c5847e2] wiggly-widgets: Make key maps for widgets visible in key map editor
Julian Eisel
noreply at git.blender.org
Sat Feb 20 19:32:01 CET 2016
Commit: c5847e2c3b1d6163c5740a19b0a80c2001d705c2
Author: Julian Eisel
Date: Sat Feb 20 19:22:57 2016 +0100
Branches: wiggly-widgets
https://developer.blender.org/rBc5847e2c3b1d6163c5740a19b0a80c2001d705c2
Make key maps for widgets visible in key map editor
For each editor that has widgets, we draw a "Widgets" category into it's key map list. Under this we have the key maps for the individual widget group types.
Having to hardcode the entries in keyconfig_utils.py is not so nice, but don't know of a better way to do this.
===================================================================
M release/datafiles/locale
M release/scripts/addons
M release/scripts/modules/bpy_extras/keyconfig_utils.py
M release/scripts/modules/rna_keymap_ui.py
M source/blender/windowmanager/intern/wm.c
M source/blender/windowmanager/intern/wm_operators.c
M source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
M source/blender/windowmanager/widgets/intern/wm_widgetmap.c
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 48e6ed5..fbb5a0e 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 48e6ed58b44b9bac6c1aa8671a07ea4a7c72ee3a
+Subproject commit fbb5a0e2ca04d7df2cb0c55c7ce97c4e23cd4ebe
diff --git a/release/scripts/addons b/release/scripts/addons
index b7a4aa5..219e882 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit b7a4aa544884c9a2a1223657875f060ad53b7b1e
+Subproject commit 219e882b3168669bb733dafcce10bb79d90e8002
diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py
index 7223357..36d6d82 100644
--- a/release/scripts/modules/bpy_extras/keyconfig_utils.py
+++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py
@@ -19,10 +19,40 @@
# <pep8 compliant>
# bpy.type.KeyMap: (km.name, km.space_type, km.region_type, [...])
+# Add (0, 0, 0, 0) to skipp adding "Foo (Global)" entry
# ('Script', 'EMPTY', 'WINDOW', []),
+# would be good to have a more generic way of doing this...
+KM_WIDGETS_HIERARCHY = [
+ # VIEW_3D
+ ('Widgets', 'EMPTY', 'WINDOW', [
+ (0, 0, 0, 0), # avoid adding 'Widgets (Global)" entry
+ ('Face Map Widgets', 'VIEW_3D', 'WINDOW', []),
+ ('Lamp Widgets', 'VIEW_3D', 'WINDOW', []),
+ ('Force Field Widgets', 'VIEW_3D', 'WINDOW', []),
+ ('Camera Widgets', 'VIEW_3D', 'WINDOW', []),
+ ('Manipulator Widgets', 'VIEW_3D', 'WINDOW', []),
+ ]),
+ # GRAPH_EDITOR
+ ('Widgets', 'EMPTY', 'WINDOW', [
+ (0, 0, 0, 0),
+ ('Backdrop Transform Widgets', 'GRAPH_EDITOR', 'WINDOW', []),
+ ]),
+ # NODE_EDITOR
+ ('Widgets', 'EMPTY', 'WINDOW', [
+ (0, 0, 0, 0),
+ ('Backdrop Transform Widgets', 'NODE_EDITOR', 'WINDOW', []),
+ ]),
+ # SEQUENCE_EDITOR
+ ('Widgets', 'EMPTY', 'WINDOW', [
+ (0, 0, 0, 0),
+ ('Backdrop Transform Widgets', 'SEQUENCE_EDITOR', 'WINDOW', []),
+ # ('Image Transform Widgets', 'SEQUENCE_EDITOR', 'WINDOW', []),
+ ]),
+ ]
+
KM_HIERARCHY = [
('Window', 'EMPTY', 'WINDOW', []), # file save, window change, exit
('Screen', 'EMPTY', 'WINDOW', [ # full screen, undo, screenshot
@@ -53,6 +83,8 @@ KM_HIERARCHY = [
('Particle', 'EMPTY', 'WINDOW', []),
+ KM_WIDGETS_HIERARCHY[0],
+
('Knife Tool Modal Map', 'EMPTY', 'WINDOW', []),
('Paint Stroke Modal', 'EMPTY', 'WINDOW', []),
('Paint Curve', 'EMPTY', 'WINDOW', []),
@@ -71,6 +103,7 @@ KM_HIERARCHY = [
('Graph Editor', 'GRAPH_EDITOR', 'WINDOW', [
('Graph Editor Generic', 'GRAPH_EDITOR', 'WINDOW', []),
+ KM_WIDGETS_HIERARCHY[1]
]),
('Dopesheet', 'DOPESHEET_EDITOR', 'WINDOW', []),
('NLA Editor', 'NLA_EDITOR', 'WINDOW', [
@@ -90,10 +123,12 @@ KM_HIERARCHY = [
('Node Editor', 'NODE_EDITOR', 'WINDOW', [
('Node Generic', 'NODE_EDITOR', 'WINDOW', []),
+ KM_WIDGETS_HIERARCHY[2],
]),
('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', [
('SequencerCommon', 'SEQUENCE_EDITOR', 'WINDOW', []),
('SequencerPreview', 'SEQUENCE_EDITOR', 'WINDOW', []),
+ KM_WIDGETS_HIERARCHY[3],
]),
('Logic Editor', 'LOGIC_EDITOR', 'WINDOW', []),
diff --git a/release/scripts/modules/rna_keymap_ui.py b/release/scripts/modules/rna_keymap_ui.py
index 2ca7a79..93fbc59 100644
--- a/release/scripts/modules/rna_keymap_ui.py
+++ b/release/scripts/modules/rna_keymap_ui.py
@@ -64,6 +64,7 @@ def draw_entry(display_keymaps, entry, col, level=0):
def draw_km(display_keymaps, kc, km, children, layout, level):
+ draw_global = children and children[0][0]; # first entry (0, 0, 0, 0) means we don't add "Global" entry
km = km.active()
layout.context_pointer_set("keymap", km)
@@ -85,7 +86,7 @@ def draw_km(display_keymaps, kc, km, children, layout, level):
del subrow
if km.show_expanded_children:
- if children:
+ if draw_global:
# 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)
@@ -101,13 +102,14 @@ def draw_km(display_keymaps, kc, km, children, layout, level):
for kmi in km.keymap_items:
draw_kmi(display_keymaps, kc, km, kmi, col, kmi_level)
- # "Add New" at end of keymap item list
- subcol = _indented_layout(col, kmi_level)
- subcol = subcol.split(percentage=0.2).column()
- subcol.operator("wm.keyitem_add", text="Add New", text_ctxt=i18n_contexts.id_windowmanager,
- icon='ZOOMIN')
+ if draw_global:
+ # "Add New" at end of keymap item list
+ subcol = _indented_layout(col, kmi_level)
+ subcol = subcol.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:
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index cf65818..b76a1f1 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -342,7 +342,6 @@ void WM_keymap_init(bContext *C)
* it's persistent across sessions */
if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
wm_window_keymap(wm->defaultconf);
- wm_widgets_keymap(wm->defaultconf);
ED_spacetypes_keymap(wm->defaultconf);
wm->defaultconf->flag |= KEYCONF_INIT_DEFAULT;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 8b45c1f..feb7a41 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -504,7 +504,8 @@ void WM_operatortype_remove_ptr(wmOperatorType *ot)
BLI_ghash_remove(global_ops_hash, ot->idname, NULL, NULL);
WM_keyconfig_update_operatortype();
- WM_widgetgrouptype_unregister(NULL, G.main, ot->wgrouptype);
+ if (ot->wgrouptype)
+ WM_widgetgrouptype_unregister(NULL, G.main, ot->wgrouptype);
MEM_freeN(ot);
}
@@ -5443,7 +5444,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
data_path = NULL;
(void)data_path;
-
+ wm_widgets_keymap(keyconf);
gesture_circle_modal_keymap(keyconf);
gesture_border_modal_keymap(keyconf);
gesture_zoom_border_modal_keymap(keyconf);
diff --git a/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c b/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
index bdf500e..88ec01f 100644
--- a/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
+++ b/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
@@ -356,7 +356,8 @@ static wmKeyMap *widgetgroup_tweak_modal_keymap(wmKeyConfig *keyconf, const char
wmKeyMap *WM_widgetgroup_keymap_common(const struct wmWidgetGroupType *wgrouptype, wmKeyConfig *config)
{
const char *wgroupname = wgrouptype->name;
- wmKeyMap *km = WM_keymap_find(config, wgroupname, 0, 0);
+ /* Use area and region id since we might have multiple widgets with the same name in different areas/regions */
+ wmKeyMap *km = WM_keymap_find(config, wgroupname, wgrouptype->spaceid, wgrouptype->regionid);
wmKeyMapItem *kmi;
WM_keymap_add_item(km, "WIDGETGROUP_OT_widget_tweak", ACTIONMOUSE, KM_PRESS, KM_ANY, 0);
diff --git a/source/blender/windowmanager/widgets/intern/wm_widgetmap.c b/source/blender/windowmanager/widgets/intern/wm_widgetmap.c
index 4ba8388..f44214d 100644
--- a/source/blender/windowmanager/widgets/intern/wm_widgetmap.c
+++ b/source/blender/windowmanager/widgets/intern/wm_widgetmap.c
@@ -721,6 +721,9 @@ void wm_widgets_keymap(wmKeyConfig *keyconf)
wmWidgetMapType *wmaptype;
wmWidgetGroupType *wgrouptype;
+ /* we add this item-less keymap once and use it to group widgetgroup keymaps into it */
+ WM_keymap_find(keyconf, "Widgets", 0, 0);
+
for (wmaptype = widgetmaptypes.first; wmaptype; wmaptype = wmaptype->next) {
for (wgrouptype = wmaptype->widgetgrouptypes.first; wgrouptype; wgrouptype = wgrouptype->next) {
wm_widgetgrouptype_keymap_init(wgrouptype, keyconf);
More information about the Bf-blender-cvs
mailing list