public void run(bContext C, Panel pa) // static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) { SpaceLink sl = bContext.CTX_wm_space_data(C); SpaceType st = null; uiLayout col; byte[] context = StringUtil.toCString(view3d_context_string(C)); if (sl != null) st = ScreenUtil.BKE_spacetype_from_id(sl.spacetype); if (st != null && st.toolshelf.first != null) { CustomTool ct; for (ct = (CustomTool) st.toolshelf.first; ct != null; ct = ct.next) { if (0 == StringUtil.strncmp( context, 0, ct.context, 0, WindowManagerTypes.OP_MAX_TYPENAME)) { col = UILayout.uiLayoutColumn((uiLayout) pa.layout, 1); UILayout.uiItemFullO( col, StringUtil.toJString(ct.opname, 0), null, 0, null, WmTypes.WM_OP_INVOKE_REGION_WIN, 0); } } } col = UILayout.uiLayoutColumn((uiLayout) pa.layout, 1); final SpaceType stf = st; Pointer<ListBase> st_toolshelf = new Pointer<ListBase>() { public ListBase get() { return stf.toolshelf; } public void set(ListBase obj) { throw new UnsupportedOperationException("Not supported yet."); } }; UI.uiDefBlockBut( UILayout.uiLayoutGetBlock((uiLayout) pa.layout), tool_search_menu, st_toolshelf, "Add Tool", 0, 0, UI.UI_UNIT_X, UI.UI_UNIT_Y, "Add Tool in shelf, gets saved in files"); }
public uiBlock run(bContext C, ARegion ar, Object arg_listbase) // static uiBlock tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) { // static char search[OP_MAX_TYPENAME]; wmEvent event; wmWindow win = bContext.CTX_wm_window(C); uiBlock block; uiBut but; /* clear initial search string, then all items show */ search[0] = 0; block = UI.uiBeginBlock(C, ar, "_popup", UI.UI_EMBOSS); UI.uiBlockSetFlag(block, UI.UI_BLOCK_LOOP | UI.UI_BLOCK_REDRAW | UI.UI_BLOCK_RET_1); /* fake button, it holds space for search items */ UI.uiDefBut( block, UI.LABEL, 0, "", 10, 15, 150, UIRegions.uiSearchBoxhHeight(), null, 0, 0, 0, 0, null); Pointer<byte[]> search_p = new Pointer<byte[]>() { public byte[] get() { return search; } public void set(byte[] obj) { throw new UnsupportedOperationException("Not supported yet."); } }; but = UI.uiDefSearchBut( block, search_p, 0, BIFIconID.ICON_VIEWZOOM, WindowManagerTypes.OP_MAX_TYPENAME, 10, 0, 150, 19, ""); // uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL); UI.uiBoundsBlock(block, 6); UI.uiBlockSetDirection(block, UI.UI_DOWN); UI.uiEndBlock(C, block); // event= win.eventstate.copy(); /* XXX huh huh? make api call */ event = WmEventSystem.eventCopy(win.eventstate); event.type = WmEventTypes.EVT_BUT_OPEN; event.val = WmTypes.KM_PRESS; event.customdata = but; event.customdatafree = 0; WmEventSystem.wm_event_add(win, event); return block; }