NLA SoC: Merge from 2.5

20571 to 20667
This commit is contained in:
2009-06-06 05:00:40 +00:00
123 changed files with 5109 additions and 1564 deletions

View File

@@ -537,10 +537,17 @@ void uiEndBlock(const bContext *C, uiBlock *block)
/* temp? Proper check for greying out */
if(but->optype) {
wmOperatorType *ot= but->optype;
if(but->context)
CTX_store_set((bContext*)C, but->context);
if(ot==NULL || (ot->poll && ot->poll((bContext *)C)==0)) {
but->flag |= UI_BUT_DISABLED;
but->lock = 1;
}
if(but->context)
CTX_store_set((bContext*)C, NULL);
}
/* only update soft range while not editing */
@@ -1359,7 +1366,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 +1409,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 +1503,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 +1547,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 +1834,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 +1943,7 @@ void ui_check_but(uiBut *but)
case IDPOIN:
case TEX:
case SEARCH_MENU:
if(!but->editstr) {
char str[UI_MAX_DRAW_STR];
@@ -2945,6 +2963,11 @@ void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2
block->func_arg2= arg2;
}
void uiBlockSetRenameFunc(uiBlock *block, uiButHandleRenameFunc func, void *arg1)
{
}
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)())
{
block->drawextra= func;
@@ -3065,6 +3088,32 @@ void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1,
ui_check_but(but);
}
/* arg is pointer to string/name, use uiButSetSearchFunc() 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;
}
/* arg is user value, searchfunc and handlefunc both get it as arg */
void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg, uiButHandleFunc bfunc)
{
but->search_func= sfunc;
but->search_arg= arg;
uiButSetFunc(but, bfunc, arg, NULL);
}
/* Program Init/Exit */
void UI_init(void)

View File

@@ -54,6 +54,12 @@ void RNA_api_ui_layout(StructRNA *srna)
FunctionRNA *func;
PropertyRNA *parm;
static EnumPropertyItem curve_type_items[] = {
{0, "NONE", "None", ""},
{'v', "VECTOR", "Vector", ""},
{'c', "COLOR", "Color", ""},
{0, NULL, NULL, NULL}};
/* simple layout specifiers */
func= RNA_def_function(srna, "row", "uiLayoutRow");
parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
@@ -214,5 +220,14 @@ void RNA_api_ui_layout(StructRNA *srna)
parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock.");
RNA_def_property_flag(parm, PROP_REQUIRED);
func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping");
parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer.");
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display.");
func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer.");
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail.");
}

View File

@@ -97,7 +97,7 @@ typedef struct uiHandleButtonData {
/* overall state */
uiHandleButtonState state;
int cancel, retval;
int cancel, escapecancel, retval;
int applied, appliedinteractive;
wmTimer *flashtimer;
@@ -127,6 +127,9 @@ typedef struct uiHandleButtonData {
/* menu open */
uiPopupBlockHandle *menu;
int menuretval;
/* search box */
ARegion *searchbox;
/* post activate */
uiButtonActivateType posttype;
@@ -139,7 +142,8 @@ typedef struct uiAfterFunc {
uiButHandleFunc func;
void *func_arg1;
void *func_arg2;
void *func_arg3;
uiButHandleNFunc funcN;
void *func_argN;
@@ -157,6 +161,8 @@ typedef struct uiAfterFunc {
PointerRNA rnapoin;
PropertyRNA *rnaprop;
bContextStore *context;
} uiAfterFunc;
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state);
@@ -228,6 +234,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->func= but->func;
after->func_arg1= but->func_arg1;
after->func_arg2= but->func_arg2;
after->func_arg3= but->func_arg3;
after->funcN= but->funcN;
after->func_argN= but->func_argN;
@@ -249,6 +256,9 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->rnapoin= but->rnapoin;
after->rnaprop= but->rnaprop;
if(but->context)
after->context= CTX_store_copy(but->context);
but->optype= NULL;
but->opcontext= 0;
but->opptr= NULL;
@@ -270,6 +280,9 @@ static void ui_apply_but_funcs_after(bContext *C)
after= *afterf; /* copy to avoid memleak on exit() */
BLI_freelinkN(&funcs, afterf);
if(after.context)
CTX_store_set(C, after.context);
if(after.func)
after.func(C, after.func_arg1, after.func_arg2);
if(after.funcN)
@@ -289,6 +302,11 @@ static void ui_apply_but_funcs_after(bContext *C)
if(after.rnapoin.data)
RNA_property_update(C, &after.rnapoin, after.rnaprop);
if(after.context) {
CTX_store_set(C, NULL);
CTX_store_free(after.context);
}
}
}
@@ -402,9 +420,10 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
/* give butfunc the original text too */
/* feature used for bone renaming, channels, etc */
if(but->func_arg2==NULL) but->func_arg2= data->origstr;
/* XXX goes via uiButHandleRenameFunc now */
// if(but->func_arg2==NULL) but->func_arg2= data->origstr;
ui_apply_but_func(C, but);
if(but->func_arg2==data->origstr) but->func_arg2= NULL;
// if(but->func_arg2==data->origstr) but->func_arg2= NULL;
data->retval= but->retval;
data->applied= 1;
@@ -557,6 +576,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:
@@ -871,7 +891,7 @@ static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char asc
}
}
return WM_UI_HANDLER_BREAK;
return changed;
}
void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction, int select, int jump)
@@ -1030,7 +1050,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio
else { /* backspace */
if(len!=0) {
if ((but->selend - but->selsta) > 0) {
ui_textedit_delete_selection(but, data);
changed= ui_textedit_delete_selection(but, data);
}
else if(but->pos>0) {
for(x=but->pos; x<len; x++)
@@ -1124,7 +1144,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,13 +1166,27 @@ 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, 1); /* 1= reset */
}
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;
if(data->searchbox) {
if(data->cancel==0)
ui_searchbox_apply(but, data->searchbox);
ui_searchbox_free(C, data->searchbox);
data->searchbox= NULL;
}
but->editstr= NULL;
but->pos= -1;
}
}
@@ -1205,18 +1239,30 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
}
}
static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
int mx, my, changed= 0, retval= WM_UI_HANDLER_CONTINUE;
int mx, my, changed= 0, inbox=0, retval= WM_UI_HANDLER_CONTINUE;
switch(event->type) {
case MOUSEMOVE:
if(data->searchbox)
ui_searchbox_event(C, data->searchbox, but, event);
break;
case RIGHTMOUSE:
case ESCKEY:
data->cancel= 1;
data->escapecancel= 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
retval= WM_UI_HANDLER_BREAK;
break;
case LEFTMOUSE: {
/* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */
if(data->searchbox)
inbox= BLI_in_rcti(&data->searchbox->winrct, event->x, event->y);
if(event->val==KM_PRESS) {
mx= event->x;
my= event->y;
@@ -1230,11 +1276,18 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
button_activate_state(C, but, BUTTON_STATE_TEXT_SELECTING);
retval= WM_UI_HANDLER_BREAK;
}
else {
else if(inbox==0) {
/* if searchbox, click outside will cancel */
if(data->searchbox)
data->cancel= data->escapecancel= 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
retval= WM_UI_HANDLER_BREAK;
}
}
else if(inbox) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
retval= WM_UI_HANDLER_BREAK;
}
break;
}
}
@@ -1264,11 +1317,21 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
retval= WM_UI_HANDLER_BREAK;
break;
case DOWNARROWKEY:
if(data->searchbox) {
ui_searchbox_event(C, data->searchbox, but, event);
break;
}
/* pass on purposedly */
case ENDKEY:
ui_textedit_move_end(but, data, 1, event->shift);
retval= WM_UI_HANDLER_BREAK;
break;
case UPARROWKEY:
if(data->searchbox) {
ui_searchbox_event(C, data->searchbox, but, event);
break;
}
/* pass on purposedly */
case HOMEKEY:
ui_textedit_move_end(but, data, 0, event->shift);
retval= WM_UI_HANDLER_BREAK;
@@ -1316,6 +1379,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, 1); /* 1 = reset */
}
if(changed || (retval == WM_UI_HANDLER_BREAK))
@@ -1549,7 +1615,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w
static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
if(data->state == BUTTON_STATE_HIGHLIGHT) {
if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
if(ELEM4(event->type, LEFTMOUSE, PADENTER, RETKEY, EVT_BUT_OPEN) && event->val==KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
return WM_UI_HANDLER_BREAK;
}
@@ -1710,7 +1776,12 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
}
}
else if(data->state == BUTTON_STATE_NUM_EDITING) {
if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
if(event->type == ESCKEY) {
data->cancel= 1;
data->escapecancel= 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
if(data->dragchange)
button_activate_state(C, but, BUTTON_STATE_EXIT);
else
@@ -1906,7 +1977,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
}
}
else if(data->state == BUTTON_STATE_NUM_EDITING) {
if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
if(event->type == ESCKEY) {
data->cancel= 1;
data->escapecancel= 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
if(data->dragchange)
button_activate_state(C, but, BUTTON_STATE_EXIT);
else
@@ -2702,6 +2778,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 +3005,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)
@@ -2982,7 +3059,9 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
data= MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
data->window= CTX_wm_window(C);
data->region= ar;
data->interactive= but->type==BUT_CURVE?0:1; // XXX temp
if( ELEM(but->type, BUT_CURVE, SEARCH_MENU) ); // XXX curve is temp
else data->interactive= 1;
data->state = BUTTON_STATE_INIT;
/* activate button */
@@ -3035,12 +3114,14 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
/* if this button is in a menu, this will set the button return
* value to the button value and the menu return value to ok, the
* menu return value will be picked up and the menu will close */
if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN) && !data->cancel) {
uiPopupBlockHandle *menu;
if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN)) {
if(!data->cancel || data->escapecancel) {
uiPopupBlockHandle *menu;
menu= block->handle;
menu->butretval= data->retval;
menu->menuretval= UI_RETURN_OK;
menu= block->handle;
menu->butretval= data->retval;
menu->menuretval= (data->cancel)? UI_RETURN_CANCEL: UI_RETURN_OK;
}
}
/* disable tooltips until mousemove */
@@ -3084,16 +3165,35 @@ void ui_button_active_cancel(const bContext *C, uiBut *but)
/************** handle activating a button *************/
static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event)
{
uiBlock *block;
uiBut *but;
for(block=ar->uiblocks.first; block; block=block->next) {
for(but=block->buttons.first; but; but= but->next)
if(but==event->customdata)
return but;
}
return NULL;
}
static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar)
{
uiBut *but;
if(event->type == MOUSEMOVE) {
but= ui_but_find_mouse_over(ar, event->x, event->y);
if(but)
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
}
else if(event->type == EVT_BUT_OPEN) {
but= uit_but_find_open_event(ar, event);
if(but) {
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
ui_do_button(C, but->block, but, event);
}
}
return WM_UI_HANDLER_CONTINUE;
}

