Exemplo n.º 1
0
static int nla_strip_panel_poll(const bContext *C, PanelType *UNUSED(pt))
{
	PointerRNA ptr;
	return (nla_panel_context(C, NULL, NULL, &ptr) && (ptr.data != NULL));
}
Exemplo n.º 2
0
/* generic settings for active NLA-Strip */
static void nla_panel_properties(const bContext *C, Panel *pa)
{
	PointerRNA strip_ptr;
	uiLayout *layout = pa->layout;
	uiLayout *column, *row, *sub;
	uiBlock *block;
	short showEvalProps = 1;
	
	if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
		return;
	
	block = uiLayoutGetBlock(layout);
	UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
	
	/* Strip Properties ------------------------------------- */
	/* strip type */
	row = uiLayoutColumn(layout, true);
	uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA);     // XXX icon?
	uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE);
	
	/* strip extents */
	column = uiLayoutColumn(layout, true);
	uiItemL(column, IFACE_("Strip Extents:"), ICON_NONE);
	uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE);
	uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE);
	
	/* Evaluation-Related Strip Properties ------------------ */
	
	/* sound properties strips don't have these settings */
	if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND)
		showEvalProps = 0;
	
	/* only show if allowed to... */
	if (showEvalProps) {
		/* extrapolation */
		row = uiLayoutRow(layout, true);
		uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE);
		
		/* blending */
		row = uiLayoutRow(layout, true);
		uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE);
			
		/* blend in/out + autoblending
		 *	- blend in/out can only be set when autoblending is off
		 */
		column = uiLayoutColumn(layout, true);
		uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence") == false);
		uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE);     // XXX as toggle?

		sub = uiLayoutColumn(column, true);
		uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend") == false);
		uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE);
		uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE);
			
		/* settings */
		column = uiLayoutColumn(layout, true);
		uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time")));
		uiItemL(column, IFACE_("Playback Settings:"), ICON_NONE);
		uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE);
		uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE);
	}
}
Exemplo n.º 3
0
static int nla_panel_poll(const bContext *C, PanelType *pt)
{
	return nla_panel_context(C, NULL, NULL);
}
Exemplo n.º 4
0
static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
{
	bAnimContext ac;
	AnimData *adt = NULL;
	int channel_index = RNA_int_get(op->ptr, "channel_index");

	/* get editor data */
	if (ANIM_animdata_get_context(C, &ac) == 0)
		return OPERATOR_CANCELLED;

	/* get anim-channel to use (or more specifically, the animdata block behind it) */
	if (channel_index == -1) {
		PointerRNA adt_ptr = {{NULL}};

		/* active animdata block */
		if (nla_panel_context(C, &adt_ptr, NULL, NULL) == 0 || (adt_ptr.data == NULL)) {
			BKE_report(op->reports, RPT_ERROR, "No active AnimData block to use "
			           "(select a data-block expander first or set the appropriate flags on an AnimData block)");
			return OPERATOR_CANCELLED;
		}
		else {
			adt = adt_ptr.data;
		}
	}
	else {
		/* indexed channel */
		ListBase anim_data = {NULL, NULL};
		bAnimListElem *ale;
		int filter;

		/* filter channels */
		filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
		ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);

		/* get channel from index */
		ale = BLI_findlink(&anim_data, channel_index);
		if (ale == NULL) {
			BKE_reportf(op->reports, RPT_ERROR, "No animation channel found at index %d", channel_index);
			ANIM_animdata_freelist(&anim_data);
			return OPERATOR_CANCELLED;
		}
		else if (ale->type != ANIMTYPE_NLAACTION) {
			BKE_reportf(op->reports, RPT_ERROR, "Animation channel at index %d is not a NLA 'Active Action' channel", channel_index);
			ANIM_animdata_freelist(&anim_data);
			return OPERATOR_CANCELLED;
		}

		/* grab AnimData from the channel */
		adt = ale->adt;

		/* we don't need anything here anymore, so free it all */
		ANIM_animdata_freelist(&anim_data);
	}

	/* double-check that we are free to push down here... */
	if (adt == NULL) {
		BKE_report(op->reports, RPT_WARNING, "Internal Error - AnimData block is not valid");
		return OPERATOR_CANCELLED;
	}
	else if (nlaedit_is_tweakmode_on(&ac)) {
		BKE_report(op->reports, RPT_WARNING,
		           "Cannot push down actions while tweaking a strip's action, exit tweak mode first");
		return OPERATOR_CANCELLED;
	}
	else if (adt->action == NULL) {
		BKE_report(op->reports, RPT_WARNING, "No active action to push down");
		return OPERATOR_CANCELLED;
	}
	else {
		/* 'push-down' action - only usable when not in TweakMode */
		BKE_nla_action_pushdown(adt);
	}

	/* set notifier that things have changed */
	WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL);
	return OPERATOR_FINISHED;
}