[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17781] branches/blender2.5/blender/source /blender/editors:

Brecht Van Lommel brecht at blender.org
Wed Dec 10 20:22:10 CET 2008


Revision: 17781
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17781
Author:   blendix
Date:     2008-12-10 20:22:10 +0100 (Wed, 10 Dec 2008)

Log Message:
-----------

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.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
    branches/blender2.5/blender/source/blender/editors/space_time/time_header.c

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2008-12-10 18:36:56 UTC (rev 17780)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2008-12-10 19:22:10 UTC (rev 17781)
@@ -275,7 +275,7 @@
 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);
 
-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,
 						short x1, short y1, short x2, short y2, void *idpp, char *tip);
 
@@ -288,7 +288,6 @@
 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);
-void uiButSetFunc3(uiBut *but, void (*func)(void *arg1, void *arg2, void *arg3), void *arg1, void *arg2, void *arg3);
 
 void uiAutoBlock(struct uiBlock *block, 
 				 float minx, float miny, 
@@ -315,14 +314,15 @@
 void	uiButSetFlag		(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	uiButSetFunc		(uiBut *but,		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)(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 */
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2008-12-10 18:36:56 UTC (rev 17780)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2008-12-10 19:22:10 UTC (rev 17781)
@@ -421,7 +421,6 @@
 	if(but->func != oldbut->func) return 0;
 	if(but->func_arg1 != oldbut->func_arg1) return 0;
 	if(but->func_arg2 != oldbut->func_arg2) return 0;
-	if(but->func_arg3 != oldbut->func_arg3) return 0;
 
 	return 1;
 }
@@ -1942,15 +1941,15 @@
 
 	if(block->themecol==TH_AUTO) but->themecol= ui_auto_themecol(but);
 	else but->themecol= block->themecol;
-	
-	if (but->type==BUTM) {
-		but->butm_func= block->butm_func;
-		but->butm_func_arg= block->butm_func_arg;
-	} else {
+
+	if(but->type != BUTM) {
 		but->func= block->func;
 		but->func_arg1= block->func_arg1;
 		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);
 	
@@ -2075,7 +2074,7 @@
 }
 
 /* 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; */
 	ListBase *listb= NULL /* XXX 2.50 needs context, wich_libbase(G.main, blocktype) */;
@@ -2468,14 +2467,19 @@
 	return but->retval;
 }
 
-/* Call this function BEFORE adding buttons to the block */
-void uiBlockSetButmFunc(uiBlock *block, void (*menufunc)(void *arg, int event), void *arg)
+void uiBlockSetHandleFunc(uiBlock *block, void (*func)(struct bContext *C, 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;
 }
 
-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_arg1= arg1;
@@ -2487,23 +2491,15 @@
 	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_arg1= arg1;
 	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->autofunc_arg= arg;
 }

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.h	2008-12-10 18:36:56 UTC (rev 17780)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.h	2008-12-10 19:22:10 UTC (rev 17781)
@@ -125,16 +125,17 @@
 	float a1, a2, hsv[3];	// hsv is temp memory for hsv buttons
 	float aspect;
 
-	void (*func)(void *, void *);
-	void (*func3)(void *, void *, void *); /* XXX remove */
+	void (*func)(struct bContext*, void *, void *);
 	void *func_arg1;
 	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 (*sliderfunc)(int , float, float, float, float, float, float, int);
 
-	void (*autocomplete_func)(char *, void *);
+	void (*autocomplete_func)(struct bContext*, char *, void *);
 	void *autofunc_arg;
 	
 	uiLink *link;
@@ -156,10 +157,6 @@
 		/* BLOCK data */
 	uiBlockFuncFP block_func;
 
-		/* BUTM data */
-	void (*butm_func)(void *arg, int event);
-	void *butm_func_arg;
-
 		/* RNA */
 	struct PointerRNA rnapoin;
 	struct PropertyRNA *rnaprop;
@@ -192,12 +189,15 @@
 	float minx, miny, maxx, maxy;
 	float aspect;
 
-	void (*butm_func)(void *arg, int event);
+	void (*func)(struct bContext*, void *arg1, void *arg2);
+	void *func_arg1;
+	void *func_arg2;
+
+	void (*butm_func)(struct bContext*, void *arg, int but_a2);
 	void *butm_func_arg;
 
-	void (*func)(void *arg1, void *arg2);
-	void *func_arg1;
-	void *func_arg2;
+	void (*handle_func)(struct bContext*, void *arg, int event);
+	void *handle_func_arg;
 	
 	/* extra draw function for custom blocks */
 	void (*drawextra)();

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c	2008-12-10 18:36:56 UTC (rev 17780)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c	2008-12-10 19:22:10 UTC (rev 17781)
@@ -139,32 +139,39 @@
 
 /* ********************** button apply/revert ************************ */
 
-static void ui_apply_but_func(uiBut *but)
+static void ui_apply_but_func(bContext *C, uiBut *but)
 {
-	if (but->func)
-		but->func(but->func_arg1, but->func_arg2);
-	if(but->func3)
-		but->func3(but->func_arg1, but->func_arg2, but->func_arg3);
+	uiBlock *block= but->block;
+
+	if(but->func)
+		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->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_apply_but_func(but);
+	ui_apply_but_func(C, but);
 
 	data->retval= but->retval;
 	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)
 		ui_set_but_vectorf(but, data->vec);
@@ -172,12 +179,12 @@
 		ui_set_but_val(but, data->value);
 
 	ui_check_but(but);
-	ui_apply_but_func(but);
+	ui_apply_but_func(C, but);
 	data->retval= but->retval;
 	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;
 	int w, lvalue, push;
@@ -230,22 +237,22 @@
 			but->poin -= 4;
 	}
 	
-	ui_apply_but_func(but);
+	ui_apply_but_func(C, but);
 
 	data->retval= but->retval;
 	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);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list