Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-11-16 23:50:02 +0300
committerMartin Poirier <theeth@yahoo.com>2009-11-16 23:50:02 +0300
commit98d4a56d5517be497c4628ad8bf67082d21767f2 (patch)
tree0e3c013e6d2d7dab2c78cef6cd08e0274762b320 /source/blender/makesrna/intern/rna_wm_api.c
parent6ed0686fccb9bf5804acfb4be25a4fccf9de9f83 (diff)
Fixing keymap export:
- Didn't support new userdef keymaps (new "active" rna function to get the active version of a keymap) - Didn't support modal keymaps (new "modal" param to add_keymap function, new "add_modal_item" function on keymaps (both functions now make sure the keymap is of the right type))
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c93
1 files changed, 91 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 59605054804..62c4fe642a1 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -43,15 +43,79 @@
#include "WM_api.h"
#include "WM_types.h"
-static wmKeyMapItem *rna_KeyMap_add_item(wmKeyMap *km, char *idname, int type, int value, int shift, int ctrl, int alt, int oskey, int keymodifier)
+static wmKeyMap *rna_keymap_add(wmKeyConfig *keyconf, char *idname, int spaceid, int regionid, int modal)
{
+ if (modal == 0) {
+ return WM_keymap_find(keyconf, idname, spaceid, regionid);
+ } else {
+ return WM_modalkeymap_add(keyconf, idname, NULL); /* items will be lazy init */
+ }
+}
+
+static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ return WM_keymap_active(wm, km);
+}
+
+
+static wmKeyMapItem *rna_KeyMap_add_modal_item(wmKeyMap *km, bContext *C, ReportList *reports, char* propvalue_str, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ int modifier= 0;
+ int propvalue = 0;
+
+ /* only modal maps */
+ if ((km->flag & KEYMAP_MODAL) == 0) {
+ BKE_report(reports, RPT_ERROR, "Not a modal keymap.");
+ return NULL;
+ }
+
+ if (!km->modal_items) {
+ if(!WM_keymap_user_init(wm, km)) {
+ BKE_report(reports, RPT_ERROR, "User defined keymap doesn't correspond to a system keymap.");
+ return NULL;
+ }
+ }
+
+ if (!km->modal_items) {
+ BKE_report(reports, RPT_ERROR, "No property values defined.");
+ return NULL;
+ }
+
+
+ if(RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue)==0) {
+ BKE_report(reports, RPT_WARNING, "Property value not in enumeration.");
+ }
+
+ if(shift) modifier |= KM_SHIFT;
+ if(ctrl) modifier |= KM_CTRL;
+ if(alt) modifier |= KM_ALT;
+ if(oskey) modifier |= KM_OSKEY;
+
+ if(any) modifier = KM_ANY;
+
+ return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue);
+}
+
+static wmKeyMapItem *rna_KeyMap_add_item(wmKeyMap *km, ReportList *reports, char *idname, int type, int any, int value, int shift, int ctrl, int alt, int oskey, int keymodifier)
+{
+// wmWindowManager *wm = CTX_wm_manager(C);
int modifier= 0;
+ /* only on non-modal maps */
+ if (km->flag & KEYMAP_MODAL) {
+ BKE_report(reports, RPT_ERROR, "Not a non-modal keymap.");
+ return NULL;
+ }
+
if(shift) modifier |= KM_SHIFT;
if(ctrl) modifier |= KM_CTRL;
if(alt) modifier |= KM_ALT;
if(oskey) modifier |= KM_OSKEY;
+ if(any) modifier = KM_ANY;
+
return WM_keymap_add_item(km, idname, type, value, modifier, keymodifier);
}
@@ -90,11 +154,12 @@ void RNA_api_keyconfig(StructRNA *srna)
FunctionRNA *func;
PropertyRNA *parm;
- func= RNA_def_function(srna, "add_keymap", "WM_keymap_find");
+ func= RNA_def_function(srna, "add_keymap", "rna_keymap_add");
parm= RNA_def_string(func, "name", "", 0, "Name", "");
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_enum(func, "space_type", space_type_items, SPACE_EMPTY, "Space Type", "");
RNA_def_enum(func, "region_type", region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
+ RNA_def_boolean(func, "modal", 0, "Modal", "");
parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map.");
RNA_def_function_return(func, parm);
}
@@ -105,12 +170,31 @@ void RNA_api_keymap(StructRNA *srna)
PropertyRNA *parm;
func= RNA_def_function(srna, "add_item", "rna_KeyMap_add_item");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm= RNA_def_string(func, "idname", "", 0, "Operator Identifier", "");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", "");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", "");
RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_boolean(func, "any", 0, "Any", "");
+ RNA_def_boolean(func, "shift", 0, "Shift", "");
+ RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
+ RNA_def_boolean(func, "alt", 0, "Alt", "");
+ RNA_def_boolean(func, "oskey", 0, "OS Key", "");
+ RNA_def_enum(func, "key_modifier", event_type_items, 0, "Key Modifier", "");
+ parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item.");
+ RNA_def_function_return(func, parm);
+
+ func= RNA_def_function(srna, "add_modal_item", "rna_KeyMap_add_modal_item");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
+ parm= RNA_def_string(func, "propvalue", "", 0, "Property Value", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_boolean(func, "any", 0, "Any", "");
RNA_def_boolean(func, "shift", 0, "Shift", "");
RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
RNA_def_boolean(func, "alt", 0, "Alt", "");
@@ -119,6 +203,11 @@ void RNA_api_keymap(StructRNA *srna)
parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item.");
RNA_def_function_return(func, parm);
+ func= RNA_def_function(srna, "active", "rna_keymap_active");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map.");
+ RNA_def_function_return(func, parm);
+
func= RNA_def_function(srna, "remove_item", "WM_keymap_remove_item");
parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
RNA_def_property_flag(parm, PROP_REQUIRED);