Exemplo n.º 1
0
/* Draw the contents for a grease-pencil panel*/
static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, PointerRNA *ctx_ptr)
{
	PointerRNA gpd_ptr;
	bGPDlayer *gpl;
	uiLayout *col, *row;
	short v3d_stroke_opts = STROKE_OPTS_NORMAL;
	const short is_v3d= CTX_wm_view3d(C) != NULL;
	
	/* make new PointerRNA for Grease Pencil block */
	RNA_id_pointer_create((ID *)gpd, &gpd_ptr);
	
	/* draw gpd settings first ------------------------------------- */
	col= uiLayoutColumn(layout, 0);
		/* current Grease Pencil block */
		// TODO: show some info about who owns this?
		uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", NULL, "GPENCIL_OT_data_unlink"); 
		
		/* add new layer button - can be used even when no data, since it can add a new block too */
		uiItemO(col, "New Layer", ICON_NONE, "GPENCIL_OT_layer_add");
		row= uiLayoutRow(col, 1);
		uiItemO(row, "Delete Frame", ICON_NONE, "GPENCIL_OT_active_frame_delete");
		uiItemO(row, "Convert", ICON_NONE, "GPENCIL_OT_convert");
		
	/* sanity checks... */
	if (gpd == NULL)
		return;
	
	/* draw each layer --------------------------------------------- */
	for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
		col= uiLayoutColumn(layout, 1);
			gp_drawui_layer(col, gpd, gpl, is_v3d);
	}
	
	/* draw gpd drawing settings first ------------------------------------- */
	col= uiLayoutColumn(layout, 1);
		/* label */
		uiItemL(col, "Drawing Settings:", ICON_NONE);
		
		/* check whether advanced 3D-View drawing space options can be used */
		if (is_v3d) {
			if (gpd->flag & (GP_DATA_DEPTH_STROKE|GP_DATA_DEPTH_VIEW))
				v3d_stroke_opts = STROKE_OPTS_V3D_ON;
			else
				v3d_stroke_opts = STROKE_OPTS_V3D_OFF;
		}
		
		/* drawing space options */
		row= uiLayoutRow(col, 1);
			uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE);
			uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE);
		row= uiLayoutRow(col, 1);
			uiLayoutSetActive(row, v3d_stroke_opts);
			uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE);
			uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE);
		
		row= uiLayoutRow(col, 0);
			uiLayoutSetActive(row, v3d_stroke_opts==STROKE_OPTS_V3D_ON);
			uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE);
}	
Exemplo n.º 2
0
static void rna_uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value,
                                   const char *name, const char *text_ctxt, int translate, int icon)
{
	PropertyRNA *prop = RNA_struct_find_property(ptr, propname);

	if (!prop) {
		RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
		return;
	}

	/* Get translated name (label). */
	name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);

	/* XXX This will search property again :( */
	uiItemEnumR_string(layout, ptr, propname, value, name, icon);
}