[Bf-blender-cvs] [10a3ca0] wiggly-widgets: Move manipulator handler to the widget system.

Antony Riakiotakis noreply at git.blender.org
Mon Sep 29 19:48:50 CEST 2014


Commit: 10a3ca018940bf7823b3bb4d9db63a4e8524a55f
Author: Antony Riakiotakis
Date:   Mon Sep 29 18:51:00 2014 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB10a3ca018940bf7823b3bb4d9db63a4e8524a55f

Move manipulator handler to the widget system.

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

M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/physics/physics_ops.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_ops.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_widgets.c

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

diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index e9a3eb0..732d0d9 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -111,6 +111,7 @@ struct ScrArea;
 struct Base;
 struct Scene;
 struct Object;
+struct wmWidget;
 
 /* UNUSED */
 // int BIF_snappingSupported(struct Object *obedit);
@@ -151,8 +152,9 @@ void Transform_Properties(struct wmOperatorType *ot, int flags);
 
 /* view3d manipulators */
 
-int BIF_do_manipulator(struct bContext *C, const struct wmEvent *event, struct wmOperator *op);
-void BIF_draw_manipulator(const struct bContext *C, void *customdata);
+int BIF_do_manipulator(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget);
+void BIF_draw_manipulator(const struct bContext *C, struct wmWidget *customdata);
+bool BIF_manipulator_poll(const struct bContext *C, struct wmWidget *customdata);
 
 /* Snapping */
 
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 48cc51f..cc1d352 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -134,9 +134,6 @@ static void keymap_particle(wmKeyConfig *keyconf)
 	kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
 	RNA_boolean_set(kmi->ptr, "unselected", true);
 
-	kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
-	RNA_boolean_set(kmi->ptr, "release_confirm", true);
-
 	WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
 
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index fd582c3..d50c53c 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -430,7 +430,7 @@ static void view3d_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
 	if (!manipulator_widget) {
 		ListBase *widgets = WM_widgetmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW);
 		