View File

@@ -164,6 +164,7 @@ struct uiBut {
uiButHandleFunc func;
void *func_arg1;
void *func_arg2;
void *func_arg3;
uiButHandleNFunc funcN;
void *func_argN;
@@ -176,6 +177,9 @@ struct uiBut {
uiButCompleteFunc autocomplete_func;
void *autofunc_arg;
uiButSearchFunc search_func;
void *search_arg;
uiLink *link;
char *tip, *lockstr;
@@ -351,6 +355,13 @@ 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);
/* searchbox for string button */
ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset);
void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event);
void ui_searchbox_apply(uiBut *but, struct ARegion *ar);
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,
@@ -389,11 +400,15 @@ extern int ui_button_is_active(struct ARegion *ar);
/* interface_widgets.c */
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
extern void ui_draw_but(ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
/* theme color init */
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);

View File

@@ -115,6 +115,7 @@ typedef enum uiItemType {
typedef struct uiItem {
void *next, *prev;
uiItemType type;
int flag;
} uiItem;
typedef struct uiButtonItem {
@@ -130,7 +131,7 @@ struct uiLayout {
ListBase items;
int x, y, w, h;
float scale;
float scale[2];
short space;
char align;
char active;
@@ -177,26 +178,29 @@ static char *ui_item_name_add_colon(char *name, char namestr[UI_MAX_NAME_STR])
return name;
}
#define UI_FIT_EXPAND 1
static int ui_item_fit(int item, int pos, int all, int available, int spacing, int last, int flag)
static int ui_item_fit(int item, int pos, int all, int available, int last, int alignment, int *offset)
{
/* available == 0 is unlimited */
if(available != 0 && all > available-spacing) {
if(available == 0)
return item;
if(offset)
*offset= 0;
if(all > available) {
/* contents is bigger than available space */
if(last)
return available-pos;
else
return (item*(available-spacing))/all;
return (item*available)/all;
}
else {
/* contents is smaller or equal to available space */
if(available != 0 && (flag & UI_FIT_EXPAND)) {
if(alignment == UI_LAYOUT_ALIGN_EXPAND) {
if(last)
return available-pos;
else
return (item*(available-spacing))/all;
return (item*available)/all;
}
else
return item;
@@ -209,7 +213,7 @@ static int ui_item_fit(int item, int pos, int all, int available, int spacing, i
static int ui_layout_vary_direction(uiLayout *layout)
{
return (layout->root->type == UI_LAYOUT_HEADER)? UI_ITEM_VARY_X: UI_ITEM_VARY_Y;
return (layout->root->type == UI_LAYOUT_HEADER || layout->alignment != UI_LAYOUT_ALIGN_EXPAND)? UI_ITEM_VARY_X: UI_ITEM_VARY_Y;
}
/* estimated size of text + icon */
@@ -220,9 +224,9 @@ static int ui_text_icon_width(uiLayout *layout, char *name, int icon)
if(icon && strcmp(name, "") == 0)
return UI_UNIT_X; /* icon only */
else if(icon)
return (variable)? UI_GetStringWidth(name) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */
return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */
else
return (variable)? UI_GetStringWidth(name) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */
return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* text only */
}
static void ui_item_size(uiItem *item, int *r_w, int *r_h)
@@ -655,9 +659,6 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA
subtype= RNA_property_subtype(prop);
len= RNA_property_array_length(prop);
if(ELEM(type, PROP_STRING, PROP_ENUM))
w += 10*UI_UNIT_X;
/* increase height for arrays */
if(index == RNA_NO_INDEX && len > 0) {
if(strcmp(name, "") == 0 && icon == 0)
@@ -1033,14 +1034,22 @@ static void ui_litem_estimate_row(uiLayout *litem)
}
}
static int ui_litem_min_width(int itemw)
{
return MIN2(UI_UNIT_X, itemw);
}
static void ui_litem_layout_row(uiLayout *litem)
{
uiItem *item;
int neww, itemw, itemh, x, y, w, tot= 0, totw= 0, extra=0, available=0;
int x, y, w, tot, totw, neww, itemw, minw, itemh, offset;
int fixedw, freew, fixedx, freex, flag= 0, lastw= 0;
x= litem->x;
y= litem->y;
w= litem->w;
totw= 0;
tot= 0;
for(item=litem->items.first; item; item=item->next) {
ui_item_size(item, &itemw, &itemh);
@@ -1051,40 +1060,81 @@ static void ui_litem_layout_row(uiLayout *litem)
if(totw == 0)
return;
/* two step to enforce minimum button with .. could be better */
for(item=litem->items.first; item; item=item->next) {
ui_item_size(item, &itemw, &itemh);
if(w != 0)
w -= (tot-1)*litem->space;
fixedw= 0;
itemw= ui_item_fit(itemw, x-litem->x, totw, w, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND);
x += itemw;
/* keep clamping items to fixed minimum size until all are done */
do {
freew= 0;
x= 0;
flag= 0;
if(itemw < UI_UNIT_X)
extra += UI_UNIT_X - itemw;
else
available += itemw - UI_UNIT_X;
for(item=litem->items.first; item; item=item->next) {
if(item->flag)
continue;
if(item->next)
x += litem->space;
}
ui_item_size(item, &itemw, &itemh);
minw= ui_litem_min_width(itemw);
if(w - lastw > 0)
neww= ui_item_fit(itemw, x, totw, w-lastw, !item->next, litem->alignment, NULL);
else
neww= 0; /* no space left, all will need clamping to minimum size */
x += neww;
if(neww < minw && w != 0) {
/* fixed size */
item->flag= 1;
fixedw += minw;
flag= 1;
totw -= itemw;
}
else {
/* keep free size */
item->flag= 0;
freew += itemw;
}
}
lastw= fixedw;
} while(flag);
freex= 0;
fixedx= 0;
x= litem->x;
for(item=litem->items.first; item; item=item->next) {
ui_item_size(item, &itemw, &itemh);
minw= ui_litem_min_width(itemw);
neww= ui_item_fit(itemw, x-litem->x, totw, w, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND);
if(neww < UI_UNIT_X) {
if(item->next)
itemw= UI_UNIT_X;
else
itemw= litem->w - (x-litem->x);
if(item->flag) {
/* fixed minimum size items */
itemw= ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL);
fixedx += itemw;
}
else {
/* free size item */
itemw= ui_item_fit(itemw, freex, freew, w-fixedw, !item->next, litem->alignment, NULL);
freex += itemw;
}
else
itemw= ui_item_fit(itemw, x-litem->x, totw, w-extra, (tot-1)*litem->space, !item->next, UI_FIT_EXPAND);
ui_item_position(item, x, y-itemh, itemw, itemh);
/* align right/center */
offset= 0;
if(litem->alignment == UI_LAYOUT_ALIGN_RIGHT) {
if(fixedw == 0 && freew < w-fixedw)
offset= (w - fixedw) - freew;
}
else if(litem->alignment == UI_LAYOUT_ALIGN_CENTER) {
if(fixedw == 0 && freew < w-fixedw)
offset= ((w - fixedw) - freew)/2;
}
/* position item */
ui_item_position(item, x+offset, y-itemh, itemw, itemh);
x += itemw;
if(item->next)
x += litem->space;
}
@@ -1263,7 +1313,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
uiLayoutItemFlow *flow= (uiLayoutItemFlow*)litem;
uiItem *item;
int col, x, y, w, emh, emy, miny, itemw, itemh;
int toth, totitem;
int toth, totitem, offset;
/* compute max needed width and total height */
toth= 0;
@@ -1280,18 +1330,18 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
emy= 0;
miny= 0;
w= litem->w;
w= litem->w - (flow->totcol-1)*style->columnspace;
emh= toth/flow->totcol;
/* create column per column */
col= 0;
for(item=litem->items.first; item; item=item->next) {
ui_item_size(item, NULL, &itemh);
itemw= ui_item_fit(1, x-litem->x, flow->totcol, w, (flow->totcol-1)*style->columnspace, col == flow->totcol-1, UI_FIT_EXPAND);
itemw= ui_item_fit(1, x-litem->x, flow->totcol, w, col == flow->totcol-1, litem->alignment, &offset);
y -= itemh;
emy -= itemh;
ui_item_position(item, x, y, itemw, itemh);
ui_item_position(item, x+offset, y, itemw, itemh);
y -= style->buttonspacey;
miny= MIN2(miny, y);
@@ -1578,9 +1628,14 @@ void uiLayoutSetAlignment(uiLayout *layout, int alignment)
layout->alignment= alignment;
}
void uiLayoutSetScale(uiLayout *layout, float scale)
void uiLayoutSetScaleX(uiLayout *layout, float scale)
{
layout->scale= scale;
layout->scale[0]= scale;
}
void uiLayoutSetScaleY(uiLayout *layout, float scale)
{
layout->scale[1]= scale;
}
int uiLayoutGetActive(uiLayout *layout)
@@ -1608,13 +1663,41 @@ int uiLayoutGetAlignment(uiLayout *layout)
return layout->alignment;
}
float uiLayoutGetScale(uiLayout *layout)
float uiLayoutGetScaleX(uiLayout *layout)
{
return layout->scale;
return layout->scale[0];
}
float uiLayoutGetScaleY(uiLayout *layout)
{
return layout->scale[0];
}
/********************** Layout *******************/
static void ui_item_scale(uiLayout *litem, float scale[2])
{
uiItem *item;
int x, y, w, h;
for(item=litem->items.last; item; item=item->prev) {
ui_item_size(item, &w, &h);
ui_item_offset(item, &x, &y);
if(scale[0] != 0.0f) {
x *= scale[0];
w *= scale[0];
}
if(scale[1] != 0.0f) {
y *= scale[1];
h *= scale[1];
}
ui_item_position(item, x, y, w, h);
}
}
static void ui_item_estimate(uiItem *item)
{
uiItem *subitem;
@@ -1628,6 +1711,9 @@ static void ui_item_estimate(uiItem *item)
if(litem->items.first == NULL)
return;
if(litem->scale[0] != 0.0f || litem->scale[1] != 0.0f)
ui_item_scale(litem, litem->scale);
switch(litem->item.type) {
case ITEM_LAYOUT_COLUMN:
ui_litem_estimate_column(litem);

View File

@@ -119,7 +119,7 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
SpaceButs *sbuts= sa->spacedata.first;
if(sbuts->align)
if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb || sbuts->tabo!=sbuts->tab[sbuts->mainb])
if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb)
return 1;
}
else if(ar->regiontype==RGN_TYPE_UI)

View File

@@ -56,6 +56,7 @@
#include "BIF_gl.h"
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "UI_view2d.h"
#include "BLF_api.h"
@@ -383,6 +384,358 @@ void ui_tooltip_free(bContext *C, ARegion *ar)
ui_remove_temporary_region(C, CTX_wm_screen(C), ar);
}
/************************* Creating Search Box **********************/
struct uiSearchItems {
int maxitem, totitem, maxstrlen;
int offset, offset_i; /* offset for inserting in array */
int more; /* flag indicating there are more items */
char **names;
void **pointers;
};
typedef struct uiSearchboxData {
rcti bbox;
uiFontStyle fstyle;
uiSearchItems items;
int active; /* index in items array */
int noback; /* when menu opened with enough space for this */
} uiSearchboxData;
#define SEARCH_ITEMS 10
/* exported for use by search callbacks */
/* returns zero if nothing to add */
int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin)
{
if(items->totitem>=items->maxitem) {
items->more= 1;
return 0;
}
/* skip first items in list */
if(items->offset_i > 0) {
items->offset_i--;
return 1;
}
BLI_strncpy(items->names[items->totitem], name, items->maxstrlen);
items->pointers[items->totitem]= poin;
items->totitem++;
return 1;
}
int uiSearchBoxhHeight(void)
{
return SEARCH_ITEMS*MENU_BUTTON_HEIGHT + 2*MENU_TOP;
}
/* ar is the search box itself */
static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step)
{
uiSearchboxData *data= ar->regiondata;
/* apply step */
data->active+= step;
if(data->items.totitem==0)
data->active= 0;
else if(data->active > data->items.totitem) {
if(data->items.more) {
data->items.offset++;
data->active= data->items.totitem;
ui_searchbox_update(C, ar, but, 0);
}
else
data->active= data->items.totitem;
}
else if(data->active < 1) {
if(data->items.offset) {
data->items.offset--;
data->active= 1;
ui_searchbox_update(C, ar, but, 0);
}
else if(data->active < 0)
data->active= 0;
}
ED_region_tag_redraw(ar);
}
static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
{
int buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_TOP)/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_TOP - itemnr*buth;
rect->ymin= rect->ymax - buth;
}
/* string validated to be of correct length (but->hardmax) */
void ui_searchbox_apply(uiBut *but, ARegion *ar)
{
uiSearchboxData *data= ar->regiondata;
but->func_arg2= NULL;
if(data->active) {
char *name= data->items.names[data->active-1];
char *cpoin= strchr(name, '|');
if(cpoin) cpoin[0]= 0;
BLI_strncpy(but->editstr, name, data->items.maxstrlen);
if(cpoin) cpoin[0]= '|';
but->func_arg2= data->items.pointers[data->active-1];
}
}
void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event)
{
uiSearchboxData *data= ar->regiondata;
switch(event->type) {
case UPARROWKEY:
ui_searchbox_select(C, ar, but, -1);
break;
case DOWNARROWKEY:
ui_searchbox_select(C, ar, but, 1);
break;
case MOUSEMOVE:
if(BLI_in_rcti(&ar->winrct, event->x, event->y)) {
rcti rect;
int a;
for(a=0; a<data->items.totitem; a++) {
ui_searchbox_butrect(&rect, data, a);
if(BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) {
if( data->active!= a+1) {
data->active= a+1;
ui_searchbox_select(C, ar, but, 0);
break;
}
}
}
}
break;
}
}
/* ar is the search box itself */
void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset)
{
uiSearchboxData *data= ar->regiondata;
/* reset vars */
data->items.totitem= 0;
data->items.more= 0;
if(reset==0)
data->items.offset_i= data->items.offset;
else {
data->items.offset_i= data->items.offset= 0;
data->active= 0;
}
/* callback */
if(but->search_func)
but->search_func(C, but->search_arg, but->editstr, &data->items);
if(reset) {
int a;
/* handle case where editstr is equal to one of items */
for(a=0; a<data->items.totitem; a++) {
char *cpoin= strchr(data->items.names[a], '|');
if(cpoin) cpoin[0]= 0;
if(0==strcmp(but->editstr, data->items.names[a]))
data->active= a+1;
if(cpoin) cpoin[0]= '|';
}
}
/* validate selected item */
ui_searchbox_select(C, ar, but, 0);
ED_region_tag_redraw(ar);
}
static void ui_searchbox_region_draw(const bContext *C, ARegion *ar)
{
uiSearchboxData *data= ar->regiondata;
/* pixel space */
wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f);
if(!data->noback)
ui_draw_search_back(U.uistyles.first, NULL, &data->bbox);
/* draw text */
if(data->items.totitem) {
rcti rect;
int a;
/* draw items */
for(a=0; a<data->items.totitem; a++) {
ui_searchbox_butrect(&rect, data, a);
ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], (a+1)==data->active?UI_ACTIVE:0);
}
/* indicate more */
if(data->items.more) {
glEnable(GL_BLEND);
UI_icon_draw((data->bbox.xmax-data->bbox.xmin)/2, 8, ICON_TRIA_DOWN);
glDisable(GL_BLEND);
}
if(data->items.offset) {
glEnable(GL_BLEND);
UI_icon_draw((data->bbox.xmax-data->bbox.xmin)/2, data->bbox.ymax-13, ICON_TRIA_UP);
glDisable(GL_BLEND);
}
}
}
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;
/* special case, hardcoded feature, not draw backdrop when called from menus,
assume for design that popup already added it */
if(but->block->flag & UI_BLOCK_LOOP)
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();
/* 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;
/* 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 */
@@ -703,8 +1056,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
/* get winmat now that we actually have the subwindow */
wmSubWindowSet(window, ar->swinid);
// XXX ton, AA pixel space...
wmOrtho2(0.0, (float)ar->winrct.xmax-ar->winrct.xmin+1, 0.0, (float)ar->winrct.ymax-ar->winrct.ymin+1);
wm_subwindow_getmatrix(window, ar->swinid, block->winmat);
@@ -716,7 +1067,9 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle)
{
ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region);
/* XXX ton added, chrash on load file with popup open... need investigate */
if(CTX_wm_screen(C))
ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region);
MEM_freeN(handle);
}

