[Bf-blender-cvs] [6c09f01] wiggly-widgets: Move widget drawing at a higher level - try drawing on top of rendering too.

Antony Riakiotakis noreply at git.blender.org
Thu Oct 2 20:34:35 CEST 2014


Commit: 6c09f016de73c67e6058e2d1957555bf928ad984
Author: Antony Riakiotakis
Date:   Wed Oct 1 20:05:47 2014 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB6c09f016de73c67e6058e2d1957555bf928ad984

Move widget drawing at a higher level - try drawing on top of rendering
too.

Rationale - widgets might be useful to have even on rendered scenes -
we'll have to see about how this will work

Also use area initialization code to register region specific widgets once.

lala

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

M	source/blender/blenkernel/BKE_screen.h
M	source/blender/editors/space_api/spacetypes.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/makesdna/DNA_lamp_types.h

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

diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 188b8e2..6c45f41 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -95,6 +95,9 @@ typedef struct SpaceType {
 	/* on startup, define dropboxes for spacetype+regions */
 	void (*dropboxes)(void);
 
+	/* on startup define areas with widget types */
+	void (*widgets)(void);
+	
 	/* return context data */
 	int (*context)(const struct bContext *, const char *, struct bContextDataResult *);
 
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index c8431d5..7bfe7e6 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -162,6 +162,11 @@ void ED_spacemacros_init(void)
 		if (type->dropboxes)
 			type->dropboxes();
 	}
+	
+	for (type = spacetypes->first; type; type = type->next) {
+		if (type->widgets)
+			type->widgets();
+	}
 }
 
 /* called in wm.c */
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 2f3ae93..1244333 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -424,22 +424,7 @@ static void view3d_free(SpaceLink *sl)
 
 /* spacetype; init callback */
 static void view3d_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
-{
-	static wmWidget *manipulator_widget = NULL;
-	
-	if (!manipulator_widget) {
-		struct wmWidgetMap *wmap = WM_widgetmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW, true);
-		int *realtimeflags = MEM_mallocN(sizeof(int), "manipulator_display_flags");
-		*realtimeflags = 0;
-		
-		manipulator_widget = WM_widget_new(BIF_manipulator_poll, 
-										   BIF_draw_manipulator, 
-										   BIF_manipulator_render_3d_intersect, 
-										   NULL, 
-										   BIF_manipulator_handler, realtimeflags, true);
-		
-		WM_widget_register(wmap, manipulator_widget);
-	}
+{	
 }
 
 static SpaceLink *view3d_duplicate(SpaceLink *sl)
@@ -705,6 +690,28 @@ static void view3d_dropboxes(void)
 	WM_dropbox_add(lb, "OBJECT_OT_group_instance_add", view3d_group_drop_poll, view3d_group_drop_copy);	
 }
 
+static void view3d_widgets(void)
+{
+	wmWidget *widget = NULL;
+	struct wmWidgetMap *wmap = WM_widgetmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW, true);
+	int *realtimeflags = MEM_mallocN(sizeof(int), "manipulator_display_flags");
+	*realtimeflags = 0;
+	
+	widget = WM_widget_new(BIF_manipulator_poll, 
+	                       BIF_draw_manipulator, 
+	                       BIF_manipulator_render_3d_intersect, 
+	                       NULL, 
+	                       BIF_manipulator_handler, realtimeflags, true);
+	
+	WM_widget_register(wmap, widget);
+	
+	widget = WM_widget_new(NULL, 
+	                       NULL, 
+	                       NULL, 
+	                       NULL, 
+	                       NULL, NULL, false);	
+	WM_widget_register(wmap, widget);
+}
 
 
 /* type callback, not region itself */
@@ -1369,6 +1376,7 @@ void ED_spacetype_view3d(void)
 	st->operatortypes = view3d_operatortypes;
 	st->keymap = view3d_keymap;
 	st->dropboxes = view3d_dropboxes;
+	st->widgets = view3d_widgets;
 	st->context = view3d_context;
 	
 	/* regions: main window */
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index f752741..9c30a2a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2763,10 +2763,6 @@ static void view3d_draw_objects(
 		view3d_draw_bgpic_test(scene, ar, v3d, true, do_camera_frame);
 	}
 
-	if (!draw_offscreen) {
-		WM_widgets_draw(C, ar);		
-	}
-
 	/* cleanup */
 	if (v3d->zbuf) {
 		v3d->zbuf = false;
@@ -3428,7 +3424,7 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3
 
 	/* main drawing call */
 	view3d_draw_objects(C, scene, v3d, ar, grid_unit, true, false);
-
+	
 	/* Disable back anti-aliasing */
 	if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) {
 		glDisable(GL_MULTISAMPLE_ARB);
@@ -3545,13 +3541,16 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
 #ifdef DEBUG_DRAW
 		bl_debug_draw();
 #endif
-		ED_region_pixelspace(ar);
 	}
 
 	/* draw viewport using external renderer */
 	if (v3d->drawtype == OB_RENDER)
 		view3d_main_area_draw_engine(C, scene, ar, v3d, clip_border, &border_rect);
 	
+	view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);	
+	WM_widgets_draw(C, ar);
+	ED_region_pixelspace(ar);
+	
 	view3d_main_area_draw_info(C, scene, ar, v3d, grid_unit, render_border);
 
 	v3d->flag |= V3D_INVALID_BACKBUF;
diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h
index a920182..727afe0 100644
--- a/source/blender/makesdna/DNA_lamp_types.h
+++ b/source/blender/makesdna/DNA_lamp_types.h
@@ -151,6 +151,7 @@ typedef struct Lamp {
 #define LA_LAYER_SHADOW	(1 << 15)
 #define LA_SHAD_TEX     (1 << 16)
 #define LA_SHOW_CONE    (1 << 17)
+#define LA_WIDGET	    (1 << 18)
 
 /* layer_shadow */
 #define LA_LAYER_SHADOW_BOTH	0




More information about the Bf-blender-cvs mailing list