[Bf-blender-cvs] [bf640a6] master: Code cleanup: use typedefs for ui handler functions

Campbell Barton noreply at git.blender.org
Tue Jun 3 01:31:42 CEST 2014


Commit: bf640a6a7faff2246d6be117fa758dd69154f27f
Author: Campbell Barton
Date:   Tue Jun 3 08:58:16 2014 +1000
https://developer.blender.org/rBbf640a6a7faff2246d6be117fa758dd69154f27f

Code cleanup: use typedefs for ui handler functions

===================================================================

M	source/blender/editors/interface/interface_regions.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 97d4869..16f42f0 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2506,7 +2506,7 @@ void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, const char *opn
 
 void uiPupBlock(bContext *C, uiBlockCreateFunc func, void *arg)
 {
-	uiPupBlockO(C, func, arg, NULL, 0);
+	uiPupBlockO(C, func, arg, NULL, WM_OP_INVOKE_DEFAULT);
 }
 
 void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 64cada9..9e50b01 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -145,19 +145,22 @@ struct wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers,
 
 void		WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap);
 
+typedef int (*wmUIHandlerFunc)(struct bContext *C, const struct wmEvent *event, void *userdata);
+typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata);
+
 struct wmEventHandler *WM_event_add_ui_handler(
         const struct bContext *C, ListBase *handlers,
-        int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata),
-        void (*remove)(struct bContext *C, void *userdata), void *userdata);
-
-void		WM_event_remove_ui_handler(ListBase *handlers,
-                                       int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata),
-                                       void (*remove)(struct bContext *C, void *userdata),
-                                       void *userdata, const bool postpone);
-void		WM_event_remove_area_handler(struct ListBase *handlers, void *area);
-void		WM_event_free_ui_handler_all(struct bContext *C, ListBase *handlers,
-                                         int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata),
-                                         void (*remove)(struct bContext *C, void *userdata));
+        wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove,
+        void *userdata);
+void WM_event_remove_ui_handler(
+        ListBase *handlers,
+        wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove,
+        void *userdata, const bool postpone);
+void WM_event_remove_area_handler(
+        struct ListBase *handlers, void *area);
+void WM_event_free_ui_handler_all(
+        struct bContext *C, ListBase *handlers,
+        wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove);
 
 struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op);
 void		WM_event_remove_handlers(struct bContext *C, ListBase *handlers);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index e73d599..9ad1bc9 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -190,9 +190,6 @@ enum {
 #define WM_UI_HANDLER_CONTINUE	0
 #define WM_UI_HANDLER_BREAK		1
 
-typedef int (*wmUIHandlerFunc)(struct bContext *C, const struct wmEvent *event, void *userdata);
-typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata);
-
 /* ************** Notifiers ****************** */
 
 typedef struct wmNotifier {
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index c9855cc..64289e0 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2547,12 +2547,14 @@ void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
 	}
 }
 
-wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers,
-                                        wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata)
+wmEventHandler *WM_event_add_ui_handler(
+        const bContext *C, ListBase *handlers,
+        wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove,
+        void *userdata)
 {
 	wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "event ui handler");
-	handler->ui_handle = func;
-	handler->ui_remove = remove;
+	handler->ui_handle = ui_handle;
+	handler->ui_remove = ui_remove;
 	handler->ui_userdata = userdata;
 	if (C) {
 		handler->ui_area    = CTX_wm_area(C);
@@ -2572,13 +2574,18 @@ wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers,
 }
 
 /* set "postpone" for win->modalhandlers, this is in a running for () loop in wm_handlers_do() */
-void WM_event_remove_ui_handler(ListBase *handlers,
-                                wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata, const bool postpone)
+void WM_event_remove_ui_handler(
+        ListBase *handlers,
+        wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove,
+        void *userdata, const bool postpone)
 {
 	wmEventHandler *handler;
 	
 	for (handler = handlers->first; handler; handler = handler->next) {
-		if (handler->ui_handle == func && handler->ui_remove == remove && handler->ui_userdata == userdata) {
+		if ((handler->ui_handle == ui_handle) &&
+		    (handler->ui_remove == ui_remove) &&
+		    (handler->ui_userdata == userdata))
+		{
 			/* handlers will be freed in wm_handlers_do() */
 			if (postpone) {
 				handler->flag |= WM_HANDLER_DO_FREE;
@@ -2592,15 +2599,18 @@ void WM_event_remove_ui_handler(ListBase *handlers,
 	}
 }
 
-void WM_event_free_ui_handler_all(bContext *C, ListBase *handlers,
-                                  wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove)
+void WM_event_free_ui_handler_all(
+        bContext *C, ListBase *handlers,
+        wmUIHandlerFunc ui_handle, wmUIHandlerRemoveFunc ui_remove)
 {
 	wmEventHandler *handler, *handler_next;
 
 	for (handler = handlers->first; handler; handler = handler_next) {
 		handler_next = handler->next;
-		if (handler->ui_handle == func && handler->ui_remove == remove) {
-			remove(C, handler->ui_userdata);
+		if ((handler->ui_handle == ui_handle) &&
+		    (handler->ui_remove == ui_remove))
+		{
+			ui_remove(C, handler->ui_userdata);
 			BLI_remlink(handlers, handler);
 			wm_event_free_handler(handler);
 		}




More information about the Bf-blender-cvs mailing list