diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-30 17:50:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-30 17:50:59 +0400 |
commit | eab50148e23955ab38dca74b964f33eaacf42d27 (patch) | |
tree | f5779b4309cbaac681b21bf76deaf59ba3d11c92 /source/blender/makesrna/intern/rna_wm.c | |
parent | ec8848d03a8d37cf41881a535416051fb7ffbeb0 (diff) |
- keymap import/export works again (broke with own api changes)
- function renames, move WM functions into collections wm.add_keymap() --> wm.keymaps.new()
note: new is used for named items in a collection, which return the result.
- Action.get_frame_range() is now a readonly property 'frame_range', floats rather then ints.
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 106 |
1 files changed, 86 insertions, 20 deletions
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index d13e4f9f616..231ca01fe25 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -928,7 +928,7 @@ static StructRNA* rna_MacroOperator_refine(PointerRNA *opr) return (op->type && op->type->ext.srna)? op->type->ext.srna: &RNA_Macro; } -static wmKeyMapItem *rna_KeyMap_add_item(wmKeyMap *km, ReportList *reports, char *idname, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier) +static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, char *idname, 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; @@ -949,7 +949,7 @@ static wmKeyMapItem *rna_KeyMap_add_item(wmKeyMap *km, ReportList *reports, char return WM_keymap_add_item(km, idname, type, value, modifier, keymodifier); } -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) +static wmKeyMapItem *rna_KeyMap_item_new_modal(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; @@ -988,6 +988,30 @@ static wmKeyMapItem *rna_KeyMap_add_modal_item(wmKeyMap *km, bContext *C, Report return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue); } +static wmKeyMap *rna_keymap_new(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_find(wmKeyConfig *keyconf, char *idname, int spaceid, int regionid) +{ + return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); +} + +static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *keyconf, char *idname) +{ + wmOperatorType *ot = WM_operatortype_find(idname, 0); + + if (!ot) + return NULL; + else + return ot->modalkeymap; +} + #else /* RNA_RUNTIME */ static void rna_def_operator(BlenderRNA *brna) @@ -1270,27 +1294,14 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; PropertyRNA *prop; - //FunctionRNA *func; - //PropertyRNA *parm; + FunctionRNA *func; + PropertyRNA *parm; RNA_def_property_srna(cprop, "KeyConfigurations"); srna= RNA_def_struct(brna, "KeyConfigurations", NULL); RNA_def_struct_sdna(srna, "wmWindowManager"); RNA_def_struct_ui_text(srna, "KeyConfigs", "Collection of KeyConfigs"); -/* - func= RNA_def_function(srna, "new", "rna_Curve_spline_new"); - RNA_def_function_ui_description(func, "Add a new spline to the curve."); - parm= RNA_def_enum(func, "type", curve_type_items, CU_POLY, "", "type for the new spline."); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "spline", "Spline", "", "The newly created spline."); - RNA_def_function_return(func, parm); - func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); - RNA_def_function_ui_description(func, "Remove a spline from a curve."); - RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); -*/ prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "KeyConfig"); RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get", "rna_WindowManager_active_keyconfig_set", NULL, NULL); @@ -1301,6 +1312,17 @@ static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_pointer_sdna(prop, NULL, "defaultconf"); RNA_def_property_struct_type(prop, "KeyConfig"); RNA_def_property_ui_text(prop, "Default Key Configuration", ""); + + /* funcs */ + func= RNA_def_function(srna, "new", "WM_keyconfig_new_user"); // add_keyconfig + parm= RNA_def_string(func, "name", "", 0, "Name", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "WM_keyconfig_remove"); // remove_keyconfig + parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration."); + RNA_def_property_flag(parm, PROP_REQUIRED); } static void rna_def_windowmanager(BlenderRNA *brna) @@ -1347,7 +1369,7 @@ static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "wmKeyMap"); RNA_def_struct_ui_text(srna, "KeyMap Items", "Collection of keymap items"); - func= RNA_def_function(srna, "add", "rna_KeyMap_add_item"); + func= RNA_def_function(srna, "new", "rna_KeyMap_item_new"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_string(func, "idname", "", 0, "Operator Identifier", ""); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -1364,7 +1386,7 @@ static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop) 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", "rna_KeyMap_add_modal_item"); + func= RNA_def_function(srna, "new_modal", "rna_KeyMap_item_new_modal"); 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); @@ -1381,6 +1403,49 @@ static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop) parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item."); RNA_def_function_return(func, parm); + func= RNA_def_function(srna, "remove", "WM_keymap_remove_item"); + parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + +} + +static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + //PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + + RNA_def_property_srna(cprop, "KeyMaps"); + srna= RNA_def_struct(brna, "KeyMaps", NULL); + RNA_def_struct_sdna(srna, "wmKeyConfig"); + RNA_def_struct_ui_text(srna, "Key Maps", "Collection of keymaps"); + + func= RNA_def_function(srna, "new", "rna_keymap_new"); // add_keymap + 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); + + func= RNA_def_function(srna, "find", "rna_keymap_find"); // find_keymap + 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", ""); + parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "find_modal", "rna_keymap_find_modal"); // find_keymap_modal + parm= RNA_def_string(func, "name", "", 0, "Operator Name", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map."); + RNA_def_function_return(func, parm); + } static void rna_def_keyconfig(BlenderRNA *brna) @@ -1407,10 +1472,11 @@ static void rna_def_keyconfig(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "idname"); RNA_def_property_ui_text(prop, "Name", "Name of the key configuration"); RNA_def_struct_name_property(srna, prop); - + prop= RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "KeyMap"); RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration"); + rna_def_wm_keymaps(brna, prop); prop= RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYCONF_USER); |