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:
authorSybren A. Stüvel <sybren@blender.org>2020-10-08 16:01:44 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-10-12 13:36:46 +0300
commit1db26e1698f68a57e3707b11852ed4160e455f9b (patch)
treee9124461a35a52292c9866cf59d696ca46e0ac27 /source/blender/editors/animation/anim_channels_edit.c
parentbfd7840358f8f37d7558063857e621c12ec69794 (diff)
Cleanup: Animation, small cleanups on anim channel selection code
Clean up some code by using early returns. No functional changes.
Diffstat (limited to 'source/blender/editors/animation/anim_channels_edit.c')
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c106
1 files changed, 54 insertions, 52 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 0b7ec0d377c..ae27d0e426d 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2881,74 +2881,77 @@ static int click_select_channel_object(bContext *C,
Object *ob = base->object;
AnimData *adt = ob->adt;
- /* set selection status */
- if (base->flag & BASE_SELECTABLE) {
- if (selectmode == SELECT_INVERT) {
- /* swap select */
- ED_object_base_select(base, BA_INVERT);
+ if ((base->flag & BASE_SELECTABLE) == 0) {
+ return 0;
+ }
- if (adt) {
- adt->flag ^= ADT_UI_SELECTED;
- }
+ if (selectmode == SELECT_INVERT) {
+ /* swap select */
+ ED_object_base_select(base, BA_INVERT);
+
+ if (adt) {
+ adt->flag ^= ADT_UI_SELECTED;
}
- else {
- Base *b;
-
- /* deselect all */
- /* TODO: should this deselect all other types of channels too? */
- for (b = view_layer->object_bases.first; b; b = b->next) {
- ED_object_base_select(b, BA_DESELECT);
- if (b->object->adt) {
- b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
- }
+ }
+ else {
+ Base *b;
+
+ /* deselect all */
+ /* TODO: should this deselect all other types of channels too? */
+ for (b = view_layer->object_bases.first; b; b = b->next) {
+ ED_object_base_select(b, BA_DESELECT);
+ if (b->object->adt) {
+ b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
}
+ }
- /* select object now */
- ED_object_base_select(base, BA_SELECT);
- if (adt) {
- adt->flag |= ADT_UI_SELECTED;
- }
+ /* select object now */
+ ED_object_base_select(base, BA_SELECT);
+ if (adt) {
+ adt->flag |= ADT_UI_SELECTED;
}
+ }
- /* change active object - regardless of whether it is now selected [T37883] */
- ED_object_base_activate(C, base); /* adds notifier */
+ /* change active object - regardless of whether it is now selected [T37883] */
+ ED_object_base_activate(C, base); /* adds notifier */
- if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
- adt->flag |= ADT_UI_ACTIVE;
- }
+ if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
+ adt->flag |= ADT_UI_ACTIVE;
+ }
- /* Ensure we exit editmode on whatever object was active before
- * to avoid getting stuck there - T48747. */
- if (ob != CTX_data_edit_object(C)) {
- ED_object_editmode_exit(C, EM_FREEDATA);
- }
- return (ND_ANIMCHAN | NA_SELECTED);
+ /* Ensure we exit editmode on whatever object was active before
+ * to avoid getting stuck there - T48747. */
+ if (ob != CTX_data_edit_object(C)) {
+ ED_object_editmode_exit(C, EM_FREEDATA);
}
- return 0;
+ return (ND_ANIMCHAN | NA_SELECTED);
}
static int click_select_channel_dummy(bAnimContext *ac,
bAnimListElem *ale,
const short /* eEditKeyframes_Select or -1 */ selectmode)
{
- /* sanity checking... */
- if (ale->adt) {
- /* select/deselect */
- if (selectmode == SELECT_INVERT) {
- /* inverse selection status of this AnimData block only */
- ale->adt->flag ^= ADT_UI_SELECTED;
- }
- else {
- /* select AnimData block by itself */
- ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- ale->adt->flag |= ADT_UI_SELECTED;
- }
+ if (ale->adt == NULL) {
+ /* TODO(Sybren): this should return 0, as nothing changed. */
+ return (ND_ANIMCHAN | NA_SELECTED);
+ }
- /* set active? */
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
- ale->adt->flag |= ADT_UI_ACTIVE;
- }
+ /* select/deselect */
+ if (selectmode == SELECT_INVERT) {
+ /* inverse selection status of this AnimData block only */
+ ale->adt->flag ^= ADT_UI_SELECTED;
+ }
+ else {
+ /* select AnimData block by itself */
+ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
+ ale->adt->flag |= ADT_UI_SELECTED;
}
+
+ /* set active? */
+ if (ale->adt->flag & ADT_UI_SELECTED) {
+ ale->adt->flag |= ADT_UI_ACTIVE;
+ }
+
return (ND_ANIMCHAN | NA_SELECTED);
}
@@ -2958,7 +2961,6 @@ static int click_select_channel_group(bAnimContext *ac,
const int filter)
{
bActionGroup *agrp = (bActionGroup *)ale->data;
-
Object *ob = NULL;
bPoseChannel *pchan = NULL;