forked from bartvdbraak/blender
UI:
* Added context pointer to function callbacks for buttons and blocks. * Added a uiBlockSetHandleFunc, which will be called with the button return value. This seems kind of redundant with uiBlockSetButmFunc, but the latter uses a2 to pass the value.
This commit is contained in:
parent
64f9c67ca8
commit
f00a75272e
@ -275,7 +275,7 @@ uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int i
|
|||||||
uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
|
uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
|
||||||
uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
|
uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
|
||||||
|
|
||||||
typedef void (*uiIDPoinFuncFP) (char *str, struct ID **idpp);
|
typedef void (*uiIDPoinFuncFP) (struct bContext *C, char *str, struct ID **idpp);
|
||||||
uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
|
uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
|
||||||
short x1, short y1, short x2, short y2, void *idpp, char *tip);
|
short x1, short y1, short x2, short y2, void *idpp, char *tip);
|
||||||
|
|
||||||
@ -288,7 +288,6 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int retv
|
|||||||
void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
|
void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
|
||||||
|
|
||||||
uiBut *uiDefRNABut(uiBlock *block, int retval, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, short x1, short y1, short x2, short y2);
|
uiBut *uiDefRNABut(uiBlock *block, int retval, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, short x1, short y1, short x2, short y2);
|
||||||
void uiButSetFunc3(uiBut *but, void (*func)(void *arg1, void *arg2, void *arg3), void *arg1, void *arg2, void *arg3);
|
|
||||||
|
|
||||||
void uiAutoBlock(struct uiBlock *block,
|
void uiAutoBlock(struct uiBlock *block,
|
||||||
float minx, float miny,
|
float minx, float miny,
|
||||||
@ -315,14 +314,15 @@ int uiButGetRetVal (uiBut *but);
|
|||||||
void uiButSetFlag (uiBut *but, int flag);
|
void uiButSetFlag (uiBut *but, int flag);
|
||||||
void uiButClearFlag (uiBut *but, int flag);
|
void uiButClearFlag (uiBut *but, int flag);
|
||||||
|
|
||||||
void uiBlockSetButmFunc (uiBlock *block, void (*butmfunc)(void *arg, int but_a2), void *arg);
|
void uiBlockSetHandleFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg, int event), void *arg);
|
||||||
|
void uiBlockSetButmFunc (uiBlock *block, void (*func)(struct bContext *C, void *arg, int but_a2), void *arg);
|
||||||
|
|
||||||
void uiBlockSetFunc (uiBlock *block, void (*func)(void *arg1, void *arg2), void *arg1, void *arg2);
|
void uiBlockSetFunc (uiBlock *block, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2);
|
||||||
void uiButSetFunc (uiBut *but, void (*func)(void *arg1, void *arg2), void *arg1, void *arg2);
|
void uiButSetFunc (uiBut *but, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2);
|
||||||
|
|
||||||
void uiButSetCompleteFunc(uiBut *but, void (*func)(char *str, void *arg), void *arg);
|
void uiButSetCompleteFunc(uiBut *but, void (*func)(struct bContext *C, char *str, void *arg), void *arg);
|
||||||
|
|
||||||
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct ScrArea *sa, uiBlock *block));
|
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct bContext *C, uiBlock *block));
|
||||||
|
|
||||||
/* Panels */
|
/* Panels */
|
||||||
|
|
||||||
|
@ -421,7 +421,6 @@ static int ui_but_equals_old(uiBut *but, uiBut *oldbut)
|
|||||||
if(but->func != oldbut->func) return 0;
|
if(but->func != oldbut->func) return 0;
|
||||||
if(but->func_arg1 != oldbut->func_arg1) return 0;
|
if(but->func_arg1 != oldbut->func_arg1) return 0;
|
||||||
if(but->func_arg2 != oldbut->func_arg2) return 0;
|
if(but->func_arg2 != oldbut->func_arg2) return 0;
|
||||||
if(but->func_arg3 != oldbut->func_arg3) return 0;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1942,15 +1941,15 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
|
|||||||
|
|
||||||
if(block->themecol==TH_AUTO) but->themecol= ui_auto_themecol(but);
|
if(block->themecol==TH_AUTO) but->themecol= ui_auto_themecol(but);
|
||||||
else but->themecol= block->themecol;
|
else but->themecol= block->themecol;
|
||||||
|
|
||||||
if (but->type==BUTM) {
|
if(but->type != BUTM) {
|
||||||
but->butm_func= block->butm_func;
|
|
||||||
but->butm_func_arg= block->butm_func_arg;
|
|
||||||
} else {
|
|
||||||
but->func= block->func;
|
but->func= block->func;
|
||||||
but->func_arg1= block->func_arg1;
|
but->func_arg1= block->func_arg1;
|
||||||
but->func_arg2= block->func_arg2;
|
but->func_arg2= block->func_arg2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
but->handle_func= block->handle_func;
|
||||||
|
but->handle_func_arg= block->handle_func_arg;
|
||||||
|
|
||||||
ui_set_embossfunc(but, block->dt);
|
ui_set_embossfunc(but, block->dt);
|
||||||
|
|
||||||
@ -2075,7 +2074,7 @@ void autocomplete_end(AutoComplete *autocpl, char *autoname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* autocomplete callback for ID buttons */
|
/* autocomplete callback for ID buttons */
|
||||||
static void autocomplete_id(char *str, void *arg_v)
|
static void autocomplete_id(bContext *C, char *str, void *arg_v)
|
||||||
{
|
{
|
||||||
/* int blocktype= (intptr_t)arg_v; */
|
/* int blocktype= (intptr_t)arg_v; */
|
||||||
ListBase *listb= NULL /* XXX 2.50 needs context, wich_libbase(G.main, blocktype) */;
|
ListBase *listb= NULL /* XXX 2.50 needs context, wich_libbase(G.main, blocktype) */;
|
||||||
@ -2468,14 +2467,19 @@ int uiButGetRetVal(uiBut *but)
|
|||||||
return but->retval;
|
return but->retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call this function BEFORE adding buttons to the block */
|
void uiBlockSetHandleFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg, int event), void *arg)
|
||||||
void uiBlockSetButmFunc(uiBlock *block, void (*menufunc)(void *arg, int event), void *arg)
|
|
||||||
{
|
{
|
||||||
block->butm_func= menufunc;
|
block->handle_func= func;
|
||||||
|
block->handle_func_arg= arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiBlockSetButmFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg, int but_a2), void *arg)
|
||||||
|
{
|
||||||
|
block->butm_func= func;
|
||||||
block->butm_func_arg= arg;
|
block->butm_func_arg= arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiBlockSetFunc(uiBlock *block, void (*func)(void *arg1, void *arg2), void *arg1, void *arg2)
|
void uiBlockSetFunc(uiBlock *block, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2)
|
||||||
{
|
{
|
||||||
block->func= func;
|
block->func= func;
|
||||||
block->func_arg1= arg1;
|
block->func_arg1= arg1;
|
||||||
@ -2487,22 +2491,14 @@ void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)())
|
|||||||
block->drawextra= func;
|
block->drawextra= func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiButSetFunc(uiBut *but, void (*func)(void *arg1, void *arg2), void *arg1, void *arg2)
|
void uiButSetFunc(uiBut *but, void (*func)(struct bContext *C, void *arg1, void *arg2), void *arg1, void *arg2)
|
||||||
{
|
{
|
||||||
but->func= func;
|
but->func= func;
|
||||||
but->func_arg1= arg1;
|
but->func_arg1= arg1;
|
||||||
but->func_arg2= arg2;
|
but->func_arg2= arg2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiButSetFunc3(uiBut *but, void (*func)(void *arg1, void *arg2, void *arg3), void *arg1, void *arg2, void *arg3)
|
void uiButSetCompleteFunc(uiBut *but, void (*func)(struct bContext *C, char *str, void *arg), void *arg)
|
||||||
{
|
|
||||||
but->func3= func;
|
|
||||||
but->func_arg1= arg1;
|
|
||||||
but->func_arg2= arg2;
|
|
||||||
but->func_arg3= arg3;
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiButSetCompleteFunc(uiBut *but, void (*func)(char *str, void *arg), void *arg)
|
|
||||||
{
|
{
|
||||||
but->autocomplete_func= func;
|
but->autocomplete_func= func;
|
||||||
but->autofunc_arg= arg;
|
but->autofunc_arg= arg;
|
||||||
|
@ -125,16 +125,17 @@ struct uiBut {
|
|||||||
float a1, a2, hsv[3]; // hsv is temp memory for hsv buttons
|
float a1, a2, hsv[3]; // hsv is temp memory for hsv buttons
|
||||||
float aspect;
|
float aspect;
|
||||||
|
|
||||||
void (*func)(void *, void *);
|
void (*func)(struct bContext*, void *, void *);
|
||||||
void (*func3)(void *, void *, void *); /* XXX remove */
|
|
||||||
void *func_arg1;
|
void *func_arg1;
|
||||||
void *func_arg2;
|
void *func_arg2;
|
||||||
void *func_arg3; /* XXX remove */
|
|
||||||
|
void (*handle_func)(struct bContext*, void *arg, int event);
|
||||||
|
void *handle_func_arg;
|
||||||
|
|
||||||
void (*embossfunc)(int , int , float, float, float, float, float, int);
|
void (*embossfunc)(int , int , float, float, float, float, float, int);
|
||||||
void (*sliderfunc)(int , float, float, float, float, float, float, int);
|
void (*sliderfunc)(int , float, float, float, float, float, float, int);
|
||||||
|
|
||||||
void (*autocomplete_func)(char *, void *);
|
void (*autocomplete_func)(struct bContext*, char *, void *);
|
||||||
void *autofunc_arg;
|
void *autofunc_arg;
|
||||||
|
|
||||||
uiLink *link;
|
uiLink *link;
|
||||||
@ -156,10 +157,6 @@ struct uiBut {
|
|||||||
/* BLOCK data */
|
/* BLOCK data */
|
||||||
uiBlockFuncFP block_func;
|
uiBlockFuncFP block_func;
|
||||||
|
|
||||||
/* BUTM data */
|
|
||||||
void (*butm_func)(void *arg, int event);
|
|
||||||
void *butm_func_arg;
|
|
||||||
|
|
||||||
/* RNA */
|
/* RNA */
|
||||||
struct PointerRNA rnapoin;
|
struct PointerRNA rnapoin;
|
||||||
struct PropertyRNA *rnaprop;
|
struct PropertyRNA *rnaprop;
|
||||||
@ -192,12 +189,15 @@ struct uiBlock {
|
|||||||
float minx, miny, maxx, maxy;
|
float minx, miny, maxx, maxy;
|
||||||
float aspect;
|
float aspect;
|
||||||
|
|
||||||
void (*butm_func)(void *arg, int event);
|
void (*func)(struct bContext*, void *arg1, void *arg2);
|
||||||
void *butm_func_arg;
|
|
||||||
|
|
||||||
void (*func)(void *arg1, void *arg2);
|
|
||||||
void *func_arg1;
|
void *func_arg1;
|
||||||
void *func_arg2;
|
void *func_arg2;
|
||||||
|
|
||||||
|
void (*butm_func)(struct bContext*, void *arg, int but_a2);
|
||||||
|
void *butm_func_arg;
|
||||||
|
|
||||||
|
void (*handle_func)(struct bContext*, void *arg, int event);
|
||||||
|
void *handle_func_arg;
|
||||||
|
|
||||||
/* extra draw function for custom blocks */
|
/* extra draw function for custom blocks */
|
||||||
void (*drawextra)();
|
void (*drawextra)();
|
||||||
|
@ -139,32 +139,39 @@ static int ui_handler_window(bContext *C, wmEvent *event);
|
|||||||
|
|
||||||
/* ********************** button apply/revert ************************ */
|
/* ********************** button apply/revert ************************ */
|
||||||
|
|
||||||
static void ui_apply_but_func(uiBut *but)
|
static void ui_apply_but_func(bContext *C, uiBut *but)
|
||||||
{
|
{
|
||||||
if (but->func)
|
uiBlock *block= but->block;
|
||||||
but->func(but->func_arg1, but->func_arg2);
|
|
||||||
if(but->func3)
|
if(but->func)
|
||||||
but->func3(but->func_arg1, but->func_arg2, but->func_arg3);
|
but->func(C, but->func_arg1, but->func_arg2);
|
||||||
|
|
||||||
|
if(block) {
|
||||||
|
if(block->handle_func)
|
||||||
|
block->handle_func(C, block->handle_func_arg, but->retval);
|
||||||
|
if(but->type == BUTM && block->butm_func)
|
||||||
|
block->butm_func(C, block->butm_func_arg, but->a2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_BUT(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
|
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_BUTM(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
ui_set_but_val(but, but->min);
|
ui_set_but_val(but, but->min);
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
|
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_BLOCK(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
if(but->type == COL)
|
if(but->type == COL)
|
||||||
ui_set_but_vectorf(but, data->vec);
|
ui_set_but_vectorf(but, data->vec);
|
||||||
@ -172,12 +179,12 @@ static void ui_apply_but_BLOCK(uiBut *but, uiHandleButtonData *data)
|
|||||||
ui_set_but_val(but, data->value);
|
ui_set_but_val(but, data->value);
|
||||||
|
|
||||||
ui_check_but(but);
|
ui_check_but(but);
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_TOG(uiBlock *block, uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_TOG(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
double value;
|
double value;
|
||||||
int w, lvalue, push;
|
int w, lvalue, push;
|
||||||
@ -230,22 +237,22 @@ static void ui_apply_but_TOG(uiBlock *block, uiBut *but, uiHandleButtonData *dat
|
|||||||
but->poin -= 4;
|
but->poin -= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
|
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_ROW(uiBlock *block, uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
ui_set_but_val(but, but->max);
|
ui_set_but_val(but, but->max);
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
|
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_TEX(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
if(!data->str)
|
if(!data->str)
|
||||||
return;
|
return;
|
||||||
@ -256,14 +263,14 @@ static void ui_apply_but_TEX(uiBut *but, uiHandleButtonData *data)
|
|||||||
/* give butfunc the original text too */
|
/* give butfunc the original text too */
|
||||||
/* feature used for bone renaming, channels, etc */
|
/* feature used for bone renaming, channels, etc */
|
||||||
if(but->func_arg2==NULL) but->func_arg2= data->origstr;
|
if(but->func_arg2==NULL) but->func_arg2= data->origstr;
|
||||||
ui_apply_but_func(but);
|
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->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_NUM(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
if(data->str) {
|
if(data->str) {
|
||||||
/* XXX 2.50 missing python api */
|
/* XXX 2.50 missing python api */
|
||||||
@ -289,20 +296,20 @@ static void ui_apply_but_NUM(uiBut *but, uiHandleButtonData *data)
|
|||||||
|
|
||||||
ui_set_but_val(but, data->value);
|
ui_set_but_val(but, data->value);
|
||||||
ui_check_but(but);
|
ui_check_but(but);
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
|
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_LABEL(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_LABEL(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_TOG3(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_TOG3(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
if(but->pointype==SHO ) {
|
if(but->pointype==SHO ) {
|
||||||
short *sp= (short *)but->poin;
|
short *sp= (short *)but->poin;
|
||||||
@ -330,54 +337,54 @@ static void ui_apply_but_TOG3(uiBut *but, uiHandleButtonData *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui_check_but(but);
|
ui_check_but(but);
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_VEC(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_VEC(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
ui_set_but_vectorf(but, data->vec);
|
ui_set_but_vectorf(but, data->vec);
|
||||||
ui_check_but(but);
|
ui_check_but(but);
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
|
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_COLORBAND(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_COLORBAND(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_CURVE(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_CURVE(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_apply_but_IDPOIN(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_IDPOIN(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
but->idpoin_func(data->str, but->idpoin_idpp);
|
but->idpoin_func(C, data->str, but->idpoin_idpp);
|
||||||
ui_check_but(but);
|
ui_check_but(but);
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef INTERNATIONAL
|
#ifdef INTERNATIONAL
|
||||||
static void ui_apply_but_CHARTAB(uiBut *but, uiHandleButtonData *data)
|
static void ui_apply_but_CHARTAB(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
ui_apply_but_func(but);
|
ui_apply_but_func(C, but);
|
||||||
data->retval= but->retval;
|
data->retval= but->retval;
|
||||||
data->applied= 1;
|
data->applied= 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ui_apply_button(uiBlock *block, uiBut *but, uiHandleButtonData *data, int interactive)
|
static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, int interactive)
|
||||||
{
|
{
|
||||||
char *editstr;
|
char *editstr;
|
||||||
double *editval;
|
double *editval;
|
||||||
@ -425,10 +432,10 @@ static void ui_apply_button(uiBlock *block, uiBut *but, uiHandleButtonData *data
|
|||||||
/* handle different types */
|
/* handle different types */
|
||||||
switch(but->type) {
|
switch(but->type) {
|
||||||
case BUT:
|
case BUT:
|
||||||
ui_apply_but_BUT(but, data);
|
ui_apply_but_BUT(C, but, data);
|
||||||
break;
|
break;
|
||||||
case TEX:
|
case TEX:
|
||||||
ui_apply_but_TEX(but, data);
|
ui_apply_but_TEX(C, but, data);
|
||||||
break;
|
break;
|
||||||
case TOG:
|
case TOG:
|
||||||
case TOGR:
|
case TOGR:
|
||||||
@ -436,29 +443,29 @@ static void ui_apply_button(uiBlock *block, uiBut *but, uiHandleButtonData *data
|
|||||||
case ICONTOGN:
|
case ICONTOGN:
|
||||||
case TOGN:
|
case TOGN:
|
||||||
case BUT_TOGDUAL:
|
case BUT_TOGDUAL:
|
||||||
ui_apply_but_TOG(block, but, data);
|
ui_apply_but_TOG(C, block, but, data);
|
||||||
break;
|
break;
|
||||||
case ROW:
|
case ROW:
|
||||||
ui_apply_but_ROW(block, but, data);
|
ui_apply_but_ROW(C, block, but, data);
|
||||||
break;
|
break;
|
||||||
case SCROLL:
|
case SCROLL:
|
||||||
break;
|
break;
|
||||||
case NUM:
|
case NUM:
|
||||||
case NUMABS:
|
case NUMABS:
|
||||||
ui_apply_but_NUM(but, data);
|
ui_apply_but_NUM(C, but, data);
|
||||||
break;
|
break;
|
||||||
case SLI:
|
case SLI:
|
||||||
case NUMSLI:
|
case NUMSLI:
|
||||||
ui_apply_but_NUM(but, data);
|
ui_apply_but_NUM(C, but, data);
|
||||||
break;
|
break;
|
||||||
case HSVSLI:
|
case HSVSLI:
|
||||||
break;
|
break;
|
||||||
case ROUNDBOX:
|
case ROUNDBOX:
|
||||||
case LABEL:
|
case LABEL:
|
||||||
ui_apply_but_LABEL(but, data);
|
ui_apply_but_LABEL(C, but, data);
|
||||||
break;
|
break;
|
||||||
case TOG3:
|
case TOG3:
|
||||||
ui_apply_but_TOG3(but, data);
|
ui_apply_but_TOG3(C, but, data);
|
||||||
break;
|
break;
|
||||||
case MENU:
|
case MENU:
|
||||||
case ICONROW:
|
case ICONROW:
|
||||||
@ -466,27 +473,27 @@ static void ui_apply_button(uiBlock *block, uiBut *but, uiHandleButtonData *data
|
|||||||
case BLOCK:
|
case BLOCK:
|
||||||
case PULLDOWN:
|
case PULLDOWN:
|
||||||
case COL:
|
case COL:
|
||||||
ui_apply_but_BLOCK(but, data);
|
ui_apply_but_BLOCK(C, but, data);
|
||||||
break;
|
break;
|
||||||
case BUTM:
|
case BUTM:
|
||||||
ui_apply_but_BUTM(but, data);
|
ui_apply_but_BUTM(C, but, data);
|
||||||
break;
|
break;
|
||||||
case BUT_NORMAL:
|
case BUT_NORMAL:
|
||||||
case HSVCUBE:
|
case HSVCUBE:
|
||||||
ui_apply_but_VEC(but, data);
|
ui_apply_but_VEC(C, but, data);
|
||||||
break;
|
break;
|
||||||
case BUT_COLORBAND:
|
case BUT_COLORBAND:
|
||||||
ui_apply_but_COLORBAND(but, data);
|
ui_apply_but_COLORBAND(C, but, data);
|
||||||
break;
|
break;
|
||||||
case BUT_CURVE:
|
case BUT_CURVE:
|
||||||
ui_apply_but_CURVE(but, data);
|
ui_apply_but_CURVE(C, but, data);
|
||||||
break;
|
break;
|
||||||
case IDPOIN:
|
case IDPOIN:
|
||||||
ui_apply_but_IDPOIN(but, data);
|
ui_apply_but_IDPOIN(C, but, data);
|
||||||
break;
|
break;
|
||||||
#ifdef INTERNATIONAL
|
#ifdef INTERNATIONAL
|
||||||
case CHARTAB:
|
case CHARTAB:
|
||||||
ui_apply_but_CHARTAB(but, data);
|
ui_apply_but_CHARTAB(C, but, data);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case LINK:
|
case LINK:
|
||||||
@ -906,13 +913,13 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ui_textedit_autocomplete(uiBut *but, uiHandleButtonData *data)
|
static int ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
int changed= 1;
|
int changed= 1;
|
||||||
|
|
||||||
str= data->str;
|
str= data->str;
|
||||||
but->autocomplete_func(str, but->autofunc_arg);
|
but->autocomplete_func(C, str, but->autofunc_arg);
|
||||||
but->pos= strlen(str);
|
but->pos= strlen(str);
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
@ -1179,7 +1186,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
|
|||||||
case TABKEY:
|
case TABKEY:
|
||||||
/* there is a key conflict here, we can't tab with autocomplete */
|
/* there is a key conflict here, we can't tab with autocomplete */
|
||||||
if(but->autocomplete_func) {
|
if(but->autocomplete_func) {
|
||||||
changed= ui_textedit_autocomplete(but, data);
|
changed= ui_textedit_autocomplete(C, but, data);
|
||||||
retval= WM_UI_HANDLER_BREAK;
|
retval= WM_UI_HANDLER_BREAK;
|
||||||
}
|
}
|
||||||
/* the hotkey here is not well defined, was G.qual so we check all */
|
/* the hotkey here is not well defined, was G.qual so we check all */
|
||||||
@ -1202,7 +1209,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(changed) {
|
if(changed) {
|
||||||
if(data->interactive) ui_apply_button(block, but, data, 1);
|
if(data->interactive) ui_apply_button(C, block, but, data, 1);
|
||||||
else ui_check_but(but);
|
else ui_check_but(but);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1286,7 +1293,7 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data)
|
|||||||
|
|
||||||
static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
|
static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
|
||||||
{
|
{
|
||||||
if(data->interactive) ui_apply_button(block, but, data, 1);
|
if(data->interactive) ui_apply_button(C, block, but, data, 1);
|
||||||
else ui_check_but(but);
|
else ui_check_but(but);
|
||||||
|
|
||||||
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
|
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
|
||||||
@ -2791,7 +2798,7 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* apply the button action or value */
|
/* apply the button action or value */
|
||||||
ui_apply_button(block, but, data, 0);
|
ui_apply_button(C, block, but, data, 0);
|
||||||
|
|
||||||
/* disable tooltips until mousemove */
|
/* disable tooltips until mousemove */
|
||||||
ui_blocks_set_tooltips(data->region, 0);
|
ui_blocks_set_tooltips(data->region, 0);
|
||||||
|
@ -1024,7 +1024,7 @@ static void ui_update_block_buts_hex(uiBlock *block, char *hexcol)
|
|||||||
|
|
||||||
/* bt1 is palette but, col1 is original color */
|
/* bt1 is palette but, col1 is original color */
|
||||||
/* callback to copy from/to palette */
|
/* callback to copy from/to palette */
|
||||||
static void do_palette_cb(void *bt1, void *col1)
|
static void do_palette_cb(bContext *C, void *bt1, void *col1)
|
||||||
{
|
{
|
||||||
uiBut *but1= (uiBut *)bt1;
|
uiBut *but1= (uiBut *)bt1;
|
||||||
float *col= (float *)col1;
|
float *col= (float *)col1;
|
||||||
@ -1048,7 +1048,7 @@ static void do_palette_cb(void *bt1, void *col1)
|
|||||||
|
|
||||||
/* bt1 is num but, hsv1 is pointer to original color in hsv space*/
|
/* bt1 is num but, hsv1 is pointer to original color in hsv space*/
|
||||||
/* callback to handle changes in num-buts in picker */
|
/* callback to handle changes in num-buts in picker */
|
||||||
static void do_palette1_cb(void *bt1, void *hsv1)
|
static void do_palette1_cb(bContext *C, void *bt1, void *hsv1)
|
||||||
{
|
{
|
||||||
uiBut *but1= (uiBut *)bt1;
|
uiBut *but1= (uiBut *)bt1;
|
||||||
float *hsv= (float *)hsv1;
|
float *hsv= (float *)hsv1;
|
||||||
@ -1067,7 +1067,7 @@ static void do_palette1_cb(void *bt1, void *hsv1)
|
|||||||
|
|
||||||
/* bt1 is num but, col1 is pointer to original color */
|
/* bt1 is num but, col1 is pointer to original color */
|
||||||
/* callback to handle changes in num-buts in picker */
|
/* callback to handle changes in num-buts in picker */
|
||||||
static void do_palette2_cb(void *bt1, void *col1)
|
static void do_palette2_cb(bContext *C, void *bt1, void *col1)
|
||||||
{
|
{
|
||||||
uiBut *but1= (uiBut *)bt1;
|
uiBut *but1= (uiBut *)bt1;
|
||||||
float *rgb= (float *)col1;
|
float *rgb= (float *)col1;
|
||||||
@ -1084,7 +1084,7 @@ static void do_palette2_cb(void *bt1, void *col1)
|
|||||||
ui_update_block_buts_hsv(but1->block, fp);
|
ui_update_block_buts_hsv(but1->block, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_palette_hex_cb(void *bt1, void *hexcl)
|
static void do_palette_hex_cb(bContext *C, void *bt1, void *hexcl)
|
||||||
{
|
{
|
||||||
uiBut *but1= (uiBut *)bt1;
|
uiBut *but1= (uiBut *)bt1;
|
||||||
char *hexcol= (char *)hexcl;
|
char *hexcol= (char *)hexcl;
|
||||||
@ -1093,7 +1093,7 @@ static void do_palette_hex_cb(void *bt1, void *hexcl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* used for both 3d view and image window */
|
/* used for both 3d view and image window */
|
||||||
static void do_palette_sample_cb(void *bt1, void *col1) /* frontbuf */
|
static void do_palette_sample_cb(bContext *C, void *bt1, void *col1) /* frontbuf */
|
||||||
{
|
{
|
||||||
/* XXX 2.50 this should become an operator? */
|
/* XXX 2.50 this should become an operator? */
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -159,9 +159,9 @@ typedef struct CellRNA {
|
|||||||
CollectionPropertyIterator iter;
|
CollectionPropertyIterator iter;
|
||||||
} CellRNA;
|
} CellRNA;
|
||||||
|
|
||||||
static void rna_back_cb(void *arg_buts, void *arg_unused)
|
static void rna_back_cb(bContext *C, void *arg_unused, void *arg_unused2)
|
||||||
{
|
{
|
||||||
SpaceOops *soutliner= arg_buts;
|
SpaceOops *soutliner= C->area->spacedata.first;
|
||||||
char *newpath;
|
char *newpath;
|
||||||
|
|
||||||
newpath= RNA_path_back(soutliner->rnapath);
|
newpath= RNA_path_back(soutliner->rnapath);
|
||||||
@ -170,9 +170,9 @@ static void rna_back_cb(void *arg_buts, void *arg_unused)
|
|||||||
soutliner->rnapath= newpath;
|
soutliner->rnapath= newpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_pointer_cb(void *arg_buts, void *arg_prop, void *arg_index)
|
static void rna_pointer_cb(bContext *C, void *arg_prop, void *arg_index)
|
||||||
{
|
{
|
||||||
SpaceOops *soutliner= arg_buts;
|
SpaceOops *soutliner= C->area->spacedata.first;
|
||||||
PropertyRNA *prop= arg_prop;
|
PropertyRNA *prop= arg_prop;
|
||||||
char *newpath;
|
char *newpath;
|
||||||
int index= GET_INT_FROM_POINTER(arg_index);;
|
int index= GET_INT_FROM_POINTER(arg_index);;
|
||||||
@ -240,7 +240,7 @@ static void rna_collection_but(CellRNA *cell, rcti *rct, uiBlock *block)
|
|||||||
if(nameptr != name)
|
if(nameptr != name)
|
||||||
MEM_freeN(nameptr);
|
MEM_freeN(nameptr);
|
||||||
|
|
||||||
uiButSetFunc3(but, rna_pointer_cb, cell->space, cell->prop, SET_INT_IN_POINTER(cell->index));
|
uiButSetFunc(but, rna_pointer_cb, cell->prop, SET_INT_IN_POINTER(cell->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_but(CellRNA *cell, rcti *rct, uiBlock *block)
|
static void rna_but(CellRNA *cell, rcti *rct, uiBlock *block)
|
||||||
@ -267,7 +267,7 @@ static void rna_but(CellRNA *cell, rcti *rct, uiBlock *block)
|
|||||||
but= uiDefRNABut(block, 0, &cell->ptr, prop, index, rct->xmin, rct->ymin, rct->xmax-rct->xmin, rct->ymax-rct->ymin);
|
but= uiDefRNABut(block, 0, &cell->ptr, prop, index, rct->xmin, rct->ymin, rct->xmax-rct->xmin, rct->ymax-rct->ymin);
|
||||||
|
|
||||||
if(type == PROP_POINTER)
|
if(type == PROP_POINTER)
|
||||||
uiButSetFunc3(but, rna_pointer_cb, cell->space, prop, SET_INT_IN_POINTER(0));
|
uiButSetFunc(but, rna_pointer_cb, prop, SET_INT_IN_POINTER(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,9 @@ static void end_animated_screen(SpaceTime *stime)
|
|||||||
#define B_TL_INSERTKEY 758
|
#define B_TL_INSERTKEY 758
|
||||||
#define B_TL_DELETEKEY 759
|
#define B_TL_DELETEKEY 759
|
||||||
|
|
||||||
void do_time_buttons(ScrArea *sa, unsigned short event)
|
void do_time_buttons(bContext *C, void *arg, int event)
|
||||||
{
|
{
|
||||||
SpaceTime *stime= sa->spacedata.first;
|
SpaceTime *stime= C->area->spacedata.first;
|
||||||
|
|
||||||
switch(event) {
|
switch(event) {
|
||||||
|
|
||||||
@ -149,10 +149,9 @@ void do_time_buttons(ScrArea *sa, unsigned short event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_time_redrawmenu(void *arg, int event)
|
static void do_time_redrawmenu(bContext *C, void *arg, int event)
|
||||||
{
|
{
|
||||||
ScrArea *curarea;
|
SpaceTime *stime= C->area->spacedata.first;
|
||||||
SpaceTime *stime= curarea->spacedata.first;
|
|
||||||
|
|
||||||
if(event < 1001) {
|
if(event < 1001) {
|
||||||
|
|
||||||
@ -169,9 +168,9 @@ static void do_time_redrawmenu(void *arg, int event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uiBlock *time_redrawmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_area)
|
static uiBlock *time_redrawmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||||
{
|
{
|
||||||
ScrArea *curarea= arg_area;
|
ScrArea *curarea= C->area;
|
||||||
SpaceTime *stime= curarea->spacedata.first;
|
SpaceTime *stime= curarea->spacedata.first;
|
||||||
uiBlock *block;
|
uiBlock *block;
|
||||||
short yco= 0, menuwidth=120, icon;
|
short yco= 0, menuwidth=120, icon;
|
||||||
@ -231,9 +230,9 @@ static uiBlock *time_redrawmenu(bContext *C, uiMenuBlockHandle *handle, void *ar
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_time_viewmenu(void *arg, int event)
|
static void do_time_viewmenu(bContext *C, void *arg, int event)
|
||||||
{
|
{
|
||||||
ScrArea *curarea;
|
ScrArea *curarea= C->area;
|
||||||
SpaceTime *stime= curarea->spacedata.first;
|
SpaceTime *stime= curarea->spacedata.first;
|
||||||
int first;
|
int first;
|
||||||
|
|
||||||
@ -284,9 +283,9 @@ static void do_time_viewmenu(void *arg, int event)
|
|||||||
//allqueue(REDRAWVIEW3D, 0);
|
//allqueue(REDRAWVIEW3D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uiBlock *time_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_area)
|
static uiBlock *time_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||||
{
|
{
|
||||||
ScrArea *curarea= arg_area;
|
ScrArea *curarea= C->area;
|
||||||
SpaceTime *stime= curarea->spacedata.first;
|
SpaceTime *stime= curarea->spacedata.first;
|
||||||
uiBlock *block;
|
uiBlock *block;
|
||||||
short yco= 0, menuwidth=120;
|
short yco= 0, menuwidth=120;
|
||||||
@ -340,7 +339,7 @@ static uiBlock *time_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_time_framemenu(void *arg, int event)
|
static void do_time_framemenu(bContext *C, void *arg, int event)
|
||||||
{
|
{
|
||||||
switch(event) {
|
switch(event) {
|
||||||
case 1: /*Set as Start */
|
case 1: /*Set as Start */
|
||||||
@ -386,9 +385,9 @@ static void do_time_framemenu(void *arg, int event)
|
|||||||
//allqueue(REDRAWSOUND, 0);
|
//allqueue(REDRAWSOUND, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uiBlock *time_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_area)
|
static uiBlock *time_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
|
||||||
{
|
{
|
||||||
ScrArea *curarea= arg_area;
|
ScrArea *curarea= C->area;
|
||||||
uiBlock *block;
|
uiBlock *block;
|
||||||
short yco= 0, menuwidth=120;
|
short yco= 0, menuwidth=120;
|
||||||
|
|
||||||
@ -436,7 +435,6 @@ static uiBlock *time_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg
|
|||||||
#define AUTOKEY_ON 0
|
#define AUTOKEY_ON 0
|
||||||
#define B_DIFF 0
|
#define B_DIFF 0
|
||||||
|
|
||||||
|
|
||||||
void time_header_buttons(const bContext *C, ARegion *ar)
|
void time_header_buttons(const bContext *C, ARegion *ar)
|
||||||
{
|
{
|
||||||
ScrArea *sa= C->area;
|
ScrArea *sa= C->area;
|
||||||
@ -445,6 +443,7 @@ void time_header_buttons(const bContext *C, ARegion *ar)
|
|||||||
int xco, yco= 3;
|
int xco, yco= 3;
|
||||||
|
|
||||||
block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
|
block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS, UI_HELV);
|
||||||
|
uiBlockSetHandleFunc(block, do_time_buttons, NULL);
|
||||||
|
|
||||||
if(ED_screen_area_active(C)) uiBlockSetCol(block, TH_HEADER);
|
if(ED_screen_area_active(C)) uiBlockSetCol(block, TH_HEADER);
|
||||||
else uiBlockSetCol(block, TH_HEADERDESEL);
|
else uiBlockSetCol(block, TH_HEADERDESEL);
|
||||||
|
Loading…
Reference in New Issue
Block a user