Example #1
0
static int action_layer_prev_poll(bContext *C)
{
	/* Action Editor's action editing modes only */
	if (ED_operator_action_active(C)) {
		AnimData *adt = ED_actedit_animdata_from_context(C);
		if (adt) {
			if (adt->flag & ADT_NLA_EDIT_ON) {
				/* 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,
					 *      so there can't be anything below it
					 *    - Otherwise, there is at least 1 track below the tweaking
					 *      track that we can descend to
					 */
					if ((nlt->flag & NLATRACK_DISABLED) == 0) {
						/* not disabled = there are actions below the one being tweaked */
						return true;
					}
				}
			}
			else {
				/* Normal Mode: If there are any tracks, we can try moving to those */
				return (adt->nla_tracks.first != NULL);
			}
		}
	}
	
	/* something failed... */
	return false;
}
Example #2
0
static int action_layer_next_poll(bContext *C)
{
	/* Action Editor's action editing modes only */
	if (ED_operator_action_active(C)) {
		AnimData *adt = ED_actedit_animdata_from_context(C);
		if (adt) {
			/* only allow if we're in tweakmode, and there's something above us... */
			if (adt->flag & ADT_NLA_EDIT_ON) {
				/* We need to check if there are any tracks above the active one
				 * since the track the action comes from is not stored in AnimData
				 */
				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.
						 *
						 * If this is the top-most one, there is the possibility
						 * that there is no active action. For now, we let this
						 * case return true too, so that there is a natural way
						 * to "move to an empty layer", even though this means
						 * that we won't actually have an action.
						 */
						// return (adt->tmpact != NULL);
						return true;
					}
				}
			}
		}
	}
	
	/* something failed... */
	return false;
}
Example #3
0
/* Criteria:
 *  1) There must be an dopesheet/action editor, and it must be in a mode which uses actions 
 *  2) The associated AnimData block must not be in tweakmode
 */
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) {
			if (!(adt->flag & ADT_NLA_EDIT_ON))
				return true;
		}
		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 
			 * 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;
}
Example #4
0
/* Criteria:
 *  1) There must be an dopesheet/action editor, and it must be in a mode which uses actions...
 *        OR
 *     The NLA Editor is active (i.e. Animation Data panel -> new action)
 *  2) The associated AnimData block must not be in tweakmode
 */
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... */	
	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 */
			if (ob) {
				if ((ob->adt == NULL) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0)
					return true;
			}
		}
		else if (saction->mode == SACTCONT_SHAPEKEY) {
			Key *key = BKE_key_from_object(ob);
			if (key) {
				if ((key->adt == NULL) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0)
					return true;
			}
		}
	}
	else if (ED_operator_nla_active(C)) {
		if (!(scene->flag & SCE_NLA_EDIT_ON)) {
			return true;
		}
	}
	
	/* something failed... */
	return false;
}
Example #5
0
static int actkeys_framejump_poll(bContext *C)
{
	/* prevent changes during render */
	if (G.is_rendering)
		return 0;

	return ED_operator_action_active(C);
}
Example #6
0
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;
}
Example #7
0
/* Criteria:
 *  1) There must be an dopesheet/action editor, and it must be in a mode which uses actions 
 *  2) There must be an action active
 *  3) The associated AnimData block must not be in tweakmode
 */
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,
			 *       as the global flag may be left dirty by some of the browsing ops here.
			 */
			if (!(adt->flag & ADT_NLA_EDIT_ON))
				return true;
		}
	}
	
	/* something failed... */
	return false;
}