From 34946e7f045344a43b263f78d001d2ed7ec3c26b Mon Sep 17 00:00:00 2001 From: Jonathan Williamson Date: Mon, 14 Oct 2013 21:03:18 +0000 Subject: Added poll function to disable "Remove Shape key from object". This disables the "-" button when no shape keys exist on the currently selected object. Thanks to Campbell for the help on my first real commit! --- source/blender/editors/object/object_shapekey.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/editors/object/object_shapekey.c') diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index ea96db514b2..6be4a2fed2c 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -290,6 +290,17 @@ static int shape_key_mode_poll(bContext *C) return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT); } +static int shape_key_mode_exists_poll(bContext *C) +{ + Object *ob = ED_object_context(C); + ID *data = (ob) ? ob->data : NULL; + + /* same as shape_key_mode_poll */ + return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT) && + /* check a keyblock exists */ + (BKE_keyblock_from_object(ob) != NULL); +} + static int shape_key_poll(bContext *C) { Object *ob = ED_object_context(C); @@ -359,6 +370,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) /* api callbacks */ ot->poll = shape_key_mode_poll; + ot->poll = shape_key_mode_exists_poll; ot->exec = shape_key_remove_exec; /* flags */ -- cgit v1.2.3