Use own list of actions for Vertex Group Lock operator instead of reusing Select All actions.

Previous actions and descriptions were confusing, e. g. UnLock All used the description of Deselect All.
This commit is contained in:
Sv. Lockal 2012-12-12 10:21:24 +00:00
parent 2713d4d5bd
commit dd2d54bae9
2 changed files with 23 additions and 9 deletions

@ -36,8 +36,8 @@ class MESH_MT_vertex_group_specials(Menu):
layout.operator("object.vertex_group_mirror", icon='ARROW_LEFTRIGHT') layout.operator("object.vertex_group_mirror", icon='ARROW_LEFTRIGHT')
layout.operator("object.vertex_group_remove", icon='X', text="Delete All").all = True layout.operator("object.vertex_group_remove", icon='X', text="Delete All").all = True
layout.separator() layout.separator()
layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock All").action = 'SELECT' layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock All").action = 'LOCK'
layout.operator("object.vertex_group_lock", icon='UNLOCKED', text="UnLock All").action = 'DESELECT' layout.operator("object.vertex_group_lock", icon='UNLOCKED', text="UnLock All").action = 'UNLOCK'
layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Invert All").action = 'INVERT' layout.operator("object.vertex_group_lock", icon='LOCKED', text="Lock Invert All").action = 'INVERT'

@ -1516,16 +1516,30 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
} }
} }
enum {
VGROUP_TOGGLE,
VGROUP_LOCK,
VGROUP_UNLOCK,
VGROUP_INVERT
};
static EnumPropertyItem vgroup_lock_actions[] = {
{VGROUP_TOGGLE, "TOGGLE", 0, "Toggle", "Unlock all vertex groups if there is at least one locked group, lock all in other case"},
{VGROUP_LOCK, "LOCK", 0, "Lock", "Lock all vertex groups"},
{VGROUP_UNLOCK, "UNLOCK", 0, "Unlock", "Unlock all vertex groups"},
{VGROUP_INVERT, "INVERT", 0, "Invert", "Invert the lock state of all vertex groups"},
{0, NULL, 0, NULL, NULL}
};
static void vgroup_lock_all(Object *ob, int action) static void vgroup_lock_all(Object *ob, int action)
{ {
bDeformGroup *dg; bDeformGroup *dg;
if (action == SEL_TOGGLE) { if (action == VGROUP_TOGGLE) {
action = SEL_SELECT; action = VGROUP_LOCK;
for (dg = ob->defbase.first; dg; dg = dg->next) { for (dg = ob->defbase.first; dg; dg = dg->next) {
if (dg->flag & DG_LOCK_WEIGHT) { if (dg->flag & DG_LOCK_WEIGHT) {
action = SEL_DESELECT; action = VGROUP_UNLOCK;
break; break;
} }
} }
@ -1533,13 +1547,13 @@ static void vgroup_lock_all(Object *ob, int action)
for (dg = ob->defbase.first; dg; dg = dg->next) { for (dg = ob->defbase.first; dg; dg = dg->next) {
switch (action) { switch (action) {
case SEL_SELECT: case VGROUP_LOCK:
dg->flag |= DG_LOCK_WEIGHT; dg->flag |= DG_LOCK_WEIGHT;
break; break;
case SEL_DESELECT: case VGROUP_UNLOCK:
dg->flag &= ~DG_LOCK_WEIGHT; dg->flag &= ~DG_LOCK_WEIGHT;
break; break;
case SEL_INVERT: case VGROUP_INVERT:
dg->flag ^= DG_LOCK_WEIGHT; dg->flag ^= DG_LOCK_WEIGHT;
break; break;
} }
@ -2963,7 +2977,7 @@ void OBJECT_OT_vertex_group_lock(wmOperatorType *ot)
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot); RNA_def_enum(ot->srna, "action", vgroup_lock_actions, VGROUP_TOGGLE, "Action", "Lock action to execute on vertex groups");
} }
static int vertex_group_invert_exec(bContext *C, wmOperator *op) static int vertex_group_invert_exec(bContext *C, wmOperator *op)