Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Vegdahl <cessen@cessen.com>2012-05-25 01:05:27 +0400
committerNathan Vegdahl <cessen@cessen.com>2012-05-25 01:05:27 +0400
commit19e1d05461abafc32b5d952d5121f765f4208f94 (patch)
tree5c1f496aa0f00bb605b5c7bd8d69d02534d4c5c6 /source/blender/editors/armature/editarmature.c
parent9dc161e8edc421463d4bb0b6237770b4656ca2a7 (diff)
Modifications to the view3d.select() operator:
1. Two new boolean options have been added to the operator: "deselect" and "toggle". 2. The previous behavior of "extend" (toggling the selection) has been moved to the "toggle" option. 3. "extend" now only extends the selection, it never deselects. 4. "deselect" is pretty self-explanatory: it deselects (i.e. opposite of extend). 5. The built-in keymap has been changed to use "toggle" where "extend" was used before for this operator, to maintain the previous behavior in the default keymap. In short, this works towards making "extend" and "deselect" fully consistent across all selection tools (adding to and removing from selection, respectively), but still preserves the old behavior as well. (Patch reviewed by Brecht.)
Diffstat (limited to 'source/blender/editors/armature/editarmature.c')
-rw-r--r--source/blender/editors/armature/editarmature.c74
1 files changed, 53 insertions, 21 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 4ccdc610cae..8ea66934a31 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -1842,7 +1842,7 @@ static int ebone_select_flag(EditBone *ebone)
}
/* context: editmode armature in view3d */
-int mouse_armature(bContext *C, const int mval[2], int extend)
+int mouse_armature(bContext *C, const int mval[2], int extend, int deselect, int toggle)
{
Object *obedit = CTX_data_edit_object(C);
bArmature *arm = obedit->data;
@@ -1857,7 +1857,7 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask);
if (nearBone) {
- if (!extend)
+ if (!extend && !deselect && !toggle)
ED_armature_deselect_all(obedit, 0);
/* by definition the non-root connected bones have no root point drawn,
@@ -1867,6 +1867,18 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
if (nearBone->parent && (nearBone->flag & BONE_CONNECTED)) {
/* click in a chain */
if (extend) {
+ /* select this bone */
+ nearBone->flag |= BONE_TIPSEL;
+ nearBone->parent->flag |= BONE_TIPSEL;
+ }
+ else if (deselect) {
+ /* deselect this bone */
+ nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED);
+ /* only deselect parent tip if it is not selected */
+ if (!(nearBone->parent->flag & BONE_SELECTED))
+ nearBone->parent->flag &= ~BONE_TIPSEL;
+ }
+ else if (toggle) {
/* hold shift inverts this bone's selection */
if (nearBone->flag & BONE_SELECTED) {
/* deselect this bone */
@@ -1889,17 +1901,28 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
}
else {
if (extend) {
+ nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ else if (deselect) {
+ nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ else if (toggle) {
/* hold shift inverts this bone's selection */
if (nearBone->flag & BONE_SELECTED)
nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL);
else
nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
}
- else nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
+ else
+ nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
}
}
else {
- if (extend && (nearBone->flag & selmask))
+ if (extend)
+ nearBone->flag |= selmask;
+ else if (deselect)
+ nearBone->flag &= ~selmask;
+ else if (toggle && (nearBone->flag & selmask))
nearBone->flag &= ~selmask;
else
nearBone->flag |= selmask;
@@ -4475,7 +4498,7 @@ static int bone_looper(Object *ob, Bone *bone, void *data,
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact is still on old situation */
-int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend)
+int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend, short deselect, short toggle)
{
Object *ob = base->object;
Bone *nearBone;
@@ -4494,7 +4517,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
* note, special exception for armature mode so we can do multi-select
* we could check for multi-select explicitly but think its fine to
* always give predictable behavior in weight paint mode - campbell */
- if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) {
+ if ((!extend && !deselect && !toggle)|| ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) {
ED_pose_deselectall(ob, 0);
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
arm->act_bone = nearBone;
@@ -4503,25 +4526,34 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
//select_actionchannel_by_name(ob->action, nearBone->name, 1);
}
else {
- if (nearBone->flag & BONE_SELECTED) {
- /* if not active, we make it active */
- if (nearBone != arm->act_bone) {
- arm->act_bone = nearBone;
+ if (extend) {
+ nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ arm->act_bone = nearBone;
+ }
+ else if (deselect) {
+ nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ else if (toggle) {
+ if (nearBone->flag & BONE_SELECTED) {
+ /* if not active, we make it active */
+ if (nearBone != arm->act_bone) {
+ arm->act_bone = nearBone;
+ }
+ else {
+ nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+
+ // XXX old cruft! use notifiers instead
+ //select_actionchannel_by_name(ob->action, nearBone->name, 0);
+ }
}
else {
- nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-
+ nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ arm->act_bone = nearBone;
+
// XXX old cruft! use notifiers instead
- //select_actionchannel_by_name(ob->action, nearBone->name, 0);
+ //select_actionchannel_by_name(ob->action, nearBone->name, 1);
}
- }
- else {
- nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- arm->act_bone = nearBone;
-
- // XXX old cruft! use notifiers instead
- //select_actionchannel_by_name(ob->action, nearBone->name, 1);
- }
+ }
}
/* in weightpaint we select the associated vertex group too */