From ddddb7bab173b040342ef99270ee71ae076d45e8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 9 Mar 2013 03:46:30 +0000 Subject: code cleanup: favor braces when blocks have mixed brace use. --- source/blender/editors/space_nla/nla_edit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 484eb47fa8e..c95f46d0e7c 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -2021,8 +2021,9 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) /* add F-Modifier of specified type to selected, and make it the active one */ fcm = add_fmodifier(&strip->modifiers, type); - if (fcm) + if (fcm) { set_active_fmodifier(&strip->modifiers, fcm); + } else { BKE_reportf(op->reports, RPT_ERROR, "Modifier could not be added to (%s : %s) (see console for details)", -- cgit v1.2.3 From aaa8a13c493a09b2db9ddd4421737c612a3634c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Mar 2013 09:03:46 +0000 Subject: code cleanup: use const events for modal and invoke operators. --- source/blender/editors/space_nla/nla_channels.c | 2 +- source/blender/editors/space_nla/nla_edit.c | 4 ++-- source/blender/editors/space_nla/nla_select.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 95e75d0e4fc..bfe2a3484b8 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -298,7 +298,7 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor /* ------------------- */ /* handle clicking */ -static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bAnimContext ac; SpaceNla *snla; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index c95f46d0e7c..16bc1c00f55 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -891,7 +891,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } -static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { nlaedit_duplicate_exec(C, op); @@ -1947,7 +1947,7 @@ void NLA_OT_snap(wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ /* present a special customised popup menu for this, with some filtering */ -static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) +static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { uiPopupMenu *pup; uiLayout *layout; diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 97553b7aa56..3d436bb565b 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -451,7 +451,7 @@ static int nlaedit_select_leftright_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -613,7 +613,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s /* ------------------- */ /* handle clicking */ -static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bAnimContext ac; /* Scene *scene; */ /* UNUSED */ -- cgit v1.2.3 From daf3fc02ada12592a7dd3f010b4daa3ac546e987 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 14 Mar 2013 05:01:51 +0000 Subject: Bugfix: Selecting AnimData "expanders" in AnimEditors works again Somewhere along the line, this functionality broke, even though the code to handle these settings was still in place for many of these. The main implication of this fix is that it should now be possible to select a particular AnimData block, which makes it possible to do things such as changing the action associated with that AnimData block (i.e. via the "Animation Data" panel in the NLA Editor), as well as other operations which I've had on the todolist for a while. Stay tuned! --- source/blender/editors/space_nla/nla_channels.c | 2 +- source/blender/editors/space_nla/nla_draw.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index bfe2a3484b8..07e6d9bca11 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -140,7 +140,7 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor } else { Base *b; - + /* deselect all */ /* TODO: should this deselect all other types of channels too? */ for (b = sce->base.first; b; b = b->next) { diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index acfb4a51b14..242192218c8 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -759,7 +759,6 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View glEnable(GL_BLEND); /* draw backing strip behind channel name */ - // FIXME: hardcoded colors!!! if (group == 5) { float color[4]; -- cgit v1.2.3 From 5f92078d53884c6b2715e64482702108316607ad Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 14 Mar 2013 05:44:56 +0000 Subject: More AnimData selection fixes * Not all supported datatypes would show up in the NLA Properties Region when selected * Clicking on the name part of the "Active Action" tracks now selects the AnimData block that action is attached to --- source/blender/editors/space_nla/nla_buttons.c | 4 +++- source/blender/editors/space_nla/nla_channels.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index eb7de072043..1e0d8437150 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -131,7 +131,6 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA case ANIMTYPE_SCENE: /* Top-Level Widgets doubling up as datablocks */ case ANIMTYPE_OBJECT: - case ANIMTYPE_FILLACTD: /* Action Expander */ case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: @@ -142,6 +141,9 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA case ANIMTYPE_DSPART: case ANIMTYPE_DSMBALL: case ANIMTYPE_DSARM: + case ANIMTYPE_DSMESH: + case ANIMTYPE_DSTEX: + case ANIMTYPE_DSLAT: case ANIMTYPE_DSSPK: { /* for these channels, we only do AnimData */ diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 07e6d9bca11..ba1a3accf93 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -265,6 +265,7 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor { AnimData *adt = BKE_animdata_from_id(ale->id); + /* button area... */ if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { if (nlaedit_is_tweakmode_on(ac) == 0) { /* 'push-down' action - only usable when not in TweakMode */ @@ -280,6 +281,30 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor /* changes to NLA-Action occurred */ notifierFlags |= ND_NLA_ACTCHANGE; } + /* OR rest of name... */ + else { + /* NOTE: rest of NLA-Action name doubles for operating on the AnimData block + * - this is useful when there's no clear divider, and makes more sense in + * the case of users trying to use this to change actions + */ + + /* select/deselect */ + if (selectmode == SELECT_INVERT) { + /* inverse selection status of this AnimData block only */ + adt->flag ^= ADT_UI_SELECTED; + } + else { + /* select AnimData block by itself */ + ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + adt->flag |= ADT_UI_SELECTED; + } + + /* set active? */ + if (adt->flag & ADT_UI_SELECTED) + adt->flag |= ADT_UI_ACTIVE; + + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); + } } break; -- cgit v1.2.3 From 0fa006cba1f8f67d91adea0ea9a1c5669ae21b72 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 14 Mar 2013 05:58:13 +0000 Subject: Remove OPTYPE_REGISTER flag from click handler operator for anim editors 1) It made no sense to show this as the last operator which was used, since these can only be used from the anim editors (and not the 3D View where this panel appears most of the time) 2) Mouse select operators in other places didn't do this 3) There aren't really any editable parameters for this operator anyway 4) It's highly dependent on valid mouse coordinates as input. Apart from that, undo still works fine, so no need to really keep this here. --- source/blender/editors/space_nla/nla_channels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index ba1a3accf93..1dccc874c17 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -380,7 +380,7 @@ void NLA_OT_channels_click(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_UNDO; /* props */ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY -- cgit v1.2.3 From 07f2efe82f0bbc2ee2772f6aa29f33cdac2b546e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 14 Mar 2013 06:34:02 +0000 Subject: NLA Editor: Operator to add AnimData to selected objects so that they can appear This commit introduces an operator in the Add menu - this operator ensures that all selected objects have AnimData attached to them (even if they don't have any actions/drivers yet). By doing this, these objects can at least appear in the NLA Editor, which will allow them to have strips added to them in future without having to create throwaway actions first (NOTE: there's still some stuff coming to allow that). Also, renamed NLA_OT_delete_tracks -> NLA_OT_tracks_delete --- source/blender/editors/space_nla/nla_channels.c | 46 +++++++++++++++++++++++-- source/blender/editors/space_nla/nla_intern.h | 4 ++- source/blender/editors/space_nla/nla_ops.c | 8 +++-- 3 files changed, 52 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 1dccc874c17..8a9e26b354c 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -507,11 +507,11 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void NLA_OT_delete_tracks(wmOperatorType *ot) +void NLA_OT_tracks_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Tracks"; - ot->idname = "NLA_OT_delete_tracks"; + ot->idname = "NLA_OT_tracks_delete"; ot->description = "Delete selected NLA-Tracks and the strips they contain"; /* api callbacks */ @@ -523,3 +523,45 @@ void NLA_OT_delete_tracks(wmOperatorType *ot) } /* *********************************************** */ +/* AnimData Related Operators */ + +/* ******************** Include Objects Operator ***************************** */ +/* Include selected objects in NLA Editor, by giving them AnimData blocks + * NOTE: This doesn't help for non-object AnimData, where we do not have any effective + * selection mechanism in place. Unfortunately, this means that non-object AnimData + * once again becomes a second-class citizen here. However, at least for the most + * common use case, we now have a nice shortcut again. + */ + +static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op)) +{ + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) + { + /* ensure that object has AnimData... that's all */ + BKE_id_add_animdata(&ob->id); + } + CTX_DATA_END; + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLA_OT_selected_objects_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Include Selected Objects"; + ot->idname = "NLA_OT_selected_objects_add"; + ot->description = "Make selected objects in NLA Editor by adding Animation Data"; + + /* api callbacks */ + ot->exec = nlaedit_objects_add_exec; + ot->poll = nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/* *********************************************** */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 398d2d5f1f4..450b85738ad 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -125,7 +125,9 @@ void NLA_OT_fmodifier_paste(wmOperatorType *ot); void NLA_OT_channels_click(wmOperatorType *ot); void NLA_OT_tracks_add(wmOperatorType *ot); -void NLA_OT_delete_tracks(wmOperatorType *ot); +void NLA_OT_tracks_delete(wmOperatorType *ot); + +void NLA_OT_selected_objects_add(wmOperatorType *ot); /* **************************************** */ /* nla_ops.c */ diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 54ade829c0d..fb0f11ffd87 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -120,7 +120,9 @@ void nla_operatortypes(void) WM_operatortype_append(NLA_OT_channels_click); WM_operatortype_append(NLA_OT_tracks_add); - WM_operatortype_append(NLA_OT_delete_tracks); + WM_operatortype_append(NLA_OT_tracks_delete); + + WM_operatortype_append(NLA_OT_selected_objects_add); /* select */ WM_operatortype_append(NLA_OT_click_select); @@ -188,8 +190,8 @@ static void nla_keymap_channels(wmKeyMap *keymap) RNA_boolean_set(kmi->ptr, "above_selected", TRUE); /* delete tracks */ - WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", XKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", DELKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", DELKEY, KM_PRESS, 0, 0); } static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) -- cgit v1.2.3 From 21dc93d275be257d9777d772a5325b6d704b1cb2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 14 Mar 2013 07:11:36 +0000 Subject: Quick fixes for previous commit * Missing word in tooltip for operator * Ensure that filters are set appropriately so that effect is visible immediately --- source/blender/editors/space_nla/nla_channels.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 8a9e26b354c..f9732a79a11 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -535,6 +535,20 @@ void NLA_OT_tracks_delete(wmOperatorType *ot) static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op)) { + bAnimContext ac; + SpaceNla *snla; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* ensure that filters are set so that the effect will be immediately visible */ + snla = (SpaceNla *)ac.sl; + if (snla && snla->ads) { + snla->ads->filterflag &= ~ADS_FILTER_NLA_NOACT; + } + + /* operate on selected objects... */ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { /* ensure that object has AnimData... that's all */ @@ -554,7 +568,7 @@ void NLA_OT_selected_objects_add(wmOperatorType *ot) /* identifiers */ ot->name = "Include Selected Objects"; ot->idname = "NLA_OT_selected_objects_add"; - ot->description = "Make selected objects in NLA Editor by adding Animation Data"; + ot->description = "Make selected objects appear in NLA Editor by adding Animation Data"; /* api callbacks */ ot->exec = nlaedit_objects_add_exec; -- cgit v1.2.3 From ffc8ecc5874931e7a0040141a7bc3ad1b70b17d0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Mar 2013 10:39:18 +0000 Subject: use BLI_strncpy_rlen() rather then BLI_snprintf() when no formatting is needed. also replace sprintf with strcpy when no formatting is done. --- source/blender/editors/space_nla/nla_draw.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 242192218c8..56f2ec9ebe1 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -695,11 +695,8 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View special = ICON_ACTION; - if (act) - BLI_snprintf(name, sizeof(name), "%s", act->id.name + 2); - else - BLI_strncpy(name, "", sizeof(name)); - + BLI_strncpy(name, act ? act->id.name + 2 : "", sizeof(name)); + /* draw manually still */ do_draw = TRUE; } -- cgit v1.2.3 From ce1a1d94d031af84b38a1cbb53465cbf4cfa163c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 16 Mar 2013 02:42:19 +0000 Subject: NLA Editor: Show the ID+AnimData block that the AnimData panel is showing the active action for --- source/blender/editors/space_nla/nla_buttons.c | 49 +++++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 1e0d8437150..e952bec0dd0 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -147,16 +147,25 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA case ANIMTYPE_DSSPK: { /* for these channels, we only do AnimData */ - if (ale->id && ale->adt) { - if (adt_ptr) { - /* AnimData pointer */ - RNA_pointer_create(ale->id, &RNA_AnimData, ale->adt, adt_ptr); - - /* set found status to -1, since setting to 1 would break the loop - * and potentially skip an active NLA-Track in some cases... - */ - found = -1; + if (ale->adt && adt_ptr) { + ID *id; + + if ((ale->data == NULL) || (ale->type == ANIMTYPE_OBJECT)) { + /* ale->data is not an ID block! */ + id = ale->id; } + else { + /* ale->data is always the proper ID block we need, but ale->id may not be (i.e. for textures) */ + id = (ID *)ale->data; + } + + /* AnimData pointer */ + RNA_pointer_create(id, &RNA_AnimData, ale->adt, adt_ptr); + + /* set found status to -1, since setting to 1 would break the loop + * and potentially skip an active NLA-Track in some cases... + */ + found = -1; } } break; @@ -249,6 +258,28 @@ static void nla_panel_animdata(const bContext *C, Panel *pa) block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); + /* AnimData Source Properties ----------------------------------- */ + + /* icon + id-block name of block where AnimData came from to prevent + * accidentally changing the properties of the wrong action + */ + if (adt_ptr.id.data) { + ID *id = adt_ptr.id.data; + PointerRNA id_ptr; + + RNA_id_pointer_create(id, &id_ptr); + + /* ID-block name > AnimData */ + row = uiLayoutRow(layout, TRUE); + uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); + + uiItemL(row, id->name + 2, RNA_struct_ui_icon(id_ptr.type)); /* id-block (src) */ + uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); /* expander */ + uiItemL(row, IFACE_("Animation Data"), ICON_ANIM_DATA); /* animdata */ + + uiItemS(layout); + } + /* Active Action Properties ------------------------------------- */ /* action */ row = uiLayoutRow(layout, TRUE); -- cgit v1.2.3 From 4db11a9e55c39eac9d2f061e87124aa30d0bfe26 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 16 Mar 2013 02:53:45 +0000 Subject: Assorted small fixes * Incorrect comment (copy+paste error) in nla_edit * Whitespace in rna_gpencil * The icon for AnimData is now attached to its RNA definition --- source/blender/editors/space_nla/nla_edit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 16bc1c00f55..dab9b3ae0b8 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -200,7 +200,7 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ale->data; - /* try entering tweakmode if valid */ + /* to be sure, just exit tweakmode... */ BKE_nla_tweakmode_exit(adt); } -- cgit v1.2.3 From 150891605f3f098070b2bb0cd6ef37ae930698d7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 16 Mar 2013 05:09:32 +0000 Subject: NLA "Add Track" can now be used to add tracks to previously empty AnimData blocks, provided the blocks in question are in fact selected. --- source/blender/editors/space_nla/nla_channels.c | 93 ++++++++++++++++++++----- 1 file changed, 76 insertions(+), 17 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index f9732a79a11..a4b036bf00f 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -48,6 +48,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_screen.h" +#include "BKE_report.h" #include "ED_anim_api.h" #include "ED_keyframes_edit.h" @@ -393,24 +394,18 @@ void NLA_OT_channels_click(wmOperatorType *ot) /* ******************** Add Tracks Operator ***************************** */ /* Add NLA Tracks to the same AnimData block as a selected track, or above the selected tracks */ -static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) +/* helper - add NLA Tracks alongside existing ones */ +static bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel) { - bAnimContext ac; - ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - AnimData *lastAdt = NULL; - short above_sel = RNA_boolean_get(op->ptr, "above_selected"); + bool added = false; - /* get editor data */ - if (ANIM_animdata_get_context(C, &ac) == 0) - return OPERATOR_CANCELLED; - - /* get a list of the AnimData blocks being shown in the NLA */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + /* get a list of the (selected) NLA Tracks being shown in the NLA */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* add tracks... */ for (ale = anim_data.first; ale; ale = ale->next) { @@ -424,11 +419,13 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) if (above_sel) { /* just add a new one above this one */ add_nlatrack(adt, nlt); + added = true; } else if ((lastAdt == NULL) || (adt != lastAdt)) { /* add one track to the top of the owning AnimData's stack, then don't add anymore to this stack */ add_nlatrack(adt, NULL); lastAdt = adt; + added = true; } } } @@ -436,17 +433,79 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) /* free temp data */ BLI_freelistN(&anim_data); - /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); + return added; +} + +/* helper - add NLA Tracks to empty (and selected) AnimData blocks */ +static bool nlaedit_add_tracks_empty(bAnimContext *ac) +{ + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + bool added = false; - /* done */ - return OPERATOR_FINISHED; + /* get a list of the selected AnimData blocks in the NLA */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + + /* check if selected AnimData blocks are empty, and add tracks if so... */ + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ale->adt; + + /* sanity check */ + BLI_assert(adt->flag & ADT_UI_SELECTED); + + /* ensure it is empty */ + if (adt->nla_tracks.first == NULL) { + /* add new track to this AnimData block then */ + add_nlatrack(adt, NULL); + added = true; + } + } + + /* cleanup */ + BLI_freelistN(&anim_data); + + return added; +} + +/* Add Tracks exec() */ +static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) +{ + bAnimContext ac; + bool above_sel = RNA_boolean_get(op->ptr, "above_selected"); + bool op_done = false; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + /* perform adding in two passes - existing first so that we don't double up for empty */ + op_done |= nlaedit_add_tracks_existing(&ac, above_sel); + op_done |= nlaedit_add_tracks_empty(&ac); + + /* done? */ + if (op_done) { + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); + + /* done */ + return OPERATOR_FINISHED; + } + else { + /* failed to add any tracks */ + BKE_report(op->reports, RPT_WARNING, + "Select an existing NLA Track or an empty action line first"); + + /* not done */ + return OPERATOR_CANCELLED; + } } void NLA_OT_tracks_add(wmOperatorType *ot) { /* identifiers */ - ot->name = "Add Track(s)"; + ot->name = "Add Tracks"; ot->idname = "NLA_OT_tracks_add"; ot->description = "Add NLA-Tracks above/after the selected tracks"; -- cgit v1.2.3 From 9aa4396a9732b0acc678d7eb309452d817493279 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 16 Mar 2013 05:48:46 +0000 Subject: Assorted anim editor fixes * Click-select operators don't have "register" flag anymore * Graph Editor click select can be undone, just like everything else * "Current frame" -> "Current Frame" for consistency with rest of menu --- source/blender/editors/space_nla/nla_edit.c | 2 +- source/blender/editors/space_nla/nla_select.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index dab9b3ae0b8..d337c3236c5 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1801,7 +1801,7 @@ void NLA_OT_clear_scale(wmOperatorType *ot) /* defines for snap keyframes tool */ static EnumPropertyItem prop_nlaedit_snap_types[] = { - {NLAEDIT_SNAP_CFRA, "CFRA", 0, "Current frame", ""}, + {NLAEDIT_SNAP_CFRA, "CFRA", 0, "Current Frame", ""}, {NLAEDIT_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry? {NLAEDIT_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry? {NLAEDIT_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""}, diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 3d436bb565b..3e414233add 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -660,7 +660,7 @@ void NLA_OT_click_select(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_UNDO; /* properties */ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY -- cgit v1.2.3 From 31356c86d3890d21e7845cd29d25ed4df28e65f3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 16 Mar 2013 05:58:59 +0000 Subject: Some more assorted fixes * More duplicate/wrong comments (copy+paste errors) * Brough Calculate/Clear Motion Path UI for bones more in line with the Object version --- source/blender/editors/space_nla/nla_channels.c | 3 ++- source/blender/editors/space_nla/nla_edit.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index a4b036bf00f..177a781bcc2 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -469,7 +469,8 @@ static bool nlaedit_add_tracks_empty(bAnimContext *ac) return added; } -/* Add Tracks exec() */ +/* ----- */ + static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) { bAnimContext ac; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index d337c3236c5..17d403789cf 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1627,7 +1627,7 @@ void NLA_OT_action_sync_length(wmOperatorType *ot) /* api callbacks */ ot->exec = nlaedit_sync_actlen_exec; - ot->poll = ED_operator_nla_active; // XXX: is this satisfactory... probably requires a check for active strip... + ot->poll = nlaop_poll_tweakmode_off; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -2102,8 +2102,10 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied"); return OPERATOR_CANCELLED; } - else + else { + /* no updates needed - copy is non-destructive operation */ return OPERATOR_FINISHED; + } } void NLA_OT_fmodifier_copy(wmOperatorType *ot) @@ -2157,8 +2159,6 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) /* successful or not? */ if (ok) { - /* set notifier that things have changed */ - /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); return OPERATOR_FINISHED; } -- cgit v1.2.3