[Bf-blender-cvs] [52700fd] temp_widgets_c++_experiment: Port widget-group-type unregister and widget-group free functions

Julian Eisel noreply at git.blender.org
Sat Dec 19 14:44:40 CET 2015


Commit: 52700fdac320d4a52d026f06a5c658625da99800
Author: Julian Eisel
Date:   Sat Dec 19 14:43:09 2015 +0100
Branches: temp_widgets_c++_experiment
https://developer.blender.org/rB52700fdac320d4a52d026f06a5c658625da99800

Port widget-group-type unregister and widget-group free functions

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

M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/widgets/wm_widget.cpp
M	source/blender/windowmanager/intern/widgets/wm_widget.h
M	source/blender/windowmanager/intern/widgets/wm_widgetgroup.cpp
M	source/blender/windowmanager/intern/widgets/wm_widgetgroup.h
M	source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cpp
M	source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h
M	source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cpp
M	source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
M	source/blender/windowmanager/intern/wm_widgets.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index bd61ae0..98fb0c5 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -562,8 +562,6 @@ wmKeyMap *WM_widgetgroup_keymap_common(wmKeyConfig *config, const char *wgroupna
 
 bool WM_widgetmap_select_all(struct bContext *C, struct wmWidgetMap *wmap, const int action);
 
-void WM_widgetgrouptype_unregister(struct bContext *C, struct Main *bmain, struct wmWidgetGroupTypeC *wgroup);
-
 /* creates a widgetmap with all registered widgets for that type */
 void WM_widgetmap_delete(struct wmWidgetMap *wmap);
 bool WM_widgetmap_cursor_set(const struct wmWidgetMap *wmap, struct wmWindow *win);
diff --git a/source/blender/windowmanager/intern/widgets/wm_widget.cpp b/source/blender/windowmanager/intern/widgets/wm_widget.cpp
index 1c5bf2e..b39281c 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widget.cpp
+++ b/source/blender/windowmanager/intern/widgets/wm_widget.cpp
@@ -29,8 +29,10 @@
 
 #include "wm_widget.h"
 
+#if 0
 wmWidget::wmWidget()
 {
 	
 }
+#endif
 
diff --git a/source/blender/windowmanager/intern/widgets/wm_widget.h b/source/blender/windowmanager/intern/widgets/wm_widget.h
index ded1593..c9ec57a 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widget.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widget.h
@@ -31,10 +31,27 @@
 #define __WM_WIDGET_H__
 
 
+/* wmWidget->flag */
+enum widgetflags {
+	/* states */
+	WM_WIDGET_HIGHLIGHT   = (1 << 0),
+	WM_WIDGET_ACTIVE      = (1 << 1),
+	WM_WIDGET_SELECTED    = (1 << 2),
+	/* settings */
+	WM_WIDGET_DRAW_HOVER  = (1 << 3),
+	WM_WIDGET_DRAW_ACTIVE = (1 << 4), /* draw while dragging */
+	WM_WIDGET_SCALE_3D    = (1 << 5),
+	WM_WIDGET_SCENE_DEPTH = (1 << 6), /* widget is depth culled with scene objects*/
+	WM_WIDGET_HIDDEN      = (1 << 7),
+	WM_WIDGET_SELECTABLE  = (1 << 8),
+};
+
+#if 0
 class wmWidget
 {
 public:
 	wmWidget();
 };
+#endif
 
 #endif // __WM_WIDGET_H__
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetgroup.cpp b/source/blender/windowmanager/intern/widgets/wm_widgetgroup.cpp
index 60418bd..df1f193 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetgroup.cpp
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetgroup.cpp
@@ -27,6 +27,23 @@
  *  \ingroup wm
  */
 
+#include "BKE_report.h"
+
+#include "BLI_listbase.h"
+
+#include "DNA_defs.h"
+#include "DNA_widget_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_types.h"
+#include "BPY_extern.h"
+
+#include "wm.h" // tmp
+
+#include "wm_widget.h"
+#include "wm_widgetmap.h"
 #include "wm_widgetgroup.h" // own_include
 
 #if 0
@@ -36,3 +53,34 @@ wmWidgetGroup::wmWidgetGroup()
 }
 #endif
 
+void widgetgroup_free(bContext *UNUSED(C), wmWidgetMap *wmap, wmWidgetGroup *wgroup)
+{
+	for (wmWidget *widget = (wmWidget *)wgroup->widgets.first; widget;) {
+		wmWidget *widget_next = widget->next;
+		if (widget->flag & WM_WIDGET_HIGHLIGHT) {
+//			wm_widgetmap_set_highlighted_widget(wmap, C, NULL, 0);
+		}
+		if (widget->flag & WM_WIDGET_ACTIVE) {
+//			wm_widgetmap_set_active_widget(wmap, C, NULL, NULL);
+		}
+//		wm_widget_delete(&wgroup->widgets, widget);
+		widget = widget_next;
+	}
+
+#ifdef WITH_PYTHON
+	if (wgroup->py_instance) {
+		/* do this first in case there are any __del__ functions or
+		 * similar that use properties */
+		BPY_DECREF_RNA_INVALIDATE(wgroup->py_instance);
+	}
+#endif
+
+	if (wgroup->reports && (wgroup->reports->flag & RPT_FREE)) {
+		BKE_reports_clear(wgroup->reports);
+		MEM_freeN(wgroup->reports);
+	}
+
+	BLI_remlink(&wmap->widgetgroups, wgroup);
+	MEM_freeN(wgroup);
+}
+
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetgroup.h b/source/blender/windowmanager/intern/widgets/wm_widgetgroup.h
index bb01bbd..8779ee5 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetgroup.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetgroup.h
@@ -43,4 +43,6 @@ public:
 };
 #endif
 
+void widgetgroup_free(bContext *C, struct wmWidgetMap *wmap, wmWidgetGroup *wgroup);
+
 #endif // __WM_WIDGETGROUP_H__
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cpp b/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cpp
index 17a5502..40fc51d 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cpp
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.cpp
@@ -46,6 +46,7 @@
 
 #include "wm_widgetmap.h"
 #include "wm_widgetmaptype.h"
+#include "wm_widgetgroup.h"
 #include "wm_widgetgrouptype.h" // own include
 
 
@@ -104,6 +105,39 @@ void wmWidgetGroupType::init(
 	}
 }
 
+void wmWidgetGroupType::unregister(bContext *C, Main *bmain)
+{
+	for (bScreen *sc = (bScreen *)bmain->screen.first; sc; sc = (bScreen *)sc->id.next) {
+		for (ScrArea *sa = (ScrArea *)sc->areabase.first; sa; sa = sa->next) {
+			for (SpaceLink *sl = (SpaceLink *)sa->spacedata.first; sl; sl = sl->next) {
+				ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+				for (ARegion *ar = (ARegion *)lb->first; ar; ar = ar->next) {
+					for (wmWidgetMap *wmap = (wmWidgetMap *)ar->widgetmaps.first; wmap; wmap = wmap->next) {
+						wmWidgetGroup *wgroup, *wgroup_next;
+
+						for (wgroup = (wmWidgetGroup *)wmap->widgetgroups.first; wgroup; wgroup = wgroup_next) {
+							wgroup_next = wgroup->next;
+							if (wgroup->type_cxx == this) {
+								widgetgroup_free(C, wmap, wgroup);
+//								ED_region_tag_redraw(ar);
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+
+	wmWidgetMapType *wmaptype = WM_widgetmaptype_find(mapidname, spaceid,
+	                                                  regionid, is_3d, false);
+
+	BLI_remlink(&wmaptype->widgetgrouptypes, this);
+	prev = next = NULL;
+
+	// yay, suicide
+	delete this;
+}
+
 void wmWidgetGroupType::attach_to_handler(bContext *C, wmEventHandler *handler, wmOperator *op)
 {
 	/* now instantiate the widgetmap */
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h b/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h
index 5fc6346..18287cd 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetgrouptype.h
@@ -53,6 +53,7 @@ public:
 	        wmKeyMap *(*keymap_init)(wmKeyConfig *, const char *),
 	        const Main *bmain, const char *mapidname, const char *name,
 	        const short spaceid, const short regionid, const bool is_3d);
+	void unregister(bContext *C, Main *bmain);
 
 	void attach_to_handler(bContext *C, struct wmEventHandler *handler, struct wmOperator *op);
 	size_t get_idname(char *r_idname);
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cpp b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cpp
index 78960ab..22e72fe 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cpp
+++ b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cpp
@@ -72,6 +72,11 @@ wmWidgetGroupType *WM_widgetgrouptype_new(
 	return wgrouptype;
 }
 
+void WM_widgetgrouptype_unregister(bContext *C, Main *bmain, wmWidgetGroupType *wgrouptype)
+{
+	wgrouptype->unregister(C, bmain);
+}
+
 void WM_widgetgrouptype_attach_to_handler(
         bContext *C, wmWidgetGroupType *wgrouptype,
         wmEventHandler *handler, wmOperator *op)
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 c2f91d4..f148a85 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
@@ -57,6 +57,7 @@ struct wmWidgetGroupType *WM_widgetgrouptype_new(
         struct wmKeyMap *(*keymap_init)(struct wmKeyConfig *, const char *),
         const struct Main *bmain, const char *mapidname, const char *name,
         const short spaceid, const short regionid, const bool is_3d);
+void WM_widgetgrouptype_unregister(struct bContext *C, struct Main *bmain, struct wmWidgetGroupType *wgrouptype);
 void WM_widgetgrouptype_attach_to_handler(
         struct bContext *C, struct wmWidgetGroupType *wgrouptype,
         struct wmEventHandler *handler, struct wmOperator *op);
diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c
index 31bceb6..778888f 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -1424,35 +1424,3 @@ void wm_widgetgrouptype_keymap_init(wmWidgetGroupTypeC *wgrouptype, wmKeyConfig
 	wgrouptype->keymap = wgrouptype->keymap_init(keyconf, wgrouptype->name);
 }
 
-void WM_widgetgrouptype_unregister(bContext *C, Main *bmain, wmWidgetGroupTypeC *wgrouptype)
-{
-	for (bScreen *sc = bmain->screen.first; sc; sc = sc->id.next) {
-		for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
-			for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
-				ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
-				for (ARegion *ar = lb->first; ar; ar = ar->next) {
-					for (wmWidgetMap *wmap = ar->widgetmaps.first; wmap; wmap = wmap->next) {
-						wmWidgetGroup *wgroup, *wgroup_next;
-
-						for (wgroup = wmap->widgetgroups.first; wgroup; wgroup = wgroup_next) {
-							wgroup_next = wgroup->next;
-							if (wgroup->type == wgrouptype) {
-								wm_widgetgroup_free(C, wmap, wgroup);
-								ED_region_tag_redraw(ar);
-							}
-						}
-					}
-				}
-			}
-		}
-	}
-
-	wmWidgetMapType *wmaptype = WM_widgetmaptype_find(wgrouptype->mapidname, wgrouptype->spaceid,
-	                                                  wgrouptype->regionid, wgrouptype->is_3d, false);
-
-	BLI_remlink(&wmaptype->widgetgrouptypes, wgrouptype);
-	wgrouptype->prev = wgrouptype->next = NULL;
-
-	MEM_freeN(wgrouptype);
-}
-
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 3904f8e..a761d1b 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -314,7 +314,6 @@ void WM_curs

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list