[Bf-blender-cvs] [100d043] custom-manipulators: Merge branch 'temp_manipulators_core' into custom-manipulators

Julian Eisel noreply at git.blender.org
Mon Oct 3 01:35:33 CEST 2016


Commit: 100d043fce2eabbbf3b55bb433551f5425180622
Author: Julian Eisel
Date:   Mon Oct 3 01:31:15 2016 +0200
Branches: custom-manipulators
https://developer.blender.org/rB100d043fce2eabbbf3b55bb433551f5425180622

Merge branch 'temp_manipulators_core' into custom-manipulators

Also made changes to get branch compile and work.
Conflicts:
	source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h

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



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

diff --cc source/blender/editors/space_graph/graph_edit.c
index 971f8a3,f38d368..6e6dbeb
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@@ -2748,177 -2746,3 +2748,177 @@@ void GRAPH_OT_driver_variables_paste(wm
  }
  
  /* ************************************************************************** */
 +
 +typedef struct BackDropTransformData {
 +	float init_offset[2];
 +	float init_zoom;
 +	short event_type;
 +} BackDropTransformData;
 +
 +static int graph_widget_backdrop_transform_poll(bContext *C)
 +{
 +	SpaceIpo *sipo = CTX_wm_space_graph(C);
 +	ARegion *ar = CTX_wm_region(C);
 +
 +	return ((sipo != NULL) &&
 +	        (ar->type->regionid == RGN_TYPE_WINDOW) &&
 +	        (sipo->flag & SIPO_DRAW_BACKDROP) &&
 +	        (sipo->backdrop_camera));
 +}
 +
 +static void widgetgroup_backdrop_init(const bContext *UNUSED(C), wmManipulatorGroup *wgroup)
 +{
 +	wmManipulatorWrapper *wwrapper = MEM_mallocN(sizeof(wmManipulatorWrapper), __func__);
 +	wgroup->customdata = wwrapper;
 +
 +	wwrapper->manipulator = MANIPULATOR_rect_transform_new(
 +	                     wgroup, "backdrop_cage",
 +	                     MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM | MANIPULATOR_RECT_TRANSFORM_STYLE_TRANSLATE);
 +}
 +
 +static void widgetgroup_backdrop_refresh(const struct bContext *C, wmManipulatorGroup *wgroup)
 +{
 +	wmManipulator *cage = ((wmManipulatorWrapper *)wgroup->customdata)->manipulator;
 +	ARegion *ar = CTX_wm_region(C);
 +	const Scene *scene = CTX_data_scene(C);
 +	const int width = (scene->r.size * scene->r.xsch) / 150.0f;
 +	const int height = (scene->r.size * scene->r.ysch) / 150.0f;
 +	float origin[3];
 +
 +	origin[0] = BLI_rcti_size_x(&ar->winrct) / 2.0f;
 +	origin[1] = BLI_rcti_size_y(&ar->winrct) / 2.0f;
 +
 +	WM_manipulator_set_origin(cage, origin);
 +	MANIPULATOR_rect_transform_set_dimensions(cage, width, height);
 +
 +	/* XXX hmmm, can't we do this in _init somehow? Issue is op->ptr is freed after OP is done. */
 +	wmOperator *op = wgroup->type->op;
 +	WM_manipulator_set_property(cage, RECT_TRANSFORM_SLOT_OFFSET, op->ptr, "offset");
 +	WM_manipulator_set_property(cage, RECT_TRANSFORM_SLOT_SCALE, op->ptr, "scale");
 +}
 +
 +static void GRAPH_WGT_backdrop_transform(wmManipulatorGroupType *wgt)
 +{
 +	wgt->name = "Backdrop Transform Widgets";
 +
 +	wgt->init = widgetgroup_backdrop_init;
 +	wgt->refresh = widgetgroup_backdrop_refresh;
 +}
 +
 +static int graph_widget_backdrop_transform_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 +{
 +	ScrArea *sa = CTX_wm_area(C);
 +	SpaceIpo *sipo = CTX_wm_space_graph(C);
 +	BackDropTransformData *data = MEM_mallocN(sizeof(BackDropTransformData), "overdrop transform data");
 +
 +	RNA_float_set_array(op->ptr, "offset", sipo->backdrop_offset);
 +	RNA_float_set(op->ptr, "scale", sipo->backdrop_zoom);
 +
 +	copy_v2_v2(data->init_offset, sipo->backdrop_offset);
 +	data->init_zoom = sipo->backdrop_zoom;
 +	data->event_type = event->type;
 +
 +	op->customdata = data;
 +	WM_event_add_modal_handler(C, op);
 +
 +	ED_area_headerprint(sa, "Drag to place, and scale, Space/Enter/Caller key to confirm, R to recenter, RClick/Esc to cancel");
 +
 +	return OPERATOR_RUNNING_MODAL;
 +}
 +
 +static void graph_widget_backdrop_transform_finish(bContext *C, BackDropTransformData *data)
 +{
 +	ScrArea *sa = CTX_wm_area(C);
 +	ED_area_headerprint(sa, NULL);
 +	MEM_freeN(data);
 +}
 +
 +static void graph_widget_backdrop_transform_cancel(struct bContext *C, struct wmOperator *op)
 +{
 +	BackDropTransformData *data = op->customdata;
 +	graph_widget_backdrop_transform_finish(C, data);
 +}
 +
 +static int graph_widget_backdrop_transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
 +{
 +	ARegion *ar = CTX_wm_region(C);
 +	BackDropTransformData *data = op->customdata;
 +
 +	if (event->type == data->event_type && event->val == KM_PRESS) {
 +		graph_widget_backdrop_transform_finish(C, data);
 +		return OPERATOR_FINISHED;
 +	}
 +
 +	switch (event->type) {
 +		case EVT_MANIPULATOR_UPDATE:
 +		{
 +			SpaceIpo *sipo = CTX_wm_space_graph(C);
 +			RNA_float_get_array(op->ptr, "offset", sipo->backdrop_offset);
 +			sipo->backdrop_zoom = RNA_float_get(op->ptr, "scale");
 +			break;
 +		}
 +		case RKEY:
 +		{
 +			SpaceIpo *sipo = CTX_wm_space_graph(C);
 +			float zero[2] = {0.0f};
 +			RNA_float_set_array(op->ptr, "offset", zero);
 +			RNA_float_set(op->ptr, "scale", 1.0f);
 +			copy_v2_v2(sipo->backdrop_offset, zero);
 +			sipo->backdrop_zoom = 1.0f;
 +			ED_region_tag_redraw(ar);
 +			/* add a mousemove to refresh the widget */
 +			WM_event_add_mousemove(C);
 +			break;
 +		}
 +		case RETKEY:
 +		case PADENTER:
 +		case SPACEKEY:
 +		{
 +			graph_widget_backdrop_transform_finish(C, data);
 +			return OPERATOR_FINISHED;
 +		}
 +		case ESCKEY:
 +		case RIGHTMOUSE:
 +		{
 +			SpaceIpo *sipo = CTX_wm_space_graph(C);
 +
 +			/* only end modal if we're not dragging a widget - XXX */
 +			if (/*!ar->manipulator_map->mmap_context.active_manipulator && */event->val == KM_PRESS) {
 +				copy_v2_v2(sipo->backdrop_offset, data->init_offset);
 +				sipo->backdrop_zoom = data->init_zoom;
 +
 +				graph_widget_backdrop_transform_finish(C, data);
 +				return OPERATOR_CANCELLED;
 +			}
 +		}
 +	}
 +	WM_manipulatormap_tag_refresh(ar->manipulator_map);
 +
 +	return OPERATOR_RUNNING_MODAL;
 +}
 +
 +void GRAPH_OT_widget_backdrop_transform(struct wmOperatorType *ot)
 +{
 +	float default_offset[2] = {0.0f, 0.0f};
 +	wmManipulatorMapType *wmaptype = WM_manipulatormaptype_find(&(const struct wmManipulatorMapType_Params) {
- 	        "Graph_Canvas", SPACE_IPO, RGN_TYPE_WINDOW, 0});
++	        "Graph_Canvas", SPACE_IPO, RGN_TYPE_WINDOW});
 +
 +	/* identifiers */
 +	ot->name = "Transform Backdrop";
 +	ot->idname = "GRAPH_OT_widget_backdrop_transform";
 +	ot->description = "";
 +
 +	/* api callbacks */
 +	ot->invoke = graph_widget_backdrop_transform_invoke;
 +	ot->modal = graph_widget_backdrop_transform_modal;
 +	ot->poll = graph_widget_backdrop_transform_poll;
 +	ot->cancel = graph_widget_backdrop_transform_cancel;
 +
 +	/* flags */
 +	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +
 +	ot->mgrouptype = WM_manipulatorgrouptype_append(wmaptype, GRAPH_WGT_backdrop_transform);
 +
 +	RNA_def_float_array(ot->srna, "offset", 2, default_offset, FLT_MIN, FLT_MAX, "Offset", "Offset of the backdrop", FLT_MIN, FLT_MAX);
 +	RNA_def_float(ot->srna, "scale", 1.0f, 0.0f, FLT_MAX, "Scale", "Scale of the backdrop", 0.0f, FLT_MAX);
 +}
