Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_workspace_api.c
| Show All 23 Lines | |||||
| #include <time.h> | #include <time.h> | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_workspace_types.h" | |||||
| #include "RNA_enum_types.h" /* own include */ | #include "RNA_enum_types.h" /* own include */ | ||||
| #include "rna_internal.h" /* own include */ | #include "rna_internal.h" /* own include */ | ||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| # include "BKE_paint.h" | # include "BKE_paint.h" | ||||
| # include "ED_screen.h" | # include "ED_screen.h" | ||||
| static void rna_WorkSpaceTool_setup(ID *id, | static void rna_WorkSpaceTool_setup(ID *id, | ||||
| bToolRef *tref, | bToolRef *tref, | ||||
| bContext *C, | bContext *C, | ||||
| const char *idname, | const char *idname, | ||||
| /* Args for: 'bToolRef_Runtime'. */ | /* Args for: 'bToolRef_Runtime'. */ | ||||
| int cursor, | int cursor, | ||||
| const char *keymap, | const char *keymap, | ||||
| const char *gizmo_group, | const char *gizmo_group, | ||||
| const char *data_block, | const char *data_block, | ||||
| const char *op_idname, | const char *op_idname, | ||||
| int index, | int index, | ||||
| int options, | |||||
| const char *idname_fallback, | const char *idname_fallback, | ||||
| const char *keymap_fallback) | const char *keymap_fallback) | ||||
| { | { | ||||
| bToolRef_Runtime tref_rt = {0}; | bToolRef_Runtime tref_rt = {0}; | ||||
| tref_rt.cursor = cursor; | tref_rt.cursor = cursor; | ||||
| STRNCPY(tref_rt.keymap, keymap); | STRNCPY(tref_rt.keymap, keymap); | ||||
| STRNCPY(tref_rt.gizmo_group, gizmo_group); | STRNCPY(tref_rt.gizmo_group, gizmo_group); | ||||
| STRNCPY(tref_rt.data_block, data_block); | STRNCPY(tref_rt.data_block, data_block); | ||||
| STRNCPY(tref_rt.op, op_idname); | STRNCPY(tref_rt.op, op_idname); | ||||
| tref_rt.index = index; | tref_rt.index = index; | ||||
| tref_rt.flag = options; | |||||
| /* While it's logical to assign both these values from setup, | /* While it's logical to assign both these values from setup, | ||||
| * it's useful to stored this in DNA for re-use, exceptional case: write to the 'tref'. */ | * it's useful to stored this in DNA for re-use, exceptional case: write to the 'tref'. */ | ||||
| STRNCPY(tref->idname_fallback, idname_fallback); | STRNCPY(tref->idname_fallback, idname_fallback); | ||||
| STRNCPY(tref_rt.keymap_fallback, keymap_fallback); | STRNCPY(tref_rt.keymap_fallback, keymap_fallback); | ||||
| WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, idname); | WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, idname); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | void RNA_api_workspace(StructRNA *srna) | ||||
| RNA_def_property_clear_flag(parm, PROP_NEVER_NULL); | RNA_def_property_clear_flag(parm, PROP_NEVER_NULL); | ||||
| } | } | ||||
| void RNA_api_workspace_tool(StructRNA *srna) | void RNA_api_workspace_tool(StructRNA *srna) | ||||
| { | { | ||||
| PropertyRNA *parm; | PropertyRNA *parm; | ||||
| FunctionRNA *func; | FunctionRNA *func; | ||||
| static EnumPropertyItem options_items[] = { | |||||
| {TOOLREF_FLAG_FALLBACK_KEYMAP, "KEYMAP_FALLBACK", 0, "Fallback", ""}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| func = RNA_def_function(srna, "setup", "rna_WorkSpaceTool_setup"); | func = RNA_def_function(srna, "setup", "rna_WorkSpaceTool_setup"); | ||||
| RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT); | RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT); | ||||
| RNA_def_function_ui_description(func, "Set the tool settings"); | RNA_def_function_ui_description(func, "Set the tool settings"); | ||||
| parm = RNA_def_string(func, "idname", NULL, MAX_NAME, "Identifier", ""); | parm = RNA_def_string(func, "idname", NULL, MAX_NAME, "Identifier", ""); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| /* 'bToolRef_Runtime' */ | /* 'bToolRef_Runtime' */ | ||||
| parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE); | parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_items(parm, rna_enum_window_cursor_items); | RNA_def_property_enum_items(parm, rna_enum_window_cursor_items); | ||||
| RNA_def_string(func, "keymap", NULL, KMAP_MAX_NAME, "Key Map", ""); | RNA_def_string(func, "keymap", NULL, KMAP_MAX_NAME, "Key Map", ""); | ||||
| RNA_def_string(func, "gizmo_group", NULL, MAX_NAME, "Gizmo Group", ""); | RNA_def_string(func, "gizmo_group", NULL, MAX_NAME, "Gizmo Group", ""); | ||||
| RNA_def_string(func, "data_block", NULL, MAX_NAME, "Data Block", ""); | RNA_def_string(func, "data_block", NULL, MAX_NAME, "Data Block", ""); | ||||
| RNA_def_string(func, "operator", NULL, MAX_NAME, "Operator", ""); | RNA_def_string(func, "operator", NULL, MAX_NAME, "Operator", ""); | ||||
| RNA_def_int(func, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX); | RNA_def_int(func, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX); | ||||
| RNA_def_enum_flag(func, "options", options_items, 0, "Tool Options", ""); | |||||
| RNA_def_string(func, "idname_fallback", NULL, MAX_NAME, "Fallback Identifier", ""); | RNA_def_string(func, "idname_fallback", NULL, MAX_NAME, "Fallback Identifier", ""); | ||||
| RNA_def_string(func, "keymap_fallback", NULL, KMAP_MAX_NAME, "Fallback Key Map", ""); | RNA_def_string(func, "keymap_fallback", NULL, KMAP_MAX_NAME, "Fallback Key Map", ""); | ||||
| /* Access tool operator options (optionally create). */ | /* Access tool operator options (optionally create). */ | ||||
| func = RNA_def_function(srna, "operator_properties", "rna_WorkSpaceTool_operator_properties"); | func = RNA_def_function(srna, "operator_properties", "rna_WorkSpaceTool_operator_properties"); | ||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | RNA_def_function_flag(func, FUNC_USE_REPORTS); | ||||
| parm = RNA_def_string(func, "operator", NULL, 0, "", ""); | parm = RNA_def_string(func, "operator", NULL, 0, "", ""); | ||||
| Show All 22 Lines | |||||