[Bf-blender-cvs] [43b415b] wiggly-widgets: Add/use typedefs for function pointers

Julian Eisel noreply at git.blender.org
Tue May 10 21:45:19 CEST 2016


Commit: 43b415b2cdc713a986dbf3a355c62a43f64a8741
Author: Julian Eisel
Date:   Tue May 10 21:42:48 2016 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB43b415b2cdc713a986dbf3a355c62a43f64a8741

Add/use typedefs for function pointers

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

M	source/blender/windowmanager/widgets/WM_widget_api.h
M	source/blender/windowmanager/widgets/WM_widget_types.h
M	source/blender/windowmanager/widgets/intern/wm_widget.c
M	source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
M	source/blender/windowmanager/widgets/wm_widget_wmapi.h

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

diff --git a/source/blender/windowmanager/widgets/WM_widget_api.h b/source/blender/windowmanager/widgets/WM_widget_api.h
index 7639d38..0bd978f 100644
--- a/source/blender/windowmanager/widgets/WM_widget_api.h
+++ b/source/blender/windowmanager/widgets/WM_widget_api.h
@@ -61,7 +61,7 @@ void WM_widget_set_property(struct wmWidget *, int slot, struct PointerRNA *ptr,
 struct PointerRNA *WM_widget_set_operator(struct wmWidget *, const char *opname);
 void WM_widget_set_func_select(
         struct wmWidget *widget,
-        void (*select)(struct bContext *, struct wmWidget *, const int action));
+        void (*select)(struct bContext *, struct wmWidget *, const int action)); /* wmWidgetSelectFunc */
 void WM_widget_set_origin(struct wmWidget *widget, const float origin[3]);
 void WM_widget_set_offset(struct wmWidget *widget, const float offset[3]);
 void WM_widget_set_flag(struct wmWidget *widget, const int flag, const bool enable);
