From 2e667e45fc02c5de285df836e59248a82b45dff9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 8 Dec 2010 03:05:46 +0000 Subject: Changed armature active bone so it is separate from selection this is consistent with active object, mesh editmode, curves & metaballs. - active is no longer assumed to be selected. this fixes a simple bug - eg: Adding a new armature, entering pose mode and toggling selection failed. - outliner editbone selection now works like object and pose mode. - mouse selection sets the bone active even when the tip is selected. - active, unselected bones draw as wire color with a 15% tint of the selected color. --- source/blender/editors/space_outliner/outliner.c | 56 ++++++++++++++++-------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'source/blender/editors/space_outliner/outliner.c') diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 6583d287cf8..7426fca844e 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -2151,8 +2151,6 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen if(set==2 && (pchan->bone->flag & BONE_SELECTED)) { pchan->bone->flag &= ~BONE_SELECTED; - if(arm->act_bone==pchan->bone) - arm->act_bone= NULL; } else { pchan->bone->flag |= BONE_SELECTED; arm->act_bone= pchan->bone; @@ -2182,8 +2180,6 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, if(set==2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; - if(arm->act_bone==bone) - arm->act_bone= NULL; } else { bone->flag |= BONE_SELECTED; arm->act_bone= bone; @@ -2204,27 +2200,49 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, /* ebones only draw in editmode armature */ +static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) +{ + if(sel) { + ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; + arm->act_edbone= ebone; + // flush to parent? + if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; + } + else { + ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + // flush to parent? + if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; + } + + WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); +} static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { + bArmature *arm= scene->obedit->data; EditBone *ebone= te->directdata; - - if(set) { - if(!(ebone->flag & BONE_HIDDEN_A)) { - bArmature *arm= scene->obedit->data; - if(set==2) ED_armature_deselect_all(scene->obedit, 2); // only clear active tag - else ED_armature_deselect_all(scene->obedit, 0); // deselect - ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; - arm->act_edbone= ebone; - - // flush to parent? - if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; - - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); + if(set==1) { + if(!(ebone->flag & BONE_HIDDEN_A)) { + ED_armature_deselect_all(scene->obedit, 0); // deselect + tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); + return 1; } } - else { - if (ebone->flag & BONE_SELECTED) return 1; + else if (set==2) { + if(!(ebone->flag & BONE_HIDDEN_A)) { + if(!(ebone->flag & BONE_SELECTED)) { + tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); + return 1; + } + else { + /* entirely selected, so de-select */ + tree_element_active_ebone__sel(C, scene, arm, ebone, FALSE); + return 0; + } + } + } + else if (ebone->flag & BONE_SELECTED) { + return 1; } return 0; } -- cgit v1.2.3