View File

@@ -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);

View File

@@ -240,33 +240,16 @@ void uiTemplateHeaderID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr
#define ERROR_LIBDATA_MESSAGE "Can't edit external libdata"
#define B_NOP 0
#define B_MODIFIER_RECALC 1
#define B_MODIFIER_REDRAW 2
#define B_CHANGEDEP 3
#define B_ARM_RECALCDATA 4
#include <string.h>
#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "BKE_bmesh.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_lattice.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_particle.h"
@@ -280,33 +263,20 @@ void uiTemplateHeaderID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr
#include "ED_object.h"
void do_modifier_panels(bContext *C, void *arg, int event)
{
Scene *scene= CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
switch(event) {
case B_MODIFIER_REDRAW:
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
break;
case B_MODIFIER_RECALC:
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
object_handle_update(scene, ob);
// XXX countall();
break;
}
}
static void modifiers_del(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
Object *ob= ob_v;
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
if(ED_object_modifier_delete(&reports, ob_v, md_v))
if(ED_object_modifier_delete(&reports, ob_v, md_v)) {
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
ED_undo_push(C, "Delete modifier");
}
else
uiPupMenuReports(C, &reports);
@@ -315,12 +285,18 @@ static void modifiers_del(bContext *C, void *ob_v, void *md_v)
static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
Object *ob= ob_v;
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
if(ED_object_modifier_move_up(&reports, ob_v, md_v))
if(ED_object_modifier_move_up(&reports, ob_v, md_v)) {
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
ED_undo_push(C, "Move modifier");
}
else
uiPupMenuReports(C, &reports);
@@ -329,12 +305,18 @@ static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v)
static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
Object *ob= ob_v;
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
if(ED_object_modifier_move_down(&reports, ob_v, md_v))
if(ED_object_modifier_move_down(&reports, ob_v, md_v)) {
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
ED_undo_push(C, "Move modifier");
}
else
uiPupMenuReports(C, &reports);
@@ -344,12 +326,17 @@ static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v)
static void modifiers_convertParticles(bContext *C, void *obv, void *mdv)
{
Scene *scene= CTX_data_scene(C);
Object *ob= obv;
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
if(ED_object_modifier_convert(&reports, scene, obv, mdv))
if(ED_object_modifier_convert(&reports, scene, obv, mdv)) {
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
ED_undo_push(C, "Convert particles to mesh object(s).");
}
else
uiPupMenuReports(C, &reports);
@@ -359,12 +346,17 @@ static void modifiers_convertParticles(bContext *C, void *obv, void *mdv)
static void modifiers_applyModifier(bContext *C, void *obv, void *mdv)
{
Scene *scene= CTX_data_scene(C);
Object *ob= obv;
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
if(ED_object_modifier_apply(&reports, scene, obv, mdv))
if(ED_object_modifier_apply(&reports, scene, obv, mdv)) {
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
ED_undo_push(C, "Apply modifier");
}
else
uiPupMenuReports(C, &reports);
@@ -373,12 +365,17 @@ static void modifiers_applyModifier(bContext *C, void *obv, void *mdv)
static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
Object *ob= ob_v;
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
if(ED_object_modifier_copy(&reports, ob_v, md_v))
if(ED_object_modifier_copy(&reports, ob_v, md_v)) {
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
ED_undo_push(C, "Copy modifier");
}
else
uiPupMenuReports(C, &reports);
@@ -387,21 +384,27 @@ static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v)
static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
Object *ob = ob_v;
ModifierData *md;
int i, cageIndex = modifiers_getCageIndex(ob, NULL );
for( i = 0, md=ob->modifiers.first; md; ++i, md=md->next )
if( md == md_v ) {
if( i >= cageIndex )
for(i = 0, md=ob->modifiers.first; md; ++i, md=md->next) {
if(md == md_v) {
if(i >= cageIndex)
md->mode ^= eModifierMode_OnCage;
break;
}
}
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
Object *ob = ob_v;
ModifierData *md = md_v;
ModifierData *nmd = modifier_new(md->type);
@@ -413,169 +416,56 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
ob->partype = PAROBJECT;
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
ED_undo_push(C, "Modifier convert to real");
}
#if 0
static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v)
static int modifier_can_delete(ModifierData *md)
{
Object *ob = ob_v;
ModifierData *md = md_v;
HookModifierData *hmd = (HookModifierData*) md;
if (hmd->object) {
Mat4Invert(hmd->object->imat, hmd->object->obmat);
Mat4MulSerie(hmd->parentinv, hmd->object->imat, ob->obmat, NULL, NULL, NULL, NULL, NULL, NULL);
ED_undo_push(C, "Clear hook offset");
}
}
// deletion over the deflection panel
// fluid particle modifier can't be deleted here
static void modifiers_cursorHookCenter(bContext *C, void *ob_v, void *md_v)
{
/* XXX
Object *ob = ob_v;
ModifierData *md = md_v;
HookModifierData *hmd = (HookModifierData*) md;
if(G.vd) {
float *curs = give_cursor();
float bmat[3][3], imat[3][3];
where_is_object(ob);
Mat3CpyMat4(bmat, ob->obmat);
Mat3Inv(imat, bmat);
curs= give_cursor();
hmd->cent[0]= curs[0]-ob->obmat[3][0];
hmd->cent[1]= curs[1]-ob->obmat[3][1];
hmd->cent[2]= curs[2]-ob->obmat[3][2];
Mat3MulVecfl(imat, hmd->cent);
ED_undo_push(C, "Hook cursor center");
}*/
}
static void modifiers_selectHook(bContext *C, void *ob_v, void *md_v)
{
/* XXX ModifierData *md = md_v;
HookModifierData *hmd = (HookModifierData*) md;
hook_select(hmd);*/
}
static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v)
{
/* XXX ModifierData *md = md_v;
HookModifierData *hmd = (HookModifierData*) md;
float cent[3];
int *indexar, tot, ok;
char name[32];
ok= hook_getIndexArray(&tot, &indexar, name, cent);
if (!ok) {
uiPupMenuError(C, "Requires selected vertices or active Vertex Group");
} else {
if (hmd->indexar) {
MEM_freeN(hmd->indexar);
}
VECCOPY(hmd->cent, cent);
hmd->indexar = indexar;
hmd->totindex = tot;
}*/
}
static void modifiers_bindMeshDeform(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
MeshDeformModifierData *mmd = (MeshDeformModifierData*) md_v;
Object *ob = (Object*)ob_v;
if(mmd->bindcos) {
if(mmd->bindweights) MEM_freeN(mmd->bindweights);
if(mmd->bindcos) MEM_freeN(mmd->bindcos);
if(mmd->dyngrid) MEM_freeN(mmd->dyngrid);
if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
if(mmd->dynverts) MEM_freeN(mmd->dynverts);
mmd->bindweights= NULL;
mmd->bindcos= NULL;
mmd->dyngrid= NULL;
mmd->dyninfluences= NULL;
mmd->dynverts= NULL;
mmd->totvert= 0;
mmd->totcagevert= 0;
mmd->totinfluence= 0;
}
else {
DerivedMesh *dm;
int mode= mmd->modifier.mode;
/* force modifier to run, it will call binding routine */
mmd->needbind= 1;
mmd->modifier.mode |= eModifierMode_Realtime;
if(ob->type == OB_MESH) {
dm= mesh_create_derived_view(scene, ob, 0);
dm->release(dm);
}
else if(ob->type == OB_LATTICE) {
lattice_calc_modifiers(scene, ob);
}
else if(ob->type==OB_MBALL) {
makeDispListMBall(scene, ob);
}
else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
makeDispListCurveTypes(scene, ob, 0);
}
mmd->needbind= 0;
mmd->modifier.mode= mode;
}
}
void modifiers_explodeFacepa(bContext *C, void *arg1, void *arg2)
{
ExplodeModifierData *emd=arg1;
emd->flag |= eExplodeFlag_CalcFaces;
}
void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2)
{
ExplodeModifierData *emd=arg1;
emd->vgroup = 0;
}
#endif
static int modifier_is_fluid_particles(ModifierData *md)
{
if(md->type == eModifierType_ParticleSystem) {
if(md->type==eModifierType_Fluidsim)
return 0;
if(md->type==eModifierType_Collision)
return 0;
if(md->type==eModifierType_Surface)
return 0;
if(md->type == eModifierType_ParticleSystem)
if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID)
return 1;
}
return 0;
return 0;
return 1;
}
static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex)
{
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
PointerRNA ptr;
uiBut *but;
uiBlock *block;
uiLayout *column, *row, *result= NULL;
uiLayout *column, *row, *subrow, *result= NULL;
int isVirtual = md->mode&eModifierMode_Virtual;
int x = 0, y = 0; // XXX , color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
// XXX short color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
short width = 295, buttonWidth = width-120-10;
char str[128];
RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
column= uiLayoutColumn(layout, 1);
uiLayoutSetContextPointer(column, "modifier", &ptr);
/* rounded header */
/* XXX uiBlockSetCol(block, color); */
/* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
block= uiLayoutFreeBlock(uiLayoutBox(column));
uiBlockSetHandleFunc(block, do_modifier_panels, NULL);
row= uiLayoutRow(uiLayoutBox(column), 0);
block= uiLayoutGetBlock(row);
subrow= uiLayoutRow(row, 0);
uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
//uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 25, NULL, 7.0, 0.0,
// (!isVirtual && (md->mode&eModifierMode_Expanded))?3:15, 20, "");
@@ -584,27 +474,27 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
/* open/close icon */
if (!isVirtual) {
uiBlockSetEmboss(block, UI_EMBOSSN);
uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, B_MODIFIER_REDRAW, ICON_TRIA_RIGHT, x-10, y-2, 20, 20, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, 0, ICON_TRIA_RIGHT, 0, 0, UI_UNIT_X, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
}
uiBlockSetEmboss(block, UI_EMBOSS);
if (isVirtual) {
sprintf(str, "%s parent deform", md->name);
uiDefBut(block, LABEL, 0, str, x+10, y-1, width-110, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name");
uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name");
but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Make Real", x+width-100, y, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier");
but = uiDefBut(block, BUT, 0, "Make Real", 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier");
uiButSetFunc(but, modifiers_convertToReal, ob, md);
} else {
uiBlockBeginAlign(block);
uiDefBut(block, TEX, B_MODIFIER_REDRAW, "", x+10, y-1, buttonWidth-60, 19, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name");
uiDefBut(block, TEX, 0, "", 0, 0, buttonWidth-60, UI_UNIT_Y, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name");
/* Softbody not allowed in this situation, enforce! */
if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+10+buttonWidth-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, ICON_VIEW3D, x+10+buttonWidth-40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
uiDefIconButBitI(block, TOG, eModifierMode_Render, 0, ICON_SCENE, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, 0, ICON_VIEW3D, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
if (mti->flags&eModifierTypeFlag_SupportsEditmode) {
uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, ICON_EDITMODE_HLT, x+10+buttonWidth-20, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
uiDefIconButBitI(block, TOG, eModifierMode_Editmode, 0, ICON_EDITMODE_HLT, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
}
}
uiBlockEndAlign(block);
@@ -625,26 +515,28 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
icon = ICON_BLANK1;
}
/* XXX uiBlockSetCol(block, color); */
but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, icon, x+width-105, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode");
but = uiDefIconBut(block, BUT, 0, icon, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode");
uiButSetFunc(but, modifiers_setOnCage, ob, md);
/* XXX uiBlockSetCol(block, TH_AUTO); */
}
}
subrow= uiLayoutRow(row, 0);
uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
if(!isVirtual) {
/* XXX uiBlockSetCol(block, TH_BUT_ACTION); */
but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_UP, x+width-75, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack");
but = uiDefIconBut(block, BUT, 0, VICON_MOVE_UP, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack");
uiButSetFunc(but, modifiers_moveUp, ob, md);
but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_MOVE_DOWN, x+width-75+20, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
but = uiDefIconBut(block, BUT, 0, VICON_MOVE_DOWN, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
uiButSetFunc(but, modifiers_moveDown, ob, md);
uiBlockSetEmboss(block, UI_EMBOSSN);
// deletion over the deflection panel
// fluid particle modifier can't be deleted here
if(md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Collision && md->type!=eModifierType_Surface && !modifier_is_fluid_particles(md))
{
but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_X, x+width-70+40, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier");
if(modifier_can_delete(md)) {
but = uiDefIconBut(block, BUT, 0, VICON_X, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier");
uiButSetFunc(but, modifiers_del, ob, md);
}
/* XXX uiBlockSetCol(block, TH_AUTO); */
@@ -653,15 +545,11 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
uiBlockSetEmboss(block, UI_EMBOSS);
if(!isVirtual && (md->mode&eModifierMode_Expanded)) {
int cy = y - 8;
int lx = x + width - 60 - 15;
uiLayout *box;
box= uiLayoutBox(column);
row= uiLayoutRow(box, 1);
y -= 18;
if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */
@@ -670,13 +558,13 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
if(!(G.f & G_PARTICLEEDIT)) {
if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) {
but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Convert", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object");
but = uiDefBut(block, BUT, 0, "Convert", 0,0,60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object");
uiButSetFunc(but, modifiers_convertParticles, ob, md);
}
}
}
else{
but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Apply", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");
but = uiDefBut(block, BUT, 0, "Apply", 0,0,60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");
uiButSetFunc(but, modifiers_applyModifier, ob, md);
}
@@ -684,16 +572,13 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
if (md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Softbody && md->type!=eModifierType_ParticleSystem && (md->type!=eModifierType_Cloth)) {
but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Copy", lx,(cy-=19),60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack");
but = uiDefBut(block, BUT, 0, "Copy", 0,0,60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack");
uiButSetFunc(but, modifiers_copyModifier, ob, md);
}
}
result= uiLayoutColumn(box, 0);
block= uiLayoutFreeBlock(box);
lx = x + 10;
cy = y + 10 - 1;
}
if (md->error) {
@@ -886,7 +771,7 @@ static void draw_constraint_spaceselect (uiBlock *block, bConstraint *con, short
}
if ((target != -1) && (owner != -1))
uiDefIconBut(block, LABEL, B_NOP, ICON_ARROW_LEFTRIGHT,
uiDefIconBut(block, LABEL, 0, ICON_ARROW_LEFTRIGHT,
iconx, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "");
/* Owner-Space */
@@ -906,8 +791,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
bPoseChannel *pchan= get_active_posechannel(ob);
bConstraintTypeInfo *cti;
uiBlock *block;
uiLayout *result= NULL, *col, *box;
uiLayout *result= NULL, *col, *box, *row, *subrow;
uiBut *but;
PointerRNA ptr;
char typestr[32];
short width = 265;
short proxy_protected, xco=0, yco=0;
@@ -936,11 +822,19 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
uiBlockSetHandleFunc(block, do_constraint_panels, NULL);
uiBlockSetFunc(block, constraint_active_func, ob, con);
RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr);
col= uiLayoutColumn(layout, 1);
uiLayoutSetContextPointer(col, "constraint", &ptr);
box= uiLayoutBox(col);
row= uiLayoutRow(box, 0);
block= uiLayoutFreeBlock(box);
subrow= uiLayoutRow(row, 0);
uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
/* Draw constraint header */
uiBlockSetEmboss(block, UI_EMBOSSN);
@@ -974,6 +868,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
}
// XXX uiBlockSetCol(block, TH_AUTO);
subrow= uiLayoutRow(row, 0);
uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
/* proxy-protected constraints cannot be edited, so hide up/down + close buttons */
if (proxy_protected) {
@@ -1141,101 +1038,11 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
}
break;
*/
case CONSTRAINT_TYPE_KINEMATIC:
/*case CONSTRAINT_TYPE_RIGIDBODYJOINT:
{
bKinematicConstraint *data = con->data;
/* IK Target */
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco, yco-24, 80, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
/* Draw target parameters */
uiBlockBeginAlign(block);
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco, yco-44, 137, 19, &data->tar, "Target Object");
if (is_armature_target(data->tar)) {
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco, yco-62,137,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
}
else if (is_geom_target(data->tar)) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco, yco-62,137,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
uiBlockEndAlign(block);
/* Settings */
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, CONSTRAINT_IK_TIP, B_CONSTRAINT_TEST, "Use Tail", xco, yco-92, 137, 19, &data->flag, 0, 0, 0, 0, "Include Bone's tail also last element in Chain");
uiDefButS(block, NUM, B_CONSTRAINT_TEST, "ChainLen:", xco, yco-112,137,19, &data->rootbone, 0, 255, 0, 0, "If not zero, the amount of bones in this chain");
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "PosW ", xco+147, yco-92, 137, 19, &data->weight, 0.01, 1.0, 2, 2, "For Tree-IK: weight of position control for this target");
uiDefButBitS(block, TOG, CONSTRAINT_IK_ROT, B_CONSTRAINT_TEST, "Rot", xco+147, yco-112, 40,19, &data->flag, 0, 0, 0, 0, "Chain follows rotation of target");
uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "W ", xco+187, yco-112, 97, 19, &data->orientweight, 0.01, 1.0, 2, 2, "For Tree-IK: Weight of orientation control for this target");
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, CONSTRAINT_IK_STRETCH, B_CONSTRAINT_TEST, "Stretch", xco, yco-137,137,19, &data->flag, 0, 0, 0, 0, "Enable IK stretching");
uiBlockBeginAlign(block);
uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", xco+147, yco-137, 137, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations");
uiBlockEndAlign(block);
/* Pole Vector */
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Pole Target:", xco+147, yco-24, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
uiBlockBeginAlign(block);
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+147, yco-44, 137, 19, &data->poletar, "Pole Target Object");
if (is_armature_target(data->poletar)) {
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+147, yco-62,137,19, &data->polesubtarget, 0, 24, 0, 0, "Pole Subtarget Bone");
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->poletar);
}
else if (is_geom_target(data->poletar)) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+147, yco-62,137,18, &data->polesubtarget, 0, 24, 0, 0, "Name of Vertex Group defining pole 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->poletar);
}
else {
strcpy(data->polesubtarget, "");
}
if (data->poletar) {
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pole Offset ", xco, yco-167, 137, 19, &data->poleangle, -180.0, 180.0, 0, 0, "Pole rotation offset");
}
}
break;
case CONSTRAINT_TYPE_RIGIDBODYJOINT:
{
bRigidBodyJointConstraint *data = con->data;
float extremeLin = 999.f;
float extremeAngX = 180.f;
float extremeAngY = 45.f;
float extremeAngZ = 45.f;
int togButWidth = 70;
int offsetY = 150;
int textButWidth = ((width/2)-togButWidth);
uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Generic 6DOF%x12",//|Extra Force%x6",
//uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic 6DOF%x12",//|Extra Force%x6",
xco, yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
uiDefButBitS(block, TOG, CONSTRAINT_DISABLE_LINKED_COLLISION, B_CONSTRAINT_TEST, "No Collision", xco+155, yco-25, 111, 18, &data->flag, 0, 24, 0, 0, "Disable Collision Between Linked Bodies");
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", xco, yco-50, 130, 18, &data->tar, "Child Object");
uiDefButBitS(block, TOG, CONSTRAINT_DRAW_PIVOT, B_CONSTRAINT_TEST, "ShowPivot", xco+135, yco-50, 130, 18, &data->flag, 0, 24, 0, 0, "Show pivot position and rotation");
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", xco, yco-75, 130, 18, &data->pivX, -1000, 1000, 100, 0.0, "Offset pivot on X");
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", xco, yco-100, 130, 18, &data->pivY, -1000, 1000, 100, 0.0, "Offset pivot on Y");
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", xco, yco-125, 130, 18, &data->pivZ, -1000, 1000, 100, 0.0, "Offset pivot on z");
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax X:", xco+135, yco-75, 130, 18, &data->axX, -360, 360, 1500, 0.0, "Rotate pivot on X Axis (in degrees)");
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Y:", xco+135, yco-100, 130, 18, &data->axY, -360, 360, 1500, 0.0, "Rotate pivot on Y Axis (in degrees)");
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Z:", xco+135, yco-125, 130, 18, &data->axZ, -360, 360, 1500, 0.0, "Rotate pivot on Z Axis (in degrees)");
if (data->type==CONSTRAINT_RB_GENERIC6DOF) {
/* Draw Pairs of LimitToggle+LimitValue */
// Draw Pairs of LimitToggle+LimitValue
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit");
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"min x limit");
@@ -1270,7 +1077,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
offsetY += 20;
}
if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) {
/* Draw Pairs of LimitToggle+LimitValue */
// Draw Pairs of LimitToggle+LimitValue /
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit");
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+togButWidth, yco-offsetY, (textButWidth-5), 18, &(data->minLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"min x limit");
@@ -1305,6 +1112,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
}
break;
*/
case CONSTRAINT_TYPE_NULL:
{
@@ -1503,3 +1311,37 @@ void uiTemplatePreview(uiLayout *layout, ID *id)
}
/********************** ColorRamp Template **************************/
void uiTemplateColorRamp(uiLayout *layout, ColorBand *coba, int expand)
{
uiBlock *block;
rctf rect;
if(coba) {
rect.xmin= 0; rect.xmax= 200;
rect.ymin= 0; rect.ymax= 190;
block= uiLayoutFreeBlock(layout);
colorband_buttons(block, coba, &rect, !expand);
}
}
/********************* CurveMapping Template ************************/
#include "DNA_color_types.h"
void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type)
{
uiBlock *block;
rctf rect;
if(cumap) {
rect.xmin= 0; rect.xmax= 200;
rect.ymin= 0; rect.ymax= 190;
block= uiLayoutFreeBlock(layout);
curvemap_buttons(block, cumap, type, 0, 0, &rect);
}
}

