diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 41 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 42 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 26 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 9 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 176 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 69 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 37 | ||||
-rw-r--r-- | source/blender/editors/space_info/info_header.c | 36 |
9 files changed, 363 insertions, 75 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 97c2da5297f..e66c4ef827b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -177,20 +177,21 @@ typedef struct uiLayout uiLayout; #define INLINK (23<<9) #define KEYEVT (24<<9) #define ICONTEXTROW (25<<9) -#define HSVCUBE (26<<9) -#define PULLDOWN (27<<9) -#define ROUNDBOX (28<<9) -#define CHARTAB (29<<9) +#define HSVCUBE (26<<9) +#define PULLDOWN (27<<9) +#define ROUNDBOX (28<<9) +#define CHARTAB (29<<9) #define BUT_COLORBAND (30<<9) -#define BUT_NORMAL (31<<9) -#define BUT_CURVE (32<<9) +#define BUT_NORMAL (31<<9) +#define BUT_CURVE (32<<9) #define BUT_TOGDUAL (33<<9) -#define ICONTOGN (34<<9) -#define FTPREVIEW (35<<9) -#define NUMABS (36<<9) -#define TOGBUT (37<<9) -#define OPTION (38<<9) -#define OPTIONN (39<<9) +#define ICONTOGN (34<<9) +#define FTPREVIEW (35<<9) +#define NUMABS (36<<9) +#define TOGBUT (37<<9) +#define OPTION (38<<9) +#define OPTIONN (39<<9) +#define SEARCH_MENU (40<<9) #define BUTTYPE (63<<9) /* Drawing @@ -401,6 +402,8 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip); +uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip); + void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval); void uiBlockColorbandButtons(struct uiBlock *block, struct ColorBand *coba, struct rctf *butr, int event); @@ -425,16 +428,29 @@ uiBut *uiFindInlink(uiBlock *block, void *poin); * * uiButSetCompleteFunc is for tab completion. * + * uiButSearchFunc is for name buttons, showing a popup with matches + * * uiBlockSetFunc and uiButSetFunc are callbacks run when a button is used, * in case events, operators or RNA are not sufficient to handle the button. * * uiButSetNFunc will free the argument with MEM_freeN. */ +typedef struct uiSearchItems { + int maxitem, totitem, maxstrlen; + + char **names; + void **pointers; + +} uiSearchItems; + + typedef void (*uiButHandleFunc)(struct bContext *C, void *arg1, void *arg2); typedef void (*uiButHandleNFunc)(struct bContext *C, void *argN, void *arg2); typedef void (*uiButCompleteFunc)(struct bContext *C, char *str, void *arg); +typedef void (*uiButSearchFunc)(const struct bContext *C, void *arg, char *str, uiSearchItems *items); typedef void (*uiBlockHandleFunc)(struct bContext *C, void *arg, int event); + void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg); void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg); @@ -443,6 +459,7 @@ void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2); void uiButSetNFunc (uiBut *but, uiButHandleNFunc func, void *argN, void *arg2); void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg); +void uiButSetSearchFunc (uiBut *but, uiButSearchFunc func, void *arg); void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct bContext *C, uiBlock *block)); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e9a886375c3..4fb2f27a618 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1359,7 +1359,7 @@ int ui_get_but_string_max_length(uiBut *but) void ui_get_but_string(uiBut *but, char *str, int maxlen) { - if(but->rnaprop && ELEM(but->type, TEX, IDPOIN)) { + if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { PropertyType type; char *buf= NULL; @@ -1402,6 +1402,11 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen) BLI_strncpy(str, but->poin, maxlen); return; } + else if(but->type == SEARCH_MENU) { + /* string */ + BLI_strncpy(str, but->poin, maxlen); + return; + } else { /* number */ double value; @@ -1491,7 +1496,7 @@ static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but) int ui_set_but_string(bContext *C, uiBut *but, const char *str) { - if(but->rnaprop && ELEM(but->type, TEX, IDPOIN)) { + if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { if(RNA_property_editable(&but->rnapoin, but->rnaprop)) { PropertyType type; @@ -1535,6 +1540,11 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) BLI_strncpy(but->poin, str, but->hardmax); return 1; } + else if(but->type == SEARCH_MENU) { + /* string */ + BLI_strncpy(but->poin, str, but->hardmax); + return 1; + } else { double value; @@ -1817,11 +1827,11 @@ void ui_check_but(uiBut *but) /* if something changed in the button */ double value; float okwidth; - int transopts= ui_translate_buttons(); +// int transopts= ui_translate_buttons(); ui_is_but_sel(but); - if(but->type==TEX || but->type==IDPOIN) transopts= 0; +// if(but->type==TEX || but->type==IDPOIN) transopts= 0; /* test for min and max, icon sliders, etc */ switch( but->type ) { @@ -1926,6 +1936,7 @@ void ui_check_but(uiBut *but) case IDPOIN: case TEX: + case SEARCH_MENU: if(!but->editstr) { char str[UI_MAX_DRAW_STR]; @@ -3065,6 +3076,29 @@ void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, ui_check_but(but); } +/* arg is pointer to string/name, use callbacks below to make this work */ +uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip) +{ + uiBut *but= ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, 0.0, 0.0, tip); + + but->icon= (BIFIconID) icon; + but->flag|= UI_HAS_ICON; + + but->flag|= UI_ICON_LEFT|UI_TEXT_LEFT; + but->flag|= UI_ICON_SUBMENU; + + ui_check_but(but); + + return but; +} + +void uiButSetSearchFunc(uiBut *but, uiButSearchFunc func, void *arg) +{ + but->search_func= func; + but->search_arg= arg; +} + + /* Program Init/Exit */ void UI_init(void) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ec2f960dd14..e0e58e61752 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -127,6 +127,9 @@ typedef struct uiHandleButtonData { /* menu open */ uiPopupBlockHandle *menu; int menuretval; + + /* search box */ + ARegion *searchbox; /* post activate */ uiButtonActivateType posttype; @@ -557,6 +560,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut ui_apply_but_BUT(C, but, data); break; case TEX: + case SEARCH_MENU: ui_apply_but_TEX(C, but, data); break; case TOGBUT: @@ -1124,7 +1128,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste return changed; } -static void ui_textedit_begin(uiBut *but, uiHandleButtonData *data) +static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) { if(data->str) { MEM_freeN(data->str); @@ -1146,14 +1150,24 @@ static void ui_textedit_begin(uiBut *but, uiHandleButtonData *data) but->selsta= 0; but->selend= strlen(but->drawstr) - strlen(but->str); + /* optional searchbox */ + if(but->type==SEARCH_MENU) { + data->searchbox= ui_searchbox_create(C, data->region, but); + ui_searchbox_update(C, data->searchbox, but); + } + ui_check_but(but); } -static void ui_textedit_end(uiBut *but, uiHandleButtonData *data) +static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) { if(but) { but->editstr= 0; but->pos= -1; + + if(data->searchbox) + ui_searchbox_free(C, data->searchbox); + data->searchbox= NULL; } } @@ -1316,6 +1330,9 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle if(changed) { if(data->interactive) ui_apply_button(C, block, but, data, 1); else ui_check_but(but); + + if(data->searchbox) + ui_searchbox_update(C, data->searchbox, but); } if(changed || (retval == WM_UI_HANDLER_BREAK)) @@ -2702,6 +2719,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) break; case TEX: case IDPOIN: + case SEARCH_MENU: retval= ui_do_but_TEX(C, block, but, data, event); break; case MENU: @@ -2928,9 +2946,9 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s /* text editing */ if(state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING) - ui_textedit_begin(but, data); + ui_textedit_begin(C, but, data); else if(data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING) - ui_textedit_end(but, data); + ui_textedit_end(C, but, data); /* number editing */ if(state == BUTTON_STATE_NUM_EDITING) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 25a1dbe3d62..f4483a0540d 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -176,6 +176,9 @@ struct uiBut { uiButCompleteFunc autocomplete_func; void *autofunc_arg; + uiButSearchFunc search_func; + void *search_arg; + uiLink *link; char *tip, *lockstr; @@ -351,6 +354,10 @@ uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but); void ui_tooltip_free(struct bContext *C, struct ARegion *ar); +ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); +void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but); +void ui_searchbox_free(struct bContext *C, struct ARegion *ar); + typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, @@ -394,6 +401,8 @@ extern void ui_draw_but(ARegion *ar, struct uiStyle *style, uiBut *but, rcti *re struct ThemeUI; void ui_widget_color_init(struct ThemeUI *tui); +void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, char *name, int state); + /* interface_style.c */ void uiStyleInit(void); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 0109612fdc0..3441abc94bd 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -383,6 +383,182 @@ void ui_tooltip_free(bContext *C, ARegion *ar) ui_remove_temporary_region(C, CTX_wm_screen(C), ar); } + +/************************* Creating Search Box **********************/ + + +typedef struct uiSearchboxData { + rcti bbox; + uiFontStyle fstyle; + uiSearchItems items; +} uiSearchboxData; + +#define SEARCH_ITEMS 10 + +/* ar is the search box itself */ +void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but) +{ + uiSearchboxData *data= ar->regiondata; + + /* callback */ + data->items.totitem= 0; + but->search_func(C, but->search_arg, but->editstr, &data->items); + + ED_region_tag_redraw(ar); +} + +static void ui_searchbox_region_draw(const bContext *C, ARegion *ar) +{ + uiSearchboxData *data= ar->regiondata; + + ui_draw_menu_back(U.uistyles.first, NULL, &data->bbox); + + /* draw text */ + if(data->items.totitem) { + rcti rect; + int a, buth; + + /* draw items */ + buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_SEPR_HEIGHT)/SEARCH_ITEMS; + rect= data->bbox; + rect.xmin= data->bbox.xmin + 3.0f; + rect.xmax= data->bbox.xmax - 3.0f; + rect.ymax= data->bbox.ymax - MENU_SEPR_HEIGHT; + rect.ymin= rect.ymax - buth; + + for(a=0; a<data->items.totitem; a++) { + ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], a==0?UI_ACTIVE:0); + rect.ymax -= buth; + rect.ymin -= buth; + } + } +} + +static void ui_searchbox_region_free(ARegion *ar) +{ + uiSearchboxData *data= ar->regiondata; + int a; + + /* free search data */ + for(a=0; a<SEARCH_ITEMS; a++) + MEM_freeN(data->items.names[a]); + MEM_freeN(data->items.names); + MEM_freeN(data->items.pointers); + + MEM_freeN(data); + ar->regiondata= NULL; +} + +ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) +{ + uiStyle *style= U.uistyles.first; // XXX pass on as arg + static ARegionType type; + ARegion *ar; + uiSearchboxData *data; + float aspect= but->block->aspect; + float x1f, x2f, y1f, y2f; + int x1, x2, y1, y2, winx, winy, ofsx, ofsy; + + /* create area region */ + ar= ui_add_temporary_region(CTX_wm_screen(C)); + + memset(&type, 0, sizeof(ARegionType)); + type.draw= ui_searchbox_region_draw; + type.free= ui_searchbox_region_free; + ar->type= &type; + + /* create searchbox data */ + data= MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData"); + + /* set font, get bb */ + data->fstyle= style->widget; /* copy struct */ + data->fstyle.align= UI_STYLE_TEXT_CENTER; + ui_fontscale(&data->fstyle.points, aspect); + uiStyleFontSet(&data->fstyle); + + ar->regiondata= data; + + /* compute position */ + ofsx= (but->block->panel)? but->block->panel->ofsx: 0; + ofsy= (but->block->panel)? but->block->panel->ofsy: 0; + + x1f= but->x1; + x2f= but->x2; + y2f= but->y1; + y1f= y2f - SEARCH_ITEMS*MENU_BUTTON_HEIGHT - 2*MENU_SEPR_HEIGHT; + + /* minimal width */ + if(x2f - x1f < 180) x2f= x1f+180; // XXX arbitrary + + /* copy to int, gets projected if possible too */ + x1= x1f; y1= y1f; x2= x2f; y2= y2f; + + if(butregion) { + if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { + UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); + UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); + } + + x1 += butregion->winrct.xmin; + x2 += butregion->winrct.xmin; + y1 += butregion->winrct.ymin; + y2 += butregion->winrct.ymin; + } + + wm_window_get_size(CTX_wm_window(C), &winx, &winy); + + if(x2 > winx) { + /* super size */ + if(x2 > winx + x1) { + x2= winx; + x1= 0; + } + else { + x1 -= x2-winx; + x2= winx; + } + } + if(y1 < 0) { + y1 += 36; + y2 += 36; + } + + /* widget rect, in region coords */ + data->bbox.xmin= MENU_SHADOW_SIDE; + data->bbox.xmax= x2-x1 + MENU_SHADOW_SIDE; + data->bbox.ymin= MENU_SHADOW_BOTTOM; + data->bbox.ymax= y2-y1 + MENU_SHADOW_BOTTOM; + + /* region bigger for shadow */ + ar->winrct.xmin= x1 - MENU_SHADOW_SIDE; + ar->winrct.xmax= x2 + MENU_SHADOW_SIDE; + ar->winrct.ymin= y1 - MENU_SHADOW_BOTTOM; + ar->winrct.ymax= y2 + MENU_TOP; + + /* adds subwindow */ + ED_region_init(C, ar); + + /* notify change and redraw */ + ED_region_tag_redraw(ar); + + /* prepare search data */ + data->items.maxitem= SEARCH_ITEMS; + data->items.maxstrlen= but->hardmax; + data->items.totitem= 0; + data->items.names= MEM_callocN(SEARCH_ITEMS*sizeof(void *), "search names"); + data->items.pointers= MEM_callocN(SEARCH_ITEMS*sizeof(void *), "search pointers"); + for(x1=0; x1<SEARCH_ITEMS; x1++) + data->items.names[x1]= MEM_callocN(but->hardmax+1, "search pointers"); + + return ar; +} + +void ui_searchbox_free(bContext *C, ARegion *ar) +{ + ui_remove_temporary_region(C, CTX_wm_screen(C), ar); +} + + /************************* Creating Menu Blocks **********************/ /* position block relative to but, result is in window space */ diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index fca88132771..62a4c01bc6c 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -170,7 +170,7 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str) if(fs->align==UI_STYLE_TEXT_CENTER) xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(str))); else if(fs->align==UI_STYLE_TEXT_RIGHT) - xofs= rect->xmax - rect->xmin - BLF_width(str); + xofs= rect->xmax - rect->xmin - BLF_width(str) - 1; /* clip is very strict, so we give it some space */ BLF_clipping(rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index f4e3a7f2899..82bfb898f99 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -844,29 +844,23 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB widget_draw_icon(but, ICON_DOT, dualset?0:-100, rect); } - if(but->drawstr[0]!=0) { + /* If there's an icon too (made with uiDefIconTextBut) then draw the icon + and offset the text label to accomodate it */ + + if (but->flag & UI_HAS_ICON) { + widget_draw_icon(but, but->icon, 0, rect); - /* If there's an icon too (made with uiDefIconTextBut) then draw the icon - and offset the text label to accomodate it */ + rect->xmin += UI_icon_get_width(but->icon); - if (but->flag & UI_HAS_ICON) { - widget_draw_icon(but, but->icon, 0, rect); - - rect->xmin += UI_icon_get_width(but->icon); - - if(but->editstr || (but->flag & UI_TEXT_LEFT)) - rect->xmin += 5; - } - else if(but->flag & UI_TEXT_LEFT) + if(but->editstr || (but->flag & UI_TEXT_LEFT)) rect->xmin += 5; - - widget_draw_text(fstyle, wcol, but, rect); - - } - /* if there's no text label, then check to see if there's an icon only and draw it */ - else if( but->flag & UI_HAS_ICON ) { - widget_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 0, rect); } + else if(but->flag & UI_TEXT_LEFT) + rect->xmin += 5; + + /* always draw text for textbutton cursor */ + widget_draw_text(fstyle, wcol, but, rect); + } } @@ -1827,6 +1821,7 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) wt= widget_type(UI_WTYPE_RADIO); break; case TEX: + case SEARCH_MENU: wt= widget_type(UI_WTYPE_NAME); break; case TOGBUT: @@ -1918,4 +1913,40 @@ void ui_draw_menu_back(uiStyle *style, uiBlock *block, rcti *rect) } +/* helper call to draw a menu item without button */ +/* state: UI_ACTIVE or 0 */ +void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int state) +{ + uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM); + rcti _rect= *rect; + char *cpoin; + + wt->state(wt, state); + wt->draw(&wt->wcol, rect, 0, 0); + + uiStyleFontSet(fstyle); + fstyle->align= UI_STYLE_TEXT_LEFT; + + /* text location offset */ + rect->xmin+=5; + + /* cut string in 2 parts? */ + cpoin= strchr(name, '|'); + if(cpoin) *cpoin= 0; + + glColor3ubv(wt->wcol.text); + uiStyleFontDraw(fstyle, rect, name); + + /* part text right aligned */ + if(cpoin) { + fstyle->align= UI_STYLE_TEXT_RIGHT; + rect->xmax-=5; + uiStyleFontDraw(fstyle, rect, cpoin+1); + *cpoin= '|'; + } + + /* restore rect, was messed with */ + *rect= _rect; + +} diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index bec3cde7935..e8314deeae9 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -225,7 +225,8 @@ int ED_operator_uvedit(bContext *C) return 1; } - BKE_mesh_end_editmesh(obedit->data, em); + if(obedit) + BKE_mesh_end_editmesh(obedit->data, em); return 0; } @@ -1971,37 +1972,6 @@ static int region_flip_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void testfunc(bContext *C, void *argv, int arg) -{ - printf("arg %d\n", arg); -} - -static void newlevel1(bContext *C, uiLayout *layout, void *arg) -{ - uiLayoutSetFunc(layout, testfunc, NULL); - - uiItemV(layout, "First", ICON_PROP_ON, 1); - uiItemV(layout, "Second", ICON_PROP_CON, 2); - uiItemV(layout, "Third", ICON_SMOOTHCURVE, 3); - uiItemV(layout, "Fourth", ICON_SHARPCURVE, 4); -} - -static int testing123(bContext *C, wmOperator *op, wmEvent *event) -{ - uiPopupMenu *pup= uiPupMenuBegin(C, "Hello world", 0); - uiLayout *layout= uiPupMenuLayout(pup); - - uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); - uiItemO(layout, NULL, ICON_PROP_ON, "SCREEN_OT_region_flip"); - uiItemO(layout, NULL, ICON_PROP_CON, "SCREEN_OT_screen_full_area"); - uiItemO(layout, NULL, ICON_SMOOTHCURVE, "SCREEN_OT_region_foursplit"); - uiItemMenuF(layout, "Submenu", 0, newlevel1); - - uiPupMenuEnd(C, pup); - - /* this operator is only for a menu, not used further */ - return OPERATOR_CANCELLED; -} void SCREEN_OT_region_flip(wmOperatorType *ot) { @@ -2010,13 +1980,10 @@ void SCREEN_OT_region_flip(wmOperatorType *ot) ot->idname= "SCREEN_OT_region_flip"; /* api callbacks */ - ot->invoke= testing123; // XXX WM_operator_confirm; ot->exec= region_flip_exec; ot->poll= ED_operator_areaactive; ot->flag= OPTYPE_REGISTER; - - RNA_def_int(ot->srna, "test", 0, INT_MIN, INT_MAX, "test", "", INT_MIN, INT_MAX); } diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index fd5d851b0c2..38e778848b9 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -387,6 +387,32 @@ static void scene_idpoin_handle(bContext *C, ID *id, int event) } } +static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items) +{ + wmOperatorType *ot = WM_operatortype_first(); + + for(; ot; ot= ot->next) { + + if(BLI_strcasestr(ot->name, str)) { + if(ot->poll==NULL || ot->poll((bContext *)C)) { + int len= strlen(ot->name); + + BLI_strncpy(items->names[items->totitem], ot->name, items->maxstrlen); + + /* check for hotkey */ + if(len < items->maxstrlen-6) { + if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, items->names[items->totitem]+len+1, items->maxstrlen-len-1)) { + items->names[items->totitem][len]= '|'; + } + } + + items->totitem++; + if(items->totitem>=items->maxitem) + break; + } + } + } +} void info_header_buttons(const bContext *C, ARegion *ar) { @@ -453,6 +479,16 @@ void info_header_buttons(const bContext *C, ARegion *ar) xco+= 90; } + { + static char search[256]= ""; + uiBut *but= uiDefSearchBut(block, search, 0, ICON_PROP_ON, 256, xco+5, yco, 120, 19, ""); + + uiButSetSearchFunc(but, operator_search_cb, NULL); + + xco+= 125; + } + + /* always as last */ UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); |