From 44505b38df557a5711703613685a1dec9fc2c3d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Jun 2018 09:31:30 +0200 Subject: Cleanup: strip trailing space in editors --- .../blender/editors/space_action/action_buttons.c | 12 +- source/blender/editors/space_action/action_data.c | 208 ++++----- source/blender/editors/space_action/action_draw.c | 110 ++--- source/blender/editors/space_action/action_edit.c | 508 ++++++++++----------- .../blender/editors/space_action/action_intern.h | 8 +- source/blender/editors/space_action/action_ops.c | 74 +-- .../blender/editors/space_action/action_select.c | 464 +++++++++---------- source/blender/editors/space_action/space_action.c | 146 +++--- 8 files changed, 765 insertions(+), 765 deletions(-) (limited to 'source/blender/editors/space_action') diff --git a/source/blender/editors/space_action/action_buttons.c b/source/blender/editors/space_action/action_buttons.c index 003fd3b5bcf..b16d0543d0e 100644 --- a/source/blender/editors/space_action/action_buttons.c +++ b/source/blender/editors/space_action/action_buttons.c @@ -76,9 +76,9 @@ void action_buttons_register(ARegionType *UNUSED(art)) { #if 0 PanelType *pt; - + // TODO: AnimData / Actions List - + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties"); strcpy(pt->idname, "ACTION_PT_properties"); strcpy(pt->label, N_("Active F-Curve")); @@ -86,7 +86,7 @@ void action_buttons_register(ARegionType *UNUSED(art)) pt->draw = action_anim_panel_properties; pt->poll = action_anim_panel_poll; BLI_addtail(&art->paneltypes, pt); - + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties"); strcpy(pt->idname, "ACTION_PT_key_properties"); strcpy(pt->label, N_("Active Keyframe")); @@ -94,7 +94,7 @@ void action_buttons_register(ARegionType *UNUSED(art)) pt->draw = action_anim_panel_key_properties; pt->poll = action_anim_panel_poll; BLI_addtail(&art->paneltypes, pt); - + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel modifiers"); strcpy(pt->idname, "ACTION_PT_modifiers"); strcpy(pt->label, N_("Modifiers")); @@ -109,7 +109,7 @@ static int action_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = action_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -121,7 +121,7 @@ void ACTION_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->idname = "ACTION_OT_properties"; ot->description = "Toggle the properties region visibility"; - + ot->exec = action_properties_toggle_exec; ot->poll = ED_operator_action_active; diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c index 2bfe756f76e..74c9f2f8cfb 100644 --- a/source/blender/editors/space_action/action_data.c +++ b/source/blender/editors/space_action/action_data.c @@ -87,7 +87,7 @@ AnimData *ED_actedit_animdata_from_context(bContext *C) SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); Object *ob = CTX_data_active_object(C); AnimData *adt = NULL; - + /* Get AnimData block to use */ if (saction->mode == SACTCONT_ACTION) { /* Currently, "Action Editor" means object-level only... */ @@ -101,7 +101,7 @@ AnimData *ED_actedit_animdata_from_context(bContext *C) adt = key->adt; } } - + return adt; } @@ -112,7 +112,7 @@ static bAction *action_create_new(bContext *C, bAction *oldact) { ScrArea *sa = CTX_wm_area(C); bAction *action; - + /* create action - the way to do this depends on whether we've got an * existing one there already, in which case we make a copy of it * (which is useful for "versioning" actions within the same file) @@ -125,24 +125,24 @@ static bAction *action_create_new(bContext *C, bAction *oldact) /* just make a new (empty) action */ action = BKE_action_add(CTX_data_main(C), "Action"); } - - /* when creating new ID blocks, there is already 1 user (as for all new datablocks), + + /* when creating new ID blocks, there is already 1 user (as for all new datablocks), * but the RNA pointer code will assign all the proper users instead, so we compensate * for that here */ BLI_assert(action->id.us == 1); id_us_min(&action->id); - + /* set ID-Root type */ if (sa->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; - + if (saction->mode == SACTCONT_SHAPEKEY) action->idroot = ID_KE; else action->idroot = ID_OB; } - + return action; } @@ -151,17 +151,17 @@ static void actedit_change_action(bContext *C, bAction *act) { bScreen *screen = CTX_wm_screen(C); SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); - + PointerRNA ptr, idptr; PropertyRNA *prop; - + /* create RNA pointers and get the property */ RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, saction, &ptr); prop = RNA_struct_find_property(&ptr, "action"); - + /* NOTE: act may be NULL here, so better to just use a cast here */ RNA_id_pointer_create((ID *)act, &idptr); - + /* set the new pointer, and force a refresh */ RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); @@ -178,13 +178,13 @@ static void actedit_change_action(bContext *C, bAction *act) static int action_new_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - + /* Check tweakmode is off (as you don't want to be tampering with the action in that case) */ - /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */ + /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */ if (ED_operator_action_active(C)) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); Object *ob = CTX_data_active_object(C); - + /* For now, actions are only for the active object, and on object and shapekey levels... */ if (saction->mode == SACTCONT_ACTION) { /* XXX: This assumes that actions are assigned to the active object in this mode */ @@ -206,7 +206,7 @@ static int action_new_poll(bContext *C) return true; } } - + /* something failed... */ return false; } @@ -215,18 +215,18 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op)) { PointerRNA ptr, idptr; PropertyRNA *prop; - + /* hook into UI */ UI_context_active_but_prop_get_templateID(C, &ptr, &prop); - + if (prop) { bAction *action = NULL, *oldact = NULL; AnimData *adt = NULL; PointerRNA oldptr; - + oldptr = RNA_property_pointer_get(&ptr, prop); oldact = (bAction *)oldptr.id.data; - + /* stash the old action to prevent it from being lost */ if (ptr.type == &RNA_AnimData) { adt = ptr.data; @@ -234,7 +234,7 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op)) else if (ptr.type == &RNA_SpaceDopeSheetEditor) { adt = ED_actedit_animdata_from_context(C); } - + /* Perform stashing operation - But only if there is an action */ if (adt && oldact) { /* stash the action */ @@ -255,10 +255,10 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op)) //printf("WARNING: Failed to stash %s. It may already exist in the NLA stack though\n", oldact->id.name); } } - + /* create action */ action = action_create_new(C, oldact); - + /* set this new action * NOTE: we can't use actedit_change_action, as this function is also called from the NLA */ @@ -266,24 +266,24 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op)) RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); } - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_new(wmOperatorType *ot) { /* identifiers */ ot->name = "New Action"; ot->idname = "ACTION_OT_new"; ot->description = "Create new action"; - + /* api callbacks */ ot->exec = action_new_exec; ot->poll = action_new_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -300,7 +300,7 @@ static int action_pushdown_poll(bContext *C) if (ED_operator_action_active(C)) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Check for AnimData, Actions, and that tweakmode is off */ if (adt && saction->action) { /* NOTE: We check this for the AnimData block in question and not the global flag, @@ -310,7 +310,7 @@ static int action_pushdown_poll(bContext *C) return true; } } - + /* something failed... */ return false; } @@ -319,7 +319,7 @@ static int action_pushdown_exec(bContext *C, wmOperator *op) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Do the deed... */ if (adt) { /* Perform the pushdown operation @@ -334,13 +334,13 @@ static int action_pushdown_exec(bContext *C, wmOperator *op) /* action can be safely added */ BKE_nla_action_pushdown(adt); } - + /* Stop displaying this action in this editor * NOTE: The editor itself doesn't set a user... */ saction->action = NULL; } - + /* Send notifiers that stuff has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); return OPERATOR_FINISHED; @@ -352,11 +352,11 @@ void ACTION_OT_push_down(wmOperatorType *ot) ot->name = "Push Down Action"; ot->idname = "ACTION_OT_push_down"; ot->description = "Push action down on to the NLA stack as a new strip"; - + /* callbacks */ ot->exec = action_pushdown_exec; ot->poll = action_pushdown_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -367,7 +367,7 @@ static int action_stash_exec(bContext *C, wmOperator *op) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Perform stashing operation */ if (adt) { /* don't do anything if this action is empty... */ @@ -390,12 +390,12 @@ static int action_stash_exec(bContext *C, wmOperator *op) /* action has already been added - simply warn about this, and clear */ BKE_report(op->reports, RPT_ERROR, "Action has already been stashed"); } - + /* clear action refs from editor, and then also the backing data (not necessary) */ actedit_change_action(C, NULL); } } - + /* Send notifiers that stuff has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); return OPERATOR_FINISHED; @@ -407,16 +407,16 @@ void ACTION_OT_stash(wmOperatorType *ot) ot->name = "Stash Action"; ot->idname = "ACTION_OT_stash"; ot->description = "Store this action in the NLA stack as a non-contributing strip for later use"; - + /* callbacks */ ot->exec = action_stash_exec; ot->poll = action_pushdown_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ - ot->prop = RNA_def_boolean(ot->srna, "create_new", true, "Create New Action", + ot->prop = RNA_def_boolean(ot->srna, "create_new", true, "Create New Action", "Create a new action once the existing one has been safely stored"); } @@ -430,7 +430,7 @@ static int action_stash_create_poll(bContext *C) { if (ED_operator_action_active(C)) { AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Check tweakmode is off (as you don't want to be tampering with the action in that case) */ /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */ if (adt) { @@ -439,19 +439,19 @@ static int action_stash_create_poll(bContext *C) } else { /* There may not be any action/animdata yet, so, just fallback to the global setting - * (which may not be totally valid yet if the action editor was used and things are + * (which may not be totally valid yet if the action editor was used and things are * now in an inconsistent state) */ SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); Scene *scene = CTX_data_scene(C); - + if (!(scene->flag & SCE_NLA_EDIT_ON)) { /* For now, actions are only for the active object, and on object and shapekey levels... */ return ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY); } } } - + /* something failed... */ return false; } @@ -460,7 +460,7 @@ static int action_stash_create_exec(bContext *C, wmOperator *op) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Check for no action... */ if (saction->action == NULL) { /* just create a new action */ @@ -478,10 +478,10 @@ static int action_stash_create_exec(bContext *C, wmOperator *op) /* stash the action */ if (BKE_nla_action_stash(adt)) { bAction *new_action = NULL; - + /* create new action not based on the old one (since the "new" operator already does that) */ new_action = action_create_new(C, NULL); - + /* The stash operation will remove the user already, * so the flushing step later shouldn't double up * the usercount fixes. Hence, we must unset this ref @@ -497,7 +497,7 @@ static int action_stash_create_exec(bContext *C, wmOperator *op) } } } - + /* Send notifiers that stuff has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); return OPERATOR_FINISHED; @@ -509,11 +509,11 @@ void ACTION_OT_stash_and_create(wmOperatorType *ot) ot->name = "Stash Action"; ot->idname = "ACTION_OT_stash_and_create"; ot->description = "Store this action in the NLA stack as a non-contributing strip for later use, and create a new action"; - + /* callbacks */ ot->exec = action_stash_create_exec; ot->poll = action_stash_create_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -533,7 +533,7 @@ void ACTION_OT_stash_and_create(wmOperatorType *ot) void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, ReportList *reports, bool force_delete) { ScrArea *sa = CTX_wm_area(C); - + /* If the old action only has a single user (that it's about to lose), * warn user about it * @@ -545,7 +545,7 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, "Action '%s' will not be saved, create Fake User or Stash in NLA Stack to retain", act->id.name + 2); } - + /* Clear Fake User and remove action stashing strip (if present) */ if (force_delete) { /* Remove stashed strip binding this action to this datablock */ @@ -556,18 +556,18 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, if (adt) { NlaTrack *nlt, *nlt_next; NlaStrip *strip, *nstrip; - + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt_next) { nlt_next = nlt->next; - + if (strstr(nlt->name, DATA_("[Action Stash]"))) { for (strip = nlt->strips.first; strip; strip = nstrip) { nstrip = strip->next; - + if (strip->act == act) { /* Remove this strip, and the track too if it doesn't have anything else */ BKE_nlastrip_free(&nlt->strips, strip); - + if (nlt->strips.first == NULL) { BLI_assert(nstrip == NULL); BKE_nlatrack_free(&adt->nla_tracks, nlt); @@ -577,18 +577,18 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, } } } - + /* Clear Fake User */ id_fake_user_clear(&act->id); } - - /* If in Tweak Mode, don't unlink. Instead, this + + /* If in Tweak Mode, don't unlink. Instead, this * becomes a shortcut to exit Tweak Mode instead */ if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { /* Exit Tweak Mode */ BKE_nla_tweakmode_exit(adt); - + /* Flush this to the Action Editor (if that's where this change was initiated) */ if (sa->spacetype == SPACE_ACTION) { actedit_change_action(C, NULL); @@ -604,11 +604,11 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, /* clear AnimData -> action */ PointerRNA ptr; PropertyRNA *prop; - + /* create AnimData RNA pointers */ RNA_pointer_create(id, &RNA_AnimData, adt, &ptr); prop = RNA_struct_find_property(&ptr, "action"); - + /* clear... */ RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL); RNA_property_update(C, &ptr, prop); @@ -623,12 +623,12 @@ static int action_unlink_poll(bContext *C) if (ED_operator_action_active(C)) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Only when there's an active action, in the right modes... */ if (saction->action && adt) return true; } - + /* something failed... */ return false; } @@ -637,11 +637,11 @@ static int action_unlink_exec(bContext *C, wmOperator *op) { AnimData *adt = ED_actedit_animdata_from_context(C); bool force_delete = RNA_boolean_get(op->ptr, "force_delete"); - + if (adt && adt->action) { ED_animedit_unlink_action(C, NULL, adt, adt->action, op->reports, force_delete); } - + return OPERATOR_FINISHED; } @@ -655,17 +655,17 @@ static int action_unlink_invoke(bContext *C, wmOperator *op, const wmEvent *evt) void ACTION_OT_unlink(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Unlink Action"; ot->idname = "ACTION_OT_unlink"; ot->description = "Unlink this action from the active action slot (and/or exit Tweak Mode)"; - + /* callbacks */ ot->invoke = action_unlink_invoke; ot->exec = action_unlink_exec; ot->poll = action_unlink_poll; - + /* properties */ prop = RNA_def_boolean(ot->srna, "force_delete", false, "Force Delete", "Clear Fake User and remove " "copy stashed in this data-block's NLA stack"); @@ -679,7 +679,7 @@ void ACTION_OT_unlink(wmOperatorType *ot) static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime) { NlaStrip *strip; - + for (strip = strips->first; strip; strip = strip->next) { /* Can we use this? */ if (IN_RANGE_INCL(ctime, strip->start, strip->end)) { @@ -695,7 +695,7 @@ static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime) return strip; } } - + /* nothing suitable found... */ return NULL; } @@ -709,18 +709,18 @@ static void action_layer_switch_strip(AnimData *adt, * NOTE: We need to manually clear this stuff ourselves, as tweakmode exit doesn't do it */ BKE_nla_tweakmode_exit(adt); - + if (old_strip) { old_strip->flag &= ~(NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT); } if (old_track) { old_track->flag &= ~(NLATRACK_ACTIVE | NLATRACK_SELECTED); } - + /* Make this one the active one instead */ strip->flag |= (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT); nlt->flag |= NLATRACK_ACTIVE; - + /* Copy over "solo" flag - This is useful for stashed actions... */ if (old_track) { if (old_track->flag & NLATRACK_SOLO) { @@ -733,15 +733,15 @@ static void action_layer_switch_strip(AnimData *adt, if (adt->flag & ADT_NLA_EVAL_OFF) { /* disable NLA muting */ adt->flag &= ~ADT_NLA_EVAL_OFF; - + /* mark this track as being solo */ adt->flag |= ADT_NLA_SOLO_TRACK; nlt->flag |= NLATRACK_SOLO; - + // TODO: Needs restpose flushing (when we get reference track) } } - + /* Enter tweakmode again - hopefully we're now "it" */ BKE_nla_tweakmode_enter(adt); BLI_assert(adt->actstrip == strip); @@ -762,7 +762,7 @@ static int action_layer_next_poll(bContext *C) */ if (adt->nla_tracks.last) { NlaTrack *nlt = (NlaTrack *)adt->nla_tracks.last; - + if (nlt->flag & NLATRACK_DISABLED) { /* A disabled track will either be the track itself, * or one of the ones above it. @@ -780,7 +780,7 @@ static int action_layer_next_poll(bContext *C) } } } - + /* something failed... */ return false; } @@ -789,26 +789,26 @@ static int action_layer_next_exec(bContext *C, wmOperator *op) { AnimData *adt = ED_actedit_animdata_from_context(C); NlaTrack *act_track; - + Scene *scene = CTX_data_scene(C); float ctime = BKE_scene_frame_get(scene); - + /* Get active track */ act_track = BKE_nlatrack_find_tweaked(adt); - + if (act_track == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find current NLA Track"); return OPERATOR_CANCELLED; } - + /* Find next action, and hook it up */ if (act_track->next) { NlaTrack *nlt; - + /* Find next action to use */ for (nlt = act_track->next; nlt; nlt = nlt->next) { NlaStrip *strip = action_layer_get_nlastrip(&nlt->strips, ctime); - + if (strip) { action_layer_switch_strip(adt, act_track, adt->actstrip, nlt, strip); break; @@ -820,7 +820,7 @@ static int action_layer_next_exec(bContext *C, wmOperator *op) * NOTE: This will mean exiting tweakmode... */ BKE_nla_tweakmode_exit(adt); - + /* Deal with solo flags... * Assume: Solo Track == NLA Muting */ @@ -828,14 +828,14 @@ static int action_layer_next_exec(bContext *C, wmOperator *op) /* turn off solo flags on tracks */ act_track->flag &= ~NLATRACK_SOLO; adt->flag &= ~ADT_NLA_SOLO_TRACK; - + /* turn on NLA muting (to keep same effect) */ adt->flag |= ADT_NLA_EVAL_OFF; - + // TODO: Needs restpose flushing (when we get reference track) } } - + /* Update the action that this editor now uses * NOTE: The calls above have already handled the usercount/animdata side of things */ @@ -849,11 +849,11 @@ void ACTION_OT_layer_next(wmOperatorType *ot) ot->name = "Next Layer"; ot->idname = "ACTION_OT_layer_next"; ot->description = "Switch to editing action in animation layer above the current action in the NLA Stack"; - + /* callbacks */ ot->exec = action_layer_next_exec; ot->poll = action_layer_next_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -870,7 +870,7 @@ static int action_layer_prev_poll(bContext *C) /* Tweak Mode: We need to check if there are any tracks below the active one that we can move to */ if (adt->nla_tracks.first) { NlaTrack *nlt = (NlaTrack *)adt->nla_tracks.first; - + /* Since the first disabled track is the track being tweaked/edited, * we can simplify things by only checking the first track: * - If it is disabled, this is the track being tweaked, @@ -890,7 +890,7 @@ static int action_layer_prev_poll(bContext *C) } } } - + /* something failed... */ return false; } @@ -900,19 +900,19 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op) AnimData *adt = ED_actedit_animdata_from_context(C); NlaTrack *act_track; NlaTrack *nlt; - + Scene *scene = CTX_data_scene(C); float ctime = BKE_scene_frame_get(scene); - + /* Sanity Check */ if (adt == NULL) { BKE_report(op->reports, RPT_ERROR, "Internal Error: Could not find Animation Data/NLA Stack to use"); return OPERATOR_CANCELLED; } - + /* Get active track */ act_track = BKE_nlatrack_find_tweaked(adt); - + /* If there is no active track, that means we are using the active action... */ if (act_track) { /* Active Track - Start from the one below it */ @@ -922,17 +922,17 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op) /* Active Action - Use the top-most track */ nlt = adt->nla_tracks.last; } - + /* Find previous action and hook it up */ for (; nlt; nlt = nlt->prev) { NlaStrip *strip = action_layer_get_nlastrip(&nlt->strips, ctime); - + if (strip) { action_layer_switch_strip(adt, act_track, adt->actstrip, nlt, strip); break; } } - + /* Update the action that this editor now uses * NOTE: The calls above have already handled the usercount/animdata side of things */ @@ -946,11 +946,11 @@ void ACTION_OT_layer_prev(wmOperatorType *ot) ot->name = "Previous Layer"; ot->idname = "ACTION_OT_layer_prev"; ot->description = "Switch to editing action in animation layer below the current action in the NLA Stack"; - + /* callbacks */ ot->exec = action_layer_prev_exec; ot->poll = action_layer_prev_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 0764f586de9..a7c94c072a4 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -49,7 +49,7 @@ #include "BKE_context.h" -/* Everything from source (BIF, BDR, BSE) ------------------------------ */ +/* Everything from source (BIF, BDR, BSE) ------------------------------ */ #include "BIF_gl.h" @@ -66,41 +66,41 @@ /* Channel List */ /* left hand part */ -void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) +void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + View2D *v2d = &ar->v2d; float y = 0.0f; size_t items; int height; - + /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac))); if (height > BLI_rcti_size_y(&v2d->mask)) { - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); } /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); - + /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; - + y = (float)ACHANNEL_FIRST(ac); - + for (ale = anim_data.first; ale; ale = ale->next) { float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -108,7 +108,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index); } - + /* adjust y-position for next one */ y -= ACHANNEL_STEP(ac); channel_index++; @@ -117,13 +117,13 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - + y = (float)ACHANNEL_FIRST(ac); - + for (ale = anim_data.first; ale; ale = ale->next) { float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -131,16 +131,16 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); } - + /* adjust y-position for next one */ y -= ACHANNEL_STEP(ac); channel_index++; } - + UI_block_end(C, block); UI_block_draw(C, block); } - + /* free tempolary channels */ ANIM_animdata_freelist(&anim_data); } @@ -157,73 +157,73 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + View2D *v2d = &ar->v2d; bDopeSheet *ads = &saction->ads; AnimData *adt = NULL; - + float act_start, act_end, y; size_t items; int height; - + unsigned char col1[3], col2[3]; unsigned char col1a[3], col2a[3]; unsigned char col1b[3], col2b[3]; - + const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS); - - + + /* get theme colors */ UI_GetThemeColor3ubv(TH_BACK, col2); UI_GetThemeColor3ubv(TH_HILITE, col1); - + UI_GetThemeColor3ubv(TH_GROUP, col2a); UI_GetThemeColor3ubv(TH_GROUP_ACTIVE, col1a); - + UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELOB, col1b); UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELSUBOB, col2b); - + /* set view-mapping rect (only used for x-axis), for NLA-scaling mapping with less calculation */ /* if in NLA there's a strip active, map the view */ if (ac->datatype == ANIMCONT_ACTION) { /* adt = ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */ - + /* start and end of action itself */ calc_action_range(ac->data, &act_start, &act_end, 0); } - + /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac))); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); - + /* first backdrop strips */ y = (float)(-ACHANNEL_HEIGHT(ac)); glEnable(GL_BLEND); - + for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int sel = 0; - + /* determine if any need to draw channel */ if (ale->datatype != ALE_NONE) { /* determine if channel is selected */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) sel = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); - + if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) { switch (ale->type) { case ANIMTYPE_SUMMARY: @@ -235,16 +235,16 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) case ANIMTYPE_SCENE: case ANIMTYPE_OBJECT: { - if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45); - else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22); + if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45); + else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22); break; } case ANIMTYPE_FILLACTD: case ANIMTYPE_DSSKEY: case ANIMTYPE_DSWOR: { - if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45); - else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22); + if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45); + else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22); break; } case ANIMTYPE_GROUP: @@ -271,7 +271,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) FCurve *fcu = ale->data; if (show_group_colors && fcu->grp && fcu->grp->customCol) { unsigned char *cp = (unsigned char *)fcu->grp->cs.active; - + if (sel) glColor4ub(cp[0], cp[1], cp[2], 0x65); else glColor4ub(cp[0], cp[1], cp[2], 0x0B); } @@ -288,10 +288,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) break; } } - + /* draw region twice: firstly backdrop, then the current range */ glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF(ac)); - + if (ac->datatype == ANIMCONT_ACTION) glRectf(act_start, (float)y - ACHANNEL_HEIGHT_HALF(ac), act_end, (float)y + ACHANNEL_HEIGHT_HALF(ac)); } @@ -300,7 +300,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac)); - + /* frames one and higher get a saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44); else glColor4ub(col2[0], col2[1], col2[2], 0x44); @@ -320,23 +320,23 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } } } - + /* Increment the step */ y -= ACHANNEL_STEP(ac); } glDisable(GL_BLEND); - - /* Draw keyframes + + /* Draw keyframes * 1) Only channels that are visible in the Action Editor get drawn/evaluated. * This is to try to optimize this for heavier data sets - * 2) Keyframes which are out of view horizontally are disregarded + * 2) Keyframes which are out of view horizontally are disregarded */ y = (float)(-ACHANNEL_HEIGHT(ac)); - + for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -344,7 +344,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* check if anything to show for this channel */ if (ale->datatype != ALE_NONE) { adt = ANIM_nla_mapping_get(ac, ale); - + /* draw 'keyframes' for each specific datatype */ switch (ale->datatype) { case ALE_ALL: @@ -374,17 +374,17 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } } } - + y -= ACHANNEL_STEP(ac); } - + /* free tempolary channels used for drawing */ ANIM_animdata_freelist(&anim_data); /* black line marking 'current frame' for Time-Slide transform mode */ if (saction->flag & SACTION_MOVING) { glColor3f(0.0f, 0.0f, 0.0f); - + glBegin(GL_LINES); glVertex2f(saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD); glVertex2f(saction->timeslide, v2d->cur.ymax); diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 1c15a7c5950..285e9afb8b4 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -95,56 +95,56 @@ static int act_markers_make_local_poll(bContext *C) { SpaceAction *sact = CTX_wm_space_action(C); - + /* 1) */ if (sact == NULL) return 0; - + /* 2) */ if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0) return 0; if (sact->action == NULL) return 0; - + /* 3) */ if (sact->flag & SACTION_POSEMARKERS_SHOW) return 0; - + /* 4) */ return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL; } static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op)) -{ +{ ListBase *markers = ED_context_get_markers(C); - + SpaceAction *sact = CTX_wm_space_action(C); bAction *act = (sact) ? sact->action : NULL; - + TimeMarker *marker, *markern = NULL; - + /* sanity checks */ if (ELEM(NULL, markers, act)) return OPERATOR_CANCELLED; - + /* migrate markers */ for (marker = markers->first; marker; marker = markern) { markern = marker->next; - + /* move if marker is selected */ if (marker->flag & SELECT) { BLI_remlink(markers, marker); BLI_addtail(&act->markers, marker); } } - + /* now enable the "show posemarkers only" setting, so that we can see that something did happen */ sact->flag |= SACTION_POSEMARKERS_SHOW; - + /* notifiers - both sets, as this change affects both */ WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); - + return OPERATOR_FINISHED; } @@ -154,11 +154,11 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot) ot->name = "Make Markers Local"; ot->idname = "ACTION_OT_markers_make_local"; ot->description = "Move selected scene markers to the active Action as local 'pose' markers"; - + /* callbacks */ ot->exec = act_markers_make_local_exec; ot->poll = act_markers_make_local_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -175,17 +175,17 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const bAnimListElem *ale; int filter; bool found = false; - + /* get data to filter, from Action or Dopesheet */ /* XXX: what is sel doing here?! * Commented it, was breaking things (eg. the "auto preview range" tool). */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* set large values to try to override */ *min = 999999999.0f; *max = -999999999.0f; - + /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ @@ -268,7 +268,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) bAnimContext ac; Scene *scene; float min, max; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -276,7 +276,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; else scene = ac.scene; - + /* set the range directly */ get_keyframe_extents(&ac, &min, &max, false); scene->r.flag |= SCER_PRV_RANGE; @@ -286,25 +286,25 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) if (scene->r.psfra == scene->r.pefra) { scene->r.pefra = scene->r.psfra + 1; } - + /* set notifier that things have changed */ // XXX err... there's nothing for frame ranges yet, but this should do fine too WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); - + return OPERATOR_FINISHED; } - + void ACTION_OT_previewrange_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Auto-Set Preview Range"; ot->idname = "ACTION_OT_previewrange_set"; ot->description = "Set Preview Range based on extents of selected Keyframes"; - + /* api callbacks */ ot->exec = actkeys_previewrange_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -323,31 +323,31 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + short found = 0; /* NOTE: not bool, since we want prioritise individual channels over expanders */ float y; - + /* get all items - we need to do it this way */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through all channels, finding the first one that's selected */ y = (float)ACHANNEL_FIRST(ac); - + for (ale = anim_data.first; ale; ale = ale->next) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - + /* must be selected... */ - if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && + if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { /* update best estimate */ *min = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); *max = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* is this high enough priority yet? */ found = acf->channel_role; - + /* only stop our search when we've found an actual channel * - datablock expanders get less priority so that we don't abort prematurely */ @@ -355,14 +355,14 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, break; } } - + /* adjust y-position for next one */ y -= ACHANNEL_STEP(ac); } - + /* free all temp data */ ANIM_animdata_freelist(&anim_data); - + return (found != 0); } @@ -372,12 +372,12 @@ static int actkeys_viewall(bContext *C, const bool only_sel) View2D *v2d; float extra, min, max; bool found; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; v2d = &ac.ar->v2d; - + /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ found = get_keyframe_extents(&ac, &min, &max, only_sel); @@ -390,7 +390,7 @@ static int actkeys_viewall(bContext *C, const bool only_sel) extra = 0.1f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - + /* set vertical range */ if (only_sel == false) { /* view all -> the summary channel is usually the shows everything, and resides right at the top... */ @@ -401,30 +401,30 @@ static int actkeys_viewall(bContext *C, const bool only_sel) /* locate first selected channel (or the active one), and frame those */ float ymin = v2d->cur.ymin; float ymax = v2d->cur.ymax; - + if (actkeys_channels_get_selected_extents(&ac, &ymin, &ymax)) { /* recenter the view so that this range is in the middle */ float ymid = (ymax - ymin) / 2.0f + ymin; float x_center; - + UI_view2d_center_get(v2d, &x_center, NULL); UI_view2d_center_set(v2d, x_center, ymid); } } - + /* do View2D syncing */ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); - + /* just redraw this view */ ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } /* ......... */ static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op)) -{ +{ /* whole range */ return actkeys_viewall(C, false); } @@ -443,11 +443,11 @@ void ACTION_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "ACTION_OT_view_all"; ot->description = "Reset viewable area to show full keyframe range"; - + /* api callbacks */ ot->exec = actkeys_viewall_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -458,11 +458,11 @@ void ACTION_OT_view_selected(wmOperatorType *ot) ot->name = "View Selected"; ot->idname = "ACTION_OT_view_selected"; ot->description = "Reset viewable area to show selected keyframes range"; - + /* api callbacks */ ot->exec = actkeys_viewsel_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -473,7 +473,7 @@ static int actkeys_view_frame_exec(bContext *C, wmOperator *op) { const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); ANIM_center_frame(C, smooth_viewtx); - + return OPERATOR_FINISHED; } @@ -483,11 +483,11 @@ void ACTION_OT_view_frame(wmOperatorType *ot) ot->name = "View Frame"; ot->idname = "ACTION_OT_view_frame"; ot->description = "Reset viewable area to show range around current frame"; - + /* api callbacks */ ot->exec = actkeys_view_frame_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -499,20 +499,20 @@ void ACTION_OT_view_frame(wmOperatorType *ot) /* NOTE: the backend code for this is shared with the graph editor */ static short copy_action_keys(bAnimContext *ac) -{ +{ ListBase anim_data = {NULL, NULL}; int filter, ok = 0; - + /* clear buffer first */ ANIM_fcurves_copybuf_free(); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* copy keyframes */ ok = copy_animedit_keys(ac, &anim_data); - + /* clean up */ ANIM_animdata_freelist(&anim_data); @@ -522,21 +522,21 @@ static short copy_action_keys(bAnimContext *ac) static short paste_action_keys(bAnimContext *ac, const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip) -{ +{ ListBase anim_data = {NULL, NULL}; int filter, ok = 0; - - /* filter data - * - First time we try to filter more strictly, allowing only selected channels + + /* filter data + * - First time we try to filter more strictly, allowing only selected channels * to allow copying animation between channels * - Second time, we loosen things up if nothing was found the first time, allowing * users to just paste keyframes back into the original curve again [#31670] */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); - + if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* paste keyframes */ ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip); @@ -551,7 +551,7 @@ static short paste_action_keys(bAnimContext *ac, static int actkeys_copy_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -574,17 +574,17 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } } - + return OPERATOR_FINISHED; } - + void ACTION_OT_copy(wmOperatorType *ot) { /* identifiers */ ot->name = "Copy Keyframes"; ot->idname = "ACTION_OT_copy"; ot->description = "Copy selected keyframes to the copy/paste buffer"; - + /* api callbacks */ ot->exec = actkeys_copy_exec; ot->poll = ED_operator_action_active; @@ -600,14 +600,14 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset"); const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge"); const bool flipped = RNA_boolean_get(op->ptr, "flipped"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* ac.reports by default will be the global reports list, which won't show warnings */ ac.reports = op->reports; - + /* paste keyframes */ if (ac.datatype == ANIMCONT_GPENCIL) { if (ED_gpencil_anim_copybuf_paste(&ac, offset_mode) == false) { @@ -629,10 +629,10 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_paste(wmOperatorType *ot) { PropertyRNA *prop; @@ -640,15 +640,15 @@ void ACTION_OT_paste(wmOperatorType *ot) ot->name = "Paste Keyframes"; ot->idname = "ACTION_OT_paste"; ot->description = "Paste keyframes from copy/paste buffer for the selected channels, starting on the current frame"; - + /* api callbacks */ // ot->invoke = WM_operator_props_popup; // better wait for action redo panel ot->exec = actkeys_paste_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_enum(ot->srna, "offset", rna_enum_keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); RNA_def_enum(ot->srna, "merge", rna_enum_keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing"); @@ -667,39 +667,39 @@ static const EnumPropertyItem prop_actkeys_insertkey_types[] = { }; /* this function is responsible for inserting new keyframes */ -static void insert_action_keys(bAnimContext *ac, short mode) +static void insert_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + ReportList *reports = ac->reports; Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; short flag = 0; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); if (mode == 2) filter |= ANIMFILTER_SEL; else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED; - + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* init keyframing flag */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* insert keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->key_data; float cfra; - + /* adjust current frame for NLA-scaling */ if (adt) cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + else cfra = (float)CFRA; - + /* read value from property the F-Curve represents, or from the curve only? * - ale->id != NULL: Typically, this means that we have enough info to try resolving the path * - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone, @@ -713,10 +713,10 @@ static void insert_action_keys(bAnimContext *ac, short mode) const float curval = evaluate_fcurve(fcu, cfra); insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0); } - + ale->update |= ANIM_UPDATE_DEFAULT; } - + ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); } @@ -727,31 +727,31 @@ static void insert_gpencil_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; eGP_GetFrame_Mode add_frame_mode; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); if (mode == 2) filter |= ANIMFILTER_SEL; - + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - + + /* add a copy or a blank frame? */ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) add_frame_mode = GP_GETFRAME_ADD_COPY; /* XXX: actframe may not be what we want? */ else add_frame_mode = GP_GETFRAME_ADD_NEW; - - + + /* insert gp frames */ for (ale = anim_data.first; ale; ale = ale->next) { bGPDlayer *gpl = (bGPDlayer *)ale->data; BKE_gpencil_layer_getframe(gpl, CFRA, add_frame_mode); } - + ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); } @@ -762,19 +762,19 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ac.datatype == ANIMCONT_MASK) { BKE_report(op->reports, RPT_ERROR, "Insert Keyframes is not yet implemented for this mode"); return OPERATOR_CANCELLED; } - + /* what channels to affect? */ mode = RNA_enum_get(op->ptr, "type"); - + /* insert keyframes */ if (ac.datatype == ANIMCONT_GPENCIL) { insert_gpencil_keys(&ac, mode); @@ -785,7 +785,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } @@ -795,15 +795,15 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot) ot->name = "Insert Keyframes"; ot->idname = "ACTION_OT_keyframe_insert"; ot->description = "Insert keyframes for the specified channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_insertkey_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", ""); } @@ -815,14 +815,14 @@ static void duplicate_action_keys(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and delete selected keys */ for (ale = anim_data.first; ale; ale = ale->next) { if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) @@ -846,31 +846,31 @@ static void duplicate_action_keys(bAnimContext *ac) static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* duplicate keyframes */ duplicate_action_keys(&ac); /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_duplicate(wmOperatorType *ot) { /* identifiers */ ot->name = "Duplicate Keyframes"; ot->idname = "ACTION_OT_duplicate"; ot->description = "Make a copy of all selected keyframes"; - + /* api callbacks */ ot->exec = actkeys_duplicate_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -904,26 +904,26 @@ static bool delete_action_keys(bAnimContext *ac) else { FCurve *fcu = (FCurve *)ale->key_data; AnimData *adt = ale->adt; - + /* delete selected keyframes only */ changed = delete_fcurve_keys(fcu); - + /* Only delete curve too if it won't be doing anything anymore */ if ((fcu->totvert == 0) && (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) { ANIM_fcurve_delete_from_animdata(ac, adt, fcu); ale->key_data = NULL; } } - + if (changed) { ale->update |= ANIM_UPDATE_DEFAULT; changed_final = true; } } - + ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + return changed_final; } @@ -932,33 +932,33 @@ static bool delete_action_keys(bAnimContext *ac) static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* delete keyframes */ if (!delete_action_keys(&ac)) return OPERATOR_CANCELLED; - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Keyframes"; ot->idname = "ACTION_OT_delete"; ot->description = "Remove all selected keyframes"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = actkeys_delete_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -966,15 +966,15 @@ void ACTION_OT_delete(wmOperatorType *ot) /* ******************** Clean Keyframes Operator ************************* */ static void clean_action_keys(bAnimContext *ac, float thresh, bool clean_chan) -{ +{ ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and clean curves */ for (ale = anim_data.first; ale; ale = ale->next) { clean_fcurve(ac, ale, thresh, clean_chan); @@ -993,44 +993,44 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op) bAnimContext ac; float thresh; bool clean_chan; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* get cleaning threshold */ thresh = RNA_float_get(op->ptr, "threshold"); clean_chan = RNA_boolean_get(op->ptr, "channels"); - + /* clean keyframes */ clean_action_keys(&ac, thresh, clean_chan); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_clean(wmOperatorType *ot) { /* identifiers */ ot->name = "Clean Keyframes"; ot->idname = "ACTION_OT_clean"; ot->description = "Simplify F-Curves by removing closely spaced keyframes"; - + /* api callbacks */ - //ot->invoke = // XXX we need that number popup for this! + //ot->invoke = // XXX we need that number popup for this! ot->exec = actkeys_clean_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); RNA_def_boolean(ot->srna, "channels", false, "Channels", ""); @@ -1040,15 +1040,15 @@ void ACTION_OT_clean(wmOperatorType *ot) /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ static void sample_action_keys(bAnimContext *ac) -{ +{ ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and add keys between selected keyframes on every frame */ for (ale = anim_data.first; ale; ale = ale->next) { sample_fcurve((FCurve *)ale->key_data); @@ -1065,36 +1065,36 @@ static void sample_action_keys(bAnimContext *ac) static int actkeys_sample_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* sample keyframes */ sample_action_keys(&ac); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_sample(wmOperatorType *ot) { /* identifiers */ ot->name = "Sample Keyframes"; ot->idname = "ACTION_OT_sample"; ot->description = "Add keyframes on every frame between the selected keyframes"; - + /* api callbacks */ ot->exec = actkeys_sample_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1112,33 +1112,33 @@ void ACTION_OT_sample(wmOperatorType *ot) static const EnumPropertyItem prop_actkeys_expo_types[] = { {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"}, {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"}, - + {MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"}, {CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"}, {0, NULL, 0, NULL, NULL} }; /* this function is responsible for setting extrapolation mode for keyframes */ -static void setexpo_action_keys(bAnimContext *ac, short mode) +static void setexpo_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting mode per F-Curve */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - + if (mode >= 0) { /* just set mode setting */ fcu->extend = mode; } else { - /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation + /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation * without having to go through FModifier UI in Graph Editor to do so */ if (mode == MAKE_CYCLIC_EXPO) { @@ -1151,10 +1151,10 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) else if (mode == CLEAR_CYCLIC_EXPO) { /* remove all the modifiers fitting this description */ FModifier *fcm, *fcn = NULL; - + for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; - + if (fcm->type == FMODIFIER_TYPE_CYCLES) remove_fmodifier(&fcu->modifiers, fcm); } @@ -1174,43 +1174,43 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ setexpo_action_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_extrapolation_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Extrapolation"; ot->idname = "ACTION_OT_extrapolation_type"; ot->description = "Set extrapolation mode for selected F-Curves"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_expo_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", ""); } @@ -1218,17 +1218,17 @@ void ACTION_OT_extrapolation_type(wmOperatorType *ot) /* ******************** Set Interpolation-Type Operator *********************** */ /* this function is responsible for setting interpolation mode for keyframes */ -static void setipo_action_keys(bAnimContext *ac, short mode) +static void setipo_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ @@ -1248,43 +1248,43 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ setipo_action_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_interpolation_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Interpolation"; ot->idname = "ACTION_OT_interpolation_type"; ot->description = "Set interpolation mode for the F-Curve segments starting from the selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_ipo_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_interpolation_mode_items, 0, "Type", ""); } @@ -1292,25 +1292,25 @@ void ACTION_OT_interpolation_type(wmOperatorType *ot) /* ******************** Set Handle-Type Operator *********************** */ /* this function is responsible for setting handle-type of selected keyframes */ -static void sethandles_action_keys(bAnimContext *ac, short mode) +static void sethandles_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode); KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - /* loop through setting flags for handles + + /* loop through setting flags for handles * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { /* change type of selected handles */ @@ -1330,43 +1330,43 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ sethandles_action_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_handle_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Handle Type"; ot->idname = "ACTION_OT_handle_type"; ot->description = "Set type of handle for selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_handletype_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_keyframe_handle_type_items, 0, "Type", ""); } @@ -1374,17 +1374,17 @@ void ACTION_OT_handle_type(wmOperatorType *ot) /* ******************** Set Keyframe-Type Operator *********************** */ /* this function is responsible for setting keyframe type for keyframes */ -static void setkeytype_action_keys(bAnimContext *ac, short mode) +static void setkeytype_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc set_cb = ANIM_editkeyframes_keytype(mode); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ @@ -1404,11 +1404,11 @@ static void setkeytype_gpencil_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through each layer */ for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { @@ -1427,19 +1427,19 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ac.datatype == ANIMCONT_MASK) { BKE_report(op->reports, RPT_ERROR, "Not implemented for Masks"); return OPERATOR_PASS_THROUGH; } - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ if (ac.datatype == ANIMCONT_GPENCIL) { setkeytype_gpencil_keys(&ac, mode); @@ -1447,28 +1447,28 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op) else { setkeytype_action_keys(&ac, mode); } - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_keyframe_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Type"; ot->idname = "ACTION_OT_keyframe_type"; ot->description = "Set type of keyframe for the selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_keytype_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_keyframe_type_items, 0, "Type", ""); } @@ -1495,39 +1495,39 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) bAnimListElem *ale; int filter; KeyframeEditData ked = {{NULL}}; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* init edit data */ /* loop over action data, averaging values */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); } - + ANIM_animdata_freelist(&anim_data); - + /* set the new current frame value, based on the average time */ if (ked.i1) { Scene *scene = ac.scene; CFRA = round_fl_to_int(ked.f1 / ked.i1); SUBFRA = 0.f; } - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); - + return OPERATOR_FINISHED; } @@ -1537,11 +1537,11 @@ void ACTION_OT_frame_jump(wmOperatorType *ot) ot->name = "Jump to Keyframes"; ot->idname = "ACTION_OT_frame_jump"; ot->description = "Set the current frame to the average frame value of selected keyframes"; - + /* api callbacks */ ot->exec = actkeys_framejump_exec; ot->poll = actkeys_framejump_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1562,22 +1562,22 @@ static const EnumPropertyItem prop_actkeys_snap_types[] = { }; /* this function is responsible for snapping keyframes to frame-times */ -static void snap_action_keys(bAnimContext *ac, short mode) +static void snap_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc edit_cb; - + /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get beztriple editing callbacks */ edit_cb = ANIM_editkeyframes_snap(mode); @@ -1586,11 +1586,11 @@ static void snap_action_keys(bAnimContext *ac, short mode) ked.list.first = (ac->markers) ? ac->markers->first : NULL; ked.list.last = (ac->markers) ? ac->markers->last : NULL; } - + /* snap keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (ale->type == ANIMTYPE_GPLAYER) { ED_gplayer_snap_frames(ale->data, ac->scene, mode); } @@ -1598,7 +1598,7 @@ static void snap_action_keys(bAnimContext *ac, short mode) ED_masklayer_snap_frames(ale->data, ac->scene, mode); } else if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } @@ -1619,38 +1619,38 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get snapping mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* snap keyframes */ snap_action_keys(&ac, mode); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_snap(wmOperatorType *ot) { /* identifiers */ ot->name = "Snap Keys"; ot->idname = "ACTION_OT_snap"; ot->description = "Snap selected keyframes to the times specified"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_snap_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", ""); } @@ -1669,42 +1669,42 @@ static const EnumPropertyItem prop_actkeys_mirror_types[] = { }; /* this function is responsible for mirroring keyframes */ -static void mirror_action_keys(bAnimContext *ac, short mode) +static void mirror_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc edit_cb; - + /* get beztriple editing callbacks */ edit_cb = ANIM_editkeyframes_mirror(mode); ked.scene = ac->scene; - + /* for 'first selected marker' mode, need to find first selected marker first! */ /* XXX should this be made into a helper func in the API? */ if (mode == ACTKEYS_MIRROR_MARKER) { TimeMarker *marker = ED_markers_get_first_selected(ac->markers); - + if (marker) ked.f1 = (float)marker->frame; else return; } - + /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* mirror keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (ale->type == ANIMTYPE_GPLAYER) { ED_gplayer_mirror_frames(ale->data, ac->scene, mode); } @@ -1712,14 +1712,14 @@ static void mirror_action_keys(bAnimContext *ac, short mode) /* TODO */ } else if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } else { ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); } - + ale->update |= ANIM_UPDATE_DEFAULT; } @@ -1733,38 +1733,38 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get mirroring mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* mirror keyframes */ mirror_action_keys(&ac, mode); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_mirror(wmOperatorType *ot) { /* identifiers */ ot->name = "Mirror Keys"; ot->idname = "ACTION_OT_mirror"; ot->description = "Flip selected keyframes over the selected mirror line"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_mirror_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", ""); } diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 0b1502e8e76..f2588b8139e 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -51,7 +51,7 @@ void ACTION_OT_properties(struct wmOperatorType *ot); /* ***************************************** */ /* action_draw.c */ -void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar); +void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar); void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); /* ***************************************** */ @@ -122,7 +122,7 @@ void ACTION_OT_layer_prev(struct wmOperatorType *ot); void ACTION_OT_markers_make_local(struct wmOperatorType *ot); -/* defines for snap keyframes +/* defines for snap keyframes * NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h) */ enum eActKeys_Snap_Mode { @@ -132,7 +132,7 @@ enum eActKeys_Snap_Mode { ACTKEYS_SNAP_NEAREST_MARKER, }; -/* defines for mirror keyframes +/* defines for mirror keyframes * NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h) */ enum eActKeys_Mirror_Mode { @@ -141,7 +141,7 @@ enum eActKeys_Mirror_Mode { ACTKEYS_MIRROR_XAXIS, ACTKEYS_MIRROR_MARKER, }; - + /* ***************************************** */ /* action_ops.c */ void action_operatortypes(void); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 40ddcf4886a..25218358ed4 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -53,7 +53,7 @@ void action_operatortypes(void) { /* view */ WM_operatortype_append(ACTION_OT_properties); - + /* keyframes */ /* selection */ WM_operatortype_append(ACTION_OT_clickselect); @@ -66,7 +66,7 @@ void action_operatortypes(void) WM_operatortype_append(ACTION_OT_select_more); WM_operatortype_append(ACTION_OT_select_less); WM_operatortype_append(ACTION_OT_select_leftright); - + /* editing */ WM_operatortype_append(ACTION_OT_snap); WM_operatortype_append(ACTION_OT_mirror); @@ -82,17 +82,17 @@ void action_operatortypes(void) WM_operatortype_append(ACTION_OT_keyframe_insert); WM_operatortype_append(ACTION_OT_copy); WM_operatortype_append(ACTION_OT_paste); - + WM_operatortype_append(ACTION_OT_new); WM_operatortype_append(ACTION_OT_unlink); - + WM_operatortype_append(ACTION_OT_push_down); WM_operatortype_append(ACTION_OT_stash); WM_operatortype_append(ACTION_OT_stash_and_create); - + WM_operatortype_append(ACTION_OT_layer_next); WM_operatortype_append(ACTION_OT_layer_prev); - + WM_operatortype_append(ACTION_OT_previewrange_set); WM_operatortype_append(ACTION_OT_view_all); WM_operatortype_append(ACTION_OT_view_selected); @@ -105,7 +105,7 @@ void ED_operatormacros_action(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", "Make a copy of all selected keyframes and move them", OPTYPE_UNDO | OPTYPE_REGISTER); @@ -120,7 +120,7 @@ void ED_operatormacros_action(void) static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; - + /* action_select.c - selection tools */ /* click-select: keyframe (replace) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); @@ -152,7 +152,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_boolean_set(kmi->ptr, "extend", true); RNA_boolean_set(kmi->ptr, "column", false); RNA_boolean_set(kmi->ptr, "channel", true); - + /* click-select: left/right */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", false); @@ -160,71 +160,71 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); - + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT); - + /* deselect all */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "invert", false); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "invert", true); - + /* borderselect */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "axis_range", false); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "axis_range", true); - + /* region select */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - + WM_keymap_add_item(keymap, "ACTION_OT_select_circle", CKEY, KM_PRESS, 0, 0); - + /* column select */ RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_CFRA); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN); - + /* select more/less */ WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - + /* select linked */ WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0); - - + + /* action_edit.c */ /* jump to selected keyframes */ WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", GKEY, KM_PRESS, KM_CTRL, 0); - + /* menu + single-step transform */ WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); - + /* menu + set setting */ WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_interpolation_type", TKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0); + /* destructive */ WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", DELKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "ACTION_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); - + /* copy/paste */ WM_keymap_add_item(keymap, "ACTION_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); @@ -246,19 +246,19 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_frame", PAD0, KM_PRESS, 0, 0); - + /* animation module */ /* channels list * NOTE: these operators were originally for the channels list, but are added here too for convenience... */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); - + /* find (i.e. a shortcut for setting the name filter) */ WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); - + /* transform system */ transform_keymap_for_space(keyconf, keymap, SPACE_ACTION); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_action"); @@ -271,20 +271,20 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) void action_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; - + /* keymap for all regions */ keymap = WM_keymap_find(keyconf, "Dopesheet Generic", SPACE_ACTION, 0); - + /* region management... */ WM_keymap_add_item(keymap, "ACTION_OT_properties", NKEY, KM_PRESS, 0, 0); - - + + /* channels */ - /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. + /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these * are all used for the Graph-Editor too. */ - + /* keyframes */ keymap = WM_keymap_find(keyconf, "Dopesheet", SPACE_ACTION, 0); action_keymap_keyframes(keyconf, keymap); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 4cc38741d3e..83bda4d63a5 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -89,22 +89,22 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc test_cb, sel_cb; - + /* determine type-based settings */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); - + /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* init BezTriple looping data */ test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); - + /* See if we should be selecting or deselecting */ if (test) { for (ale = anim_data.first; ale; ale = ale->next) { @@ -128,10 +128,10 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) } } } - + /* convert sel to selectmode, and use that to get editor */ sel_cb = ANIM_editkeyframes_select(sel); - + /* Now set the flags */ for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) @@ -139,9 +139,9 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) else if (ale->type == ANIMTYPE_MASKLAYER) ED_masklayer_frame_select_set(ale->data, sel); else - ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -151,37 +151,37 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) static int actkeys_deselectall_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* 'standard' behavior - check if selected, then apply relevant selection */ if (RNA_boolean_get(op->ptr, "invert")) deselect_action_keys(&ac, 0, SELECT_INVERT); else deselect_action_keys(&ac, 1, SELECT_ADD); - + /* set notifier that keyframe selection have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; ot->idname = "ACTION_OT_select_all_toggle"; ot->description = "Toggle selection of all keyframes"; - + /* api callbacks */ ot->exec = actkeys_deselectall_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); @@ -208,39 +208,39 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; View2D *v2d = &ac->ar->v2d; rctf rectf; float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac)); - + /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get beztriple editing/validation funcs */ select_cb = ANIM_editkeyframes_select(selectmode); - + if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); else ok_cb = NULL; - + /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); - + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* get new vertical minimum extent of channel */ ymin = ymax - ACHANNEL_STEP(ac); - + /* set horizontal range (if applicable) */ if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) { /* if channel is mapped in NLA, apply correction */ @@ -255,7 +255,7 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s ked.f2 = rectf.xmax; } } - + /* perform vertical suitability check (if applicable) */ if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) || !((ymax < rectf.ymin) || (ymin > rectf.ymax))) @@ -293,11 +293,11 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s break; } } - + /* set minimum extent to be the maximum of the next channel */ ymax = ymin; } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -311,7 +311,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) short mode = 0, selectmode = 0; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -320,7 +320,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) if (!extend) { deselect_action_keys(&ac, 1, SELECT_SUBTRACT); } - + /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); @@ -330,10 +330,10 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) else { selectmode = SELECT_SUBTRACT; } - + /* selection 'mode' depends on whether borderselect region only matters on one axis */ if (RNA_boolean_get(op->ptr, "axis_range")) { - /* mode depends on which axis of the range is larger to determine which axis to use + /* mode depends on which axis of the range is larger to determine which axis to use * - checking this in region-space is fine, as it's fundamentally still going to be a different rect size * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... @@ -343,17 +343,17 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) else mode = ACTKEYS_BORDERSEL_CHANNELS; } - else + else mode = ACTKEYS_BORDERSEL_ALLKEYS; - + /* apply borderselect action */ borderselect_action(&ac, rect, mode, selectmode); - + /* set notifier that keyframe selection have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; -} +} void ACTION_OT_select_border(wmOperatorType *ot) { @@ -361,21 +361,21 @@ void ACTION_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "ACTION_OT_select_border"; ot->description = "Select all keyframes within the specified region"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = actkeys_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); - + ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); } @@ -390,24 +390,24 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; View2D *v2d = &ac->ar->v2d; rctf rectf, scaled_rectf; float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac)); - + /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get beztriple editing/validation funcs */ select_cb = ANIM_editkeyframes_select(selectmode); ok_cb = ANIM_editkeyframes_ok(mode); - + /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); if (mode == BEZT_OK_CHANNEL_LASSO) { @@ -423,17 +423,17 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, else { ked.data = &scaled_rectf; } - + /* loop over data, doing region select */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* get new vertical minimum extent of channel */ ymin = ymax - ACHANNEL_STEP(ac); - + /* compute midpoint of channel (used for testing if the key is in the region or not) */ ked.channel_y = ymin + ACHANNEL_HEIGHT_HALF(ac); - + /* if channel is mapped in NLA, apply correction * - Apply to the bounds being checked, not all the keyframe points, * to avoid having scaling everything @@ -450,16 +450,16 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, ked.f1 = rectf.xmin; ked.f2 = rectf.xmax; } - + /* Update values for scaled_rectf - which is used to compute the mapping in the callbacks - * NOTE: Since summary tracks need late-binding remapping, the callbacks may overwrite these + * NOTE: Since summary tracks need late-binding remapping, the callbacks may overwrite these * with the properly remapped ked.f1/f2 values, when needed */ scaled_rectf.xmin = ked.f1; scaled_rectf.xmax = ked.f2; scaled_rectf.ymin = ymin; scaled_rectf.ymax = ymax; - + /* perform vertical suitability check (if applicable) */ if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) || !((ymax < rectf.ymin) || (ymin > rectf.ymax))) @@ -501,59 +501,59 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, break; } } - + /* set minimum extent to be the maximum of the next channel */ ymax = ymin; } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } - + /* ----------------------------------- */ - + static int actkeys_lassoselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + KeyframeEdit_LassoData data_lasso; rcti rect; rctf rect_fl; - + short selectmode; bool extend; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + data_lasso.rectf_view = &rect_fl; data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot); if (data_lasso.mcords == NULL) return OPERATOR_CANCELLED; - + /* clear all selection if not extending selection */ extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_action_keys(&ac, 1, SELECT_SUBTRACT); - + if (!RNA_boolean_get(op->ptr, "deselect")) selectmode = SELECT_ADD; else selectmode = SELECT_SUBTRACT; - + /* get settings from operator */ BLI_lasso_boundbox(&rect, data_lasso.mcords, data_lasso.mcords_tot); BLI_rctf_rcti_copy(&rect_fl, &rect); - + /* apply borderselect action */ region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_LASSO, selectmode, &data_lasso); - + MEM_freeN((void *)data_lasso.mcords); - + /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -563,17 +563,17 @@ void ACTION_OT_select_lasso(wmOperatorType *ot) ot->name = "Lasso Select"; ot->description = "Select keyframe points using lasso selection"; ot->idname = "ACTION_OT_select_lasso"; - + /* api callbacks */ ot->invoke = WM_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = actkeys_lassoselect_exec; ot->poll = ED_operator_action_active; ot->cancel = WM_gesture_lasso_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_gesture_lasso_select(ot); } @@ -585,10 +585,10 @@ static int action_circle_select_exec(bContext *C, wmOperator *op) bAnimContext ac; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT; - + KeyframeEdit_CircleData data = {0}; rctf rect_fl; - + float x = RNA_int_get(op->ptr, "x"); float y = RNA_int_get(op->ptr, "y"); float radius = RNA_int_get(op->ptr, "radius"); @@ -596,23 +596,23 @@ static int action_circle_select_exec(bContext *C, wmOperator *op) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + data.mval[0] = x; data.mval[1] = y; data.radius_squared = radius * radius; data.rectf_view = &rect_fl; - + rect_fl.xmin = x - radius; rect_fl.xmax = x + radius; rect_fl.ymin = y - radius; rect_fl.ymax = y + radius; - + /* apply region select action */ region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_CIRCLE, selectmode, &data); - + /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -621,13 +621,13 @@ void ACTION_OT_select_circle(wmOperatorType *ot) ot->name = "Circle Select"; ot->description = "Select keyframe points using circle selection"; ot->idname = "ACTION_OT_select_circle"; - + ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = action_circle_select_exec; ot->poll = ED_operator_action_active; ot->cancel = WM_gesture_circle_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; @@ -652,7 +652,7 @@ static const EnumPropertyItem prop_column_select_types[] = { {0, NULL, 0, NULL, NULL} }; -/* ------------------- */ +/* ------------------- */ /* Selects all visible keyframes between the specified markers */ /* TODO, this is almost an _exact_ duplicate of a function of the same name in graph_select.c @@ -662,31 +662,31 @@ static void markers_selectkeys_between(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb, select_cb; KeyframeEditData ked = {{NULL}}; float min, max; - + /* get extreme markers */ ED_markers_get_minmax(ac->markers, 1, &min, &max); min -= 0.5f; max += 0.5f; - + /* get editing funcs + data */ ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); select_cb = ANIM_editkeyframes_select(SELECT_ADD); ked.f1 = min; ked.f2 = max; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* select keys in-between */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -702,7 +702,7 @@ static void markers_selectkeys_between(bAnimContext *ac) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -714,52 +714,52 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene = ac->scene; CfraElem *ce; KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked = {{NULL}}; - + /* build list of columns */ switch (mode) { case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */ if (ac->datatype == ANIMCONT_GPENCIL) { filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) ED_gplayer_make_cfra_list(ale->data, &ked.list, 1); } else { filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); } ANIM_animdata_freelist(&anim_data); break; - + case ACTKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked.list, ce); - + ce->cfra = (float)CFRA; break; - + case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT); break; - + default: /* invalid option */ return; } - + /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(SELECT_ADD); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); - + /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ @@ -768,10 +768,10 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* loop over cfraelems (stored in the KeyframeEditData->list) * - we need to do this here, as we can apply fewer NLA-mapping conversions */ @@ -781,7 +781,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); else ked.f1 = ce->cfra; - + /* select elements with frame number matching cfraelem */ if (ale->type == ANIMTYPE_GPLAYER) ED_gpencil_select_frame(ale->data, ce->cfra, SELECT_ADD); @@ -791,7 +791,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } } - + /* free elements */ BLI_freelistN(&ked.list); ANIM_animdata_freelist(&anim_data); @@ -803,39 +803,39 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* action to take depends on the mode */ mode = RNA_enum_get(op->ptr, "mode"); - + if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN) markers_selectkeys_between(&ac); else columnselect_action_keys(&ac, mode); - + /* set notifier that keyframe selection have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_select_column(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; ot->idname = "ACTION_OT_select_column"; ot->description = "Select all keyframes on the specified frame(s)"; - + /* api callbacks */ ot->exec = actkeys_columnselect_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); } @@ -845,38 +845,38 @@ void ACTION_OT_select_column(wmOperatorType *ot) static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* loop through all of the keys and select additional keyframes based on these */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* check if anything selected? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { /* select every keyframe in this curve then */ ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL); } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -886,11 +886,11 @@ void ACTION_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->idname = "ACTION_OT_select_linked"; ot->description = "Select keyframes occurring in the same F-Curves as selected ones"; - + /* api callbacks */ ot->exec = actkeys_select_linked_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -903,37 +903,37 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc build_cb; - - + + /* init selmap building data */ build_cb = ANIM_editkeyframes_buildselmap(mode); - + /* loop through all of the keys and select additional keyframes based on these */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* only continue if F-Curve has keyframes */ if (fcu->bezt == NULL) continue; - + /* build up map of whether F-Curve's keyframes should be selected or not */ ked.data = MEM_callocN(fcu->totvert, "selmap actEdit more"); ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL); - + /* based on this map, adjust the selection status of the keyframes */ ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_selmap_flush, NULL); - + /* free the selmap used here */ MEM_freeN(ked.data); ked.data = NULL; } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -943,17 +943,17 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode) static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* perform select changes */ select_moreless_action_keys(&ac, SELMAP_MORE); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -963,11 +963,11 @@ void ACTION_OT_select_more(wmOperatorType *ot) ot->name = "Select More"; ot->idname = "ACTION_OT_select_more"; ot->description = "Select keyframes beside already selected ones"; - + /* api callbacks */ ot->exec = actkeys_select_more_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -977,17 +977,17 @@ void ACTION_OT_select_more(wmOperatorType *ot) static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* perform select changes */ select_moreless_action_keys(&ac, SELMAP_LESS); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -997,11 +997,11 @@ void ACTION_OT_select_less(wmOperatorType *ot) ot->name = "Select Less"; ot->idname = "ACTION_OT_select_less"; ot->description = "Deselect keyframes on ends of selection islands"; - + /* api callbacks */ ot->exec = actkeys_select_less_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1024,25 +1024,25 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb, select_cb; KeyframeEditData ked = {{NULL}}; Scene *scene = ac->scene; - + /* if select mode is replace, deselect all keyframes (and channels) first */ if (select_mode == SELECT_REPLACE) { select_mode = SELECT_ADD; - + /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence */ deselect_action_keys(ac, 0, SELECT_SUBTRACT); } - + /* set callbacks and editing data */ ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); select_cb = ANIM_editkeyframes_select(select_mode); - + if (leftright == ACTKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; ked.f2 = (float)(CFRA + 0.1f); @@ -1051,18 +1051,18 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se ked.f1 = (float)(CFRA - 0.1f); ked.f2 = MAXFRAMEF; } - + /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* select keys */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -1075,15 +1075,15 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } - + /* Sync marker support */ if (select_mode == SELECT_ADD) { SpaceAction *saction = (SpaceAction *)ac->sl; - + if ((saction) && (saction->flag & SACTION_MARKERS_MOVE)) { ListBase *markers = ED_animcontext_get_markers(ac); TimeMarker *marker; - + for (marker = markers->first; marker; marker = marker->next) { if (((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) || ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA))) @@ -1108,28 +1108,28 @@ static int actkeys_select_leftright_exec(bContext *C, wmOperator *op) bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); short selectmode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - + /* if "test" mode is set, we don't have any info to set this with */ if (leftright == ACTKEYS_LRSEL_TEST) return OPERATOR_CANCELLED; - + /* do the selecting now */ actkeys_select_leftright(&ac, leftright, selectmode); - + /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -1137,11 +1137,11 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* handle mode-based testing */ if (leftright == ACTKEYS_LRSEL_TEST) { Scene *scene = ac.scene; @@ -1156,7 +1156,7 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm else RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT); } - + /* perform selection */ return actkeys_select_leftright_exec(C, op); } @@ -1164,24 +1164,24 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm void ACTION_OT_select_leftright(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Select Left/Right"; ot->idname = "ACTION_OT_select_leftright"; ot->description = "Select keyframes to the left or the right of the current frame"; - + /* api callbacks */ ot->invoke = actkeys_select_leftright_invoke; ot->exec = actkeys_select_leftright_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_actkeys_leftright_select_types, ACTKEYS_LRSEL_TEST, "Mode", ""); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); - + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -1198,19 +1198,19 @@ void ACTION_OT_select_leftright(wmOperatorType *ot) */ /* ------------------- */ - + /* option 1) select keyframe directly under mouse */ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx) { KeyframeEditData ked = {{NULL}}; KeyframeEditFunc select_cb, ok_cb; - + /* get functions for selecting keyframes */ select_cb = ANIM_editkeyframes_select(select_mode); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); ked.f1 = selx; ked.iterflags |= KED_F1_NLA_UNMAP; - + /* select the nominated keyframe on the given frame */ if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frame(ale->data, selx, select_mode); @@ -1224,10 +1224,10 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s { ListBase anim_data = {NULL, NULL}; int filter; - + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frame(ale->data, selx, select_mode); @@ -1236,7 +1236,7 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s ED_mask_select_frame(ale->data, selx, select_mode); } } - + ANIM_animdata_freelist(&anim_data); } else { @@ -1254,14 +1254,14 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked = {{NULL}}; - + /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(select_mode); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); - + /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ @@ -1270,16 +1270,16 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* set frame for validation callback to refer to */ if (adt) ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); else ked.f1 = selx; - + /* select elements with frame number matching cfra */ if (ale->type == ANIMTYPE_GPLAYER) ED_gpencil_select_frame(ale->key_data, selx, select_mode); @@ -1288,7 +1288,7 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } - + /* free elements */ BLI_freelistN(&ked.list); ANIM_animdata_freelist(&anim_data); @@ -1298,10 +1298,10 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, short select_mode) { KeyframeEditFunc select_cb; - + /* get functions for selecting keyframes */ select_cb = ANIM_editkeyframes_select(select_mode); - + /* select all keyframes in this channel */ if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frames(ale->data, select_mode); @@ -1315,10 +1315,10 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s { ListBase anim_data = {NULL, NULL}; int filter; - + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frames(ale->data, select_mode); @@ -1327,7 +1327,7 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s ED_mask_select_frames(ale->data, select_mode); } } - + ANIM_animdata_freelist(&anim_data); } else { @@ -1335,7 +1335,7 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s } } } - + /* ------------------- */ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, bool column, bool same_channel) @@ -1344,7 +1344,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ DLRBT_Tree anim_keys; bAnimListElem *ale; int filter; - + View2D *v2d = &ac->ar->v2d; bDopeSheet *ads = NULL; int channel_index; @@ -1354,28 +1354,28 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ float key_hsize; float x, y; rctf rectf; - + /* get dopesheet info */ if (ac->datatype == ANIMCONT_DOPESHEET) ads = ac->data; - + /* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); UI_view2d_listview_view_to_cell(v2d, 0, ACHANNEL_STEP(ac), 0, (float)ACHANNEL_HEIGHT_HALF(ac), x, y, NULL, &channel_index); - + /* x-range to check is +/- 7px for standard keyframe under standard dpi/y-scale (in screen/region-space), * on either side of mouse click (size of keyframe icon) */ key_hsize = ACHANNEL_HEIGHT(ac) * 0.8f; /* standard channel height (to allow for some slop) */ key_hsize = roundf(key_hsize / 2.0f); /* half-size (for either side), but rounded up to nearest int (for easier targetting) */ - + UI_view2d_region_to_view(v2d, mval[0] - (int)key_hsize, mval[1], &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(v2d, mval[0] + (int)key_hsize, mval[1], &rectf.xmax, &rectf.ymax); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* try to get channel */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { @@ -1388,10 +1388,10 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ /* found match - must return here... */ AnimData *adt = ANIM_nla_mapping_get(ac, ale); ActKeyColumn *ak, *akn = NULL; - + /* make list of keyframes */ BLI_dlrbTree_init(&anim_keys); - + if (ale->key_data) { switch (ale->datatype) { case ALE_SCE: @@ -1443,7 +1443,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ /* start from keyframe at root of BST, traversing until we find one within the range that was clicked on */ for (ak = anim_keys.root; ak; ak = akn) { if (IN_RANGE(ak->cfra, rectf.xmin, rectf.xmax)) { - /* set the frame to use, and apply inverse-correction for NLA-mapping + /* set the frame to use, and apply inverse-correction for NLA-mapping * so that the frame will get selected by the selection functions without * requiring to map each frame once again... */ @@ -1457,41 +1457,41 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ else akn = ak->left; } - + /* remove active channel from list of channels for separate treatment (since it's needed later on) */ BLI_remlink(&anim_data, ale); - + /* cleanup temporary lists */ BLI_dlrbTree_free(&anim_keys); - + /* free list of channels, since it's not used anymore */ ANIM_animdata_freelist(&anim_data); } - + /* for replacing selection, firstly need to clear existing selection */ if (select_mode == SELECT_REPLACE) { /* reset selection mode for next steps */ select_mode = SELECT_ADD; - + /* deselect all keyframes */ deselect_action_keys(ac, 0, SELECT_SUBTRACT); - + /* highlight channel clicked on */ if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) { /* deselect all other channels first */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - + /* Highlight Action-Group or F-Curve? */ if (ale && ale->data) { if (ale->type == ANIMTYPE_GROUP) { bActionGroup *agrp = ale->data; - + agrp->flag |= AGRP_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); } else if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = ale->data; - + fcu->flag |= FCURVE_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type); } @@ -1500,11 +1500,11 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ else if (ac->datatype == ANIMCONT_GPENCIL) { /* deselect all other channels first */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - + /* Highlight GPencil Layer */ if ((ale && ale->data) && (ale->type == ANIMTYPE_GPLAYER)) { bGPDlayer *gpl = ale->data; - + gpl->flag |= GP_LAYER_SELECT; //gpencil_layer_setactive(gpd, gpl); } @@ -1522,28 +1522,28 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ } } } - + /* only select keyframes if we clicked on a valid channel and hit something */ if (ale) { if (found) { /* apply selection to keyframes */ if (column) { - /* select all keyframes in the same frame as the one we hit on the active channel + /* select all keyframes in the same frame as the one we hit on the active channel * [T41077]: "frame" not "selx" here (i.e. no NLA corrections yet) as the code here - * does that itself again as it needs to work on multiple datablocks + * does that itself again as it needs to work on multiple datablocks */ actkeys_mselect_column(ac, select_mode, frame); } else if (same_channel) { /* select all keyframes in the active channel */ - actkeys_mselect_channel_only(ac, ale, select_mode); + actkeys_mselect_channel_only(ac, ale, select_mode); } else { /* select the nominated keyframe on the given frame */ actkeys_mselect_single(ac, ale, select_mode, selx); } } - + /* free this channel */ MEM_freeN(ale); } @@ -1556,11 +1556,11 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent /* ARegion *ar; */ /* UNUSED */ short selectmode; bool column, channel; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get useful pointers from animation context data */ /* ar = ac.ar; */ /* UNUSED */ @@ -1569,48 +1569,48 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - + /* column selection */ column = RNA_boolean_get(op->ptr, "column"); channel = RNA_boolean_get(op->ptr, "channel"); - + /* select keyframe(s) based upon mouse position*/ mouse_action_keys(&ac, event->mval, selectmode, column, channel); - + /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + /* for tweak grab to work */ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } - + void ACTION_OT_clickselect(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Mouse Select Keys"; ot->idname = "ACTION_OT_clickselect"; ot->description = "Select keyframes by clicking on them"; - + /* callbacks */ ot->invoke = actkeys_clickselect_invoke; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ - prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - - prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", + + prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", "Select all keyframes that occur on the same frame as the one under the mouse"); // ALTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - - prop = RNA_def_boolean(ot->srna, "channel", 0, "Only Channel", + + prop = RNA_def_boolean(ot->srna, "channel", 0, "Only Channel", "Select all the keyframes in the channel under the mouse"); // CTRLKEY + ALTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 9c387072945..0b7201c2857 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -65,24 +65,24 @@ ARegion *action_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after main */ ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - + /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "buttons for action"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -94,56 +94,56 @@ static SpaceLink *action_new(const bContext *C) ScrArea *sa = CTX_wm_area(C); SpaceAction *saction; ARegion *ar; - + saction = MEM_callocN(sizeof(SpaceAction), "initaction"); saction->spacetype = SPACE_ACTION; - + saction->autosnap = SACTSNAP_FRAME; saction->mode = SACTCONT_DOPESHEET; - + saction->ads.filterflag |= ADS_FILTER_SUMMARY; - + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for action"); - + BLI_addtail(&saction->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* channel list region */ ar = MEM_callocN(sizeof(ARegion), "channel region for action"); BLI_addtail(&saction->regionbase, ar); ar->regiontype = RGN_TYPE_CHANNELS; ar->alignment = RGN_ALIGN_LEFT; - + /* only need to set scroll settings, as this will use 'listview' v2d configuration */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - + /* ui buttons */ ar = MEM_callocN(sizeof(ARegion), "buttons region for action"); - + BLI_addtail(&saction->regionbase, ar); ar->regiontype = RGN_TYPE_UI; ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for action"); - + BLI_addtail(&saction->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + ar->v2d.tot.xmin = (float)(SFRA - 10); ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)(EFRA + 10); ar->v2d.tot.ymax = 0.0f; - + ar->v2d.cur = ar->v2d.tot; - + ar->v2d.min[0] = 0.0f; ar->v2d.min[1] = 0.0f; - + ar->v2d.max[0] = MAXFRAMEF; ar->v2d.max[1] = FLT_MAX; @@ -155,13 +155,13 @@ static SpaceLink *action_new(const bContext *C) ar->v2d.keepofs = V2D_KEEPOFS_Y; ar->v2d.align = V2D_ALIGN_NO_POS_Y; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - + return (SpaceLink *)saction; } /* not spacelink itself */ static void action_free(SpaceLink *UNUSED(sl)) -{ +{ // SpaceAction *saction = (SpaceAction *) sl; } @@ -176,9 +176,9 @@ static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *action_duplicate(SpaceLink *sl) { SpaceAction *sactionn = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ - + return (SpaceLink *)sactionn; } @@ -188,9 +188,9 @@ static SpaceLink *action_duplicate(SpaceLink *sl) static void action_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -207,37 +207,37 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) View2DGrid *grid; View2DScrollers *scrollers; short unit = 0, flag = 0; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* time grid */ unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* data */ if (ANIM_animdata_get_context(C, &ac)) { draw_channel_strips(&ac, saction, ar); } - + /* current frame */ if (saction->flag & SACTION_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); - + /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - + flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN; ED_markers_draw(C, flag); - + /* preview range */ UI_view2d_view_ortho(v2d); ANIM_draw_previewrange(C, v2d, 0); @@ -245,10 +245,10 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) /* callback */ UI_view2d_view_ortho(v2d); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -259,16 +259,16 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) static void action_channel_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + /* ensure the 2d view sync works - main region has bottom scroller */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - + keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -278,21 +278,21 @@ static void action_channel_region_draw(const bContext *C, ARegion *ar) /* draw entirely, view changes should be handled here */ bAnimContext ac; View2D *v2d = &ar->v2d; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* data */ if (ANIM_animdata_get_context(C, &ac)) { draw_channel_names((bContext *)C, &ac, ar); } - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* no scrollers here */ } @@ -391,7 +391,7 @@ static void action_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; - + default: if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); @@ -403,7 +403,7 @@ static void action_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; - + /* context changes */ switch (wmn->category) { case NC_GPENCIL: @@ -424,7 +424,7 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); } - /* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears + /* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears * (assume for now that if just adding these works, that will be fine) */ else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) || @@ -432,7 +432,7 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) { ED_area_tag_refresh(sa); } - /* for simple edits to the curve data though (or just plain selections), a simple redraw should work + /* for simple edits to the curve data though (or just plain selections), a simple redraw should work * (see T39851 for an example of how this can go wrong) */ else { @@ -446,7 +446,7 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); break; - + default: /* just redrawing the view will do */ ED_area_tag_redraw(sa); break; @@ -527,12 +527,12 @@ static void action_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s case NC_ANIMATION: switch (wmn->data) { case ND_ANIMCHAN: /* set of visible animchannels changed */ - /* NOTE: for now, this should usually just mean that the filters changed + /* NOTE: for now, this should usually just mean that the filters changed * It may be better if we had a dedicated flag for that though */ ED_region_tag_redraw(ar); break; - + case ND_KEYFRAME: /* new keyframed added -> active action may have changed */ //saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_region_tag_redraw(ar); @@ -547,9 +547,9 @@ static void action_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s static void action_buttons_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -594,19 +594,19 @@ static void action_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARe static void action_refresh(const bContext *C, ScrArea *sa) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; - - /* update the state of the animchannels in response to changes from the data they represent + + /* update the state of the animchannels in response to changes from the data they represent * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled */ if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) { ARegion *ar; - + /* Perform syncing of channel state incl. selection * Active action setting also occurs here (as part of anim channel filtering in anim_filter.c) */ ANIM_sync_animchannels_to_data(C); saction->flag &= ~SACTION_TEMP_NEEDCHANSYNC; - + /* Tag everything for redraw * - Regions (such as header) need to be manually tagged for redraw too * or else they don't update [#28962] @@ -615,7 +615,7 @@ static void action_refresh(const bContext *C, ScrArea *sa) for (ar = sa->regionbase.first; ar; ar = ar->next) ED_region_tag_redraw(ar); } - + /* region updates? */ // XXX re-sizing y-extents of tot should go here? } @@ -642,10 +642,10 @@ void ED_spacetype_action(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action"); ARegionType *art; - + st->spaceid = SPACE_ACTION; strncpy(st->name, "Action", BKE_ST_MAXNAME); - + st->new = action_new; st->free = action_free; st->init = action_init; @@ -665,31 +665,31 @@ void ED_spacetype_action(void) art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - + art->init = action_header_region_init; art->draw = action_header_region_draw; art->listener = action_header_region_listener; - + BLI_addhead(&st->regiontypes, art); - + /* regions: channels */ art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; - + art->init = action_channel_region_init; art->draw = action_channel_region_draw; art->listener = action_channel_region_listener; - + BLI_addhead(&st->regiontypes, art); - + /* regions: UI buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_UI; @@ -698,11 +698,11 @@ void ED_spacetype_action(void) art->listener = action_region_listener; art->init = action_buttons_area_init; art->draw = action_buttons_area_draw; - + BLI_addhead(&st->regiontypes, art); - + action_buttons_register(art); - + BKE_spacetype_register(st); } -- cgit v1.2.3