Example #1
0
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;
}
Example #2
0
static void do_action_buttons(bContext *C, void *arg, int event)
{
	/* special exception for mode changing - enable custom settings? */
	if (event == B_MODECHANGE) {
		SpaceAction *saction= CTX_wm_space_action(C);
		
		/* if the new mode is ShapeKeys editor, enable sliders */
		if (saction->mode == SACTCONT_SHAPEKEY)
			saction->flag |= SACTION_SLIDERS;
	}
	
	ED_area_tag_refresh(CTX_wm_area(C));
	ED_area_tag_redraw(CTX_wm_area(C));
}
Example #3
0
static int toggle_time_exec(bContext *C, wmOperator *UNUSED(op))
{
    ScrArea *curarea= CTX_wm_area(C);

    if (curarea == NULL)
        return OPERATOR_CANCELLED;

    /* simply toggle draw frames flag in applicable spaces */
    // XXX or should relevant spaces define their own version of this?
    switch (curarea->spacetype) {
    case SPACE_TIME: /* TimeLine */
    {
        SpaceTime *stime= CTX_wm_space_time(C);
        stime->flag ^= TIME_DRAWFRAMES;
    }
    break;
    case SPACE_ACTION: /* Action Editor */
    {
        SpaceAction *saction= CTX_wm_space_action(C);
        saction->flag ^= SACTION_DRAWTIME;
    }
    break;
    case SPACE_IPO: /* Graph Editor */
    {
        SpaceIpo *sipo= CTX_wm_space_graph(C);
        sipo->flag ^= SIPO_DRAWTIME;
    }
    break;
    case SPACE_NLA: /* NLA Editor */
    {
        SpaceNla *snla= CTX_wm_space_nla(C);
        snla->flag ^= SNLA_DRAWTIME;
    }
    break;
    case SPACE_SEQ: /* Sequencer */
    {
        SpaceSeq *sseq= CTX_wm_space_seq(C);
        sseq->flag ^= SEQ_DRAWFRAMES;
    }
    break;

    default: /* editor doesn't show frames */
        return OPERATOR_CANCELLED; // XXX or should we pass through instead?
    }

    ED_area_tag_redraw(curarea);

    return OPERATOR_FINISHED;
}
Example #4
0
static void act_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
{
	bScreen *sc= CTX_wm_screen(C);
	ScrArea *sa= CTX_wm_area(C);
	SpaceAction *sact= CTX_wm_space_action(C);
	PointerRNA spaceptr;
	
	/* retrieve state */
	RNA_pointer_create(&sc->id, &RNA_SpaceDopeSheetEditor, sact, &spaceptr);
	
	/* create menu */
	//uiItemO(layout, NULL, ICON_MENU_PANEL, "ACT_OT_properties");
	
	//uiItemS(layout);
	
	uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0);
	uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0);
	uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0);
	
	if (sact->flag & SACTION_DRAWTIME)
		uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle");
	else
		uiItemO(layout, "Show Seconds", 0, "ANIM_OT_time_toggle");
	
	uiItemS(layout);
	
	uiItemO(layout, NULL, 0, "ANIM_OT_previewrange_set");
	uiItemO(layout, NULL, 0, "ANIM_OT_previewrange_clear");
	
	uiItemO(layout, NULL, 0, "ACT_OT_previewrange_set");
	
	uiItemS(layout);
	
	uiItemO(layout, NULL, 0, "ACT_OT_frame_jump");
	
	uiItemO(layout, NULL, 0, "ACT_OT_view_all");
	
	if (sa->full) 
		uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow
	else 
		uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctrl DownArrow
}
Example #5
0
/* ensure that there is:
 *  1) an active action editor
 *  2) that the mode will have an active action available
 *  3) that the set of markers being shown are the scene markers, not the list we're merging
 *	4) that there are some selected markers
 */
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;
}
Example #6
0
void action_header_buttons(const bContext *C, ARegion *ar)
{
	ScrArea *sa= CTX_wm_area(C);
	SpaceAction *saction= CTX_wm_space_action(C);
	bAnimContext ac;
	uiBlock *block;
	int xco, yco= 3, xmax;
	
	block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
	uiBlockSetHandleFunc(block, do_action_buttons, NULL);
	
	xco= ED_area_header_standardbuttons(C, block, yco);
	
	uiBlockSetEmboss(block, UI_EMBOSS);
	
	/* get context... (also syncs data) */
	ANIM_animdata_get_context(C, &ac);
	
	if ((sa->flag & HEADER_NO_PULLDOWN)==0) {
		
		xmax= GetButStringLength("View");
		uiDefMenuBut(block, act_viewmenu, NULL, "View", xco, yco, xmax-3, 20, "");
		xco+= xmax;
		
		xmax= GetButStringLength("Select");
		uiDefMenuBut(block, act_selectmenu, NULL, "Select", xco, yco, xmax-3, 20, "");
		xco+= xmax;
		
		if ( (saction->mode == SACTCONT_DOPESHEET) ||
			 ((saction->action) && (saction->mode==SACTCONT_ACTION)) ) 
		{
			xmax= GetButStringLength("Channel");
			uiDefMenuBut(block, act_channelmenu, NULL, "Channel", xco, yco, xmax-3, 20, "");
			xco+= xmax;
		}
		else if (saction->mode==SACTCONT_GPENCIL) {
			xmax= GetButStringLength("Channel");
			uiDefMenuBut(block, act_gplayermenu, NULL, "Channel", xco, yco, xmax-3, 20, "");
			xco+= xmax;
		}
		
		//xmax= GetButStringLength("Marker");
		//uiDefMenuBut(block, act_markermenu, NULL, "Marker", xco, yco, xmax-3, 20, "");
		//xco+= xmax;
		
		if (saction->mode == SACTCONT_GPENCIL) {
			//xmax= GetButStringLength("Frame");
			//uiDefMenuBut(block, act_selectmenu, NULL, "Frame", xco, yco, xmax-3, 20, "");
			//xco+= xmax;
		}
		else {
			xmax= GetButStringLength("Key");
			uiDefMenuBut(block, act_editmenu, NULL, "Key", xco, yco, xmax-3, 20, "");
			xco+= xmax;
		}
	}

	uiBlockSetEmboss(block, UI_EMBOSS);
	
	/* MODE SELECTOR */
	uiDefButC(block, MENU, B_MODECHANGE, 
			"Editor Mode %t|DopeSheet %x3|Action Editor %x0|ShapeKey Editor %x1|Grease Pencil %x2", 
			xco,yco,90,YIC, &saction->mode, 0, 1, 0, 0, 
			"Editing modes for this editor");
	
	
	xco += (90 + 8);
	
	/* SUMMARY CHANNEL */
	uiDefIconTextButBitI(block, TOG, ADS_FILTER_SUMMARY, B_REDR, ICON_BORDERMOVE, "Summary", xco,yco,XIC*4,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Include DopeSheet summary row"); // TODO: needs a better icon
	xco += (XIC*4.5);
	
	/*if (ac.data)*/ 
	{
		/* MODE-DEPENDENT DRAWING */
		if (saction->mode == SACTCONT_DOPESHEET) {
			/* FILTERING OPTIONS */
			xco -= XIC; // XXX first button incurs this offset...
			xco= ANIM_headerUI_standard_buttons(C, &saction->ads, block, xco, yco);
		}
		else if (saction->mode == SACTCONT_ACTION) {
			uiLayout *layout;
			bScreen *sc= CTX_wm_screen(C);
			PointerRNA ptr;
			
			RNA_pointer_create(&sc->id, &RNA_SpaceDopeSheetEditor, saction, &ptr);
			
			layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, 20+3, 20, 1, U.uistyles.first);
			uiTemplateID(layout, (bContext*)C, &ptr, "action", "ACT_OT_new", NULL, NULL);
			uiBlockLayoutResolve(block, &xco, NULL);
			
			xco += 8;
		}
		
		/* draw AUTOSNAP */
		if (saction->mode != SACTCONT_GPENCIL) {
			if (saction->flag & SACTION_DRAWTIME) {
				uiDefButC(block, MENU, B_REDR,
						"Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", 
						xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, 
						"Auto-snapping mode for keyframes when transforming");
			}
			else {
				uiDefButC(block, MENU, B_REDR, 
						"Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", 
						xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, 
						"Auto-snapping mode for keyframes when transforming");
			}
			
			xco += (90 + 8);
		}
		
		/* COPY PASTE */
		uiBlockBeginAlign(block);
			uiDefIconButO(block, BUT, "ACT_OT_copy", WM_OP_INVOKE_REGION_WIN, ICON_COPYDOWN, xco,yco,XIC,YIC, "Copies the selected keyframes to the buffer.");
			xco += XIC;
			uiDefIconButO(block, BUT, "ACT_OT_paste", WM_OP_INVOKE_REGION_WIN, ICON_PASTEDOWN, xco,yco,XIC,YIC, "Pastes the keyframes from the buffer into the selected channels.");
		uiBlockEndAlign(block);
		xco += (XIC + 8);
	}

	/* always as last */
	UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin));
	
	uiEndBlock(C, block);
	uiDrawBlock(C, block);
}