Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-06-10 15:43:21 +0400
committerTon Roosendaal <ton@blender.org>2009-06-10 15:43:21 +0400
commitfba6a9931c81e8cc6a3ea5d3cbd466f2d759c514 (patch)
tree573f2d39036d37cecde991ffba8000a5f845b48d /source
parent872767f5c76db75797344b84c056d6cef28248e8 (diff)
2.5
First version of search-based ID browsing. Now only in use for the top bar screen/scene browse. The python buttons will follow. Also made search button colors match the theme colors from menu back. Todos for browse-search: - "Add new" will disappear, and become a separate icon button in the row of widgets (like X, delete). - Drawing the preview icons in menu - Make search menu dynamic, with configurable number of items? And/or multi-collumn... for now it's static - Search menu should popup with last active ID visible and selected
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface.c12
-rw-r--r--source/blender/editors/interface/interface_handlers.c214
-rw-r--r--source/blender/editors/interface/interface_regions.c29
-rw-r--r--source/blender/editors/interface/interface_utils.c120
-rw-r--r--source/blender/editors/interface/interface_widgets.c73
6 files changed, 289 insertions, 161 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index fad19b6063d..0604a5e27e1 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -399,6 +399,8 @@ uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, char *str,
uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
+uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *str, short x1, short y1, short x2, short y2, char *tip);
+
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index bef01b5a454..79e32d4a5f1 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -432,6 +432,7 @@ static void ui_draw_links(uiBlock *block)
/* ************** BLOCK ENDING FUNCTION ************* */
+/* NOTE: if but->poin is allocated memory for every defbut, things fail... */
static int ui_but_equals_old(uiBut *but, uiBut *oldbut)
{
/* various properties are being compared here, hopfully sufficient
@@ -3012,6 +3013,16 @@ uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *st
return but;
}
+uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *str, short x1, short y1, short x2, short y2, char *tip)
+{
+ uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip);
+ but->block_create_func= func;
+ but->func_argN= argN;
+ ui_check_but(but);
+ return but;
+}
+
+
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip)
{
uiBut *but= ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
@@ -3095,7 +3106,6 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle
but->flag|= UI_HAS_ICON;
but->flag|= UI_ICON_LEFT|UI_TEXT_LEFT;
- but->flag|= UI_ICON_SUBMENU;
ui_check_but(but);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index b9e4b18761f..74559b36c60 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1494,7 +1494,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
}
else {
func= but->block_create_func;
- arg= but->poin;
+ arg= but->poin?but->poin:but->func_argN;
}
break;
case MENU:
@@ -2078,6 +2078,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
+
if(data->state == BUTTON_STATE_HIGHLIGHT) {
if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
@@ -3112,7 +3113,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
but->block->auto_open= 0;
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
-
+
if(type == BUTTON_ACTIVATE_OPEN) {
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
@@ -3522,7 +3523,9 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu,
if(block->miny <= my && block->maxy >= my)
inside= 1;
- if((but=ui_but_find_activated(ar)) && button_modal_state(but->active->state)) {
+ /* if there's an active modal button, don't check events or outside, except for search menu */
+ but= ui_but_find_activated(ar);
+ if(but && button_modal_state(but->active->state) && but->type!=SEARCH_MENU) {
/* if a button is activated modal, always reset the start mouse
* position of the towards mechanism to avoid loosing focus,
* and don't handle events */
@@ -3533,125 +3536,128 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu,
if(event->type == MOUSEMOVE)
ui_mouse_motion_towards_init(menu, mx, my, 0);
- switch(event->type) {
- /* closing sublevels of pulldowns */
- case LEFTARROWKEY:
- if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP))
- if(BLI_countlist(&block->saferct) > 0)
- menu->menuretval= UI_RETURN_OUT;
+ /* events not for active search menu button */
+ if(but==NULL || but->type!=SEARCH_MENU) {
+ switch(event->type) {
+ /* closing sublevels of pulldowns */
+ case LEFTARROWKEY:
+ if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP))
+ if(BLI_countlist(&block->saferct) > 0)
+ menu->menuretval= UI_RETURN_OUT;
- retval= WM_UI_HANDLER_BREAK;
- break;
-
- /* opening sublevels of pulldowns */
- case RIGHTARROWKEY:
- if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
- but= ui_but_find_activated(ar);
-
- if(!but) {
- /* no item active, we make first active */
- if(block->direction & UI_TOP) but= ui_but_last(block);
- else but= ui_but_first(block);
- }
-
- if(but && ELEM(but->type, BLOCK, PULLDOWN))
- ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN);
- }
+ retval= WM_UI_HANDLER_BREAK;
+ break;
- retval= WM_UI_HANDLER_BREAK;
- break;
-
- case UPARROWKEY:
- case DOWNARROWKEY:
- case WHEELUPMOUSE:
- case WHEELDOWNMOUSE:
- /* arrowkeys: only handle for block_loop blocks */
- if(inside || (block->flag & UI_BLOCK_LOOP)) {
- if(event->val==KM_PRESS) {
+ /* opening sublevels of pulldowns */
+ case RIGHTARROWKEY:
+ if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
but= ui_but_find_activated(ar);
- if(but) {
- if(ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) {
- if(block->direction & UI_TOP) but= ui_but_prev(but);
- else but= ui_but_next(but);
- }
- else {
- if(block->direction & UI_TOP) but= ui_but_next(but);
- else but= ui_but_prev(but);
- }
- if(but)
- ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
+ if(!but) {
+ /* no item active, we make first active */
+ if(block->direction & UI_TOP) but= ui_but_last(block);
+ else but= ui_but_first(block);
}
- if(!but) {
- if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) {
- if(block->direction & UI_TOP) bt= ui_but_first(block);
- else bt= ui_but_last(block);
- }
- else {
- if(block->direction & UI_TOP) bt= ui_but_last(block);
- else bt= ui_but_first(block);
+ if(but && ELEM(but->type, BLOCK, PULLDOWN))
+ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN);
+ }
+
+ retval= WM_UI_HANDLER_BREAK;
+ break;
+
+ case UPARROWKEY:
+ case DOWNARROWKEY:
+ case WHEELUPMOUSE:
+ case WHEELDOWNMOUSE:
+ /* arrowkeys: only handle for block_loop blocks */
+ if(inside || (block->flag & UI_BLOCK_LOOP)) {
+ if(event->val==KM_PRESS) {
+ but= ui_but_find_activated(ar);
+ if(but) {
+ if(ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) {
+ if(block->direction & UI_TOP) but= ui_but_prev(but);
+ else but= ui_but_next(but);
+ }
+ else {
+ if(block->direction & UI_TOP) but= ui_but_next(but);
+ else but= ui_but_prev(but);
+ }
+
+ if(but)
+ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
}
- if(bt)
- ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE);
+ if(!but) {
+ if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) {
+ if(block->direction & UI_TOP) bt= ui_but_first(block);
+ else bt= ui_but_last(block);
+ }
+ else {
+ if(block->direction & UI_TOP) bt= ui_but_last(block);
+ else bt= ui_but_first(block);
+ }
+
+ if(bt)
+ ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE);
+ }
}
}
- }
- retval= WM_UI_HANDLER_BREAK;
- break;
+ retval= WM_UI_HANDLER_BREAK;
+ break;
- case ONEKEY: case PAD1:
- act= 1;
- case TWOKEY: case PAD2:
- if(act==0) act= 2;
- case THREEKEY: case PAD3:
- if(act==0) act= 3;
- case FOURKEY: case PAD4:
- if(act==0) act= 4;
- case FIVEKEY: case PAD5:
- if(act==0) act= 5;
- case SIXKEY: case PAD6:
- if(act==0) act= 6;
- case SEVENKEY: case PAD7:
- if(act==0) act= 7;
- case EIGHTKEY: case PAD8:
- if(act==0) act= 8;
- case NINEKEY: case PAD9:
- if(act==0) act= 9;
- case ZEROKEY: case PAD0:
- if(act==0) act= 10;
-
- if(block->flag & UI_BLOCK_NUMSELECT) {
- if(event->alt) act+= 10;
-
- count= 0;
- for(but= block->buttons.first; but; but= but->next) {
- int doit= 0;
+ case ONEKEY: case PAD1:
+ act= 1;
+ case TWOKEY: case PAD2:
+ if(act==0) act= 2;
+ case THREEKEY: case PAD3:
+ if(act==0) act= 3;
+ case FOURKEY: case PAD4:
+ if(act==0) act= 4;
+ case FIVEKEY: case PAD5:
+ if(act==0) act= 5;
+ case SIXKEY: case PAD6:
+ if(act==0) act= 6;
+ case SEVENKEY: case PAD7:
+ if(act==0) act= 7;
+ case EIGHTKEY: case PAD8:
+ if(act==0) act= 8;
+ case NINEKEY: case PAD9:
+ if(act==0) act= 9;
+ case ZEROKEY: case PAD0:
+ if(act==0) act= 10;
+
+ if(block->flag & UI_BLOCK_NUMSELECT) {
+ if(event->alt) act+= 10;
- if(but->type!=LABEL && but->type!=SEPR)
- count++;
+ count= 0;
+ for(but= block->buttons.first; but; but= but->next) {
+ int doit= 0;
+
+ if(but->type!=LABEL && but->type!=SEPR)
+ count++;
- /* exception for menus like layer buts, with button aligning they're not drawn in order */
- if(but->type==TOGR) {
- if(but->bitnr==act-1)
- doit= 1;
- }
- else if(count==act)
- doit=1;
-
- if(doit) {
- ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
- break;
+ /* exception for menus like layer buts, with button aligning they're not drawn in order */
+ if(but->type==TOGR) {
+ if(but->bitnr==act-1)
+ doit= 1;
+ }
+ else if(count==act)
+ doit=1;
+
+ if(doit) {
+ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
+ break;
+ }
}
}
- }
- retval= WM_UI_HANDLER_BREAK;
- break;
+ retval= WM_UI_HANDLER_BREAK;
+ break;
+ }
}
-
+
/* here we check return conditions for menus */
if(block->flag & UI_BLOCK_LOOP) {
/* if we click outside the block, verify if we clicked on the
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 222c3fe892d..f4b606dac72 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -602,6 +602,8 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset)
data->active= a+1;
if(cpoin) cpoin[0]= '|';
}
+ if(data->items.totitem==1)
+ data->active= 1;
}
/* validate selected item */
@@ -669,7 +671,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
uiSearchboxData *data;
float aspect= but->block->aspect;
float x1f, x2f, y1f, y2f;
- int x1, x2, y1, y2, winx, winy, ofsx, ofsy;
+ int x1, x2, y1, y2, winx, winy;
/* create area region */
ar= ui_add_temporary_region(CTX_wm_screen(C));
@@ -696,16 +698,27 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
data->noback= 1;
/* compute position */
- ofsx= (but->block->panel)? but->block->panel->ofsx: 0;
- ofsy= (but->block->panel)? but->block->panel->ofsy: 0;
x1f= but->x1 - 5; /* align text with button */
x2f= but->x2 + 5; /* symmetrical */
- y2f= but->y1;
- y1f= y2f - uiSearchBoxhHeight();
+ if(but->block->flag & UI_BLOCK_LOOP) {
+ /* check if button is lower half */
+ if( but->y2 < (but->block->minx+but->block->maxx)/2 ) {
+ y1f= but->y2;
+ y2f= y1f + uiSearchBoxhHeight();
+ }
+ else {
+ y2f= but->y1;
+ y1f= y2f - uiSearchBoxhHeight();
+ }
+ }
+ else {
+ y2f= but->y1;
+ y1f= y2f - uiSearchBoxhHeight();
+ }
/* minimal width */
- if(x2f - x1f < 180) x2f= x1f+180; // XXX arbitrary
+ if(x2f - x1f < 150) x2f= x1f+150; // XXX arbitrary
/* copy to int, gets projected if possible too */
x1= x1f; y1= y1f; x2= x2f; y2= y2f;
@@ -1146,7 +1159,7 @@ uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_b
rows++;
/* prevent scaling up of pupmenu */
- aspect= but->aspect;
+ aspect= but->block->aspect;
if(aspect < 1.0f)
aspect = 1.0f;
@@ -1169,7 +1182,7 @@ uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_b
width = (but->x2 - but->x1);
if(width<50)
width=50;
-
+
boxh= MENU_BUTTON_HEIGHT;
height= rows*boxh;
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index fa7de1151a3..e08aeb1b371 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -38,6 +38,8 @@
#include "DNA_texture_types.h"
#include "DNA_windowmanager_types.h"
+#include "BLI_blenlib.h"
+
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
@@ -199,10 +201,12 @@ void uiDefAutoButsRNA_single(const bContext *C, uiLayout *layout, PointerRNA *pt
RNA_property_collection_end(&iter);
}
+
/***************************** ID Utilities *******************************/
typedef struct uiIDPoinParams {
uiIDPoinFunc func;
+ ListBase *lb;
ID *id;
short id_code;
short browsenr;
@@ -210,16 +214,12 @@ typedef struct uiIDPoinParams {
static void idpoin_cb(bContext *C, void *arg_params, void *arg_event)
{
- Main *bmain;
- ListBase *lb;
uiIDPoinParams *params= (uiIDPoinParams*)arg_params;
+ ListBase *lb= params->lb;
uiIDPoinFunc func= params->func;
ID *id= params->id, *idtest;
int nr, event= GET_INT_FROM_POINTER(arg_event);
- bmain= CTX_data_main(C);
- lb= wich_libbase(bmain, params->id_code);
-
if(event == UI_ID_BROWSE && params->browsenr == 32767)
event= UI_ID_ADD_NEW;
else if(event == UI_ID_BROWSE && params->browsenr == 32766)
@@ -286,22 +286,84 @@ static void idpoin_cb(bContext *C, void *arg_params, void *arg_event)
func(C, id, event);
}
+/* ***************************** ID Search browse menu ********************** */
+
+static void id_search_call_cb(struct bContext *C, void *arg_params, void *item)
+{
+ uiIDPoinParams *params= (uiIDPoinParams*)arg_params;
+
+ if(item && params->func)
+ params->func(C, item, UI_ID_BROWSE);
+
+}
+
+static void id_search_cb(const struct bContext *C, void *arg_params, char *str, uiSearchItems *items)
+{
+ uiIDPoinParams *params= (uiIDPoinParams*)arg_params;
+ ID *id;
+
+ for(id= params->lb->first; id; id= id->next) {
+
+ if(BLI_strcasestr(id->name+2, str)) {
+ if(0==uiSearchItemAdd(items, id->name+2, id))
+ break;
+ }
+ }
+}
+
+static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_params)
+{
+ static char search[256];
+ static uiIDPoinParams params;
+ wmEvent event;
+ wmWindow *win= CTX_wm_window(C);
+ uiBlock *block;
+ uiBut *but;
+
+ /* clear initial search string, then all items show */
+ search[0]= 0;
+ /* params is malloced, can be freed by parent button */
+ params= *((uiIDPoinParams*)arg_params);
+
+ block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1);
+
+ /* fake button, it holds space for search items */
+ uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
+
+ but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, 19, "");
+ uiButSetSearchFunc(but, id_search_cb, &params, id_search_call_cb);
+
+ uiBoundsBlock(block, 6);
+ uiBlockSetDirection(block, UI_DOWN);
+ uiEndBlock(C, block);
+
+ event= *(win->eventstate); /* XXX huh huh? make api call */
+ event.type= EVT_BUT_OPEN;
+ event.val= KM_PRESS;
+ event.customdata= but;
+ event.customdatafree= FALSE;
+ wm_event_add(win, &event);
+
+ return block;
+}
+
+/* ****************** */
+
int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID *id, int id_code, short *pin_p, int x, int y, uiIDPoinFunc func, int events)
{
- ListBase *lb;
uiBut *but;
uiIDPoinParams *params, *dup_params;
- char *str=NULL, str1[10];
+ char str1[10];
int len, add_addbutton=0;
/* setup struct that we will pass on with the buttons */
params= MEM_callocN(sizeof(uiIDPoinParams), "uiIDPoinParams");
+ params->lb= wich_libbase(bmain, id_code);
params->id= id;
params->id_code= id_code;
params->func= func;
- lb= wich_libbase(bmain, id_code);
-
/* create buttons */
uiBlockBeginAlign(block);
@@ -322,45 +384,11 @@ int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID *id, int id_code,
/* browse menu */
if(events & UI_ID_BROWSE) {
- char *extrastr= NULL;
-
- if(ELEM4(id_code, ID_MA, ID_TE, ID_BR, ID_PA))
- add_addbutton= 1;
-
- if(ELEM8(id_code, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC, ID_BR) || id_code == ID_PA)
- extrastr= "ADD NEW %x 32767";
- else if(id_code==ID_TXT)
- extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
- else if(id_code==ID_SO)
- extrastr= "OPEN NEW %x 32766";
-
- /* XXX should be moved out of this function
- uiBlockSetButLock(block, G.scene->id.lib!=0, "Can't edit external libdata");
- if( id_code==ID_SCE || id_code==ID_SCR ) uiBlockClearButLock(block); */
-
- /* XXX should be moved out of this function
- if(curarea->spacetype==SPACE_BUTS)
- uiBlockSetButLock(block, id_code!=ID_SCR && G.obedit!=0 && G.buts->mainb==CONTEXT_EDITING, "Cannot perform in EditMode"); */
-
- if(parid)
- uiBlockSetButLock(block, parid->lib!=0, "Can't edit external libdata");
-
- if(lb) {
- if(id_code!=ID_IM || (events & UI_ID_BROWSE_RENDER))
- IDnames_to_pupstring(&str, NULL, extrastr, lb, id, &params->browsenr);
- else
- IMAnames_to_pupstring(&str, NULL, extrastr, lb, id, &params->browsenr);
- }
-
- dup_params= MEM_dupallocN(params);
- but= uiDefButS(block, MENU, 0, str, x, y, DEF_ICON_BUT_WIDTH, DEF_BUT_HEIGHT, &dup_params->browsenr, 0, 0, 0, 0, "Browse existing choices, or add new");
- uiButSetNFunc(but, idpoin_cb, dup_params, SET_INT_IN_POINTER(UI_ID_BROWSE));
+ uiDefBlockButN(block, id_search_menu, MEM_dupallocN(params), "", x, y, DEF_ICON_BUT_WIDTH, DEF_BUT_HEIGHT, "Browse ID data");
x+= DEF_ICON_BUT_WIDTH;
-
- uiBlockClearButLock(block);
-
- MEM_freeN(str);
}
+
+
/* text button with name */
if(id) {
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 03487e2301c..ab8569bf47e 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1024,11 +1024,11 @@ static struct uiWidgetColors wcol_menu_item= {
static struct uiWidgetColors wcol_menu_back= {
{0, 0, 0, 255},
{25, 25, 25, 230},
- {46, 124, 217, 204},
+ {45, 45, 45, 230},
{255, 255, 255, 255},
{255, 255, 255, 255},
- {0, 0, 0, 255},
+ {255, 255, 255, 255},
0,
25, -20
@@ -1264,6 +1264,71 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
/* ************ custom buttons, old stuff ************** */
+static void ui_hsvcircle_to_val(float *valrad, float *valdist, rcti *rect, float mx, float my)
+{
+ /* duplication of code... well, simple is better now */
+ float centx= (float)(rect->xmin + rect->xmax)/2;
+ float centy= (float)(rect->ymin + rect->ymax)/2;
+ float radius, dist;
+
+ if( rect->xmax-rect->xmin > rect->ymax-rect->ymin )
+ radius= (float)(rect->ymax - rect->ymin)/2;
+ else
+ radius= (float)(rect->xmax - rect->xmin)/2;
+
+ mx-= centx;
+ my-= centy;
+ dist= sqrt( mx*mx + my*my);
+ if(dist < radius)
+ *valdist= dist/radius;
+ else
+ *valdist= 1.0f;
+
+ *valrad= atan2(mx, my)/(2.0f*M_PI) + 0.5f;
+}
+
+void ui_draw_but_HSVCIRCLE(uiBut *but, rcti *rect)
+{
+ /* gouraud triangle fan */
+ float radstep, ang= 0.0f;
+ float centx, centy, radius;
+ float hsv[3], col[3], colcent[3];
+ int a, tot= 32;
+
+ radstep= 2.0f*M_PI/(float)tot;
+ centx= (float)(rect->xmin + rect->xmax)/2;
+ centy= (float)(rect->ymin + rect->ymax)/2;
+
+ if( rect->xmax-rect->xmin > rect->ymax-rect->ymin )
+ radius= (float)(rect->ymax - rect->ymin)/2;
+ else
+ radius= (float)(rect->xmax - rect->xmin)/2;
+
+ /* color */
+ VECCOPY(hsv, but->hsv);
+ hsv[0]= hsv[1]= 0.0f;
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], colcent, colcent+1, colcent+2);
+
+ glShadeModel(GL_SMOOTH);
+
+ glBegin(GL_TRIANGLE_FAN);
+ glColor3fv(colcent);
+ glVertex2f( centx, centy);
+
+ for(a=0; a<=tot; a++, ang+=radstep) {
+ float si= sin(ang);
+ float co= cos(ang);
+
+ ui_hsvcircle_to_val(hsv, hsv+1, rect, centx + co*radius, centy + si*radius);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
+ glColor3fv(col);
+ glVertex2f( centx + co*radius, centy + si*radius);
+ }
+ glEnd();
+
+ glShadeModel(GL_FLAT);
+}
+
/* draws in resolution of 20x4 colors */
static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
{
@@ -1881,8 +1946,12 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
wt= widget_type(UI_WTYPE_RADIO);
break;
case TEX:
+ wt= widget_type(UI_WTYPE_NAME);
+ break;
case SEARCH_MENU:
wt= widget_type(UI_WTYPE_NAME);
+ if(but->block->flag & UI_BLOCK_LOOP)
+ wt->wcol_theme= &btheme->tui.wcol_menu_back;
break;
case TOGBUT:
case TOG: