[Bf-blender-cvs] [ff50cd9] wiggly-widgets: 2D widgets Cleanup:

Antony Riakiotakis noreply at git.blender.org
Fri Nov 21 17:07:40 CET 2014


Commit: ff50cd97407e646093cdbedefc4fc87a83c42fb0
Author: Antony Riakiotakis
Date:   Fri Nov 21 17:07:26 2014 +0100
Branches: wiggly-widgets
https://developer.blender.org/rBff50cd97407e646093cdbedefc4fc87a83c42fb0

2D widgets Cleanup:

* Get rid of invalid flag (we avoid drawing widgets by dereferencing RNA
now so it should be OK)

* Add intersect function for 2D widgets (still needs correct mapping to
be any useful though)

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

M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_generic_widgets.c
M	source/blender/windowmanager/intern/wm_widgets.c
M	source/blender/windowmanager/wm_event_system.h

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

diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 077df67..2cc66ff 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2016,10 +2016,11 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
 							action |= WM_HANDLER_BREAK;
 						}
 						else if (wm_widgetmap_is_3d(wmap)) {
-							widget = wm_widget_find_highlighted_3D (wmap, C, event);
+							widget = wm_widget_find_highlighted_3D(wmap, C, event);
 							wm_widgetmap_set_highlighted_widget(wmap, C, widget);
 						}
 						else {
+							widget = wm_widget_find_highlighted(wmap, C, event);
 							wm_widgetmap_set_highlighted_widget(wmap, C, NULL);
 						}
 						break;
diff --git a/source/blender/windowmanager/intern/wm_generic_widgets.c b/source/blender/windowmanager/intern/wm_generic_widgets.c
index 5ab0b3b..2552457 100644
--- a/source/blender/windowmanager/intern/wm_generic_widgets.c
+++ b/source/blender/windowmanager/intern/wm_generic_widgets.c
@@ -664,9 +664,11 @@ static void widget_cage_draw(struct wmWidget *widget, const struct bContext *UNU
 	
 	glColor4f(1.0f, 0.6f, 0.0f, 0.1f);
 
-//	glEnable(GL_BLEND);
-//	glRectf(cage->bound.xmin, cage->bound.ymin, cage->bound.xmax, cage->bound.ymax);
-//	glDisable(GL_BLEND);
+	if (widget->flag & WM_WIDGET_HIGHLIGHT) {
+		glEnable(GL_BLEND);
+		glRectf(cage->bound.xmin, cage->bound.ymin, cage->bound.xmax, cage->bound.ymax);
+		glDisable(GL_BLEND);
+	}
 	
 	if (w > h)
 		aspx = h / w;
diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c
index b0fb8c5..f602f1e 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -125,9 +125,6 @@ typedef struct wmWidgetMapType {
 } wmWidgetMapType;
 
 
-#define WGROUP_FLAG_INVALID 1
-
-
 /* store all widgetboxmaps here. Anyone who wants to register a widget for a certain
  * area type can query the widgetbox to do so */
 static ListBase widgetmaptypes = {NULL, NULL};
@@ -286,7 +283,6 @@ void WM_widgets_draw(const bContext *C, struct ARegion *ar)
 
 				if (wgroup->type->update) {
 					wgroup->type->update(wgroup, C);
-					wgroup->flag &= ~WGROUP_FLAG_INVALID;
 				}
 
 				for (widget_iter = wgroup->widgets.first; widget_iter; widget_iter = widget_iter->next) {
@@ -524,19 +520,13 @@ static int wm_widget_find_highlighted_3D_intern (ListBase *visible_widgets, bCon
 	return -1;
 }
 
-static void wm_prepare_visible_widgets(struct wmWidgetMap *wmap, ListBase *visible_widgets, bContext *C)
+static void wm_prepare_visible_widgets_3D(struct wmWidgetMap *wmap, ListBase *visible_widgets, bContext *C)
 {
 	wmWidget *widget;
 	wmWidgetGroup *wgroup;
 
 	for (wgroup = wmap->widgetgroups.first; wgroup; wgroup = wgroup->next) {
 		if (!wgroup->type->poll || wgroup->type->poll(wgroup, C)) {
-			/* update if needed, data may become invalid after undoing */
-			if (wgroup->type->update && (wgroup->flag & WGROUP_FLAG_INVALID)) {
-				wgroup->type->update(wgroup, C);
-				wgroup->flag &= ~WGROUP_FLAG_INVALID;
-			}
-
 			for (widget = wgroup->widgets.first; widget; widget = widget->next) {
 				if (!(widget->flag & WM_WIDGET_SKIP_DRAW) && widget->render_3d_intersection) {
 					BLI_addhead(visible_widgets, BLI_genericNodeN(widget));
@@ -548,12 +538,12 @@ static void wm_prepare_visible_widgets(struct wmWidgetMap *wmap, ListBase *visib
 
 wmWidget *wm_widget_find_highlighted_3D(struct wmWidgetMap *wmap, bContext *C, const struct wmEvent *event)
 {
-	int ret, retsec;
+	int ret;
 	wmWidget *result = NULL;
 	
 	ListBase visible_widgets = {0};
 
-	wm_prepare_visible_widgets(wmap, &visible_widgets, C);
+	wm_prepare_visible_widgets_3D(wmap, &visible_widgets, C);
 
 	/* set up view matrices */	
 	view3d_operator_needs_opengl(C);
@@ -562,7 +552,7 @@ wmWidget *wm_widget_find_highlighted_3D(struct wmWidgetMap *wmap, bContext *C, c
 	
 	if (ret != -1) {
 		LinkData *link;
-		int retfinal;
+		int retfinal, retsec;
 		retsec = wm_widget_find_highlighted_3D_intern(&visible_widgets, C, event, 0.2f * (float)U.tw_hotspot);
 		
 		if (retsec == -1)
@@ -579,6 +569,26 @@ wmWidget *wm_widget_find_highlighted_3D(struct wmWidgetMap *wmap, bContext *C, c
 	return result;
 }
 
+wmWidget *wm_widget_find_highlighted(struct wmWidgetMap *wmap, bContext *C, const struct wmEvent *event)
+{
+	wmWidget *widget;
+	wmWidgetGroup *wgroup;
+
+	for (wgroup = wmap->widgetgroups.first; wgroup; wgroup = wgroup->next) {
+		if (!wgroup->type->poll || wgroup->type->poll(wgroup, C)) {
+			for (widget = wgroup->widgets.first; widget; widget = widget->next) {
+				if (!(widget->flag & WM_WIDGET_SKIP_DRAW) && widget->intersect) {
+					if (widget->intersect(C, event, widget))
+						return widget;
+				}
+			}
+		}
+	}
+	
+	return NULL;
+}
+
+
 void wm_widgetmap_set_highlighted_widget(struct wmWidgetMap *wmap, struct bContext *C, struct wmWidget *widget)
 {
 	if (widget != wmap->highlighted_widget) {
diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h
index d049ec2..3256cc8 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -112,6 +112,7 @@ void        wm_drags_draw(bContext *C, wmWindow *win, rcti *rect);
 
 /* wm_widgets.c */
 struct wmWidget *wm_widget_find_highlighted_3D(struct wmWidgetMap *wmap, struct bContext *C, const struct wmEvent *event);
+wmWidget *wm_widget_find_highlighted(struct wmWidgetMap *wmap, bContext *C, const struct wmEvent *event);
 void wm_widgetmap_set_highlighted_widget(struct wmWidgetMap *wmap, struct bContext *C, struct wmWidget *widget);
 struct wmWidget *wm_widgetmap_get_highlighted_widget(struct wmWidgetMap *wmap);




More information about the Bf-blender-cvs mailing list