Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \name Operator Type Append | /** \name Operator Type Append | ||||
| * \{ */ | * \{ */ | ||||
| static wmOperatorType *wm_operatortype_append__begin(void) | static wmOperatorType *wm_operatortype_append__begin(void) | ||||
| { | { | ||||
| wmOperatorType *ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); | wmOperatorType *ot = MEM_callocN(sizeof(wmOperatorType), "operatortype"); | ||||
| ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); | ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties); | ||||
| /* Set the default i18n context now, so that opfunc can redefine it if needed! */ | /* Set the default i18n context now, so that opfunc can redefine it if needed! */ | ||||
| RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); | RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); | ||||
| ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; | ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; | ||||
| ot->tot_basic_props = -1; | |||||
| return ot; | return ot; | ||||
| } | } | ||||
| static void wm_operatortype_append__end(wmOperatorType *ot) | static void wm_operatortype_append__end(wmOperatorType *ot) | ||||
| { | { | ||||
| if (ot->name == NULL) { | if (ot->name == NULL) { | ||||
| fprintf(stderr, "ERROR: Operator %s has no name property!\n", ot->idname); | fprintf(stderr, "ERROR: Operator %s has no name property!\n", ot->idname); | ||||
| ot->name = N_("Dummy Name"); | ot->name = N_("Dummy Name"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Lines | for (WM_operatortype_iter(&iter); | ||||
| if (ot->last_properties) { | if (ot->last_properties) { | ||||
| IDP_FreeProperty(ot->last_properties); | IDP_FreeProperty(ot->last_properties); | ||||
| MEM_freeN(ot->last_properties); | MEM_freeN(ot->last_properties); | ||||
| ot->last_properties = NULL; | ot->last_properties = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * \brief Mark operator properties as "Advanced" | |||||
| * | |||||
| * All operator properties added after calling this are considered "Advanced". UI code can use | |||||
| * #WM_operatortype_is_prop_advanced to show non-advanced options separately from advanced ones then. | |||||
| */ | |||||
| void WM_operatortype_props_advanced(wmOperatorType *ot) | |||||
| { | |||||
| /* The way this works is pretty primitive and evil :) Simply counts how many properties | |||||
| * were added so far and stores the value. Code differentiating between basic and advanced | |||||
| * properties can then consider the first N (count_basic_props) elements as basic. */ | |||||
| ot->tot_basic_props = RNA_struct_count_properties(ot->srna); | |||||
| } | |||||
| bool WM_operatortype_is_prop_advanced(const wmOperatorType *ot, const PropertyRNA *prop) | |||||
| { | |||||
| PointerRNA struct_ptr; | |||||
| unsigned int tot = 0; | |||||
| if (ot->tot_basic_props < 0) { | |||||
| return false; | |||||
| } | |||||
| RNA_pointer_create(NULL, ot->srna, NULL, &struct_ptr); | |||||
| RNA_STRUCT_BEGIN(&struct_ptr, iter_prop) | |||||
| { | |||||
| tot++; | |||||
| if (tot > ot->tot_basic_props) { | |||||
| return true; | |||||
| } | |||||
| if (prop == iter_prop) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| RNA_STRUCT_END; | |||||
| return false; | |||||
| } | |||||
| /* SOME_OT_op -> some.op */ | /* SOME_OT_op -> some.op */ | ||||
| void WM_operator_py_idname(char *to, const char *from) | void WM_operator_py_idname(char *to, const char *from) | ||||
| { | { | ||||
| const char *sep = strstr(from, "_OT_"); | const char *sep = strstr(from, "_OT_"); | ||||
| if (sep) { | if (sep) { | ||||
| int ofs = (sep - from); | int ofs = (sep - from); | ||||
| /* note, we use ascii tolower instead of system tolower, because the | /* note, we use ascii tolower instead of system tolower, because the | ||||
| ▲ Show 20 Lines • Show All 4,170 Lines • Show Last 20 Lines | |||||