Beispiel #1
0
static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
{
	uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu, NULL);
	uiItemMenuEnumO(layout, "Snap", 0, "ACT_OT_snap", "type");
	uiItemMenuEnumO(layout, "Mirror", 0, "ACT_OT_mirror", "type");
	
	uiItemS(layout);
	
	uiItemO(layout, NULL, 0, "ACT_OT_insert_keyframe");
	
	uiItemS(layout);
	
	uiItemO(layout, NULL, 0, "ACT_OT_duplicate");
	uiItemO(layout, NULL, 0, "ACT_OT_delete");
	
	uiItemS(layout);
	
	uiItemMenuEnumO(layout, "Keyframe Type", 0, "ACT_OT_keyframe_type", "type");
	uiItemMenuEnumO(layout, "Handle Type", 0, "ACT_OT_handle_type", "type");
	uiItemMenuEnumO(layout, "Interpolation Type", 0, "ACT_OT_interpolation_type", "type");
	uiItemMenuEnumO(layout, "Extrapolation Type", 0, "ACT_OT_extrapolation_type", "type");
	
	uiItemS(layout);
	
	uiItemO(layout, NULL, 0, "ACT_OT_clean");
	uiItemO(layout, NULL, 0, "ACT_OT_sample");
	
	uiItemS(layout);
	
	uiItemO(layout, NULL, 0, "ACT_OT_copy");
	uiItemO(layout, NULL, 0, "ACT_OT_paste");
}
static void rna_uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name,
                                const char *text_ctxt, int translate, int icon)
{
	wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */

	if (!ot || !ot->srna) {
		RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
		return;
	}

	/* Get translated name (label). */
	name = rna_translate_ui_text(name, text_ctxt, ot->srna, NULL, translate);

	/* XXX This will search operator again :( */
	uiItemMenuEnumO(layout, C, opname, propname, name, icon);
}
Beispiel #3
0
static void graph_panel_modifiers(const bContext *C, Panel *pa)	
{
	bAnimListElem *ale;
	FCurve *fcu;
	FModifier *fcm;
	uiLayout *col, *row;
	uiBlock *block;
	bool active;
	
	if (!graph_panel_context(C, &ale, &fcu))
		return;
	
	block = uiLayoutGetBlock(pa->layout);
	UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL);
	
	/* 'add modifier' button at top of panel */
	{
		row = uiLayoutRow(pa->layout, false);
		
		/* this is an operator button which calls a 'add modifier' operator... 
		 * a menu might be nicer but would be tricky as we need some custom filtering
		 */
		uiItemMenuEnumO(row, (bContext *)C, "GRAPH_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE);
		
		/* copy/paste (as sub-row) */
		row = uiLayoutRow(row, true);
		uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy");
		uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste");
	}
	
	active = !(fcu->flag & FCURVE_MOD_OFF);
	/* draw each modifier */
	for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
		col = uiLayoutColumn(pa->layout, true);
		uiLayoutSetActive(col, active);
		
		ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm);
	}
	
	MEM_freeN(ale);
}
Beispiel #4
0
/* F-Modifiers for active NLA-Strip */
static void nla_panel_modifiers(const bContext *C, Panel *pa)
{
	PointerRNA strip_ptr;
	NlaStrip *strip;
	FModifier *fcm;
	uiLayout *col, *row;
	uiBlock *block;

	/* check context and also validity of pointer */
	if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
		return;
	strip = strip_ptr.data;
		
	block = uiLayoutGetBlock(pa->layout);
	UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
	
	/* 'add modifier' button at top of panel */
	{
		row = uiLayoutRow(pa->layout, false);
		block = uiLayoutGetBlock(row);
		
		// FIXME: we need to set the only-active property so that this will only add modifiers for the active strip (not all selected)
		uiItemMenuEnumO(row, (bContext *)C, "NLA_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE);
		
		/* copy/paste (as sub-row) */
		row = uiLayoutRow(row, true);
		uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy");
		uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste");
	}
	
	/* draw each modifier */
	for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) {
		col = uiLayoutColumn(pa->layout, true);
		
		ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm);
	}
}
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
{
	bScreen *screen = CTX_wm_screen(C);
	ScrArea *sa = CTX_wm_area(C);
	View3D *v3d = sa->spacedata.first;
	Scene *scene = CTX_data_scene(C);
	ToolSettings *ts = CTX_data_tool_settings(C);
	PointerRNA v3dptr, toolsptr, sceneptr;
	Object *ob = OBACT;
	Object *obedit = CTX_data_edit_object(C);
	uiBlock *block;
	uiLayout *row;
	bool is_paint = false;
	int modeselect;
	
	RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);
	RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr);
	RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr);

	block = uiLayoutGetBlock(layout);
	uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);

	/* other buttons: */
	uiBlockSetEmboss(block, UI_EMBOSS);
	
	/* mode */
	if (ob) {
		modeselect = ob->mode;
		is_paint = ELEM4(ob->mode, OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT);
	}
	else {
		modeselect = OB_MODE_OBJECT;
	}

	row = uiLayoutRow(layout, false);
	{
		EnumPropertyItem *item = object_mode_items;
		const char *name = "";
		int icon = ICON_OBJECT_DATAMODE;

		while (item->identifier) {
			if (item->value == modeselect && item->identifier[0]) {
				name = IFACE_(item->name);
				icon = item->icon;
				break;
			}
			item++;
		}

		uiItemMenuEnumO(row, C, "OBJECT_OT_mode_set", "mode", name, icon);
	}

	/* Draw type */
	uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);

	if (obedit == NULL && is_paint) {

		if (ob->mode & OB_MODE_WEIGHT_PAINT) {
			/* Only for Weight Paint. makes no sense in other paint modes. */
			row = uiLayoutRow(layout, true);
			uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		}

		/* Manipulators aren't used in paint modes */
		if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) {
			/* masks aren't used for sculpt and particle painting */
			PointerRNA meshptr;

			RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr);
			if (ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT)) {
				uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
			}
			else {
				row = uiLayoutRow(layout, true);
				uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
				uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
			}
		}
	}
	else {
		row = uiLayoutRow(layout, true);
		uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);

		/* pose/object only however we want to allow in weight paint mode too
		 * so don't be totally strict and just check not-editmode for now 
		 * XXX We never get here when we are in Weight Paint mode
		 */
		if (obedit == NULL) {
			uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		}

		/* Transform widget / manipulators */
		row = uiLayoutRow(layout, true);
		uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		if (v3d->twflag & V3D_USE_MANIPULATOR) {
			uiItemR(row, &v3dptr, "transform_manipulators", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		}
		uiItemR(row, &v3dptr, "transform_orientation", 0, "", ICON_NONE);
	}

	if (obedit == NULL && v3d->localvd == NULL) {
		unsigned int ob_lay = ob ? ob->lay : 0;

		/* Layers */
		uiTemplateLayers(layout, v3d->scenelock ? &sceneptr : &v3dptr, "layers", &v3dptr, "layers_used", ob_lay);

		/* Scene lock */
		uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
	}
	
	uiTemplateEditModeSelection(layout, C);
}