From 9caab2e26501f709109024ade3063e3762a19929 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Apr 2012 10:33:32 +0000 Subject: code cleanup: replace some long ELEM7 checks with macro OB_TYPE_SUPPORT_EDITMODE() --- source/blender/editors/object/object_edit.c | 6 +++--- source/blender/editors/space_view3d/view3d_header.c | 8 ++++---- source/blender/editors/util/undo.c | 15 +++++++++------ source/blender/makesdna/DNA_object_types.h | 8 ++++++-- 4 files changed, 22 insertions(+), 15 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 8531ec5701d..69ced0c0f8a 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1351,11 +1351,11 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED( if (!C) /* needed for docs */ return object_mode_items; + + ob = CTX_data_active_object(C); while (ob && input->identifier) { - if ((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) || - (ob->type == OB_CURVE) || (ob->type == OB_SURF) || - (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) || + if ((input->value == OB_MODE_EDIT && OB_TYPE_SUPPORT_EDITMODE(ob->type)) || (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) || (input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) || ((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT || diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index ab4eca2e303..c4309980b18 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -294,15 +294,15 @@ static char *view3d_modeselect_pup(Scene *scene) if (!((ID *)ob->data)->lib) { /* if active object is editable */ - if (ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) { - str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT); - } - else if (ob->type == OB_ARMATURE) { + if (ob->type == OB_ARMATURE) { if (ob->mode & OB_MODE_POSE) str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT | OB_MODE_POSE, ICON_EDITMODE_HLT); else str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT); } + else if (OB_TYPE_SUPPORT_EDITMODE(ob->type)) { + str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT); + } if (ob->type == OB_MESH) { diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index a43d549cba1..cd88614f8fe 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -155,7 +155,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) ED_text_undo_step(C, step); } else if (obedit) { - if (ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) { + if (OB_TYPE_SUPPORT_EDITMODE(obedit->type)) { if (undoname) undo_editmode_name(C, undoname); else @@ -247,7 +247,7 @@ int ED_undo_valid(const bContext *C, const char *undoname) return 1; } else if (obedit) { - if (ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) { + if (OB_TYPE_SUPPORT_EDITMODE(obedit->type)) { return undo_editmode_valid(undoname); } } @@ -413,9 +413,11 @@ void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int UNUSED(arg_ev /* ************************** */ -#define UNDOSYSTEM_GLOBAL 1 -#define UNDOSYSTEM_EDITMODE 2 -#define UNDOSYSTEM_PARTICLE 3 +enum { + UNDOSYSTEM_GLOBAL = 1, + UNDOSYSTEM_EDITMODE = 2, + UNDOSYSTEM_PARTICLE = 3 +}; static int get_undo_system(bContext *C) { @@ -423,8 +425,9 @@ static int get_undo_system(bContext *C) /* find out which undo system */ if (obedit) { - if (ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) + if (OB_TYPE_SUPPORT_EDITMODE(obedit->type)) { return UNDOSYSTEM_EDITMODE; + } } else { Object *obact = CTX_data_active_object(C); diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 86a2bb60cc9..05a96ef2f35 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -319,8 +319,12 @@ typedef struct DupliObject { #define OB_ARMATURE 25 /* check if the object type supports materials */ -#define OB_TYPE_SUPPORT_MATERIAL(_type) ((_type) >= OB_MESH && (_type) <= OB_MBALL) -#define OB_TYPE_SUPPORT_VGROUP(_type) (ELEM(_type, OB_MESH, OB_LATTICE)) +#define OB_TYPE_SUPPORT_MATERIAL(_type) \ + ((_type) >= OB_MESH && (_type) <= OB_MBALL) +#define OB_TYPE_SUPPORT_VGROUP(_type) \ + (ELEM(_type, OB_MESH, OB_LATTICE)) +#define OB_TYPE_SUPPORT_EDITMODE(_type) \ + (ELEM7(_type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) /* partype: first 4 bits: type */ #define PARTYPE 15 -- cgit v1.2.3