diff options
Diffstat (limited to 'source/blender/editors/object/object_edit.c')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 105 |
1 files changed, 5 insertions, 100 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index dc010ac40ec..84808817b94 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -553,7 +553,7 @@ void ED_object_editmode_enter(bContext *C, int flag) /* note, when switching scenes the object can have editmode data but * not be scene->obedit: bug 22954, this avoids calling self eternally */ if ((ob->restore_mode & OB_MODE_EDIT) == 0) - ED_object_toggle_modes(C, ob->mode); + ED_object_mode_toggle(C, ob->mode); ob->mode = OB_MODE_EDIT; @@ -1670,91 +1670,6 @@ static const EnumPropertyItem *object_mode_set_itemsf( return item; } -static const char *object_mode_op_string(eObjectMode mode) -{ - if (mode & OB_MODE_EDIT) - return "OBJECT_OT_editmode_toggle"; - if (mode == OB_MODE_SCULPT) - return "SCULPT_OT_sculptmode_toggle"; - if (mode == OB_MODE_VERTEX_PAINT) - return "PAINT_OT_vertex_paint_toggle"; - if (mode == OB_MODE_WEIGHT_PAINT) - return "PAINT_OT_weight_paint_toggle"; - if (mode == OB_MODE_TEXTURE_PAINT) - return "PAINT_OT_texture_paint_toggle"; - if (mode == OB_MODE_PARTICLE_EDIT) - return "PARTICLE_OT_particle_edit_toggle"; - if (mode == OB_MODE_POSE) - return "OBJECT_OT_posemode_toggle"; - if (mode == OB_MODE_GPENCIL) - return "GPENCIL_OT_editmode_toggle"; - return NULL; -} - -/* checks the mode to be set is compatible with the object - * should be made into a generic function - */ -static bool object_mode_compat_test(Object *ob, eObjectMode mode) -{ - if (ob) { - if (mode == OB_MODE_OBJECT) - return true; - else if (mode == OB_MODE_GPENCIL) - return true; /* XXX: assume this is the case for now... */ - - switch (ob->type) { - case OB_MESH: - if (mode & (OB_MODE_EDIT | OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | - OB_MODE_TEXTURE_PAINT | OB_MODE_PARTICLE_EDIT)) - { - return true; - } - break; - case OB_CURVE: - case OB_SURF: - case OB_FONT: - case OB_MBALL: - if (mode & (OB_MODE_EDIT)) - return true; - break; - case OB_LATTICE: - if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT)) - return true; - break; - case OB_ARMATURE: - if (mode & (OB_MODE_EDIT | OB_MODE_POSE)) - return true; - break; - } - } - - return false; -} - -/** - * Sets the mode to a compatible state (use before entering the mode). - * - * This is so each mode's exec function can call - */ -bool ED_object_mode_compat_set(bContext *C, Object *ob, eObjectMode mode, ReportList *reports) -{ - bool ok; - if (!ELEM(ob->mode, mode, OB_MODE_OBJECT)) { - const char *opstring = object_mode_op_string(ob->mode); - WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL); - ok = ELEM(ob->mode, mode, OB_MODE_OBJECT); - if (!ok) { - wmOperatorType *ot = WM_operatortype_find(opstring, false); - BKE_reportf(reports, RPT_ERROR, "Unable to execute '%s', error changing modes", ot->name); - } - } - else { - ok = true; - } - - return ok; -} - static int object_mode_set_poll(bContext *C) { /* Since Grease Pencil editmode is also handled here, @@ -1794,7 +1709,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) } } - if (!ob || !object_mode_compat_test(ob, mode)) + if (!ob || !ED_object_mode_compat_test(ob, mode)) return OPERATOR_PASS_THROUGH; if (ob->mode != mode) { @@ -1805,20 +1720,20 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) /* Exit current mode if it's not the mode we're setting */ if (mode != OB_MODE_OBJECT && (ob->mode != mode || toggle)) { /* Enter new mode */ - ED_object_toggle_modes(C, mode); + ED_object_mode_toggle(C, mode); } if (toggle) { /* Special case for Object mode! */ if (mode == OB_MODE_OBJECT && restore_mode == OB_MODE_OBJECT && ob->restore_mode != OB_MODE_OBJECT) { - ED_object_toggle_modes(C, ob->restore_mode); + ED_object_mode_toggle(C, ob->restore_mode); } else if (ob->mode == mode) { /* For toggling, store old mode so we know what to go back to */ ob->restore_mode = restore_mode; } else if (ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) { - ED_object_toggle_modes(C, ob->restore_mode); + ED_object_mode_toggle(C, ob->restore_mode); } } @@ -1850,16 +1765,6 @@ void OBJECT_OT_mode_set(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -void ED_object_toggle_modes(bContext *C, eObjectMode mode) -{ - if (mode != OB_MODE_OBJECT) { - const char *opstring = object_mode_op_string(mode); - if (opstring) { - WM_operator_name_call(C, opstring, WM_OP_EXEC_REGION_WIN, NULL); - } - } -} - /************************ Game Properties ***********************/ static int game_property_new_exec(bContext *C, wmOperator *op) |