diff --cc source/blender/editors/space_graph/space_graph.c
index 3996420,f12db31..79c4db8
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@@ -708,15 -679,6 +708,15 @@@ static void graph_refresh(const bContex
  	graph_refresh_fcurve_colors(C);
  }
  
 +/* ************************************* */
 +
 +static void graph_widgets(void)
 +{
 +	/* create the widgetmap for the area here */
 +	WM_manipulatormaptype_ensure(&(const struct wmManipulatorMapType_Params) {
- 	        "Graph_Canvas", SPACE_IPO, RGN_TYPE_WINDOW, 0});
++	        "Graph_Canvas", SPACE_IPO, RGN_TYPE_WINDOW});
 +}
 +
  static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
  {
  	SpaceIpo *sgraph = (SpaceIpo *)slink;
diff --cc source/blender/editors/space_image/space_image.c
index 5d11afa,6ddf782..9dc55eb
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@@ -588,28 -587,6 +588,27 @@@ static int image_context(const bContex
  	return 0;
  }
  
 +static void IMAGE_WGT_manipulator2d(wmManipulatorGroupType *wgt)
 +{
 +	wgt->name = "UV Transform Manipulator";
 +
 +	wgt->poll = WIDGETGROUP_manipulator2d_poll;
 +	wgt->init = WIDGETGROUP_manipulator2d_init;
 +	wgt->refresh = WIDGETGROUP_manipulator2d_refresh;
 +	wgt->draw_prepare = WIDGETGROUP_manipulator2d_draw_prepare;
 +}
 +
 +static void image_widgets(void)
 +{
 +	const struct wmManipulatorMapType_Params wmap_params = {
 +		.idname = "Image_UV",
- 		.spaceid = SPACE_IMAGE, .regionid = RGN_TYPE_WINDOW,
- 		.flag = 0,
++		.spaceid = SPACE_IMAGE, .regionid = RGN_TYPE_WINDOW
 +	};
 +	wmManipulatorMapType *wmaptype = WM_manipulatormaptype_ensure(&wmap_params);
 +
 +	WM_manipulatorgrouptype_append(wmaptype, IMAGE_WGT_manipulator2d);
 +}
 +
  /************************** main region ***************************/
  
  /* sets up the fields of the View2D from zoom and offset */
diff --cc source/blender/editors/space_node/space_node.c
index 754e509,4ef703c..74e2684
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@@ -856,14 -822,6 +856,14 @@@ static int node_context(const bContext 
  	return 0;
  }
  
 +static void node_widgets(void)
 +{
 +	/* create the widgetmap for the area here */
 +	wmManipulatorMapType *wmaptype = WM_manipulatormaptype_ensure(&(const struct wmManipulatorMapType_Params) {
- 	        "Node_Canvas", SPACE_NODE, RGN_TYPE_WINDOW, 0});
++	        "Node_Canvas", SPACE_NODE, RGN_TYPE_WINDOW});
 +	WM_manipulatorgrouptype_append(wmaptype, NODE_WGT_backdrop_transform);
 +}
 +
  static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
  {
  	SpaceNode *snode = (SpaceNode *)slink;
diff --cc source/blender/editors/space_sequencer/sequencer_view.c
index 19456b0,4d6ea86..8b26fbb
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@@ -246,364 -241,3 +246,364 @@@ void SEQUENCER_OT_sample(wmOperatorTyp
  	/* flags */
  	ot->flag = OPTYPE_BLOCKING;
  }
 +
 +/******** Backdrop Transform *******/
 +
 +typedef struct OverDropTransformData {
 +	ImBuf *ibuf; /* image to be transformed (preview image transformation widget) */
 +	int init_size[2];
 +	float init_zoom;
 +	float init_offset[2];
 +	int event_type;
 +} OverDropTransformData;
 +
 +static int sequencer_overdrop_transform_poll(bContext *C)
 +{
 +	SpaceSeq *sseq = CTX_wm_space_seq(C);
 +	ARegion *ar = CTX_wm_region(C);
 +
 +	return (sseq && ar && ar->type->regionid == RGN_TYPE_WINDOW && (sseq->draw_flag & SEQ_DRAW_OVERDROP));
 +}
 +
 +static void widgetgroup_overdrop_init(const bContext *UNUSED(C), wmManipul

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list