View File

@@ -35,6 +35,7 @@
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_texture_types.h"
#include "DNA_windowmanager_types.h"
#include "BKE_colortools.h"
@@ -42,6 +43,7 @@
#include "BKE_idprop.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -63,186 +65,6 @@
/*************************** RNA Utilities ******************************/
int UI_GetIconRNA(PointerRNA *ptr)
{
StructRNA *rnatype= ptr->type;
if(rnatype == &RNA_Scene)
return ICON_SCENE_DATA;
else if(rnatype == &RNA_World)
return ICON_WORLD_DATA;
else if(rnatype == &RNA_Object)
return ICON_OBJECT_DATA;
else if(rnatype == &RNA_Mesh)
return ICON_MESH_DATA;
else if(rnatype == &RNA_MeshVertex)
return ICON_VERTEXSEL;
else if(rnatype == &RNA_MeshEdge)
return ICON_EDGESEL;
else if(rnatype == &RNA_MeshFace)
return ICON_FACESEL;
else if(rnatype == &RNA_MeshTextureFace)
return ICON_FACESEL_HLT;
else if(rnatype == &RNA_VertexGroup)
return ICON_GROUP_VERTEX;
else if(rnatype == &RNA_VertexGroupElement)
return ICON_GROUP_VERTEX;
else if(rnatype == &RNA_Curve)
return ICON_CURVE_DATA;
else if(rnatype == &RNA_MetaBall)
return ICON_META_DATA;
else if(rnatype == &RNA_MetaElement)
return ICON_OUTLINER_DATA_META;
else if(rnatype == &RNA_Lattice)
return ICON_LATTICE_DATA;
else if(rnatype == &RNA_Armature)
return ICON_ARMATURE_DATA;
else if(rnatype == &RNA_Bone)
return ICON_BONE_DATA;
else if(rnatype == &RNA_Camera)
return ICON_CAMERA_DATA;
else if(rnatype == &RNA_LocalLamp)
return ICON_LAMP_DATA;
else if(rnatype == &RNA_AreaLamp)
return ICON_LAMP_DATA;
else if(rnatype == &RNA_SpotLamp)
return ICON_LAMP_DATA;
else if(rnatype == &RNA_SunLamp)
return ICON_LAMP_DATA;
else if(rnatype == &RNA_HemiLamp)
return ICON_LAMP_DATA;
else if(rnatype == &RNA_Lamp)
return ICON_LAMP_DATA;
else if(rnatype == &RNA_Group)
return ICON_GROUP;
else if(rnatype == &RNA_ParticleSystem)
return ICON_PARTICLE_DATA;
else if(rnatype == &RNA_ParticleSettings)
return ICON_PARTICLE_DATA;
else if(rnatype == &RNA_Material)
return ICON_MATERIAL_DATA;
else if(rnatype == &RNA_Texture)
return ICON_TEXTURE_DATA;
else if(rnatype == &RNA_TextureSlot)
return ICON_TEXTURE_DATA;
else if(rnatype == &RNA_WorldTextureSlot)
return ICON_TEXTURE_DATA;
else if(rnatype == &RNA_MaterialTextureSlot)
return ICON_TEXTURE_DATA;
else if(rnatype == &RNA_Image)
return ICON_IMAGE_DATA;
else if(rnatype == &RNA_Screen)
return ICON_SPLITSCREEN;
else if(rnatype == &RNA_NodeTree)
return ICON_NODE;
else if(rnatype == &RNA_Text)
return ICON_TEXT;
else if(rnatype == &RNA_Sound)
return ICON_SOUND;
else if(rnatype == &RNA_Brush)
return ICON_BRUSH_DATA;
else if(rnatype == &RNA_VectorFont)
return ICON_FONT_DATA;
else if(rnatype == &RNA_Library)
return ICON_LIBRARY_DATA_DIRECT;
else if(rnatype == &RNA_Action)
return ICON_ACTION;
else if(rnatype == &RNA_FCurve)
return ICON_ANIM_DATA;
//else if(rnatype == &RNA_Ipo)
// return ICON_ANIM_DATA;
else if(rnatype == &RNA_Key)
return ICON_SHAPEKEY_DATA;
else if(rnatype == &RNA_Main)
return ICON_BLENDER;
else if(rnatype == &RNA_Struct)
return ICON_RNA;
else if(rnatype == &RNA_Property)
return ICON_RNA;
else if(rnatype == &RNA_BooleanProperty)
return ICON_RNA;
else if(rnatype == &RNA_IntProperty)
return ICON_RNA;
else if(rnatype == &RNA_FloatProperty)
return ICON_RNA;
else if(rnatype == &RNA_StringProperty)
return ICON_RNA;
else if(rnatype == &RNA_EnumProperty)
return ICON_RNA;
else if(rnatype == &RNA_EnumPropertyItem)
return ICON_RNA;
else if(rnatype == &RNA_PointerProperty)
return ICON_RNA;
else if(rnatype == &RNA_CollectionProperty)
return ICON_RNA;
else if(rnatype == &RNA_GameObjectSettings)
return ICON_GAME;
else if(rnatype == &RNA_ScriptLink)
return ICON_PYTHON;
/* modifiers */
else if(rnatype == &RNA_SubsurfModifier)
return ICON_MOD_SUBSURF;
else if(rnatype == &RNA_ArmatureModifier)
return ICON_MOD_ARMATURE;
else if(rnatype == &RNA_LatticeModifier)
return ICON_MOD_LATTICE;
else if(rnatype == &RNA_CurveModifier)
return ICON_MOD_CURVE;
else if(rnatype == &RNA_BuildModifier)
return ICON_MOD_BUILD;
else if(rnatype == &RNA_MirrorModifier)
return ICON_MOD_MIRROR;
else if(rnatype == &RNA_DecimateModifier)
return ICON_MOD_DECIM;
else if(rnatype == &RNA_WaveModifier)
return ICON_MOD_WAVE;
else if(rnatype == &RNA_HookModifier)
return ICON_HOOK;
else if(rnatype == &RNA_SoftbodyModifier)
return ICON_MOD_SOFT;
else if(rnatype == &RNA_BooleanModifier)
return ICON_MOD_BOOLEAN;
else if(rnatype == &RNA_ParticleInstanceModifier)
return ICON_MOD_PARTICLES;
else if(rnatype == &RNA_ParticleSystemModifier)
return ICON_MOD_PARTICLES;
else if(rnatype == &RNA_EdgeSplitModifier)
return ICON_MOD_EDGESPLIT;
else if(rnatype == &RNA_ArrayModifier)
return ICON_MOD_ARRAY;
else if(rnatype == &RNA_UVProjectModifier)
return ICON_MOD_UVPROJECT;
else if(rnatype == &RNA_DisplaceModifier)
return ICON_MOD_DISPLACE;
else if(rnatype == &RNA_ShrinkwrapModifier)
return ICON_MOD_SHRINKWRAP;
else if(rnatype == &RNA_CastModifier)
return ICON_MOD_CAST;
else if(rnatype == &RNA_MeshDeformModifier)
return ICON_MOD_MESHDEFORM;
else if(rnatype == &RNA_BevelModifier)
return ICON_MOD_BEVEL;
else if(rnatype == &RNA_SmoothModifier)
return ICON_MOD_SMOOTH;
else if(rnatype == &RNA_SimpleDeformModifier)
return ICON_MOD_SIMPLEDEFORM;
else if(rnatype == &RNA_MaskModifier)
return ICON_MOD_MASK;
else if(rnatype == &RNA_ClothModifier)
return ICON_MOD_CLOTH;
else if(rnatype == &RNA_ExplodeModifier)
return ICON_MOD_EXPLODE;
else if(rnatype == &RNA_CollisionModifier)
return ICON_MOD_PHYSICS;
else if(rnatype == &RNA_FluidSimulationModifier)
return ICON_MOD_FLUIDSIM;
else if(rnatype == &RNA_MultiresModifier)
return ICON_MOD_MULTIRES;
else
return ICON_DOT;
}
uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2)
{
uiBut *but=NULL;
@@ -295,7 +117,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
pptr= RNA_property_pointer_get(ptr, prop);
if(!pptr.type)
pptr.type= RNA_property_pointer_type(prop);
icon= UI_GetIconRNA(&pptr);
icon= RNA_struct_ui_icon(pptr.type);
but= uiDefIconTextButR(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
break;
@@ -1098,3 +920,128 @@ void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short
cumap, 0.0f, 1.0f, 0, 0, "");
}
#define B_BANDCOL 1
static int vergcband(const void *a1, const void *a2)
{
const CBData *x1=a1, *x2=a2;
if( x1->pos > x2->pos ) return 1;
else if( x1->pos < x2->pos) return -1;
return 0;
}
static void colorband_pos_cb(bContext *C, void *coba_v, void *unused_v)
{
ColorBand *coba= coba_v;
int a;
if(coba->tot<2) return;
for(a=0; a<coba->tot; a++) coba->data[a].cur= a;
qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
for(a=0; a<coba->tot; a++) {
if(coba->data[a].cur==coba->cur) {
// XXX if(coba->cur!=a) addqueue(curarea->win, REDRAW, 0); /* button cur */
coba->cur= a;
break;
}
}
}
static void colorband_add_cb(bContext *C, void *coba_v, void *unused_v)
{
ColorBand *coba= coba_v;
if(coba->tot < MAXCOLORBAND-1) coba->tot++;
coba->cur= coba->tot-1;
colorband_pos_cb(C, coba, NULL);
ED_undo_push(C, "Add colorband");
}
static void colorband_del_cb(bContext *C, void *coba_v, void *unused_v)
{
ColorBand *coba= coba_v;
int a;
if(coba->tot<2) return;
for(a=coba->cur; a<coba->tot; a++) {
coba->data[a]= coba->data[a+1];
}
if(coba->cur) coba->cur--;
coba->tot--;
ED_undo_push(C, "Delete colorband");
// XXX BIF_preview_changed(ID_TE);
}
/* offset aligns from bottom, standard width 300, height 115 */
static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs, int yoffs, int redraw)
{
CBData *cbd;
uiBut *bt;
if(coba==NULL) return;
bt= uiDefBut(block, BUT, redraw, "Add", 80+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Adds a new color position to the colorband");
uiButSetFunc(bt, colorband_add_cb, coba, NULL);
uiDefButS(block, NUM, redraw, "Cur:", 117+xoffs,95+yoffs,81,20, &coba->cur, 0.0, (float)(coba->tot-1), 0, 0, "Displays the active color from the colorband");
bt= uiDefBut(block, BUT, redraw, "Del", 199+xoffs,95+yoffs,37,20, 0, 0, 0, 0, 0, "Deletes the active position");
uiButSetFunc(bt, colorband_del_cb, coba, NULL);
uiDefButS(block, MENU, redraw, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
236+xoffs, 95+yoffs, 64, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Sets interpolation type");
uiDefBut(block, BUT_COLORBAND, redraw, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
cbd= coba->data + coba->cur;
uiBlockBeginAlign(block);
bt= uiDefButF(block, NUM, redraw, "Pos", xoffs,40+yoffs,110,20, &cbd->pos, 0.0, 1.0, 10, 0, "Sets the position of the active color");
uiButSetFunc(bt, colorband_pos_cb, coba, NULL);
uiDefButF(block, COL, redraw, "", xoffs,20+yoffs,110,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "");
uiDefButF(block, NUMSLI, redraw, "A ", xoffs,yoffs,110,20, &cbd->a, 0.0, 1.0, 10, 0, "Sets the alpha value for this position");
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI, redraw, "R ", 115+xoffs,40+yoffs,185,20, &cbd->r, 0.0, 1.0, B_BANDCOL, 0, "Sets the red value for the active color");
uiDefButF(block, NUMSLI, redraw, "G ", 115+xoffs,20+yoffs,185,20, &cbd->g, 0.0, 1.0, B_BANDCOL, 0, "Sets the green value for the active color");
uiDefButF(block, NUMSLI, redraw, "B ", 115+xoffs,yoffs,185,20, &cbd->b, 0.0, 1.0, B_BANDCOL, 0, "Sets the blue value for the active color");
uiBlockEndAlign(block);
}
static void colorband_buttons_small(uiBlock *block, ColorBand *coba, rctf *butr, int event)
{
CBData *cbd;
uiBut *bt;
float unit= (butr->xmax-butr->xmin)/14.0f;
float xs= butr->xmin;
cbd= coba->data + coba->cur;
uiBlockBeginAlign(block);
uiDefButF(block, COL, event, "", xs,butr->ymin+20.0f,2.0f*unit,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "");
uiDefButF(block, NUM, event, "A:", xs+2.0f*unit,butr->ymin+20.0f,4.0f*unit,20, &(cbd->a), 0.0f, 1.0f, 10, 2, "");
bt= uiDefBut(block, BUT, event, "Add", xs+6.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Adds a new color position to the colorband");
uiButSetFunc(bt, colorband_add_cb, coba, NULL);
bt= uiDefBut(block, BUT, event, "Del", xs+8.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Deletes the active position");
uiButSetFunc(bt, colorband_del_cb, coba, NULL);
uiDefButS(block, MENU, event, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
xs+10.0f*unit, butr->ymin+20.0f, unit*4, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Sets interpolation type");
uiDefBut(block, BUT_COLORBAND, event, "", xs,butr->ymin,butr->xmax-butr->xmin,20.0f, coba, 0, 0, 0, 0, "");
uiBlockEndAlign(block);
}
void colorband_buttons(uiBlock *block, ColorBand *coba, rctf *butr, int small)
{
if(small)
colorband_buttons_small(block, coba, butr, 0);
else
colorband_buttons_large(block, coba, 0, 0, 0);
}

View File

@@ -630,7 +630,8 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect)
{
float xs=0, ys=0, aspect, height;
int xs=0, ys=0;
float aspect, height;
/* this icon doesn't need draw... */
if(icon==ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU)==0) return;
@@ -663,33 +664,36 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect)
if(but->flag & UI_ICON_LEFT) {
if (but->type==BUT_TOGDUAL) {
if (but->drawstr[0]) {
xs= rect->xmin-1.0;
xs= rect->xmin-1;
} else {
xs= (rect->xmin+rect->xmax- height)/2.0;
xs= (rect->xmin+rect->xmax- height)/2;
}
}
else if (but->block->flag & UI_BLOCK_LOOP) {
xs= rect->xmin+1.0;
if(but->type==SEARCH_MENU)
xs= rect->xmin+4;
else
xs= rect->xmin+1;
}
else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) {
xs= rect->xmin+3.0;
xs= rect->xmin+3;
}
else {
xs= rect->xmin+4.0;
xs= rect->xmin+4;
}
ys= (rect->ymin+rect->ymax- height)/2.0;
ys= (rect->ymin+rect->ymax- height)/2;
}
else {
xs= (rect->xmin+rect->xmax- height)/2.0;
ys= (rect->ymin+rect->ymax- height)/2.0;
xs= (rect->xmin+rect->xmax- height)/2;
ys= (rect->ymin+rect->ymax- height)/2;
}
UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend);
}
if(but->flag & UI_ICON_SUBMENU) {
xs= rect->xmax-17.0;
ys= (rect->ymin+rect->ymax- height)/2.0;
xs= rect->xmax-17;
ys= (rect->ymin+rect->ymax- height)/2;
UI_icon_draw_aspect_blended(xs, ys, ICON_RIGHTARROW_THIN, aspect, blend);
}
@@ -844,29 +848,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);
}
}
@@ -1220,8 +1218,8 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
/* menu is 2nd level or deeper */
if (flag & UI_BLOCK_POPUP) {
rect->ymin -= 4.0;
rect->ymax += 4.0;
//rect->ymin -= 4.0;
//rect->ymax += 4.0;
}
else if (direction == UI_DOWN) {
roundboxalign= 12;
@@ -1473,7 +1471,7 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
widget_init(&wtb);
/* half rounded */
round_box_edges(&wtb, roundboxalign, rect, 4.0f);
round_box_edges(&wtb, roundboxalign, rect, 5.0f);
widgetbase_draw(&wtb, wcol);
@@ -1827,6 +1825,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 +1917,60 @@ void ui_draw_menu_back(uiStyle *style, uiBlock *block, rcti *rect)
}
void ui_draw_search_back(uiStyle *style, uiBlock *block, rcti *rect)
{
uiWidgetType *wt= widget_type(UI_WTYPE_BOX);
glEnable(GL_BLEND);
widget_softshadow(rect, 15, 5.0f, 8.0f);
glDisable(GL_BLEND);
wt->state(wt, 0);
if(block)
wt->draw(&wt->wcol, rect, block->flag, 15);
else
wt->draw(&wt->wcol, rect, 0, 15);
}
/* 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;
rect->xmax -= BLF_width(cpoin+1) + 10;
}
glColor3ubv(wt->wcol.text);
uiStyleFontDraw(fstyle, rect, name);
/* part text right aligned */
if(cpoin) {
fstyle->align= UI_STYLE_TEXT_RIGHT;
rect->xmax= _rect.xmax - 5;
uiStyleFontDraw(fstyle, rect, cpoin+1);
*cpoin= '|';
}
/* restore rect, was messed with */
*rect= _rect;
}