Пример #1
0
/* Modal event handling of cursor changing */
static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
	/* execute the events */
	switch (event->type) {
		case ESCKEY:
			return OPERATOR_FINISHED;
		
		case MOUSEMOVE:
			/* set the new values */
			graphview_cursor_setprops(C, op, event);
			graphview_cursor_apply(C, op);
			break;
		
		case LEFTMOUSE: 
		case RIGHTMOUSE:
			/* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init 
			 * the modal op) doesn't work for some reason
			 */
			if (event->val == KM_RELEASE)
				return OPERATOR_FINISHED;
			break;
	}

	return OPERATOR_RUNNING_MODAL;
}
Пример #2
0
/* Modal Operator init */
static int graphview_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
	/* Change to frame that mouse is over before adding modal handler,
	 * as user could click on a single frame (jump to frame) as well as
	 * click-dragging over a range (modal scrubbing).
	 */
	graphview_cursor_setprops(C, op, event);
	
	/* apply these changes first */
	graphview_cursor_apply(C, op);
	
	/* add temp handler */
	WM_event_add_modal_handler(C, op);
	return OPERATOR_RUNNING_MODAL;
}
Пример #3
0
/* Modal Operator init */
static int graphview_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
	bScreen *screen = CTX_wm_screen(C);
	
	/* Change to frame that mouse is over before adding modal handler,
	 * as user could click on a single frame (jump to frame) as well as
	 * click-dragging over a range (modal scrubbing). Apply this change.
	 */
	graphview_cursor_setprops(C, op, event);
	graphview_cursor_apply(C, op);
	
	/* Signal that a scrubbing operating is starting */
	if (screen)
		screen->scrubbing = true;
	
	/* add temp handler */
	WM_event_add_modal_handler(C, op);
	return OPERATOR_RUNNING_MODAL;
}
Пример #4
0
/* Modal event handling of cursor changing */
static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
	bScreen *screen = CTX_wm_screen(C);
	Scene *scene = CTX_data_scene(C);
	
	/* execute the events */
	switch (event->type) {
		case ESCKEY:
			if (screen)
				screen->scrubbing = false;
			
			WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
			return OPERATOR_FINISHED;
		
		case MOUSEMOVE:
			/* set the new values */
			graphview_cursor_setprops(C, op, event);
			graphview_cursor_apply(C, op);
			break;
		
		case LEFTMOUSE: 
		case RIGHTMOUSE:
		case MIDDLEMOUSE:
			/* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init 
			 * the modal op) doesn't work for some reason
			 */
			if (event->val == KM_RELEASE) {
				if (screen)
					screen->scrubbing = false;
				
				WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
				return OPERATOR_FINISHED;
			}
			break;
	}

	return OPERATOR_RUNNING_MODAL;
}