[Bf-blender-cvs] [19719d0] temp_widgets_c++_experiment: Move Widget register functions to C++ file, remove unused function

Julian Eisel noreply at git.blender.org
Wed Dec 23 21:59:57 CET 2015


Commit: 19719d0c567b14ac6069fae6e04572ea93ed9045
Author: Julian Eisel
Date:   Wed Dec 23 21:58:37 2015 +0100
Branches: temp_widgets_c++_experiment
https://developer.blender.org/rB19719d0c567b14ac6069fae6e04572ea93ed9045

Move Widget register functions to C++ file, remove unused function

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

M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/widgets/wm_widget.cc
M	source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
M	source/blender/windowmanager/intern/wm_widgets.c
M	source/blender/windowmanager/wm.h

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

diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index da87884..ece3ed4 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -499,15 +499,7 @@ float       WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, flo
 bool        WM_event_is_tablet(const struct wmEvent *event);
 
 
-/* *************** Widget API ********************
- *
- * TODO getting a bit crowded here - maybe move into own .h file?
- */
-
-struct wmWidget *WM_widget_new(void (*draw)(const struct bContext *, struct wmWidget *),
-                               void (*render_3d_intersection)(const struct bContext *, struct wmWidget *, int),
-                               int  (*intersect)(struct bContext *, const struct wmEvent *, struct wmWidget *),
-                               int  (*handler)(struct bContext *, const struct wmEvent *, struct wmWidget *, const int));
+/* *************** Widget API ******************** */
 
 /* wmWidget->flag */
 enum widgetflags {
diff --git a/source/blender/windowmanager/intern/widgets/wm_widget.cc b/source/blender/windowmanager/intern/widgets/wm_widget.cc
index 45ccbb2..9dfdb60 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widget.cc
+++ b/source/blender/windowmanager/intern/widgets/wm_widget.cc
@@ -31,6 +31,10 @@
 
 #include "BKE_context.h"
 
+#include "BLI_math.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
 #include "DNA_defs.h"
 #include "DNA_listBase.h"
 #include "DNA_view3d_types.h"
@@ -41,6 +45,8 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "RNA_access.h"
+
 #include "WM_api.h"
 
 #include "wm_widgetmap.h"
@@ -54,9 +60,68 @@ wmWidget::wmWidget()
 {
 	
 }
+
 #endif
 
 /**
+ * Assign an idname that is unique in \a wgroup to \a widget.
+ *
+ * \param rawname  Name used as basis to define final unique idname.
+ */
+static void widget_unique_idname_set(wmWidgetGroup *wgroup, wmWidget *widget, const char *rawname)
+{
+	char groupname[MAX_NAME];
+
+	WM_widgetgrouptype_idname_get(wgroup->type, groupname);
+
+	if (groupname[0]) {
+		BLI_snprintf(widget->idname, sizeof(widget->idname), "%s_%s", groupname, rawname);
+	}
+	else {
+		BLI_strncpy(widget->idname, rawname, sizeof(widget->idname));
+	}
+
+	/* ensure name is unique, append '.001', '.002', etc if not */
+	BLI_uniquename(&wgroup->widgets, widget, "Widget", '.', offsetof(wmWidget, idname), sizeof(widget->idname));
+}
+
+/**
+ * Register \a widget.
+ *
+ * \param name  name used to create a unique idname for \a widget in \a wgroup
+ */
+bool wm_widget_register(wmWidgetGroup *wgroup, wmWidget *widget, const char *name)
+{
+	const float col_default[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+	widget_unique_idname_set(wgroup, widget, name);
+
+	widget->user_scale = 1.0f;
+	widget->line_width = 1.0f;
+
+	/* defaults */
+	copy_v4_v4(widget->col, col_default);
+	copy_v4_v4(widget->col_hi, col_default);
+
+	/* create at least one property for interaction */
+	if (widget->max_prop == 0) {
+		widget->max_prop = 1;
+	}
+
+	widget->props = (PropertyRNA **)MEM_callocN(sizeof(PropertyRNA *) * widget->max_prop, "widget->props");
+	widget->ptr = (PointerRNA *)MEM_callocN(sizeof(PointerRNA) * widget->max_prop, "widget->ptr");
+	widget->opptr = PointerRNA_NULL;
+
+	widget->wgroup = wgroup;
+
+	BLI_addtail(&wgroup->widgets, widget);
+
+	fix_linking_widget_lib();
+
+	return true;
+}
+
+/**
  * Free widget data, not widget itself.
  */
 void widget_data_free(wmWidget *widget)
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
index 5b77bb2..2fda017 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
@@ -99,6 +99,10 @@ size_t      WM_widgetgrouptype_idname_get(struct wmWidgetGroupType *wgrouptype,
 wmOperator *WM_widgetgrouptype_operator_get(struct wmWidgetGroupType *wgrouptype);
 wmKeyMap   *WM_widgetgrouptype_user_keymap_get(struct wmWidgetGroupType *wgrouptype);
 
+bool wm_widget_register(struct wmWidgetGroup *wgroup, struct wmWidget *widget, const char *name);
+
+void fix_linking_widget_lib(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c
index ed72e0c..43f17fd 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -74,79 +74,6 @@
 #include "BPY_extern.h"
 
 
-wmWidget *WM_widget_new(void (*draw)(const bContext *C, wmWidget *customdata),
-                        void (*render_3d_intersection)(const bContext *C, wmWidget *customdata, int selectionbase),
-                        int  (*intersect)(bContext *C, const wmEvent *event, wmWidget *widget),
-                        int  (*handler)(bContext *C, const wmEvent *event, wmWidget *widget, const int flag))
-{
-	wmWidget *widget = MEM_callocN(sizeof(wmWidget), "widget");
-
-	widget->draw = draw;
-	widget->handler = handler;
-	widget->intersect = intersect;
-	widget->render_3d_intersection = render_3d_intersection;
-
-	fix_linking_widget_lib();
-
-	return widget;
-}
-
-/**
- * Assign an idname that is unique in \a wgroup to \a widget.
- *
- * \param rawname  Name used as basis to define final unique idname.
- */
-static void widget_unique_idname_set(wmWidgetGroup *wgroup, wmWidget *widget, const char *rawname)
-{
-	char groupname[MAX_NAME];
-
-	WM_widgetgrouptype_idname_get(wgroup->type, groupname);
-
-	if (groupname[0]) {
-		BLI_snprintf(widget->idname, sizeof(widget->idname), "%s_%s", groupname, rawname);
-	}
-	else {
-		BLI_strncpy(widget->idname, rawname, sizeof(widget->idname));
-	}
-
-	/* ensure name is unique, append '.001', '.002', etc if not */
-	BLI_uniquename(&wgroup->widgets, widget, "Widget", '.', offsetof(wmWidget, idname), sizeof(widget->idname));
-}
-
-/**
- * Register \a widget.
- *
- * \param name  name used to create a unique idname for \a widget in \a wgroup
- */
-bool wm_widget_register(wmWidgetGroup *wgroup, wmWidget *widget, const char *name)
-{
-	const float col_default[4] = {1.0f, 1.0f, 1.0f, 1.0f};
-
-	widget_unique_idname_set(wgroup, widget, name);
-
-	widget->user_scale = 1.0f;
-	widget->line_width = 1.0f;
-
-	/* defaults */
-	copy_v4_v4(widget->col, col_default);
-	copy_v4_v4(widget->col_hi, col_default);
-
-	/* create at least one property for interaction */
-	if (widget->max_prop == 0) {
-		widget->max_prop = 1;
-	}
-
-	widget->props = MEM_callocN(sizeof(PropertyRNA *) * widget->max_prop, "widget->props");
-	widget->ptr = MEM_callocN(sizeof(PointerRNA) * widget->max_prop, "widget->ptr");
-	widget->opptr = PointerRNA_NULL;
-
-	widget->wgroup = wgroup;
-
-	BLI_addtail(&wgroup->widgets, widget);
-	return true;
-}
-
-
 /** \name Widget Creation API
  *
  * API for defining data on widget creation.
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index 11b51eb..9e5c44c 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -172,7 +172,6 @@ void wm_open_init_load_ui(wmOperator *op, bool use_prefs);
 void wm_open_init_use_scripts(wmOperator *op, bool use_prefs);
 
 /* wm_widgets.c */
-bool wm_widget_register(wmWidgetGroup *wgroup, wmWidget *widget, const char *name);
 void fix_linking_widgets(void);
 
 
@@ -183,7 +182,5 @@ void fix_linking_widgets(void);
 extern int circle_select_size;
 #endif
 
-void fix_linking_widget_lib(void);
-
 #endif /* __WM_H__ */




More information about the Bf-blender-cvs mailing list