@@ -75,14 +75,14 @@ void WM_widget_set_colors(struct wmWidget *widget, const float col[4], const flo
 
 struct wmWidgetGroupType *WM_widgetgrouptype_register_ptr(
         const struct Main *bmain, struct wmWidgetMapType *wmaptype,
-        int (*poll)(const struct bContext *, struct wmWidgetGroupType *),
-        void (*create)(const struct bContext *, struct wmWidgetGroup *),
+        int (*poll)(const struct bContext *, struct wmWidgetGroupType *), /* wmWidgetGroupPollFunc */
+        void (*create)(const struct bContext *, struct wmWidgetGroup *),  /* wmWidgetGroupCreateFunc */
         struct wmKeyMap *(*keymap_init)(const struct wmWidgetGroupType *wgrouptype, struct wmKeyConfig *config),
         const char *name);
 struct wmWidgetGroupType *WM_widgetgrouptype_register(
         const struct Main *bmain, const struct wmWidgetMapType_Params *wmap_params,
-        int (*poll)(const struct bContext *, struct wmWidgetGroupType *),
-        void (*create)(const struct bContext *, struct wmWidgetGroup *),
+        int (*poll)(const struct bContext *, struct wmWidgetGroupType *), /* wmWidgetGroupPollFunc */
+        void (*create)(const struct bContext *, struct wmWidgetGroup *),  /* wmWidgetGroupCreateFunc */
         struct wmKeyMap *(*keymap_init)(const struct wmWidgetGroupType *wgrouptype, struct wmKeyConfig *config),
         const char *name);
 void WM_widgetgrouptype_init_runtime(
diff --git a/source/blender/windowmanager/widgets/WM_widget_types.h b/source/blender/windowmanager/widgets/WM_widget_types.h
index 75f5cf1..7c4b651 100644
--- a/source/blender/windowmanager/widgets/WM_widget_types.h
+++ b/source/blender/windowmanager/widgets/WM_widget_types.h
@@ -38,9 +38,15 @@
 
 #include "BLI_compiler_attrs.h"
 
+struct wmWidgetGroupType;
 struct wmWidgetGroup;
 struct wmKeyConfig;
 
+typedef int (*wmWidgetGroupPollFunc)(const struct bContext *, struct wmWidgetGroupType *) ATTR_WARN_UNUSED_RESULT;
+typedef void (*wmWidgetGroupCreateFunc)(const struct bContext *, struct wmWidgetGroup *);
+
+
+/* -------------------------------------------------------------------- */
 
 /* factory class for a widgetgroup type, gets called every time a new area is spawned */
 typedef struct wmWidgetGroupType {
@@ -50,13 +56,12 @@ typedef struct wmWidgetGroupType {
 	char name[64]; /* widget group name - displayed in UI (keymap editor) */
 
 	/* poll if widgetmap should be active */
-	int (*poll)(const struct bContext *C, struct wmWidgetGroupType *wgrouptype) ATTR_WARN_UNUSED_RESULT;
-
+	wmWidgetGroupPollFunc poll;
 	/* update widgets, called right before drawing */
-	void (*create)(const struct bContext *C, struct wmWidgetGroup *wgroup);
+	wmWidgetGroupCreateFunc create;
 
 	/* keymap init callback for this widgetgroup */
-	struct wmKeyMap *(*keymap_init)(const struct wmWidgetGroupType *wgrouptype, struct wmKeyConfig *);
+	struct wmKeyMap *(*keymap_init)(const struct wmWidgetGroupType *, struct wmKeyConfig *);
 
 	/* keymap created with callback from above */
 	struct wmKeyMap *keymap;
diff --git a/source/blender/windowmanager/widgets/intern/wm_widget.c b/source/blender/windowmanager/widgets/intern/wm_widget.c
index 520c9ba..d2814cc 100644
--- a/source/blender/windowmanager/widgets/intern/wm_widget.c
+++ b/source/blender/windowmanager/widgets/intern/wm_widget.c
@@ -252,7 +252,7 @@ PointerRNA *WM_widget_set_operator(wmWidget *widget, const char *opname)
  *
  * Callback is called when widget gets selected/deselected.
  */
-void WM_widget_set_func_select(wmWidget *widget, void (*select)(bContext *, wmWidget *, const int action))
+void WM_widget_set_func_select(wmWidget *widget, wmWidgetSelectFunc select)
 {
 	widget->flag |= WM_WIDGET_SELECTABLE;
 	widget->select = select;
diff --git a/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c b/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
index 622629e..11db495 100644
--- a/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
+++ b/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
@@ -400,8 +400,7 @@ wmKeyMap *WM_widgetgroup_keymap_common_sel(const struct wmWidgetGroupType *wgrou
  */
 wmWidgetGroupType *WM_widgetgrouptype_register_ptr(
         const Main *bmain, wmWidgetMapType *wmaptype,
-        int (*poll)(const bContext *C, wmWidgetGroupType *),
-        void (*create)(const bContext *, wmWidgetGroup *),
+        wmWidgetGroupPollFunc poll, wmWidgetGroupCreateFunc create,
         wmKeyMap *(*keymap_init)(const wmWidgetGroupType *wgrouptype, wmKeyConfig *config),
         const char *name)
 {
@@ -431,8 +430,7 @@ wmWidgetGroupType *WM_widgetgrouptype_register_ptr(
 
 wmWidgetGroupType *WM_widgetgrouptype_register(
         const Main *bmain, const struct wmWidgetMapType_Params *wmap_params,
-        int (*poll)(const bContext *C, wmWidgetGroupType *),
-        void (*create)(const bContext *, wmWidgetGroup *),
+        wmWidgetGroupPollFunc poll, wmWidgetGroupCreateFunc create,
         wmKeyMap *(*keymap_init)(const wmWidgetGroupType *wgrouptype, wmKeyConfig *config),
         const char *name)
 {
diff --git a/source/blender/windowmanager/widgets/wm_widget_wmapi.h b/source/blender/windowmanager/widgets/wm_widget_wmapi.h
index 8489b03..93e3ccb 100644
--- a/source/blender/windowmanager/widgets/wm_widget_wmapi.h
+++ b/source/blender/windowmanager/widgets/wm_widget_wmapi.h
@@ -44,6 +44,9 @@ struct wmOperator;
 /* -------------------------------------------------------------------- */
 /* wmWidget */
 
+typedef void (*wmWidgetSelectFunc)(struct bContext *, struct wmWidget *, const int);
+
+
 /* widgets are set per region by registering them on widgetmaps */
 typedef struct wmWidget {
 	struct wmWidget *next, *prev;
@@ -53,6 +56,7 @@ typedef struct wmWidget {
 	/* pointer back to parent widget group */
 	struct wmWidgetGroup *wgroup;
 
+	/* could become wmWidgetType */
 	/* draw widget */
 	void (*draw)(const struct bContext *C, struct wmWidget *widget);
 
@@ -81,7 +85,7 @@ typedef struct wmWidget {
 	int (*get_cursor)(struct wmWidget *widget);
 
 	/* called when widget selection state changes */
-	void (*select)(struct bContext *C, struct wmWidget *widget, const int action);
+	wmWidgetSelectFunc select;
 
 	int flag; /* flags set by drawing and interaction, such as highlighting */




More information about the Bf-blender-cvs mailing list