static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
	switch (event->type) {
		case LEFTMOUSE:
		case RIGHTMOUSE: /* XXX hardcoded */
			sample_exit(C, op);
			return OPERATOR_CANCELLED;
		case MOUSEMOVE:
			sample_apply(C, op, event);
			break;
	}

	return OPERATOR_RUNNING_MODAL;
}
static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
	ARegion *ar = CTX_wm_region(C);
	SpaceSeq *sseq = CTX_wm_space_seq(C);
	ImageSampleInfo *info;

	if (sseq->mainb != SEQ_DRAW_IMG_IMBUF)
		return OPERATOR_CANCELLED;

	info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
	info->art = ar->type;
	info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
	op->customdata = info;

	sample_apply(C, op, event);

	WM_event_add_modal_handler(C, op);

	return OPERATOR_RUNNING_MODAL;
}
示例#3
0
static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
    SpaceNode *snode = CTX_wm_space_node(C);
    ARegion *ar = CTX_wm_region(C);
    ImageSampleInfo *info;

    if (!ED_node_is_compositor(snode) || !(snode->flag & SNODE_BACKDRAW))
        return OPERATOR_CANCELLED;

    info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
    info->art = ar->type;
    info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
    op->customdata = info;

    sample_apply(C, op, event);

    WM_event_add_modal_handler(C, op);

    return OPERATOR_RUNNING_MODAL;
}