-		manipulator_widget = WM_widget_new(NULL, BIF_draw_manipulator, NULL, NULL, NULL, NULL, 0, 0);
+		manipulator_widget = WM_widget_new(BIF_manipulator_poll, BIF_draw_manipulator, NULL, BIF_do_manipulator, NULL, 0, 0);
 		
 		WM_widget_register(widgets, manipulator_widget);
 	}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index d771e33..ee4a06d 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2763,7 +2763,6 @@ static void view3d_draw_objects(
 
 	if (!draw_offscreen) {
 		WM_widgets_draw(C, ar);		
-		//BIF_draw_manipulator(C);
 	}
 
 	/* cleanup */
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index cff6761..2011a53 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4537,43 +4537,6 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
 
 /* ***************** manipulator op ******************* */
 
-
-static int manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *event)
-{
-	View3D *v3d = CTX_wm_view3d(C);
-
-	if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
-	if (!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
-
-	/* only no modifier or shift */
-	if (event->keymodifier != 0 && event->keymodifier != KM_SHIFT) return OPERATOR_PASS_THROUGH;
-
-	/* note; otherwise opengl won't work */
-	view3d_operator_needs_opengl(C);
-
-	if (0 == BIF_do_manipulator(C, event, op))
-		return OPERATOR_PASS_THROUGH;
-
-	return OPERATOR_FINISHED;
-}
-
-void VIEW3D_OT_manipulator(wmOperatorType *ot)
-{
-
-	/* identifiers */
-	ot->name = "3D Manipulator";
-	ot->description = "Manipulate selected item by axis";
-	ot->idname = "VIEW3D_OT_manipulator";
-
-	/* api callbacks */
-	ot->invoke = manipulator_invoke;
-
-	ot->poll = ED_operator_view3d_active;
-
-	/* properties to pass to transform */
-	Transform_Properties(ot, P_CONSTRAINT);
-}
-
 static int enable_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 {
 	View3D *v3d = CTX_wm_view3d(C);
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 7e101fe..26cce12 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -168,7 +168,6 @@ void view3d_operatortypes(void)
 	WM_operatortype_append(VIEW3D_OT_render_border);
 	WM_operatortype_append(VIEW3D_OT_clear_render_border);
 	WM_operatortype_append(VIEW3D_OT_zoom_border);
-	WM_operatortype_append(VIEW3D_OT_manipulator);
 	WM_operatortype_append(VIEW3D_OT_enable_manipulator);
 	WM_operatortype_append(VIEW3D_OT_cursor3d);
 	WM_operatortype_append(VIEW3D_OT_select_lasso);
@@ -211,13 +210,6 @@ void view3d_keymap(wmKeyConfig *keyconf)
 	
 	/* only for region 3D window */
 	keymap = WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
-
-	kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
-	RNA_boolean_set(kmi->ptr, "release_confirm", true);
-	/*
-	 * Doesn't work with KM_SHIFT, have to use KM_ANY and filter in invoke
-	 * */
-	// WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
 	
 	WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
 	
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index ca85e63..c6a93d5 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -72,6 +72,8 @@
 /* local module include */
 #include "transform.h"
 
+#include "MEM_guardedalloc.h"
+
 #include "GPU_select.h"
 
 /* return codes for select, and drawing flags */
@@ -1604,7 +1606,7 @@ static void draw_manipulator_rotate_cyl(
 /* main call, does calc centers & orientation too */
 static int drawflags = 0xFFFF;       // only for the calls below, belongs in scene...?
 
-void BIF_draw_manipulator(const bContext *C, void *UNUSED(customdata))
+void BIF_draw_manipulator(const bContext *C, wmWidget *UNUSED(customdata))
 {
 	ScrArea *sa = CTX_wm_area(C);
 	ARegion *ar = CTX_wm_region(C);
@@ -1615,8 +1617,6 @@ void BIF_draw_manipulator(const bContext *C, void *UNUSED(customdata))
 
 	const bool is_picksel = false;
 
-	if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return;
-
 	{
 		v3d->twflag &= ~V3D_DRAW_MANIPULATOR;
 
@@ -1688,6 +1688,15 @@ void BIF_draw_manipulator(const bContext *C, void *UNUSED(customdata))
 	}
 }
 
+bool BIF_manipulator_poll(const struct bContext *C, wmWidget *UNUSED(customdata))
+{
+	ScrArea *sa = CTX_wm_area(C);
+	View3D *v3d = sa->spacedata.first;
+
+	return ((v3d->twflag & V3D_USE_MANIPULATOR) != 0);
+}
+
+
 static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot)
 {
 	View3D *v3d = sa->spacedata.first;
@@ -1796,7 +1805,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl
 
 
 /* return 0; nothing happened */
-int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
+int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmWidget *UNUSED(widget))
 {
 	ScrArea *sa = CTX_wm_area(C);
 	View3D *v3d = sa->spacedata.first;
@@ -1805,12 +1814,18 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 	int val;
 	int shift = event->shift;
 
-	if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return 0;
-	if (!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return 0;
-
-	/* Force orientation */
-	RNA_enum_set(op->ptr, "constraint_orientation", v3d->twmode);
-
+	struct IDProperty *properties = NULL;	/* operator properties, assigned to ptr->data and can be written to a file */
+	struct PointerRNA *ptr = NULL;			/* rna pointer to access properties */
+		
+	if (!((v3d->twflag & V3D_USE_MANIPULATOR) && (v3d->twflag & V3D_DRAW_MANIPULATOR)) ||
+	    !(event->keymodifier == 0 || event->keymodifier == KM_SHIFT) || 
+		!((event->val == KM_PRESS) && (event->type == LEFTMOUSE)))
+	{
+		return OPERATOR_PASS_THROUGH;
+	}
+	
+	view3d_operator_needs_opengl(C);
+	
 	// find the hotspots first test narrow hotspot
 	val = manipulator_selectbuf(sa, ar, event->mval, 0.5f * (float)U.tw_hotspot);
 	if (val) {
@@ -1848,8 +1863,12 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 						constraint_axis[2] = 1;
 					break;
 			}
-			RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
-			WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, op->ptr);
+			WM_operator_properties_alloc(&ptr, &properties, "TRANSFORM_OT_translate");
+			/* Force orientation */
+			RNA_boolean_set(ptr, "release_confirm", true);
+			RNA_enum_set(ptr, "constraint_orientation", v3d->twmode);
+			RNA_boolean_set_array(ptr, "constraint_axis", constraint_axis);
+			WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, ptr);
 			//wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL, false);
 		}
 		else if (drawflags & MAN_SCALE_C) {
@@ -1879,8 +1898,12 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
 						constraint_axis[2] = 1;
 					break;
 			}
-			RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis);
-			WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, op->ptr);
+			WM_operator_properties_alloc(&ptr, &properties, "TRANSFORM_OT_resize");
+			/* Force orientation */
+			RNA_boolean_set(ptr, "release_confirm", true);
+			RNA_enum_set(ptr, "constraint_orientation", v3d->twmode);
+			RNA_boolean_set_array(ptr, "constraint_axis", constraint_axis);
+			WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, ptr);
 			//wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_resize", 0), event, op->ptr, NULL, 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list