Exemplo n.º 1
0
/**
 * Invokes a new pie menu for a new level.
 */
static void ui_pie_menu_level_invoke(bContext *C, void *argN, void *arg2)
{
	EnumPropertyItem *item_array = (EnumPropertyItem *)argN;
	PieMenuLevelData *lvl = (PieMenuLevelData *)arg2;
	wmWindow *win = CTX_wm_window(C);

	uiPieMenu *pie = UI_pie_menu_begin(C, IFACE_(lvl->title), lvl->icon, win->eventstate);
	uiLayout *layout = UI_pie_menu_layout(pie);

	layout = uiLayoutRadial(layout);

	PointerRNA ptr;

	WM_operator_properties_create_ptr(&ptr, lvl->ot);
	/* so the context is passed to itemf functions (some need it) */
	WM_operator_properties_sanitize(&ptr, false);
	PropertyRNA *prop = RNA_struct_find_property(&ptr, lvl->propname);

	if (prop) {
		uiItemsFullEnumO_items(
		        layout, lvl->ot, ptr, prop, lvl->properties, lvl->context, lvl->flag,
		        item_array, lvl->totitem);
	}
	else {
		RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), lvl->propname);
	}

	UI_pie_menu_end(C, pie);
}
Exemplo n.º 2
0
int UI_pie_menu_invoke_from_rna_enum(
        struct bContext *C, const char *title, const char *path,
        const wmEvent *event)
{
	PointerRNA ctx_ptr;
	PointerRNA r_ptr;
	PropertyRNA *r_prop;
	uiPieMenu *pie;
	uiLayout *layout;

	RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);

	if (!RNA_path_resolve(&ctx_ptr, path, &r_ptr, &r_prop)) {
		return OPERATOR_CANCELLED;
	}

	/* invalid property, only accept enums */
	if (RNA_property_type(r_prop) != PROP_ENUM) {
		BLI_assert(0);
		return OPERATOR_CANCELLED;
	}

	pie = UI_pie_menu_begin(C, IFACE_(title), ICON_NONE, event);

	layout = UI_pie_menu_layout(pie);

	layout = uiLayoutRadial(layout);
	uiItemFullR(layout, &r_ptr, r_prop, RNA_NO_INDEX, 0, UI_ITEM_R_EXPAND, NULL, 0);

	UI_pie_menu_end(C, pie);

	return OPERATOR_INTERFACE;
}
Exemplo n.º 3
0
int UI_pie_menu_invoke_from_operator_enum(
        struct bContext *C, const char *title, const char *opname,
        const char *propname, const wmEvent *event)
{
	uiPieMenu *pie;
	uiLayout *layout;

	pie = UI_pie_menu_begin(C, IFACE_(title), ICON_NONE, event);
	layout = UI_pie_menu_layout(pie);

	layout = uiLayoutRadial(layout);
	uiItemsEnumO(layout, opname, propname);

	UI_pie_menu_end(C, pie);

	return OPERATOR_INTERFACE;
}
Exemplo n.º 4
0
int UI_pie_menu_invoke(struct bContext *C, const char *idname, const wmEvent *event)
{
	uiPieMenu *pie;
	uiLayout *layout;
	MenuType *mt = WM_menutype_find(idname, true);

	if (mt == NULL) {
		printf("%s: named menu \"%s\" not found\n", __func__, idname);
		return OPERATOR_CANCELLED;
	}

	if (mt->poll && mt->poll(C, mt) == 0)
		/* cancel but allow event to pass through, just like operators do */
		return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);

	pie = UI_pie_menu_begin(C, IFACE_(mt->label), ICON_NONE, event);
	layout = UI_pie_menu_layout(pie);

	UI_menutype_draw(C, mt, layout);

	UI_pie_menu_end(C, pie);

	return OPERATOR_INTERFACE;
}
Exemplo n.º 5
0
static void rna_PieMenuEnd(bContext *C, PointerRNA *handle)
{
  UI_pie_menu_end(C, handle->data);
}